Skip to content

Commit

Permalink
Merge pull request #3314 from ashie/fix-unstable-test-on-mac
Browse files Browse the repository at this point in the history
Fix an unstable test of in_tail (especially on macOS)
  • Loading branch information
ashie authored Apr 2, 2021
2 parents 6a2852a + 240c72a commit f03611d
Showing 1 changed file with 15 additions and 10 deletions.
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

0 comments on commit f03611d

Please sign in to comment.