-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 unstable test_in_tail #957
Conversation
Is this test the problem correctly?
Tests should confirm the sources of events. |
Not directly writing, but this does test both tail1.txt and tail2.txt appears twice. |
I meant that it should check that the sources of these records are |
like this? diff --git a/test/plugin/test_in_tail.rb b/test/plugin/test_in_tail.rb
index a0c1b6a..80818d1 100644
--- a/test/plugin/test_in_tail.rb
+++ b/test/plugin/test_in_tail.rb
@@ -908,10 +908,10 @@ class TailInputTest < Test::Unit::TestCase
files.each do |file|
File.open(file, 'ab') { |f|
f.puts "f #{file} line should be ignored"
- f.puts "s test1"
+ f.puts "s #{file}"
f.puts "f test2"
f.puts "f test3"
- f.puts "s test4"
+ f.puts "s #{file}"
}
end
sleep 1
@@ -920,8 +920,12 @@ class TailInputTest < Test::Unit::TestCase
emits = d.emits
assert(emits.length == 4)
assert_equal(files, [emits[0][2]["path"], emits[1][2]["path"]].sort)
- # "test4" events are here because these events are flushed at shutdown phase
+ assert_equal(emits[0][2]["path"], emits[0][2]["message"].lines.first.chomp)
+ assert_equal(emits[1][2]["path"], emits[1][2]["message"].lines.first.chomp)
+ # last line events are here because these events are flushed at shutdown phase
assert_equal(files, [emits[2][2]["path"], emits[3][2]["path"]].sort)
+ assert_equal(emits[2][2]["path"], emits[2][2]["message"].lines.first.chomp)
+ assert_equal(emits[3][2]["path"], emits[3][2]["message"].lines.first.chomp)
end
end
end |
No. It's incorrect because these paths might be different one from unknown files which are used in other tests and not cleaned up. paths = emits.map{|e| e[2]["path"] }
assert{ paths.select{|path| path == "#{TMP_DIR}/tail1.txt" }.size == 2 }
assert{ paths.select{|path| path == "#{TMP_DIR}/tail2.txt" }.size == 2 } |
Well, I want to test last lines (which are flushed on shutdown fluentd/lib/fluent/plugin/in_tail.rb Line 257 in 0ce19ec
fluentd/lib/fluent/plugin/in_tail.rb Line 301 in 0ce19ec
expresses almost same tests with your tests in addition to the option. |
I mean what I want to do is like below, but this is almost same with the current test codes paths = emits[0..1].map{|e| e[2]["path"] }
assert{ paths.select{|path| path == "#{TMP_DIR}/tail1.txt" }.size == 1 }
assert{ paths.select{|path| path == "#{TMP_DIR}/tail2.txt" }.size == 1 }
# last line events are here because these events are flushed at shutdown phase
paths = emits[2..3].map{|e| e[2]["path"] }
assert{ paths.select{|path| path == "#{TMP_DIR}/tail1.txt" }.size == 1 }
assert{ paths.select{|path| path == "#{TMP_DIR}/tail2.txt" }.size == 1 } |
Ah, okay, got it > "records flushed at shutdown" |
Fix #951 (comment)