Skip to content

Commit

Permalink
test_in_tail: Fix wrong rotation tests on Windows
Browse files Browse the repository at this point in the history
`sub_test_rotate_file` should pass a rotated file to block, not a new
file. In addition, it should be opened by `Fluent::FileWrapper` to avoid
locking.

Signed-off-by: Takuro Ashie <[email protected]>
  • Loading branch information
ashie committed Jun 1, 2022
1 parent d784872 commit 3fbcc11
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/plugin/test_in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ def test_rotate_file_with_write_old_and_no_new_file(data)
assert_equal({"message" => "test8"}, events[3][2])
end

def sub_test_rotate_file(config = nil, expect_emits: nil, expect_records: nil, timeout: nil)
def sub_test_rotate_file(config = nil, expect_emits: nil, expect_records: nil, timeout: 5)
file = Fluent::FileWrapper.open("#{TMP_DIR}/tail.txt", "wb")
file.puts "test1"
file.puts "test2"
Expand All @@ -1016,7 +1016,7 @@ def sub_test_rotate_file(config = nil, expect_emits: nil, expect_records: nil, t
if Fluent.windows?
file.close
FileUtils.mv("#{TMP_DIR}/tail.txt", "#{TMP_DIR}/tail2.txt", force: true)
file = File.open("#{TMP_DIR}/tail.txt", "ab")
file = Fluent::FileWrapper.open("#{TMP_DIR}/tail2.txt", "ab")
else
FileUtils.mv("#{TMP_DIR}/tail.txt", "#{TMP_DIR}/tail2.txt")
end
Expand Down

0 comments on commit 3fbcc11

Please sign in to comment.