Skip to content

Commit

Permalink
in_tail: thread_pool: Add tailing thread poll testcases
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <hatake@clear-code.com>
  • Loading branch information
cosmo0920 committed Jan 5, 2021
1 parent e191f3b commit ddb30af
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/plugin/in_tail/test_tailthread_pool.rb
@@ -0,0 +1,26 @@
require_relative '../../helper'
require 'fluent/plugin/in_tail'

class TailThreadPoolTest < Test::Unit::TestCase
data("single thread" => 1,
"max thread pool size (10)" => 10,
"max thread pool size (20)" => 20,
)
test "thread pool creation" do |data|
max_threads_pool_size = data
thread_pool = Fluent::Plugin::TailInput::TailThread::Pool.new(max_threads_pool_size) do |pool|
100.times {|n|
pool.run {
nop_task(0.01)
assert do
pool.instance_variable_get(:@threads).size <= max_threads_pool_size
end
}
}
end
end

def nop_task(sleep_time)
sleep sleep_time
end
end

0 comments on commit ddb30af

Please sign in to comment.