Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Use Driver::logs for asserting log messages #4136

Open
daipom opened this issue Apr 10, 2023 · 0 comments · Fixed by #4138
Open

CI: Use Driver::logs for asserting log messages #4136

daipom opened this issue Apr 10, 2023 · 0 comments · Fixed by #4138
Assignees
Labels
enhancement Feature request or improve operations

Comments

@daipom
Copy link
Contributor

daipom commented Apr 10, 2023

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

d.run(shutdown: false, expect_records: 2, timeout: 10) do
entries = []
# These entries are skipped
entries << ['tag1', true, {'a' => 3}] << ['tag2', time, 'invalid record']
entries += records.map { |tag, _time, record| [tag, _time, record] }
entries.each {|tag, _time, record|
# Without ack, logs are sometimes not saved to logs during test.
send_data packer.write([tag, _time, record]).to_s #, try_to_receive_response: true
}
end
logs = d.instance.log.logs
assert_equal 2, logs.count { |line| line =~ /got invalid event and drop it/ }
assert_equal records[0], d.events[0]
assert_equal records[1], d.events[1]
d.instance_shutdown

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.

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 daipom added waiting-for-triage enhancement Feature request or improve operations and removed waiting-for-triage labels Apr 10, 2023
@daipom daipom self-assigned this Apr 10, 2023
@daipom daipom reopened this Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request or improve operations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant