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

Fix an unstable test of in_tail (especially on macOS) #3314

Merged
merged 1 commit into from
Apr 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 15 additions & 10 deletions test/plugin/test_in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ def test_truncate_file
File.open("#{TMP_DIR}/tail.txt", "wb") {|f|
f.puts "test1"
f.puts "test2"
f.flush
}

d = create_driver(config)
Expand All @@ -598,19 +599,23 @@ def test_truncate_file
f.puts "test3\ntest4"
f.flush
}
sleep 1
waiting(2) { sleep 0.1 until d.events.length == 2 }
File.truncate("#{TMP_DIR}/tail.txt", 6)
end

events = d.events
assert_equal(3, events.length)
assert_equal({"message" => "test3"}, events[0][2])
assert_equal({"message" => "test4"}, events[1][2])
assert_equal({"message" => "test1"}, events[2][2])
assert(events[0][1].is_a?(Fluent::EventTime))
assert(events[1][1].is_a?(Fluent::EventTime))
assert(events[2][1].is_a?(Fluent::EventTime))
assert_equal(2, d.emit_count)
expected = {
emit_count: 2,
events: [
[Fluent::EventTime, {"message" => "test3"}],
[Fluent::EventTime, {"message" => "test4"}],
[Fluent::EventTime, {"message" => "test1"}],
]
}
actual = {
emit_count: d.emit_count,
events: d.events.collect{|event| [event[1].class, event[2]]}
}
assert_equal(expected, actual)
end

def test_move_truncate_move_back
Expand Down