8
8
require 'timecop'
9
9
require 'tmpdir'
10
10
require 'securerandom'
11
- require 'etc'
12
11
13
12
class TailInputTest < Test ::Unit ::TestCase
14
13
include FlexMock ::TestCase
@@ -103,7 +102,6 @@ def create_target_info(path)
103
102
CONFIG_ENABLE_WATCH_TIMER = config_element ( "" , "" , { "enable_watch_timer" => false } )
104
103
CONFIG_DISABLE_STAT_WATCHER = config_element ( "" , "" , { "enable_stat_watcher" => false } )
105
104
CONFIG_OPEN_ON_EVERY_UPDATE = config_element ( "" , "" , { "open_on_every_update" => true } )
106
- CONFIG_MAX_THREAD_POOL_SIZE = config_element ( "" , "" , { "max_thread_pool_size" => ( Etc . nprocessors / 1.5 ) . ceil } )
107
105
COMMON_FOLLOW_INODE_CONFIG = config_element ( "ROOT" , "" , {
108
106
"path" => "#{ TMP_DIR } /tail.txt*" ,
109
107
"pos_file" => "#{ TMP_DIR } /tail.pos" ,
@@ -159,7 +157,6 @@ def create_driver(conf = SINGLE_LINE_CONFIG, use_common_conf = true)
159
157
assert_equal "#{ TMP_DIR } /tail.pos" , d . instance . pos_file
160
158
assert_equal 1000 , d . instance . read_lines_limit
161
159
assert_equal -1 , d . instance . read_bytes_limit_per_second
162
- assert_equal 1 , d . instance . max_thread_pool_size
163
160
assert_equal false , d . instance . ignore_repeated_permission_error
164
161
assert_nothing_raised do
165
162
d . instance . have_read_capability?
@@ -201,21 +198,14 @@ def create_driver(conf = SINGLE_LINE_CONFIG, use_common_conf = true)
201
198
202
199
sub_test_case "log throttling per file" do
203
200
test "w/o watcher timer is invalid" do
204
- conf = CONFIG_ENABLE_WATCH_TIMER + CONFIG_MAX_THREAD_POOL_SIZE + config_element ( "ROOT" , "" , { "read_bytes_limit_per_second" => "8k" } )
205
- assert_raise ( Fluent ::ConfigError ) do
206
- create_driver ( conf )
207
- end
208
- end
209
-
210
- test "w/o 2 or more thread pool size is invalid" do
211
- conf = config_element ( "ROOT" , "" , { "read_bytes_limit_per_second" => "8k" } )
201
+ conf = CONFIG_ENABLE_WATCH_TIMER + config_element ( "ROOT" , "" , { "read_bytes_limit_per_second" => "8k" } )
212
202
assert_raise ( Fluent ::ConfigError ) do
213
203
create_driver ( conf )
214
204
end
215
205
end
216
206
217
207
test "valid" do
218
- conf = CONFIG_MAX_THREAD_POOL_SIZE + config_element ( "ROOT" , "" , { "read_bytes_limit_per_second" => "8k" } )
208
+ conf = config_element ( "ROOT" , "" , { "read_bytes_limit_per_second" => "8k" } )
219
209
assert_raise ( Fluent ::ConfigError ) do
220
210
create_driver ( conf )
221
211
end
@@ -355,14 +345,6 @@ def test_emit_with_read_lines_limit(data)
355
345
cleanup_file ( "#{ TMP_DIR } /tail.txt" )
356
346
end
357
347
358
- def count_thread_pool_object
359
- num = 0
360
- ObjectSpace . each_object ( Fluent ::Plugin ::TailInput ::TailThread ::Pool ) { |obj |
361
- num += 1
362
- }
363
- num
364
- end
365
-
366
348
data ( "flat 8192 bytes, 2 events" => [ :flat , 100 , 8192 , 2 ] ,
367
349
"flat 8192 bytes, 2 events w/o stat watcher" => [ :flat_without_stat , 100 , 8192 , 2 ] ,
368
350
"flat #{ 8192 *10 } bytes, 20 events" => [ :flat , 100 , ( 8192 * 10 ) , 20 ] ,
@@ -383,13 +365,13 @@ def test_emit_with_read_bytes_limit_per_second(data)
383
365
config_style , limit , limit_bytes , num_events = data
384
366
case config_style
385
367
when :flat
386
- config = CONFIG_READ_FROM_HEAD + SINGLE_LINE_CONFIG + config_element ( "" , "" , { "read_lines_limit" => limit , "read_bytes_limit_per_second" => limit_bytes } ) + CONFIG_MAX_THREAD_POOL_SIZE
368
+ config = CONFIG_READ_FROM_HEAD + SINGLE_LINE_CONFIG + config_element ( "" , "" , { "read_lines_limit" => limit , "read_bytes_limit_per_second" => limit_bytes } )
387
369
when :parse
388
- config = CONFIG_READ_FROM_HEAD + config_element ( "" , "" , { "read_lines_limit" => limit , "read_bytes_limit_per_second" => limit_bytes } ) + PARSE_SINGLE_LINE_CONFIG + CONFIG_MAX_THREAD_POOL_SIZE
370
+ config = CONFIG_READ_FROM_HEAD + config_element ( "" , "" , { "read_lines_limit" => limit , "read_bytes_limit_per_second" => limit_bytes } ) + PARSE_SINGLE_LINE_CONFIG
389
371
when :flat_without_stat
390
- config = CONFIG_READ_FROM_HEAD + SINGLE_LINE_CONFIG + CONFIG_DISABLE_STAT_WATCHER + config_element ( "" , "" , { "read_lines_limit" => limit , "read_bytes_limit_per_second" => limit_bytes } ) + CONFIG_MAX_THREAD_POOL_SIZE
372
+ config = CONFIG_READ_FROM_HEAD + SINGLE_LINE_CONFIG + CONFIG_DISABLE_STAT_WATCHER + config_element ( "" , "" , { "read_lines_limit" => limit , "read_bytes_limit_per_second" => limit_bytes } )
391
373
when :parse_without_stat
392
- config = CONFIG_READ_FROM_HEAD + CONFIG_DISABLE_STAT_WATCHER + config_element ( "" , "" , { "read_lines_limit" => limit , "read_bytes_limit_per_second" => limit_bytes } ) + PARSE_SINGLE_LINE_CONFIG + CONFIG_MAX_THREAD_POOL_SIZE
374
+ config = CONFIG_READ_FROM_HEAD + CONFIG_DISABLE_STAT_WATCHER + config_element ( "" , "" , { "read_lines_limit" => limit , "read_bytes_limit_per_second" => limit_bytes } ) + PARSE_SINGLE_LINE_CONFIG
393
375
end
394
376
d = create_driver ( config )
395
377
msg = 'test' * 2000 # in_tail reads 8192 bytes at once.
@@ -403,10 +385,6 @@ def test_emit_with_read_bytes_limit_per_second(data)
403
385
}
404
386
end
405
387
406
- assert do
407
- count_thread_pool_object >= 1
408
- end
409
-
410
388
events = d . events
411
389
assert_true ( events . length <= num_events )
412
390
assert_equal ( { "message" => msg } , events [ 0 ] [ 2 ] )
0 commit comments