summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-04-01 17:21:40 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2026-04-01 17:21:40 +0900
commit538749d0daa43ec94c48cdf35110d19c39e3c896 (patch)
tree913ac33553830f49ed73af6a5ab0a838e88bff57
parent5673b2c42c7a317c775777b1135996b4c3993ef4 (diff)
test: add Docker Compose E2E test script
-rw-r--r--Makefile5
-rwxr-xr-xscripts/e2e-test.sh73
2 files changed, 77 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 4a41ebe..f0e0743 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-.PHONY: infra up down logs test lint format migrate migrate-down migrate-new ci
+.PHONY: infra up down logs test lint format migrate migrate-down migrate-new ci e2e
infra:
docker compose up -d redis postgres
@@ -34,3 +34,6 @@ migrate-new:
ci:
./scripts/ci.sh
+
+e2e:
+ ./scripts/e2e-test.sh
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 ==="