diff --git a/tests/runtime_shell/proxy_logs_expect.sh b/tests/runtime_shell/proxy_logs_expect.sh index 08148d7542c..d32406c5042 100755 --- a/tests/runtime_shell/proxy_logs_expect.sh +++ b/tests/runtime_shell/proxy_logs_expect.sh @@ -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 + + 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