Files
clawmates/scripts/test-server.sh
T
Omar SobhandClaude Fable 5 add4f79fed Rebrand: TeamClaw -> Clawmates (clawmates.work)
Full-depth rename per the approved plan; the 'claw' product vocabulary
(claws, /claws routes, clawId, Claw Chat) stays — it is now the brand.

- Display brand: Clawmates (manifest, titles, hero, login/rail logo
  'clawmates'); default host app.clawmates.work; registry
  ghcr.io/clawmates
- Crates tc-* -> cm-* (16 crates + all imports); binaries
  clawmates-server/broker/bundler; images clawmates/*; env prefix
  CLAWMATES_* (+ CM_TEST_DATABASE_URL / CM_LIVE_LLM); config
  clawmates.toml; helm chart deploy/helm/clawmates with clawmates-*
  resources; db names clawmates*; sockets /run/clawmates; cookie
  cm_session; kind cluster clawmates-test; seccomp node profile
  clawmates-agent-profile.json
- All 9 Playwright brand assertions updated in lockstep; historical
  spec document left untouched as the only remaining 'TeamClaw'
- Local env migrated: dev pg clawmates-dev-pg/clawmates_dev, shared
  test server clawmates-test-pg, kind cluster recreated with image +
  profile, compose images rebuilt under clawmates/*

Verified end to end: 161 Rust + 68 frontend tests, 29 Playwright
journeys, 4 live kind tests, helm/install/LOC/placeholder gates, and
the clean-room install rehearsal serving the clawmates login page from
a signed bundle of the rebuilt images.

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-06-10 12:31:25 -05:00

60 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Manages the persistent shared Postgres that the whole test suite points at via
# CM_TEST_DATABASE_URL (wired up in .cargo/config.toml). One long-lived server
# means cm-testkit takes its `_container: None` branch and NEVER starts a
# per-test testcontainer — so a killed/panicking/orphaned `cargo test` has no
# container to leak. `--restart unless-stopped` keeps it up across Docker
# restarts so direct `cargo test` always has a server to connect to.
#
# Usage: scripts/test-server.sh {up|down|status|clean}
# up start the server if not already running (idempotent)
# down remove the server
# status show its state
# clean drop leftover test_<uuid> databases (reclaim space without a restart)
set -euo pipefail
CONTAINER="${CM_TEST_PG_CONTAINER:-clawmates-test-pg}"
PORT="${CM_TEST_PG_PORT:-54331}"
case "${1:-up}" in
up)
if docker ps --format '{{.Names}}' | grep -qx "$CONTAINER"; then
echo "$CONTAINER already up on :$PORT"
exit 0
fi
docker rm -f "$CONTAINER" >/dev/null 2>&1 || true
docker run -d --name "$CONTAINER" --restart unless-stopped \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=postgres \
-p "${PORT}:5432" \
postgres:16-alpine \
-c fsync=off -c full_page_writes=off -c max_connections=300 >/dev/null
until docker exec "$CONTAINER" pg_isready -U postgres -q >/dev/null 2>&1; do
sleep 0.5
done
echo "$CONTAINER up on :$PORT"
;;
down)
docker rm -f "$CONTAINER" >/dev/null 2>&1 || true
echo "$CONTAINER removed"
;;
status)
docker ps -a --filter "name=^/${CONTAINER}$" \
--format '{{.Names}} | {{.Status}} | {{.Ports}}' || true
;;
clean)
# Drop every transient test database to reclaim space (cm-testkit creates
# test_<uuid> per test and does not drop them). Safe to run anytime.
docker exec "$CONTAINER" psql -U postgres -tAc \
"SELECT datname FROM pg_database WHERE datname LIKE 'test\_%'" \
| while IFS= read -r db; do
[ -n "$db" ] && docker exec "$CONTAINER" dropdb -U postgres --force "$db" || true
done
echo "dropped leftover test_* databases"
;;
*)
echo "usage: $0 {up|down|status|clean}" >&2
exit 2
;;
esac