briven-engine-local-e2e.sh97 lines · main
1#!/usr/bin/env bash
2# Local end-to-end smoke for briven-engine (NO production deploy).
3#
4# 1) Starts local compose (postgres + briven-engine) if not already up
5# 2) Proves Core /hello
6# 3) Optionally hits a local API if BRIVEN_API_ORIGIN is set
7#
8# Usage:
9# chmod +x scripts/briven-engine-local-e2e.sh
10# ./scripts/briven-engine-local-e2e.sh
11#
12set -euo pipefail
13
14ROOT="$(cd "$(dirname "$0")/.." && pwd)"
15COMPOSE="$ROOT/infra/dokploy/compose.briven-engine.local.yml"
16ENGINE_URL="${BRIVEN_ENGINE_CONNECTION_URI:-http://127.0.0.1:3567}"
17API_URL="${BRIVEN_API_ORIGIN:-}"
18
19echo "==> briven-engine local e2e (deploy gate: local only)"
20echo " ENGINE_URL=$ENGINE_URL"
21
22if ! command -v docker >/dev/null 2>&1; then
23 echo "✖ docker not found — cannot start local engine"
24 exit 1
25fi
26
27export BRIVEN_POSTGRES_PASSWORD="${BRIVEN_POSTGRES_PASSWORD:-devpass}"
28
29echo "==> ensure local compose is up"
30# Prefer docker-compose v2 standalone (some docker CLI wrappers reject `compose -f`)
31if command -v docker-compose >/dev/null 2>&1; then
32 DC=(docker-compose -f "$COMPOSE")
33elif docker compose version >/dev/null 2>&1; then
34 DC=(docker compose -f "$COMPOSE")
35else
36 echo "✖ neither docker-compose nor docker compose available"
37 exit 1
38fi
39"${DC[@]}" up -d
40
41echo "==> wait for /hello"
42ok=0
43for i in $(seq 1 40); do
44 if curl -sf "$ENGINE_URL/hello" | grep -qi hello; then
45 ok=1
46 break
47 fi
48 sleep 1
49done
50
51if [[ "$ok" -ne 1 ]]; then
52 echo "✖ briven-engine did not become healthy at $ENGINE_URL"
53 "${DC[@]}" ps || true
54 "${DC[@]}" logs --tail=80 briven-engine || true
55 exit 1
56fi
57
58HELLO=$(curl -sf "$ENGINE_URL/hello" | tr -d '\r')
59echo "✔ Core hello: $HELLO"
60
61# CDI-style signup is via API/SDK, not raw Core. If API is running with
62# BRIVEN_ENGINE_CONNECTION_URI pointing here, try FDI emailpassword signup.
63if [[ -n "$API_URL" ]]; then
64 API_URL="${API_URL%/}"
65 echo "==> probe API auth-core ($API_URL)"
66 curl -sf "$API_URL/v1/auth-core/info" | head -c 400 || true
67 echo
68
69 EMAIL="e2e_$(date +%s)@example.com"
70 PASS='E2eTest!Pass99'
71 PROJECT="${BRIVEN_E2E_PROJECT_ID:-p_e2e_local}"
72
73 echo "==> attempt EmailPassword sign-up via FDI (project=$PROJECT)"
74 # SuperTokens EP signup path under apiBasePath
75 CODE=$(curl -sS -o /tmp/briven-engine-e2e-signup.json -w '%{http_code}' \
76 -X POST "$API_URL/v1/auth-core/fdi/signup" \
77 -H 'content-type: application/json' \
78 -H 'rid: emailpassword' \
79 -H "x-briven-project-id: $PROJECT" \
80 -H 'x-briven-engine: briven-engine' \
81 -d "{\"formFields\":[{\"id\":\"email\",\"value\":\"$EMAIL\"},{\"id\":\"password\",\"value\":\"$PASS\"}]}" \
82 || true)
83
84 echo " HTTP $CODE"
85 head -c 500 /tmp/briven-engine-e2e-signup.json 2>/dev/null || true
86 echo
87
88 if [[ "$CODE" == "200" ]]; then
89 echo "✔ sign-up response 200 — check JSON status field"
90 else
91 echo "⚠ sign-up not 200 (API may lack SDK init or recipes). Engine /hello still OK."
92 fi
93else
94 echo "==> skip API sign-up (set BRIVEN_API_ORIGIN=http://localhost:3001 to include)"
95fi
96
97echo "==> done. briven-engine is local-only; production deploy still blocked."