diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 1042fc9a..00000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 49ed3c80..125abd9b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -392,22 +392,7 @@ jobs: SQL - name: Start Go server with fixture DB - run: | - fuser -k 13581/tcp 2>/dev/null || true - sleep 1 - ./corescope-server -port 13581 -db test-fixtures/e2e-fixture.db -public public-instrumented & - echo $! > .server.pid - for i in $(seq 1 30); do - if curl -sf http://localhost:13581/api/healthz > /dev/null 2>&1; then - echo "Server ready after ${i}s" - break - fi - if [ "$i" -eq 30 ]; then - echo "Server failed to start within 30s" - exit 1 - fi - sleep 1 - done + run: bash scripts/e2e-fresh-server.sh - name: Run Playwright E2E tests (fail-fast) run: | @@ -665,6 +650,7 @@ jobs: run_e2e_suite || { echo "::warning::E2E suite failed - flake-guard retry once (issue #61)" cp e2e-output.txt e2e-output.attempt1.txt 2>/dev/null || true + bash scripts/e2e-fresh-server.sh run_e2e_suite } diff --git a/scripts/e2e-fresh-server.sh b/scripts/e2e-fresh-server.sh new file mode 100644 index 00000000..982e1a2d --- /dev/null +++ b/scripts/e2e-fresh-server.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# Restore the pristine E2E fixture, freshen its timestamps, and (re)start the +# server. The Packets page defaults to a 15-minute window, so fixture data goes +# stale ~15 min after freshen; every suite attempt needs its own fresh start. +# Run from the repo root. +set -euo pipefail + +PORT="${E2E_PORT:-13581}" +DB="${E2E_DB:-test-fixtures/e2e-fixture.db}" +PRISTINE="${E2E_PRISTINE:-/tmp/e2e-fixture.pristine.db}" +PUBLIC_DIR="${E2E_PUBLIC:-public-instrumented}" +LOG="${E2E_SERVER_LOG:-server.log}" + +# First call: snapshot the seeded fixture before the server ever opens it. +if [ ! -f "$PRISTINE" ]; then + sqlite3 "$DB" "PRAGMA wal_checkpoint(TRUNCATE);" >/dev/null 2>&1 || true + cp "$DB" "$PRISTINE" +fi + +if [ -f .server.pid ]; then kill "$(cat .server.pid)" 2>/dev/null || true; fi +fuser -k "$PORT"/tcp 2>/dev/null || true +sleep 1 + +rm -f "$DB-wal" "$DB-shm" +cp "$PRISTINE" "$DB" +bash tools/freshen-fixture.sh "$DB" + +./corescope-server -port "$PORT" -db "$DB" -public "$PUBLIC_DIR" >"$LOG" 2>&1 & +echo $! > .server.pid + +for i in $(seq 1 180); do + if curl -sf "http://localhost:$PORT/api/healthz" >/dev/null 2>&1; then + echo "Server ready after ${i}s" + exit 0 + fi + sleep 1 +done +echo "Server failed to start within 180s" >&2 +tail -n 50 "$LOG" >&2 || true +exit 1 \ No newline at end of file