-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
in_tail: Untracked files should be removed from watching list. fix #1455 #1467
Changes from 2 commits
05a767b
3de7f11
e721379
030045a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -866,6 +866,46 @@ def test_log_file_without_extension | |
plugin = create_driver(config, false).instance | ||
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 implementaion. | ||
# So if you modify in_tail internal, this test may break. | ||
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.run(expect_emits: 1, shutdown: false) do | ||
File.open("#{TMP_DIR}/tail.txt", "ab") { |f| f.puts "test3\n" } | ||
end | ||
|
||
assert_equal 1, d.instance.instance_variable_get(:@tails).keys.size | ||
File.unlink("#{TMP_DIR}/tail.txt") | ||
sleep 2 | ||
assert_equal 0, d.instance.instance_variable_get(:@tails).keys.size | ||
|
||
base_num = count_timer_object | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want to confirm that the number of timer watcher does not increase anymore, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why comment is needed? Hard to understand from the code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. The name of test case doesn't explain what to do here. |
||
2.times { | ||
sleep 1 | ||
num = count_timer_object | ||
assert_equal base_num, num | ||
} | ||
|
||
d.instance_shutdown | ||
end | ||
|
||
def count_timer_object | ||
num = 0 | ||
ObjectSpace.each_object(Fluent::PluginHelper::Timer::TimerWatcher) { |obj| | ||
num += 1 | ||
} | ||
num | ||
end | ||
end | ||
|
||
def test_z_refresh_watchers | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
waiting(5){ sleep 0.1 until the_size_of_tails == 0 }
instead of justsleep 2
for stability.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is good. Will fix.