52 lines
1.7 KiB
Bash
Executable File
52 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Run the peddlers-test harness while streaming the server container logs to
|
|
# a timestamped file in the repo root. This helps correlate client-side
|
|
# intercepted WS sends with server handling (e.g., setPlayerName lines).
|
|
|
|
TS=$(date +%s)
|
|
OUT_DIR=$(pwd)
|
|
LOGFILE="$OUT_DIR/tmp-server-logs-$TS.server.log"
|
|
echo "ts=$TS"
|
|
|
|
# Find the server container by common names used in docker-compose
|
|
CID=$(docker ps -q --filter "name=ketr.ketran.dev" || true)
|
|
if [ -z "$CID" ]; then CID=$(docker ps -q --filter "name=ketr.ketran" || true); fi
|
|
if [ -z "$CID" ]; then
|
|
# fallback: try to find the compose service container
|
|
CID=$(docker compose -f docker-compose.yml ps -q peddlers-of-ketran || true)
|
|
fi
|
|
echo "server container id: ${CID:-<none>}"
|
|
|
|
LOG_PID=""
|
|
if [ -n "$CID" ]; then
|
|
echo "Starting log follower: docker logs -f $CID -> $LOGFILE"
|
|
# Stream logs (since 0s to include recent lines) in background
|
|
docker logs --since 0s -f "$CID" > "$LOGFILE" 2>&1 &
|
|
LOG_PID=$!
|
|
echo "log follower pid: $LOG_PID"
|
|
else
|
|
echo "Warning: no server container found; server logs will not be captured"
|
|
fi
|
|
|
|
cleanup() {
|
|
rc=$?
|
|
if [ -n "$LOG_PID" ]; then
|
|
echo "Stopping log follower pid $LOG_PID"
|
|
kill "$LOG_PID" 2>/dev/null || true
|
|
wait "$LOG_PID" 2>/dev/null || true
|
|
fi
|
|
echo "Artifacts in repo root (tmp-*)"
|
|
ls -la tmp-* 2>/dev/null || true
|
|
exit $rc
|
|
}
|
|
|
|
trap cleanup EXIT INT TERM
|
|
|
|
echo "Running harness (docker compose run --rm -e TEST_MAX_MS=20000 peddlers-test)"
|
|
# Run the test harness inside compose; let it run with the env override for a short test
|
|
docker compose -f docker-compose.yml run --rm -e TEST_MAX_MS=20000 peddlers-test
|
|
|
|
echo "Harness completed; cleanup will run via trap"
|