Skip to content

Commit cf0940b

Browse files
Backport(v1.19): test_out_buffer: fix flaky BufferOutputTest#write (#5443) (#5455)
**Which issue(s) this PR fixes**: Backport #5443 Fixes # **What this PR does / why we need it**: `out_buffer` flushes its buffer immediately and re-emits events asynchronously via the flush thread. The test driver's `wait_flush_completion` only waits until the chunk leaves the buffer queue , not until `write()` actually emits. When the flush thread is still between `dequeue_chunk` and `write`, `run()` proceeds to shutdown, where `EventEmitter#after_shutdown` nil-s out @router before `Output#after_shutdown` joins the flush thread. The in-flight write then emits to a `nil` router and the event is dropped, making `d.events` empty. This surfaces as a flaky failure under CI load. Pass `expect_emits: 1` so `run()` waits until the event is actually emitted (while the router is still valid) before shutting the plugin down. This PR should fix following error: ``` 1) Failure: test: #write(BufferOutputTest) /Users/runner/hostedtoolcache/Ruby/3.2.11/arm64/bin/bundle:25:in `load' /Users/runner/work/fluentd/fluentd/test/plugin/test_out_buffer.rb:52:in `block in <class:BufferOutputTest>' /Users/runner/hostedtoolcache/Ruby/3.2.11/arm64/bin/bundle:25:in `<main>' 49: d.feed(time, record) Tasks: TOP => test => base_test 50: end (See full trace by running task with --trace) 51: => 52: assert_equal [["test", time, record]], d.events 53: end 54: end <[["test", 2026-07-16 07:03:01.673742000 +0000, {"message"=>"test"}]]> expected but was <[]> diff: ? [["test", 2026-07-16 07:03:01.673742000 +0000, {"message"=>"test"}]] Error: <[["test", 2026-07-16 07:03:01.673742000 +0000, {"message"=>"test"}]]> expected but was <[]>. ``` Ref. https://github.com/fluent/fluentd/actions/runs/29478564922/job/87556893864#step:6:5358 **Docs Changes**: N/A **Release Note**: N/A Signed-off-by: Shizuo Fujita <fujita@clear-code.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Shizuo Fujita <fujita@clear-code.com>
1 parent 2f9c16d commit cf0940b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

test/plugin/test_out_buffer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def create_driver(conf = "")
4545

4646
time = event_time
4747
record = {"message" => "test"}
48-
d.run(default_tag: 'test') do
48+
d.run(default_tag: 'test', expect_emits: 1) do
4949
d.feed(time, record)
5050
end
5151

0 commit comments

Comments
 (0)