Skip to content

Commit 2b33a69

Browse files
authored
test_in_tail: fix flaky tests for file rotation (#4710)
* test_in_tail: fix flaky tests for file rotation Signed-off-by: Shizuo Fujita <[email protected]> * test_in_tail: remove unnecessary inode assertions Signed-off-by: Shizuo Fujita <[email protected]> --------- Signed-off-by: Shizuo Fujita <[email protected]>
1 parent eebc7e1 commit 2b33a69

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

test/plugin/test_in_tail.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3262,9 +3262,7 @@ def test_refreshTW_during_rotation
32623262
Fluent::FileWrapper.open("#{@tmp_dir}/tail.txt0", "ab") {|f| f.puts "file3 log2"}
32633263
end
32643264

3265-
inode_0 = tail_watchers[0]&.ino
3266-
inode_1 = tail_watchers[1]&.ino
3267-
inode_2 = tail_watchers[2]&.ino
3265+
pos_file_inode = tail_watchers[2].pe.read_inode
32683266
record_values = d.events.collect { |event| event[2]["message"] }.sort
32693267
position_entries = []
32703268
Fluent::FileWrapper.open("#{@tmp_dir}/tail.pos", "r") do |f|
@@ -3278,17 +3276,15 @@ def test_refreshTW_during_rotation
32783276
{
32793277
record_values: ["file1 log1", "file1 log2", "file2 log1", "file2 log2", "file3 log1", "file3 log2"],
32803278
tail_watcher_paths: ["#{@tmp_dir}/tail.txt0", "#{@tmp_dir}/tail.txt0", "#{@tmp_dir}/tail.txt0"],
3281-
tail_watcher_inodes: [inode_0, inode_1, inode_2],
32823279
tail_watcher_io_handler_opened_statuses: [false, false, false],
32833280
position_entries: [
32843281
# The recorded path is old, but it is no problem. The path is not used when using follow_inodes.
3285-
["#{@tmp_dir}/tail.txt0", "0000000000000016", inode_2],
3282+
["#{@tmp_dir}/tail.txt0", "0000000000000016", pos_file_inode],
32863283
],
32873284
},
32883285
{
32893286
record_values: record_values,
32903287
tail_watcher_paths: tail_watchers.collect { |tw| tw.path },
3291-
tail_watcher_inodes: tail_watchers.collect { |tw| tw.ino },
32923288
tail_watcher_io_handler_opened_statuses: tail_watchers.collect { |tw| tw.instance_variable_get(:@io_handler)&.opened? || false },
32933289
position_entries: position_entries
32943290
},
@@ -3343,9 +3339,7 @@ def test_next_rotation_occurs_very_fast_while_old_TW_still_waiting_rotate_wait
33433339
sleep 4
33443340
end
33453341

3346-
inode_0 = tail_watchers[0]&.ino
3347-
inode_1 = tail_watchers[1]&.ino
3348-
inode_2 = tail_watchers[2]&.ino
3342+
pos_file_inode = tail_watchers[2].pe.read_inode
33493343
record_values = d.events.collect { |event| event[2]["message"] }.sort
33503344
position_entries = []
33513345
Fluent::FileWrapper.open("#{@tmp_dir}/tail.pos", "r") do |f|
@@ -3359,16 +3353,14 @@ def test_next_rotation_occurs_very_fast_while_old_TW_still_waiting_rotate_wait
33593353
{
33603354
record_values: ["file1 log1", "file1 log2", "file2 log1", "file2 log2", "file3 log1", "file3 log2"],
33613355
tail_watcher_paths: ["#{@tmp_dir}/tail.txt0", "#{@tmp_dir}/tail.txt0", "#{@tmp_dir}/tail.txt0"],
3362-
tail_watcher_inodes: [inode_0, inode_1, inode_2],
33633356
tail_watcher_io_handler_opened_statuses: [false, false, false],
33643357
position_entries: [
3365-
["#{@tmp_dir}/tail.txt0", "0000000000000016", inode_2],
3358+
["#{@tmp_dir}/tail.txt0", "0000000000000016", pos_file_inode],
33663359
],
33673360
},
33683361
{
33693362
record_values: record_values,
33703363
tail_watcher_paths: tail_watchers.collect { |tw| tw.path },
3371-
tail_watcher_inodes: tail_watchers.collect { |tw| tw.ino },
33723364
tail_watcher_io_handler_opened_statuses: tail_watchers.collect { |tw| tw.instance_variable_get(:@io_handler)&.opened? || false },
33733365
position_entries: position_entries
33743366
},

0 commit comments

Comments
 (0)