mirror of
https://github.com/azaion/admin.git
synced 2026-06-21 15:31:09 +00:00
c7b297de83
- Deleted the deploy.cmd script as it was no longer needed. - Updated Dockerfile to include curl for health checks and added a non-root user for improved security. - Modified health check command to use curl for better reliability. - Adjusted docker-compose.test.yml to reflect changes in health check configuration. - Cleaned up appsettings.json and removed unused configuration properties. - Removed Resource entity and related requests from the codebase as part of the architectural shift. - Updated documentation to reflect the removal of hardware binding and related endpoints. Co-authored-by: Cursor <cursoragent@cursor.com>
67 lines
2.1 KiB
Bash
Executable File
67 lines
2.1 KiB
Bash
Executable File
#!/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 <<SQL
|
|
INSERT INTO public.users (id, email, password_hash, role)
|
|
SELECT
|
|
gen_random_uuid(),
|
|
'perf-user-' || lpad(g::text, 5, '0') || '@perf.azaion.com',
|
|
'282wqVHZU0liTxphiGkKIaJtUA1W6rILdvfEOx8Ez350x0XLbgNtrSUYCK1r/ajq',
|
|
'ApiAdmin'
|
|
FROM generate_series(1, $PERF_USER_COUNT) AS g
|
|
ON CONFLICT (email) DO NOTHING;
|
|
SELECT count(*) AS users_total FROM public.users;
|
|
SQL
|
|
|
|
echo "=== Running k6 performance scenarios ==="
|
|
# handleSummary() in perf-scenarios.js writes the JSON summary to RESULTS_DIR.
|
|
set +e
|
|
BASE_URL="$BASE_URL" k6 run "$SCENARIOS_FILE"
|
|
K6_EXIT=$?
|
|
set -e
|
|
|
|
echo "=== Performance test run complete (k6 exit=$K6_EXIT) ==="
|
|
exit $K6_EXIT
|