diff --git a/test.sh b/test.sh index 428f848..198076a 100755 --- a/test.sh +++ b/test.sh @@ -157,8 +157,8 @@ function start_test_server() { die "Failed to restart container" fi - # Give container a moment to initialize after restart - sleep 3 + # Give container more time to initialize after restart + sleep 5 # Check if container is still running if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then @@ -176,14 +176,21 @@ function start_test_server() { # Wait for server to be ready log_info "Waiting for server to be ready..." - local max_attempts=30 + local max_attempts=60 local attempt=0 while [ $attempt -lt $max_attempts ]; do - # Try multiple endpoints - if curl -s "http://localhost:${TEST_PORT}/health" >/dev/null 2>&1 || \ - curl -s "http://localhost:${TEST_PORT}/" >/dev/null 2>&1; then - log_info "Server is ready!" + # Try to check if the server responds - use a simple curl with timeout + # The SOS server should respond to a basic GET request + local http_code=$(curl -s --max-time 2 -o /dev/null -w "%{http_code}" "http://localhost:${TEST_PORT}/" 2>/dev/null || echo "000") + + # Debug: Show HTTP code on first few attempts + if [ $attempt -lt 3 ]; then + log_info "Health check attempt $((attempt + 1)): HTTP code ${http_code}" + fi + + if [ "$http_code" = "200" ] || [ "$http_code" = "204" ] || [ "$http_code" = "404" ]; then + log_info "Server is ready! (HTTP ${http_code})" return 0 fi @@ -194,6 +201,10 @@ function start_test_server() { docker logs "${CONTAINER_NAME}" 2>&1 | tail -20 die "Container stopped unexpectedly" fi + # Show progress every 5 seconds + if [ $attempt -gt 0 ]; then + log_info "Still waiting for server... (${attempt}/${max_attempts})" + fi fi sleep 1