fluentd icon indicating copy to clipboard operation
fluentd copied to clipboard

CI: Use `Driver::logs` for asserting log messages

Open daipom opened this issue 2 years ago • 0 comments

Describe the bug

Some tests are asserting log messages as follows. We should fix these tests.

  • Use shutdown: false and manually do d.instance_shutdown
  • Take logs from Driver::instance

https://github.com/fluent/fluentd/blob/206b46b91560177366371c1f05bbcf09ac006d86/test/plugin/test_in_forward.rb#L186-L203

We should not use this approach.

The log messages of the instance will be cleared after the shutdown, but we can still take log messages from Driver::logs. So we should use Driver::logs and should not use shutdown: false for this purpose.

Note: Driver::logs is the same instance as instance.log.out.logs (= instance.log.logs), but reset will not clear it, just re-assign the new list to DummyLogDevice. So we can use Driver::logs after the shutdown.

  • https://github.com/fluent/fluentd/blob/206b46b91560177366371c1f05bbcf09ac006d86/lib/fluent/test/driver/base_owner.rb#L30-L31
  • https://github.com/fluent/fluentd/blob/206b46b91560177366371c1f05bbcf09ac006d86/lib/fluent/test/log.rb#L32-L34

To Reproduce

None.

Expected behavior

None.

Your Environment

Not related.

Your Configuration

Not related.

Your Error Log

Not related.

Additional context

The document also says we should use Driver::logs.

https://docs.fluentd.org/plugin-development/plugin-test-code#tests-for-logs

daipom avatar Apr 10 '23 06:04 daipom