| #!/usr/bin/env bash |
| set -euo pipefail |
|
|
| |
| |
| |
|
|
| |
| if command -v readlink >/dev/null 2>&1 && readlink -f "$0" >/dev/null 2>&1; then |
| SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" |
| else |
| SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)" |
| fi |
|
|
| |
| REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd -P)" |
|
|
| |
| source "$SCRIPT_DIR/setup-go-workspace.sh" |
|
|
| echo "π§ͺ Running Integration Tests" |
| echo " Repository root: $REPO_ROOT" |
|
|
| |
| TEST_PORT="${PORT:-8080}" |
| TEST_HOST="${HOST:-localhost}" |
| BIFROST_PID="" |
| TEST_FAILED=0 |
| LOG_FILE="$(mktemp /tmp/bifrost-integrations.XXXXXX.log)" |
|
|
| |
| cleanup() { |
| local exit_code=$? |
| echo "" |
| echo "π§Ή Cleaning up..." |
| |
| |
| if [ -n "${BIFROST_PID:-}" ]; then |
| echo " Stopping Bifrost server (PID: $BIFROST_PID)..." |
| kill "$BIFROST_PID" 2>/dev/null || true |
| wait "$BIFROST_PID" 2>/dev/null || true |
| fi |
|
|
| rm -f "${LOG_FILE:-}" 2>/dev/null || true |
|
|
| exit $exit_code |
| } |
| trap cleanup EXIT |
|
|
| |
| echo "" |
| echo "π¨ Building bifrost-http from source..." |
| cd "$REPO_ROOT" |
|
|
| |
| make build-ui |
| make build |
|
|
| if [ ! -f "$REPO_ROOT/tmp/bifrost-http" ]; then |
| echo "β Error: bifrost-http binary not found at $REPO_ROOT/tmp/bifrost-http" |
| exit 1 |
| fi |
|
|
| echo "β
Build complete: $REPO_ROOT/tmp/bifrost-http" |
|
|
| |
| echo "" |
| echo "π Starting Bifrost server..." |
| echo " Config: tests/integrations/python/config.json" |
| echo " Host: $TEST_HOST" |
| echo " Port: $TEST_PORT" |
|
|
| |
| "$REPO_ROOT/tmp/bifrost-http" \ |
| -host "$TEST_HOST" \ |
| -port "$TEST_PORT" \ |
| -log-style json \ |
| -log-level info \ |
| -app-dir "$REPO_ROOT/tests/integrations/python" \ |
| > "$LOG_FILE" 2>&1 & |
|
|
| BIFROST_PID=$! |
| echo " Started with PID: $BIFROST_PID" |
|
|
|
|
| |
| echo "β³ Waiting for Bifrost to be ready..." |
| MAX_WAIT=30 |
| ELAPSED=0 |
| SERVER_READY=false |
|
|
| while [ $ELAPSED -lt $MAX_WAIT ]; do |
| if curl --connect-timeout 10 --max-time 20 -sf "http://$TEST_HOST:$TEST_PORT/health" > /dev/null 2>&1; then |
| SERVER_READY=true |
| echo "β
Bifrost is ready (took ${ELAPSED}s)" |
| break |
| fi |
| |
| |
| if ! kill -0 "$BIFROST_PID" 2>/dev/null; then |
| echo "β Bifrost process died unexpectedly" |
| exit 1 |
| fi |
| |
| sleep 1 |
| ELAPSED=$((ELAPSED + 1)) |
| done |
|
|
| if [ "$SERVER_READY" = false ]; then |
| echo "β Bifrost failed to start within ${MAX_WAIT}s" |
| exit 1 |
| fi |
|
|
| |
| export BIFROST_BASE_URL="http://$TEST_HOST:$TEST_PORT" |
| echo " BIFROST_BASE_URL=$BIFROST_BASE_URL" |
|
|
| |
| echo "" |
| echo "π Running Python integration tests..." |
| echo "=" |
|
|
| cd "$REPO_ROOT/tests/integrations/python" |
|
|
| |
| if command -v uv >/dev/null 2>&1; then |
| echo "π¦ Installing Python dependencies with uv..." |
| uv sync --frozen --quiet |
| |
| echo "" |
| echo "π Running Python tests..." |
| if ! uv run pytest -v --tb=short; then |
| echo "β οΈ Python tests failed" |
| TEST_FAILED=1 |
| fi |
| else |
| echo "β οΈ uv not found, trying pip..." |
| |
| |
| if [ ! -d ".venv" ]; then |
| python3 -m venv .venv |
| fi |
| |
| source .venv/bin/activate |
| pip install -q -e . |
| |
| echo "" |
| echo "π Running Python tests..." |
| if ! pytest -v --tb=short; then |
| echo "β οΈ Python tests failed" |
| TEST_FAILED=1 |
| fi |
| fi |
|
|
| |
| echo "" |
| echo "π Running TypeScript integration tests..." |
| echo "=" |
|
|
| cd "$REPO_ROOT/tests/integrations/typescript" |
|
|
| |
| if [ ! -d "node_modules" ]; then |
| echo "π¦ Installing TypeScript dependencies with npm..." |
| npm ci |
| fi |
|
|
| echo "" |
| echo "π Running TypeScript tests..." |
| if ! npm test; then |
| echo "β οΈ TypeScript tests failed" |
| TEST_FAILED=1 |
| fi |
|
|
| |
| echo "" |
| echo "=" |
| if [ $TEST_FAILED -eq 1 ]; then |
| echo "β Some integration tests failed" |
| exit 1 |
| else |
| echo "β
All integration tests passed!" |
| fi |
|
|