@@ -93,18 +93,42 @@ jobs:
9393 --format '{{ (index .NetworkSettings.Networks "ci_default").IPAddress }}' \
9494 ci_rlgl-server_1)
9595
96+ podman logs --follow ci_rlgl-server_1 &
97+ LOG_PID=$!
98+
9699 if [ -z "$CONTAINER_IP" ]; then
97- echo "ERROR: Container has no IP address"
100+ echo "ERROR: Container has no IP address"
101+ podman container inspect ci_rlgl-server_1
102+ exit 1
103+ fi
104+ echo "Container IP: $CONTAINER_IP"
105+
106+ # Check if container is running
107+ if ! podman container exists ci_rlgl-server_1; then
108+ echo "ERROR: Container doesn't exist"
98109 exit 1
99110 fi
100111
101- echo "Container IP: $CONTAINER_IP"
112+ CONTAINER_STATUS=$(podman container inspect --format '{{.State.Status}}' ci_rlgl-server_1)
113+ echo "Container status: $CONTAINER_STATUS"
114+
115+ if [ "$CONTAINER_STATUS" != "running" ]; then
116+ echo "ERROR: Container is not running"
117+ podman logs ci_rlgl-server_1
118+ exit 1
119+ fi
120+
121+ # Wait for service with better logging
122+ echo "Waiting for service to be ready..."
123+ WAIT_COUNT=0
124+ if timeout -s TERM 120 bash -c \
125+ 'while [[ "$(curl -s -o /dev/null -L -w ''%{http_code}'' ${0})" != "200" ]]; do
126+ echo "Attempt $((++WAIT_COUNT)): Waiting for ${0}"
127+ sleep 5
128+ done' http://$CONTAINER_IP:8080/healthz ; then
102129
103- # Wait for service to be ready
104- if timeout -s TERM 45 bash -c \
105- 'while [[ "$(curl -s -o /dev/null -L -w ''%{http_code}'' ${0})" != "200" ]];\
106- do echo "Waiting for ${0}" && sleep 2;\
107- done' http://$CONTAINER_IP:8080/healthz ; then
130+ echo "Service is ready!"
131+ sleep 5 # Extra safety margin
108132
109133 # Setup test environment in` container
110134 podman exec -t -e IP="$CONTAINER_IP" ci_rlgl-server_1 \
@@ -117,13 +141,15 @@ jobs:
117141 ./.ci/test.sh "$CONTAINER_IP:8080" || TEST_FAILED=true
118142
119143 # Always show logs
144+ kill $LOG_PID 2>/dev/null || true
120145 podman logs ci_rlgl-server_1
121146
122147 if [ "$TEST_FAILED" = "true" ]; then
123148 exit 1
124149 fi
125150 else
126151 echo "ERROR: Service failed to start within timeout"
152+ kill $LOG_PID 2>/dev/null || true
127153 podman logs ci_rlgl-server_1
128154 exit 1
129155 fi
0 commit comments