#!/usr/bin/env bash # Orchestrates the Phase 4.1 ยง21 Lab Host loss/rebuild drill: brings up the real dev stack, # bootstraps an owner, runs test-lab-host-loss.js, tears down. See that file's header for what # it actually proves. set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")/../../../platform" export PROVISIONER_SHARED_SECRET="${PROVISIONER_SHARED_SECRET:-drill-shared-secret-not-for-production}" docker compose -f docker-compose.dev.yml up -d --build cleanup() { echo "==> Tearing down" docker ps -aq --filter "name=rootnode-lab-" | xargs -r docker rm -f >/dev/null 2>&1 || true docker network ls --filter "name=rootnode-lab-net-" --format "{{.Name}}" | xargs -r -n1 docker network rm >/dev/null 2>&1 || true docker compose -f docker-compose.dev.yml down >/dev/null 2>&1 || true } trap cleanup EXIT echo "==> Waiting for the stack" for i in $(seq 1 60); do curl -sf http://localhost:4300/healthz >/dev/null 2>&1 && curl -sf http://localhost:4200/healthz >/dev/null 2>&1 && break sleep 2 done echo "==> Bootstrapping the drill owner" ( cd api && PLATFORM_DB_URL=postgres://postgres:postgres@localhost:5433/rootnode_platform \ node bootstrap-owner.js labhost-drill-owner@rootnode.test "LabHost Drill Owner" 'LabHostDrillPass!2026' ) echo "==> Running the drill" OWNER_EMAIL=labhost-drill-owner@rootnode.test OWNER_PASSWORD='LabHostDrillPass!2026' \ node ../infra/scripts/drills/test-lab-host-loss.js