Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
d8709c0849 | |||
b753866b98 | |||
6141140beb |
@@ -218,23 +218,74 @@ jobs:
|
|||||||
echo "📋 Recent container logs:"
|
echo "📋 Recent container logs:"
|
||||||
docker logs --tail 10 ping-river-monitor-test || true
|
docker logs --tail 10 ping-river-monitor-test || true
|
||||||
|
|
||||||
# Wait for the application to be ready
|
# Wait for the application to be ready with more robust checking
|
||||||
for i in {1..12}; do
|
echo "🔍 Testing application readiness..."
|
||||||
if curl -f http://127.0.0.1:8080/health; then
|
for i in {1..15}; do
|
||||||
echo "✅ Health endpoint responding"
|
echo "⏳ Attempt $i/15: Testing health endpoint..."
|
||||||
|
|
||||||
|
# Test health endpoint with container networking
|
||||||
|
echo "Testing health endpoint..."
|
||||||
|
|
||||||
|
# Get the container's IP address for direct communication
|
||||||
|
CONTAINER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ping-river-monitor-test)
|
||||||
|
echo "Container IP: $CONTAINER_IP"
|
||||||
|
|
||||||
|
# Test using container IP directly (port 8000 inside container)
|
||||||
|
if [ -n "$CONTAINER_IP" ]; then
|
||||||
|
response=$(curl -s --max-time 10 --connect-timeout 5 -w "HTTP_CODE:%{http_code}" http://$CONTAINER_IP:8000/health)
|
||||||
|
else
|
||||||
|
# Fallback to localhost if IP detection fails
|
||||||
|
response=$(curl -s --max-time 10 --connect-timeout 5 -w "HTTP_CODE:%{http_code}" http://127.0.0.1:8080/health)
|
||||||
|
fi
|
||||||
|
|
||||||
|
http_code=$(echo "$response" | grep -o "HTTP_CODE:[0-9]*" | cut -d: -f2)
|
||||||
|
response_body=$(echo "$response" | sed 's/HTTP_CODE:[0-9]*$//')
|
||||||
|
|
||||||
|
echo "HTTP Code: $http_code"
|
||||||
|
echo "Response Body: $response_body"
|
||||||
|
|
||||||
|
if [ "$http_code" = "200" ] && [ -n "$response_body" ]; then
|
||||||
|
echo "✅ Health endpoint responding successfully!"
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
echo "⏳ Waiting for health endpoint... (attempt $i/12)"
|
echo "❌ Health check failed (HTTP: $http_code), waiting 15 seconds..."
|
||||||
sleep 10
|
# Show what's happening with the container
|
||||||
|
echo "Container status:"
|
||||||
|
docker ps | grep ping-river-monitor-test || echo "Container not found"
|
||||||
|
echo "Recent container logs:"
|
||||||
|
docker logs --tail 5 ping-river-monitor-test || true
|
||||||
|
sleep 15
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Test API endpoints
|
# Test API endpoints with container networking
|
||||||
echo "🧪 Testing API endpoints..."
|
echo "🧪 Testing API endpoints..."
|
||||||
curl -f http://127.0.0.1:8080/health || exit 1
|
|
||||||
curl -f http://127.0.0.1:8080/docs || exit 1
|
# Get container IP for direct communication
|
||||||
curl -f http://127.0.0.1:8080/stations || exit 1
|
CONTAINER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ping-river-monitor-test)
|
||||||
curl -f http://127.0.0.1:8080/metrics || exit 1
|
echo "Using container IP: $CONTAINER_IP"
|
||||||
|
|
||||||
|
endpoints=("health" "docs" "stations" "metrics")
|
||||||
|
for endpoint in "${endpoints[@]}"; do
|
||||||
|
echo "Testing /$endpoint..."
|
||||||
|
|
||||||
|
# Use container IP if available, otherwise fallback to localhost
|
||||||
|
if [ -n "$CONTAINER_IP" ]; then
|
||||||
|
response=$(curl -s --max-time 10 -w "HTTP_CODE:%{http_code}" http://$CONTAINER_IP:8000/$endpoint)
|
||||||
|
else
|
||||||
|
response=$(curl -s --max-time 10 -w "HTTP_CODE:%{http_code}" http://127.0.0.1:8080/$endpoint)
|
||||||
|
fi
|
||||||
|
|
||||||
|
http_code=$(echo "$response" | grep -o "HTTP_CODE:[0-9]*" | cut -d: -f2)
|
||||||
|
|
||||||
|
if [ "$http_code" = "200" ]; then
|
||||||
|
echo "✅ /$endpoint: OK (HTTP $http_code)"
|
||||||
|
else
|
||||||
|
echo "❌ /$endpoint: FAILED (HTTP $http_code)"
|
||||||
|
echo "Response: $(echo "$response" | sed 's/HTTP_CODE:[0-9]*$//')"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
echo "✅ All health checks passed!"
|
echo "✅ All health checks passed!"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user