Skip to content

Commit 593d9e7

Browse files
authored
test_output_as_buffered: ensure to shutdown plugin instances (#5330)
**Which issue(s) this PR fixes**: Fixes # **What this PR does / why we need it**: Fix thread and resource leaks in test_output.rb by ensuring proper shutdown sequences for plugin instances. Before: ``` $ ruby -Ilib:test -e "at_exit { puts '--- Thread count at exit: ' + Thread.list.size.to_s; pp Thread.list }; require './test/plugin/test_output_as_buffered.rb'" Loaded suite -e Started Finished in 53.238291615 seconds. ------------------------------------------------------------------------------------------------------------------------------------------- 56 tests, 393 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ------------------------------------------------------------------------------------------------------------------------------------------- 1.05 tests/s, 7.38 assertions/s --- Thread count at exit: 10 [#<Thread:0x00007f9fba067f50 run>, #<Thread:0x00007f9f9cb744c0@Timeout stdlib thread /home/watson/.rbenv/versions/4.0.2/lib/ruby/4.0.0/timeout.rb:87 sleep_forever>, #<Thread:0x00007f9f9d401160@flush_thread_0 /home/watson/src/fluentd/lib/fluent/plugin_helper/thread.rb:70 sleep>, #<Thread:0x00007f9f9d400170@enqueue_thread /home/watson/src/fluentd/lib/fluent/plugin_helper/thread.rb:70 sleep>, #<Thread:0x00007f9f9cde87b0@flush_thread_0 /home/watson/src/fluentd/lib/fluent/plugin_helper/thread.rb:70 sleep>, #<Thread:0x00007f9f9cde81e8@enqueue_thread /home/watson/src/fluentd/lib/fluent/plugin_helper/thread.rb:70 sleep>, #<Thread:0x00007f9f9cd0dae8@flush_thread_0 /home/watson/src/fluentd/lib/fluent/plugin_helper/thread.rb:70 sleep>, #<Thread:0x00007f9f9cd0d660@enqueue_thread /home/watson/src/fluentd/lib/fluent/plugin_helper/thread.rb:70 sleep>, #<Thread:0x00007f9f9cbfb6f0@flush_thread_0 /home/watson/src/fluentd/lib/fluent/plugin_helper/thread.rb:70 sleep>, #<Thread:0x00007f9f9cbfb330@enqueue_thread /home/watson/src/fluentd/lib/fluent/plugin_helper/thread.rb:70 sleep>] ``` After: ``` $ ruby -Ilib:test -e "at_exit { puts '--- Thread count at exit: ' + Thread.list.size.to_s; pp Thread.list }; require './test/plugin/test_output_as_buffered.rb'" Loaded suite -e Started Finished in 53.240484088 seconds. ------------------------------------------------------------------------------------------------------------------------------------------- 56 tests, 393 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ------------------------------------------------------------------------------------------------------------------------------------------- 1.05 tests/s, 7.38 assertions/s --- Thread count at exit: 2 [#<Thread:0x00007f2df88d7f70 run>, #<Thread:0x00007f2ddb3e3bd0@Timeout stdlib thread /home/watson/.rbenv/versions/4.0.2/lib/ruby/4.0.0/timeout.rb:87 sleep_forever>] ``` **Docs Changes**: N/A **Release Note**: N/A Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
1 parent 462e5e4 commit 593d9e7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

test/plugin/test_output_as_buffered.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,7 +2067,10 @@ def waiting(seconds)
20672067
end
20682068
# staged buffer (.b) was picked up, then ready to flush by enqueuing (.q)
20692069
assert{ @resumer.buffer.stage.size == 0 && @resumer.buffer.queue.size == 1 }
2070+
@resumer.stop
2071+
@resumer.before_shutdown
20702072
@resumer.shutdown
2073+
@resumer.after_shutdown
20712074
end
20722075
end
20732076
end

0 commit comments

Comments
 (0)