From 71e8cc4e6d6259b07f0882920fbe330350edf6f1 Mon Sep 17 00:00:00 2001 From: Zhi Date: Sat, 14 Mar 2026 07:43:19 +0000 Subject: [PATCH] Wait for services to be ready before running test --- run-test.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/run-test.sh b/run-test.sh index de236ca..a4d42e1 100755 --- a/run-test.sh +++ b/run-test.sh @@ -9,6 +9,29 @@ echo "🚀 Running HarborForge Test..." # Clean any previous containers first docker compose -f "$COMPOSE_FILE" down 2>/dev/null || true +# Start services +echo "📦 Starting services..." +docker compose -f "$COMPOSE_FILE" up -d + +# Wait for frontend to be ready +echo "⏳ Waiting for services..." +MAX_RETRIES=30 +RETRY_COUNT=0 +until curl -s -o /dev/null -w "%{http_code}" http://frontend:3000/ | grep -q "200" || [ $RETRY_COUNT -eq $MAX_RETRIES ]; do + echo " Waiting for frontend... ($RETRY_COUNT/$MAX_RETRIES)" + sleep 2 + RETRY_COUNT=$((RETRY_COUNT+1)) +done + +if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then + echo "❌ Frontend failed to start" + docker compose -f "$COMPOSE_FILE" logs + docker compose -f "$COMPOSE_FILE" down -v + exit 1 +fi + +echo "✅ Services ready!" + # Run test docker compose -f "$COMPOSE_FILE" run --rm test TEST_EXIT_CODE=$?