From 97b5ee2fb389b8844f936c5662e2851848b2b733 Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Sun, 19 Jul 2026 18:26:13 +0900 Subject: [PATCH] test_fluentd: read until EOF in assert_fluentd_fails_to_start Gating the read loop on `process_exist?(pid)` is racy: fluentd can write its final error line and exit right after `eager_read` drains the pipe, so the loop exits (process gone) before that last line is read. The error message is then missing from `stdio_buf` and the assertion fails even though fluentd did fail to start as expected. This showed up as a flaky failure of "fails to launch fluentd if specified root path is invalid path for directory": the captured output ended at "bundler: failed to load command:" without the following "non directory entry exists:" line. Loop until the pipe reaches EOF (the write-end is closed when the process exits) instead, so the remaining buffered output is always drained. The success case still breaks early once the worker is running, and hangs are still caught by the outer `waiting(timeout)`. This mirrors the existing EOF handling in `assert_log_matches`. Signed-off-by: Shizuo Fujita --- test/command/test_fluentd.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/command/test_fluentd.rb b/test/command/test_fluentd.rb index 2ca08f5779..042c2c70db 100644 --- a/test/command/test_fluentd.rb +++ b/test/command/test_fluentd.rb @@ -230,10 +230,10 @@ def assert_fluentd_fails_to_start(cmdline, *pattern_list, timeout: 20) execute_command(cmdline) do |pid, stdout| begin waiting(timeout) do - while process_exist?(pid) && !running + until running readables, _, _ = IO.select([stdout], nil, nil, 1) next unless readables - next if readables.first.eof? + break if readables.first.eof? stdio_buf << eager_read(readables.first) lines = stdio_buf.split("\n")