mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
If the Go event recorder itself dies or cannot start, the rest of its stream (stdout, and the stderr side) now drains through cat, so go test never writes into a closed pipe and its own exit status stays the answer. Twins with a recorder that exits after 100 bytes and a large stream: exit 0 stays 0, exit 7 stays 7. Stopping the load sampler now waits on its pidfd (readable on exit) for 2 s; a sampler still alive leaves load.incomplete beside its rows and a stderr note instead of returning as if it had flushed. The stop test checks the process is gone (no file-stability guess) and a SIGTERM- ignoring stand-in yields the note within 5 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23 lines
907 B
Bash
23 lines
907 B
Bash
#!/usr/bin/env bash
|
|
# Keep timestamped Go events, while preserving the existing human output and
|
|
# nonzero pipeline status. One caller at a time appends to a job's event file.
|
|
set -euo pipefail
|
|
out=$1
|
|
shift
|
|
mkdir -p "$(dirname "$out")" || true
|
|
capture="$(dirname "$0")/go-test-output.py"
|
|
# A recorder that dies (or cannot start) hands the rest of its stream to cat,
|
|
# so Go never writes into a closed pipe.
|
|
exec 3> >({ "${PYTHON:-python3}" -u "$capture" "${out%.json}.stderr" --raw || cat; } >&2)
|
|
stderr_pid=$!
|
|
# Only Go judges the test. The readers keep draining after evidence IO errors,
|
|
# so a disk-full recorder cannot turn Go's PASS into a pipeline/SIGPIPE failure.
|
|
set +e
|
|
go test -json "$@" 2>&3 |
|
|
{ "${PYTHON:-python3}" -u "$capture" "$out" || { echo "test evidence unavailable: the recorder exited" >&2; cat; }; }
|
|
status=${PIPESTATUS[0]}
|
|
set -e
|
|
exec 3>&-
|
|
wait "$stderr_pid" || true
|
|
exit "$status"
|