#!/usr/bin/env bash set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" RESULTS_DIR="$PROJECT_ROOT/e2e/test-results" COMPOSE_FILE="$PROJECT_ROOT/docker-compose.test.yml" SCENARIOS_FILE="$SCRIPT_DIR/perf-scenarios.js" BASE_URL="${BASE_URL:-http://localhost:8080}" PERF_USER_COUNT="${PERF_USER_COUNT:-500}" if ! command -v k6 >/dev/null 2>&1; then echo "ERROR: k6 not found on PATH. Install with: brew install k6" exit 1 fi mkdir -p "$RESULTS_DIR" cleanup() { echo "=== Tearing down ===" docker compose -f "$COMPOSE_FILE" down -v --remove-orphans || true } trap cleanup EXIT echo "=== Starting system under test ===" docker compose -f "$COMPOSE_FILE" up -d system-under-test test-db echo "=== Waiting for system to be ready ===" MAX_WAIT=60 WAIT=0 until curl -sf "$BASE_URL/swagger/index.html" > /dev/null 2>&1 || [ $WAIT -ge $MAX_WAIT ]; do sleep 1 WAIT=$((WAIT + 1)) done if [ $WAIT -ge $MAX_WAIT ]; then echo "ERROR: System did not become ready within ${MAX_WAIT}s" docker compose -f "$COMPOSE_FILE" logs --tail=80 system-under-test || true exit 1 fi echo "=== Seeding $PERF_USER_COUNT perf users ===" # Reuse the admin password hash so the rows satisfy NOT NULL on password_hash. # These users are only used as listing volume, never for login. docker compose -f "$COMPOSE_FILE" exec -T test-db psql -U postgres -d azaion -v ON_ERROR_STOP=1 <