Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: The test_unwatched_files_should_be_removed test fails sometimes #4079

Open
daipom opened this issue Mar 3, 2023 · 2 comments
Open

CI: The test_unwatched_files_should_be_removed test fails sometimes #4079

daipom opened this issue Mar 3, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@daipom
Copy link
Contributor

daipom commented Mar 3, 2023

Describe the bug

The test_unwatched_files_should_be_removed test fails sometimes.

 Failure: test_unwatched_files_should_be_removed(TailInputTest::path)
/Users/runner/work/fluentd/fluentd/test/plugin/test_in_tail.rb:1616:in `test_unwatched_files_should_be_removed'
     1613:       waiting(20) { sleep 0.1 until Dir.glob("#{@tmp_dir}/*.txt").size == 0 } # Ensure file is deleted on Windows
     1614:       waiting(5) { sleep 0.1 until d.instance.instance_variable_get(:@tails).keys.size <= 0 }
     1615: 
  => 1616:       assert_equal(
     1617:         {
     1618:           files: [],
     1619:           tails: []
<{:files=>[], :tails=>[]}> expected but was
<{:files=>[],
 :tails=>
  ["/Users/runner/work/fluentd/fluentd/test/plugin/../tmp/tail/dcebe801d2a39d7ba0fc/tail.txt"]}>

diff:
? {:files=>[], :tails=>[]}
+  :tails=>
+   ["/Users/runner/work/fluentd/fluentd/test/plugin/../tmp/tail/dcebe801d2a39d7ba0fc/tail.txt"]}

def test_unwatched_files_should_be_removed
config = config_element("", "", {
"tag" => "tail",
"path" => "#{@tmp_dir}/*.txt",
"format" => "none",
"pos_file" => "#{@tmp_dir}/tail.pos",
"read_from_head" => true,
"refresh_interval" => 1,
})
d = create_driver(config, false)
d.end_if { d.instance.instance_variable_get(:@tails).keys.size >= 1 }
d.run(expect_emits: 1, shutdown: false) do
Fluent::FileWrapper.open("#{@tmp_dir}/tail.txt", "ab") { |f| f.puts "test3\n" }
end
cleanup_file("#{@tmp_dir}/tail.txt")
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(
{
files: [],
tails: []
},
{
files: Dir.glob("#{@tmp_dir}/*.txt"),
tails: d.instance.instance_variable_get(:@tails).keys
}
)
ensure
d.instance_shutdown if d && d.instance
cleanup_directory(@tmp_dir)
end
def count_timer_object
num = 0
ObjectSpace.each_object(Fluent::PluginHelper::Timer::TimerWatcher) { |obj|
num += 1
}
num
end
end

To Reproduce

I can't reproduce this on my local yet.

In CI, I have confirmed this on Ruby 2.7 on macos-latest.

Not sure if this is related to Ruby version or OS.

Expected behavior

The test always succeeds.

Your Environment

None

Your Configuration

None

Your Error Log

None

Additional context

No response

@abetomo
Copy link
Contributor

abetomo commented Mar 3, 2023

I have tested it on my local Mac and it does not seem to reproduce.

% sw_vers
ProductName:        macOS
ProductVersion:     13.2.1
BuildVersion:       22D68
% ruby -v
ruby 2.7.7p221 (2022-11-24 revision 168ec2b1e5) [x86_64-darwin22]

@daipom
Copy link
Contributor Author

daipom commented Mar 4, 2023

@abetomo Thanks!!
It doesn't seem to happen very often on CI. Maybe this rarely occurs.

@ashie ashie added the bug Something isn't working label Mar 31, 2023
@daipom daipom changed the title The test_unwatched_files_should_be_removed test fails sometimes CI: The test_unwatched_files_should_be_removed test fails sometimes Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants