forked from molecule-ai/molecule-core
The harness brings up the SaaS tenant topology on localhost using the SAME workspace-server/Dockerfile.tenant image that ships to production. Tests run against http://harness-tenant.localhost:8080 and exercise the same code path a real tenant takes: client → cf-proxy (nginx; CF tunnel + LB header rewrites) → tenant (Dockerfile.tenant — combined platform + canvas) → cp-stub (minimal Go CP stand-in for /cp/* paths) → postgres + redis Why this exists: bugs that survive `go run ./cmd/server` and ship to prod almost always live in env-gated middleware (TenantGuard, /cp/* proxy, canvas proxy), header rewrites, or the strict-auth / live-token mode. The harness activates ALL of them locally so #2395 + #2397-class bugs can be reproduced before deploy. Phase 1 surface: - cp-stub/main.go: minimal CP stand-in. /cp/auth/me, redeploy-fleet, /__stub/{peers,mode,state} for replay scripts. Catch-all returns 501 with a clear message when a new CP route appears. - cf-proxy/nginx.conf: rewrites Host to <slug>.localhost, injects X-Forwarded-*, disables buffering to mirror CF tunnel streaming semantics. - compose.yml: one service per topology layer; tenant builds from the actual production Dockerfile.tenant. - up.sh / down.sh / seed.sh: lifecycle scripts. - replays/peer-discovery-404.sh: reproduces #2397 + asserts the diagnostic helper from PR #2399 surfaces "404" + "registered". - replays/buildinfo-stale-image.sh: reproduces #2395 + asserts /buildinfo wire shape + GIT_SHA injection from PR #2398. - README.md: topology, quickstart, what the harness does NOT cover. Phases 2-3 (separate PRs): - Phase 2: convert tests/e2e/test_api.sh to target the harness URL instead of localhost; make harness-based replays a required CI gate. - Phase 3: config-coherence lint that diffs harness env list against production CP's env list, fails CI on drift. Verification: - cp-stub builds (go build ./...). - cp-stub responds to all stubbed endpoints (smoke-tested locally). - compose.yml passes `docker compose config --quiet`. - All shell scripts pass `bash -n` syntax check. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
40 lines
1.3 KiB
Bash
Executable File
40 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Bring the production-shape harness up.
|
|
#
|
|
# Usage: ./up.sh [--rebuild]
|
|
#
|
|
# Always operates in tests/harness/ regardless of where it's invoked
|
|
# from — test scripts under tests/harness/replays/ source it via the
|
|
# absolute path, so cd-ing first prevents compose-context surprises.
|
|
|
|
set -euo pipefail
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$HERE"
|
|
|
|
REBUILD=false
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--rebuild) REBUILD=true ;;
|
|
esac
|
|
done
|
|
|
|
if [ "$REBUILD" = true ]; then
|
|
docker compose -f compose.yml build --no-cache tenant cp-stub
|
|
fi
|
|
|
|
echo "[harness] starting cp-stub + postgres + redis + tenant + cf-proxy ..."
|
|
docker compose -f compose.yml up -d --wait
|
|
|
|
echo "[harness] /etc/hosts entry for harness-tenant.localhost..."
|
|
if ! grep -q '^127\.0\.0\.1[[:space:]]\+harness-tenant\.localhost' /etc/hosts; then
|
|
echo " (skip — your /etc/hosts may not resolve *.localhost. If tests fail with"
|
|
echo " 'getaddrinfo' errors, add: 127.0.0.1 harness-tenant.localhost)"
|
|
fi
|
|
|
|
echo ""
|
|
echo "[harness] up. Tenant: http://harness-tenant.localhost:8080/health"
|
|
echo " http://harness-tenant.localhost:8080/buildinfo"
|
|
echo " cp-stub: http://localhost (internal-only via compose net)"
|
|
echo ""
|
|
echo "Next: ./seed.sh # mint admin token + register sample workspaces"
|