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

This test checks that tail_watcher must be empty #2938

Merged
merged 1 commit into from
Apr 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions test/plugin/test_in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ def teardown
def cleanup_directory(path)
FileUtils.rm_rf(path, secure: true)
if File.exist?(path)
# ensure files are closed for Windows, on which deleted files
# are still visible from filesystem
GC.start(full_mark: true, immediate_mark: true, immediate_sweep: true)
FileUtils.remove_entry_secure(path, true)
end
FileUtils.mkdir_p(path)
Expand Down Expand Up @@ -1065,9 +1062,6 @@ def test_log_file_without_extension
assert_equal expected_files, plugin.expand_paths.sort
end

# For https://github.com/fluent/fluentd/issues/1455
# This test is fragile because test content depends on internal implementation.
# So if you modify in_tail internal, this test may break.
def test_unwatched_files_should_be_removed
config = config_element("", "", {
"tag" => "tail",
Expand All @@ -1085,16 +1079,9 @@ def test_unwatched_files_should_be_removed

cleanup_directory(TMP_DIR)
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 }
waiting(5) { sleep 0.1 until d.instance.instance_variable_get(:@tails).keys.size <= 0 }

# Previous implementation has an infinite watcher creation bug.
# Following code checks such unexpected bug by counting actual object allocation.
base_num = count_timer_object
2.times {
sleep 1
num = count_timer_object
assert_equal base_num, num
}
assert_equal 0, d.instance.instance_variable_get(:@tails).keys.size

d.instance_shutdown
end
Expand Down