Update test.sh
This commit is contained in:
25
test.sh
25
test.sh
@@ -157,8 +157,8 @@ function start_test_server() {
|
|||||||
die "Failed to restart container"
|
die "Failed to restart container"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Give container a moment to initialize after restart
|
# Give container more time to initialize after restart
|
||||||
sleep 3
|
sleep 5
|
||||||
|
|
||||||
# Check if container is still running
|
# Check if container is still running
|
||||||
if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
|
||||||
@@ -176,14 +176,21 @@ function start_test_server() {
|
|||||||
|
|
||||||
# Wait for server to be ready
|
# Wait for server to be ready
|
||||||
log_info "Waiting for server to be ready..."
|
log_info "Waiting for server to be ready..."
|
||||||
local max_attempts=30
|
local max_attempts=60
|
||||||
local attempt=0
|
local attempt=0
|
||||||
|
|
||||||
while [ $attempt -lt $max_attempts ]; do
|
while [ $attempt -lt $max_attempts ]; do
|
||||||
# Try multiple endpoints
|
# Try to check if the server responds - use a simple curl with timeout
|
||||||
if curl -s "http://localhost:${TEST_PORT}/health" >/dev/null 2>&1 || \
|
# The SOS server should respond to a basic GET request
|
||||||
curl -s "http://localhost:${TEST_PORT}/" >/dev/null 2>&1; then
|
local http_code=$(curl -s --max-time 2 -o /dev/null -w "%{http_code}" "http://localhost:${TEST_PORT}/" 2>/dev/null || echo "000")
|
||||||
log_info "Server is ready!"
|
|
||||||
|
# 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
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -194,6 +201,10 @@ function start_test_server() {
|
|||||||
docker logs "${CONTAINER_NAME}" 2>&1 | tail -20
|
docker logs "${CONTAINER_NAME}" 2>&1 | tail -20
|
||||||
die "Container stopped unexpectedly"
|
die "Container stopped unexpectedly"
|
||||||
fi
|
fi
|
||||||
|
# Show progress every 5 seconds
|
||||||
|
if [ $attempt -gt 0 ]; then
|
||||||
|
log_info "Still waiting for server... (${attempt}/${max_attempts})"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
|
Reference in New Issue
Block a user