fluent / fluent/fluentd

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

Open
#4,136 0 comments 0 reactions 1 assignee Claimed by @daipom View on GitHub
enhancement
Dominant language
Ruby
Stars
13.6k
Forks
1.4k
Avg merge
1d 3h
Merged PRs (30d)
20

Description

### 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

```markdown
Not related.
```

### Your Configuration

```apache
Not related.
```

### Your Error Log

```shell
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.