From 5467ba9ed18eef2caa3d792bc7eb91b9ecbe7f05 Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Tue, 19 Nov 2024 17:18:50 +0900 Subject: [PATCH 1/2] test_in_tail: fix flaky tests for file rotation Signed-off-by: Shizuo Fujita --- test/plugin/test_in_tail.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/plugin/test_in_tail.rb b/test/plugin/test_in_tail.rb index f9e3b1a0c5..9684ddd1aa 100644 --- a/test/plugin/test_in_tail.rb +++ b/test/plugin/test_in_tail.rb @@ -3265,6 +3265,7 @@ def test_refreshTW_during_rotation inode_0 = tail_watchers[0]&.ino inode_1 = tail_watchers[1]&.ino inode_2 = tail_watchers[2]&.ino + pos_file_inode = tail_watchers[2].pe.read_inode record_values = d.events.collect { |event| event[2]["message"] }.sort position_entries = [] Fluent::FileWrapper.open("#{@tmp_dir}/tail.pos", "r") do |f| @@ -3282,7 +3283,7 @@ def test_refreshTW_during_rotation tail_watcher_io_handler_opened_statuses: [false, false, false], position_entries: [ # The recorded path is old, but it is no problem. The path is not used when using follow_inodes. - ["#{@tmp_dir}/tail.txt0", "0000000000000016", inode_2], + ["#{@tmp_dir}/tail.txt0", "0000000000000016", pos_file_inode], ], }, { @@ -3346,6 +3347,7 @@ def test_next_rotation_occurs_very_fast_while_old_TW_still_waiting_rotate_wait inode_0 = tail_watchers[0]&.ino inode_1 = tail_watchers[1]&.ino inode_2 = tail_watchers[2]&.ino + pos_file_inode = tail_watchers[2].pe.read_inode record_values = d.events.collect { |event| event[2]["message"] }.sort position_entries = [] Fluent::FileWrapper.open("#{@tmp_dir}/tail.pos", "r") do |f| @@ -3362,7 +3364,7 @@ def test_next_rotation_occurs_very_fast_while_old_TW_still_waiting_rotate_wait tail_watcher_inodes: [inode_0, inode_1, inode_2], tail_watcher_io_handler_opened_statuses: [false, false, false], position_entries: [ - ["#{@tmp_dir}/tail.txt0", "0000000000000016", inode_2], + ["#{@tmp_dir}/tail.txt0", "0000000000000016", pos_file_inode], ], }, { From 8880cb679aa131c0692d43fe3bab232ce812cf06 Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Wed, 20 Nov 2024 09:28:35 +0900 Subject: [PATCH 2/2] test_in_tail: remove unnecessary inode assertions Signed-off-by: Shizuo Fujita --- test/plugin/test_in_tail.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/plugin/test_in_tail.rb b/test/plugin/test_in_tail.rb index 9684ddd1aa..7b1405999a 100644 --- a/test/plugin/test_in_tail.rb +++ b/test/plugin/test_in_tail.rb @@ -3262,9 +3262,6 @@ def test_refreshTW_during_rotation Fluent::FileWrapper.open("#{@tmp_dir}/tail.txt0", "ab") {|f| f.puts "file3 log2"} end - inode_0 = tail_watchers[0]&.ino - inode_1 = tail_watchers[1]&.ino - inode_2 = tail_watchers[2]&.ino pos_file_inode = tail_watchers[2].pe.read_inode record_values = d.events.collect { |event| event[2]["message"] }.sort position_entries = [] @@ -3279,7 +3276,6 @@ def test_refreshTW_during_rotation { record_values: ["file1 log1", "file1 log2", "file2 log1", "file2 log2", "file3 log1", "file3 log2"], tail_watcher_paths: ["#{@tmp_dir}/tail.txt0", "#{@tmp_dir}/tail.txt0", "#{@tmp_dir}/tail.txt0"], - tail_watcher_inodes: [inode_0, inode_1, inode_2], tail_watcher_io_handler_opened_statuses: [false, false, false], position_entries: [ # The recorded path is old, but it is no problem. The path is not used when using follow_inodes. @@ -3289,7 +3285,6 @@ def test_refreshTW_during_rotation { record_values: record_values, tail_watcher_paths: tail_watchers.collect { |tw| tw.path }, - tail_watcher_inodes: tail_watchers.collect { |tw| tw.ino }, tail_watcher_io_handler_opened_statuses: tail_watchers.collect { |tw| tw.instance_variable_get(:@io_handler)&.opened? || false }, position_entries: position_entries }, @@ -3344,9 +3339,6 @@ def test_next_rotation_occurs_very_fast_while_old_TW_still_waiting_rotate_wait sleep 4 end - inode_0 = tail_watchers[0]&.ino - inode_1 = tail_watchers[1]&.ino - inode_2 = tail_watchers[2]&.ino pos_file_inode = tail_watchers[2].pe.read_inode record_values = d.events.collect { |event| event[2]["message"] }.sort position_entries = [] @@ -3361,7 +3353,6 @@ def test_next_rotation_occurs_very_fast_while_old_TW_still_waiting_rotate_wait { record_values: ["file1 log1", "file1 log2", "file2 log1", "file2 log2", "file3 log1", "file3 log2"], tail_watcher_paths: ["#{@tmp_dir}/tail.txt0", "#{@tmp_dir}/tail.txt0", "#{@tmp_dir}/tail.txt0"], - tail_watcher_inodes: [inode_0, inode_1, inode_2], tail_watcher_io_handler_opened_statuses: [false, false, false], position_entries: [ ["#{@tmp_dir}/tail.txt0", "0000000000000016", pos_file_inode], @@ -3370,7 +3361,6 @@ def test_next_rotation_occurs_very_fast_while_old_TW_still_waiting_rotate_wait { record_values: record_values, tail_watcher_paths: tail_watchers.collect { |tw| tw.path }, - tail_watcher_inodes: tail_watchers.collect { |tw| tw.ino }, tail_watcher_io_handler_opened_statuses: tail_watchers.collect { |tw| tw.instance_variable_get(:@io_handler)&.opened? || false }, position_entries: position_entries },