Skip to content

Conversation

@belimawr
Copy link
Contributor

@belimawr belimawr commented Nov 6, 2025

Proposed commit message

Use logp.NewNopLogger on TestRunnerFactoryWithCommonInputSettings to avoid panic: "
Log in goroutine after TestRunnerFactoryWithCommonInputSettings has completed"

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works. Where relevant, I have used the stresstest.sh script to run them under stress conditions and race detector to verify their stability.
  • I have added an entry in ./changelog/fragments using the changelog tool.

## Disruptive User Impact
## Author's Checklist

How to test this PR locally

go test -v -count=1 -run=TestRunnerFactoryWithCommonInputSettings ./filebeat/channel

## Related issues
## Use cases
## Screenshots
## Logs

Use logp.NewNopLogger on TestRunnerFactoryWithCommonInputSettings to
avoid panic: "
Log in goroutine after TestRunnerFactoryWithCommonInputSettings has
completed"
@belimawr belimawr self-assigned this Nov 6, 2025
@belimawr belimawr requested a review from a team as a code owner November 6, 2025 20:50
@belimawr belimawr added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Nov 6, 2025
@belimawr belimawr added backport-active-all Automated backport with mergify to all the active branches skip-changelog labels Nov 6, 2025
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Nov 6, 2025
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Nov 6, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2025

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

require.NoError(t, err)

b := beat.Info{Logger: logptest.NewTestingLogger(t, "")} // not important for the test
b := beat.Info{Logger: logp.NewNopLogger()} // not important for the test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not obvious to me why it would panic. It's not explained in the description of this PR either.

I think it would be preferable if we made the test logger in elastic-agent-libs to never panic somehow:

https://github.com/elastic/elastic-agent-libs/blob/03ca4525a4b679f00ea3baeeafe2a76e469e486c/logp/logptest/logptest.go#L33-L42

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not obvious to me why it would panic.

logptest.NewTestingLogger uses the testing.T as the logger output, if the test ends and the logger tries to log, then the testing.T panics.

It's not explained in the description of this PR either.

It is, the explanation is in the proposed commit message:
Log in goroutine after Testxxx has completed

Use logp.NewNopLogger on TestRunnerFactoryWithCommonInputSettings to avoid panic: "
Log in goroutine after TestRunnerFactoryWithCommonInputSettings has completed"

I think it would be preferable if we made the test logger in elastic-agent-libs to never panic somehow:

The root cause of the panics are components that do not get completely shutdown and try to log something after the test ends, leading to a panic. Which actually exposes an issue with the test design or the component design.

For the test logger never to panic we "just" need to stop using zaptest.NewLogger, which I believe is the main feature of logptest.NewTestingLogger.

You have a good point there, I'll make a PR for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rdner I created this PR to make logptest.NewTestingLogger not panic any more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@belimawr after merging elastic/elastic-agent-libs#368 do you still think it makes sense to make this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, if we merge elastic/elastic-agent-libs#368, we won't need this PR any more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-all Automated backport with mergify to all the active branches skip-changelog Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants