summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/e2e-test.sh73
1 files changed, 73 insertions, 0 deletions
diff --git a/scripts/e2e-test.sh b/scripts/e2e-test.sh
new file mode 100755
index 0000000..9ec7cf9
--- /dev/null
+++ b/scripts/e2e-test.sh
@@ -0,0 +1,73 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+COMPOSE="docker compose"
+TIMEOUT=60
+
+echo "=== Starting infrastructure ==="
+$COMPOSE up -d redis postgres
+sleep 5
+
+echo "=== Running migrations ==="
+cd shared && alembic upgrade head && cd ..
+
+echo "=== Starting services ==="
+$COMPOSE up -d data-collector strategy-engine order-executor portfolio-manager
+
+echo "=== Waiting for services to be healthy ==="
+services=("data-collector" "strategy-engine" "order-executor" "portfolio-manager")
+for svc in "${services[@]}"; do
+ echo -n "Waiting for $svc..."
+ elapsed=0
+ while [ $elapsed -lt $TIMEOUT ]; do
+ status=$($COMPOSE ps --format json "$svc" 2>/dev/null | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('Health',''))" 2>/dev/null || echo "")
+ if [ "$status" = "healthy" ]; then
+ echo " OK"
+ break
+ fi
+ sleep 2
+ elapsed=$((elapsed + 2))
+ echo -n "."
+ done
+ if [ $elapsed -ge $TIMEOUT ]; then
+ echo " TIMEOUT"
+ echo "=== Logs for $svc ==="
+ $COMPOSE logs --tail=50 "$svc"
+ $COMPOSE down
+ exit 1
+ fi
+done
+
+echo "=== Health check endpoints ==="
+ports=(8080 8081 8082 8083)
+names=("data-collector" "strategy-engine" "order-executor" "portfolio-manager")
+for i in "${!ports[@]}"; do
+ echo -n " ${names[$i]} (${ports[$i]}): "
+ status=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:${ports[$i]}/health" 2>/dev/null || echo "000")
+ if [ "$status" = "200" ] || [ "$status" = "503" ]; then
+ echo "OK ($status)"
+ else
+ echo "FAIL ($status)"
+ fi
+done
+
+echo "=== Metrics endpoints ==="
+for i in "${!ports[@]}"; do
+ echo -n " ${names[$i]} (${ports[$i]}): "
+ body=$(curl -s "http://localhost:${ports[$i]}/metrics" 2>/dev/null || echo "")
+ if echo "$body" | grep -q "# HELP"; then
+ echo "OK (Prometheus metrics found)"
+ else
+ echo "FAIL (no metrics)"
+ fi
+done
+
+echo "=== Smoke test: Redis streams exist ==="
+streams=$($COMPOSE exec -T redis redis-cli KEYS "candles.*" 2>/dev/null || echo "")
+echo " Redis streams: ${streams:-none yet (normal if no data flowing)}"
+
+echo "=== Cleanup ==="
+$COMPOSE down
+
+echo ""
+echo "=== E2E test complete ==="