From 765e36a127243a463ef3861bfdd872e01d756c18 Mon Sep 17 00:00:00 2001 From: Takuro Ashie Date: Tue, 14 Jun 2022 11:55:27 +0900 Subject: [PATCH] test_in_tail: Show more information of test_unwatched_files_should_be_removed It's unstable on macOS but hard to debug due to less information: https://github.com/fluent/fluentd/runs/6872721774?check_suite_focus=true ``` 2022-06-14T02:25:40.1951760Z Failure: test_unwatched_files_should_be_removed(TailInputTest::path) 2022-06-14T02:25:40.1968250Z /Users/runner/work/fluentd/fluentd/test/plugin/test_in_tail.rb:1615:in `test_unwatched_files_should_be_removed' 2022-06-14T02:25:40.1968820Z 1612: waiting(20) { sleep 0.1 until Dir.glob("#{@tmp_dir}/*.txt").size == 0 } # Ensure file is deleted on Windows 2022-06-14T02:25:40.1969220Z 1613: waiting(5) { sleep 0.1 until d.instance.instance_variable_get(:@tails).keys.size <= 0 } 2022-06-14T02:25:40.1969500Z 1614: 2022-06-14T02:25:40.1969770Z => 1615: assert_equal(0, d.instance.instance_variable_get(:@tails).keys.size) 2022-06-14T02:25:40.1970010Z 1616: 2022-06-14T02:25:40.1970200Z 1617: d.instance_shutdown 2022-06-14T02:25:40.1970500Z 1618: end 2022-06-14T02:25:40.1970720Z <0> expected but was 2022-06-14T02:25:40.1970910Z <1> ``` Signed-off-by: Takuro Ashie --- test/plugin/test_in_tail.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/plugin/test_in_tail.rb b/test/plugin/test_in_tail.rb index 25d9afa5ac..8d8fd4eae5 100644 --- a/test/plugin/test_in_tail.rb +++ b/test/plugin/test_in_tail.rb @@ -1612,9 +1612,18 @@ def test_unwatched_files_should_be_removed waiting(20) { sleep 0.1 until Dir.glob("#{@tmp_dir}/*.txt").size == 0 } # Ensure file is deleted on Windows waiting(5) { sleep 0.1 until d.instance.instance_variable_get(:@tails).keys.size <= 0 } - assert_equal(0, d.instance.instance_variable_get(:@tails).keys.size) - - d.instance_shutdown + assert_equal( + { + files: [], + tails: {} + }, + { + files: Dir.glob("#{@tmp_dir}/*.txt"), + tails: d.instance.instance_variable_get(:@tails) + } + ) + ensure + d.instance_shutdown if d && d.instance end def count_timer_object