Skip to content

Commit 2ce6d49

Browse files
authored
test_buf_file: ensure to shutdown plugin instances (#5326)
**Which issue(s) this PR fixes**: Fixes # **What this PR does / why we need it**: Same with #5325 Fix thread and resource leaks in test_buf_file.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_buf_file.rb'" Loaded suite -e Started Finished in 2.152264481 seconds. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 37 tests, 204 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 17.19 tests/s, 94.78 assertions/s --- Thread count at exit: 6 [#<Thread:0x00007f1812e67f68 run>, #<Thread:0x00007f17f68df288@Timeout stdlib thread /home/watson/.rbenv/versions/4.0.2/lib/ruby/4.0.0/timeout.rb:87 sleep>, #<Thread:0x00007f17f5bdc810@flush_thread_0 /home/watson/src/fluentd/lib/fluent/plugin_helper/thread.rb:70 sleep>, #<Thread:0x00007f17f5bdc108@enqueue_thread /home/watson/src/fluentd/lib/fluent/plugin_helper/thread.rb:70 sleep>, #<Thread:0x00007f17f5a02a30@flush_thread_0 /home/watson/src/fluentd/lib/fluent/plugin_helper/thread.rb:70 sleep>, #<Thread:0x00007f17f5a026e8@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_buf_file.rb'" Loaded suite -e Started Finished in 2.154188075 seconds. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 37 tests, 204 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 17.18 tests/s, 94.70 assertions/s --- Thread count at exit: 2 [#<Thread:0x00007fc10b277fa8 run>, #<Thread:0x00007fc0eecec9d8@Timeout stdlib thread /home/watson/.rbenv/versions/4.0.2/lib/ruby/4.0.0/timeout.rb:87 sleep>] ``` **Docs Changes**: **Release Note**: Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
1 parent b5d5630 commit 2ce6d49

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

test/plugin/test_buf_file.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,12 @@ def write_metadata(path, chunk_id, metadata, size, ctime, mtime)
755755
@p.close unless @p.closed?
756756
@p.terminate unless @p.terminated?
757757
end
758+
if @d
759+
@d.stop unless @d.stopped?
760+
@d.before_shutdown unless @d.before_shutdown?
761+
@d.shutdown unless @d.shutdown?
762+
@d.after_shutdown unless @d.after_shutdown?
763+
end
758764
end
759765

760766
test 'worker(id=0) #resume returns staged/queued chunks with metadata, not only in worker dir, including the directory specified by path' do

0 commit comments

Comments
 (0)