briven-engine-local-e2e.sh 3.0 KB

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