From 108e4de667df6f0b61863922361697bdd09a02a0 Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Sun, 19 Jul 2026 01:14:45 +0900 Subject: [PATCH] test_out_buffer: fix flaky BufferOutputTest#write 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 (via dequeue_chunk), 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. Signed-off-by: Shizuo Fujita --- test/plugin/test_out_buffer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/plugin/test_out_buffer.rb b/test/plugin/test_out_buffer.rb index afaac1bcdd..b683bea2b0 100644 --- a/test/plugin/test_out_buffer.rb +++ b/test/plugin/test_out_buffer.rb @@ -45,7 +45,7 @@ def create_driver(conf = "") time = event_time record = {"message" => "test"} - d.run(default_tag: 'test') do + d.run(default_tag: 'test', expect_emits: 1) do d.feed(time, record) end