Files
clawmates/scripts/e2e-backend.sh
T
Omar SobhandClaude Fable 5 889c65685e e2e harness: refuse to run when port 8080 is already serving
The Playwright backend harness now aborts if something else (e.g. the
compose stack) is already on :8080, instead of letting reuseExistingServer
silently point every journey at the wrong backend with the wrong seed —
the failure mode that surfaced mid-restyle. Also gitignore the local
data/ blob-store artifacts.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-06-10 20:32:29 -05:00

55 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Boots the real backend for Playwright: a fresh Postgres container plus
# clawmates-server in e2e mode (deterministic seed). Playwright's webServer
# waits on the /healthz port.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
docker rm -f clawmates-e2e-pg >/dev/null 2>&1 || true
docker run -d --name clawmates-e2e-pg \
-e POSTGRES_PASSWORD=e2e \
-e POSTGRES_DB=clawmates_e2e \
-p 54330:5432 \
postgres:16-alpine >/dev/null
until docker exec clawmates-e2e-pg pg_isready -U postgres -q >/dev/null 2>&1; do
sleep 0.5
done
# Real OIDC IdP for the OAuth browser-flow journey.
docker rm -f clawmates-e2e-dex >/dev/null 2>&1 || true
docker run -d --name clawmates-e2e-dex \
-p 54556:5556 \
-v "$ROOT/deploy/e2e/dex.yaml:/etc/dex/config.yaml:ro" \
dexidp/dex:v2.41.1 dex serve /etc/dex/config.yaml >/dev/null
until curl -fsS http://127.0.0.1:54556/dex/.well-known/openid-configuration >/dev/null 2>&1; do
sleep 0.5
done
# Refuse to run against someone else's 8080 (e.g. the compose stack):
# reuseExistingServer would silently point every journey at the wrong
# backend with the wrong seed.
if curl -fsS -o /dev/null --max-time 2 http://127.0.0.1:8080/healthz 2>/dev/null; then
echo "e2e-backend: port 8080 is already serving — stop the other stack first" >&2
echo " (docker compose -f deploy/compose/docker-compose.yml down)" >&2
exit 1
fi
cd "$ROOT"
export CLAWMATES_MODE=e2e
export CLAWMATES_CONFIG="$ROOT/deploy/e2e/clawmates.e2e.toml"
export SQLX_OFFLINE=true
# The secret broker daemon (own process, like production).
export CLAWMATES_DATABASE__URL="postgres://postgres:[email protected]:54330/clawmates_e2e"
export CLAWMATES_BROKER_SOCKET="/tmp/clawmates-e2e-broker.sock"
export CLAWMATES_BROKER_KEY_FILE="/tmp/clawmates-e2e-broker.key"
rm -f "$CLAWMATES_BROKER_SOCKET" "$CLAWMATES_BROKER_KEY_FILE"
cargo build -p clawmates-server -p clawmates-broker
cargo run -p clawmates-broker &
BROKER_PID=$!
trap 'kill $BROKER_PID 2>/dev/null' EXIT
exec cargo run -p clawmates-server