Skip to content
Open
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
39 changes: 24 additions & 15 deletions tests/runtime_shell/proxy_logs_expect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,34 @@ echo "Using Fluent Bit at: $FLB_BIN"
test_proxy_logs_compatibility() {
export SIGNAL_FILE_PATH="/tmp/flb_signal_logs_$$.txt"
STDOUT_OUTPUT_FILE="/tmp/test_logs_stdout_$$.txt"

rm -f "$STDOUT_OUTPUT_FILE" "$SIGNAL_FILE_PATH"

$FLB_BIN -e $FLB_ROOT/build/test_logs_go.so -c $FLB_RUNTIME_SHELL_CONF/proxy_logs_test.conf > "$STDOUT_OUTPUT_FILE" 2>&1 &
FLB_PID=$!

sleep 3

if [ -f "$STDOUT_OUTPUT_FILE" ]; then
echo "SUCCESS: Captured Fluent Bit output"
echo "Output contents:"
cat "$STDOUT_OUTPUT_FILE"
else
echo "FAIL: No stdout output captured"
return 1
fi

# Clean up

# the Go output prints every record it receives: wait for the 3 samples
records=0
for retry in `seq 20`
do
records=$(grep -c '^map\[level:' "$STDOUT_OUTPUT_FILE" 2>/dev/null || true)
records=${records:-0}
if [ "$records" -ge 3 ]; then
break
fi
sleep 0.5
done

# stop Fluent Bit, it does not exit by itself
kill -15 "$FLB_PID" 2>/dev/null || true
wait "$FLB_PID" 2>/dev/null || true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Detect abnormal Fluent Bit exits

If Fluent Bit prints the three expected records and then crashes or exits nonzero—including during SIGTERM teardown—this wait ... || true discards the failure status, and the record-count assertion still passes. Fluent Bit handles SIGTERM as a clean shutdown, so capture the wait status and require a successful exit rather than masking every termination failure.

Useful? React with 👍 / 👎.


echo "Output contents:"
cat "$STDOUT_OUTPUT_FILE"

rm -f "$STDOUT_OUTPUT_FILE" "$SIGNAL_FILE_PATH"

assertEquals "records printed by the Go output" 3 "$records"
}

# Load the runtime shell environment
Expand Down
Loading