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

When data is bigger than 1024, data loss can happen #2900

Merged
merged 1 commit into from
Mar 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions test/command/test_fluentd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ def execute_command(cmdline, chdir=TMP_DIR, env = {})
null_stream.close rescue nil
end

def eager_read(io)
buf = +''

loop do
b = io.read_nonblock(1024, nil, exception: false)
if b == :wait_readable || b.nil?
return buf
end
buf << b
end
end

def assert_log_matches(cmdline, *pattern_list, patterns_not_match: [], timeout: 10, env: {})
matched = false
assert_error_msg = "matched correctly"
Expand All @@ -97,7 +109,7 @@ def assert_log_matches(cmdline, *pattern_list, patterns_not_match: [], timeout:
next unless readables
break if readables.first.eof?

buf = readables.first.readpartial(1024)
buf = eager_read(readables.first)
# puts buf
stdio_buf << buf
lines = stdio_buf.split("\n")
Expand Down Expand Up @@ -150,7 +162,7 @@ def assert_fluentd_fails_to_start(cmdline, *pattern_list, timeout: 10)
next unless readables
next if readables.first.eof?

stdio_buf << readables.first.readpartial(1024)
stdio_buf << eager_read(readables.first)
lines = stdio_buf.split("\n")
if lines.any?{|line| line.include?("fluentd worker is now running") }
running = true
Expand Down