avoid panics in TestPublisherStopShutdownInactive by using in memory logs - #21640
Open
aelnahas wants to merge 1 commit into
Open
avoid panics in TestPublisherStopShutdownInactive by using in memory logs#21640aelnahas wants to merge 1 commit into
aelnahas wants to merge 1 commit into
Conversation
…logs TestPublisherStopShutdownInactive is flaky due to a potential for a routine to write to the logs after the test function has returned. The shutdown sequence used in the teest cleanup: https://github.com/elastic/beats/blob/57e75fbd5b2923a308da39a27d1ce24185c3/libbeat/publisher/pipeline/consumer.go#L239 might happen before the queueReader had a chance to log its stop message. Therefore, the cleanup might exit too early. This commit bypasses this problem by using logp.NewTestingLoggerWithObserver.
Contributor
🤖 GitHub commentsJust comment with:
|
💚 Build Succeeded
|
carsonip
reviewed
Aug 7, 2026
carsonip
left a comment
Member
There was a problem hiding this comment.
given that this is likely caused by a regression from beats, could you gauge how much more effort it is to address the root cause (or are we using the pipeline correctly in our usage), before we jump to a workaround?
Contributor
|
This pull request does not have a backport label. Could you fix it @aelnahas? 🙏
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation/summary
TestPublisherStopShutdownInactive is flaky due to a potential for a routine to write to the logs after the test function has returned. The shutdown sequence used in the test cleanup:
https://github.com/elastic/beats/blob/50ef57e75fbd5b2923a308da39a27d1ce24185c3/libbeat/publisher/pipeline/consumer.go#L237 might happen before the queueReader had a chance to log its stop message. Therefore, the cleanup might exit too early. This commit bypasses this problem by using logp.NewTestingLoggerWithObserver which still returns a logging output using *testing.T but an in memory slice of the logs to bypass the cleanup panics.
Reference for ogp.NewTestingLoggerWithObserver: https://github.com/elastic/elastic-agent-libs/blob/main/logp/logptest/logptest.go#L46
Checklist
For functional changes, consider:
How to test these changes
I used the following steps to reproduce the problem and also check if the fix works
Related issues
#21375