Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion filebeat/channel/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ index: "%{[fields.log_type]}-%{[agent.version]}-%{+yyyy.MM.dd}"
cfg, err := conf.NewConfigWithYAML([]byte(configYAML), configYAML)
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.

rf := &runnerFactoryMock{
clientCount: 3, // we will create 3 clients from the wrapped pipeline
}
Expand Down