Skip to content

Commit 0e18367

Browse files
bpamiriclaude
andcommitted
Fix CI flakiness: retry on transient HTTP errors and add warm-up requests
The retry loop only retried on connection failure (HTTP 000) but not on server errors (HTTP 500) caused by incomplete Wheels app initialization. Additionally, tests ran immediately after the web server responded without waiting for Wheels' onApplicationStart to complete (datasource verification, model scanning, ORM metadata). Changes: - Retry on all transient errors (500, 000, etc.), stop only on 200 or 417 - Add warm-up request before first test run to trigger app initialization - Add warm-up request after each between-DB container restart - Apply same fixes to test-lucee7-mysql.yml Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d05d44c commit 0e18367

2 files changed

Lines changed: 40 additions & 8 deletions

File tree

.github/workflows/test-lucee7-mysql.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,16 @@ jobs:
8686
TEST_URL="http://localhost:${PORT}/wheels/core/tests?db=mysql&format=json&only=failure,error"
8787
RESULT_FILE="/tmp/lucee7-mysql-result.txt"
8888
89+
# Warm up Wheels app before running tests
90+
echo "Warming up Wheels application..."
91+
curl -s -o /dev/null --max-time 60 "http://localhost:${PORT}/" || true
92+
sleep 2
93+
8994
MAX_RETRIES=3
9095
RETRY_COUNT=0
9196
HTTP_CODE="000"
9297
93-
while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ] && [ "$HTTP_CODE" = "000" ]; do
98+
while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; do
9499
RETRY_COUNT=$((RETRY_COUNT + 1))
95100
echo "Test attempt ${RETRY_COUNT} of ${MAX_RETRIES}..."
96101
@@ -101,9 +106,13 @@ jobs:
101106
102107
echo "HTTP Code: ${HTTP_CODE}"
103108
104-
if [ "$HTTP_CODE" = "000" ] && [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; then
105-
echo "Connection failed, waiting 10 seconds before retry..."
106-
sleep 10
109+
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "417" ]; then
110+
break
111+
fi
112+
113+
if [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; then
114+
echo "Transient error (HTTP ${HTTP_CODE}), waiting 15 seconds before retry..."
115+
sleep 15
107116
fi
108117
done
109118

.github/workflows/tests.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ jobs:
236236
mkdir -p /tmp/test-results
237237
mkdir -p /tmp/junit-results
238238
239+
# Warm-up: trigger Wheels onApplicationStart before first test run.
240+
# The engine readiness check only verifies the web server responds —
241+
# Wheels app initialization (datasource verification, model scanning)
242+
# happens on the first real request.
243+
echo "Warming up Wheels application before first test run..."
244+
curl -s -o /dev/null --max-time 60 "http://localhost:${PORT}/" || true
245+
sleep 2
246+
239247
DB_INDEX=0
240248
for db in "${DBS[@]}"; do
241249
DB_INDEX=$((DB_INDEX + 1))
@@ -264,6 +272,14 @@ jobs:
264272
fi
265273
sleep 5
266274
done
275+
# Warm-up request: trigger Wheels onApplicationStart so datasources
276+
# and ORM metadata are fully initialized before running the test suite.
277+
# The readiness check above only confirms the web server responds —
278+
# Wheels app init (datasource verification, model scanning, etc.)
279+
# happens on the first real request and can take a few seconds.
280+
echo "Warming up Wheels application..."
281+
curl -s -o /dev/null --max-time 60 "http://localhost:${PORT}/" || true
282+
sleep 2
267283
fi
268284
269285
TEST_URL="${BASE_URL}?db=${db}&format=json"
@@ -275,7 +291,7 @@ jobs:
275291
RETRY_COUNT=0
276292
HTTP_CODE="000"
277293
278-
while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ] && [ "$HTTP_CODE" = "000" ]; do
294+
while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; do
279295
RETRY_COUNT=$((RETRY_COUNT + 1))
280296
echo "Test attempt ${RETRY_COUNT} of ${MAX_RETRIES}..."
281297
@@ -286,9 +302,16 @@ jobs:
286302
287303
echo "HTTP Code: ${HTTP_CODE}"
288304
289-
if [ "$HTTP_CODE" = "000" ] && [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; then
290-
echo "Connection failed, waiting 10 seconds before retry..."
291-
sleep 10
305+
# Stop retrying on success (200) or test failures (417) —
306+
# 417 means tests ran to completion but some failed, which
307+
# is a definitive result. Only retry on transient errors.
308+
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "417" ]; then
309+
break
310+
fi
311+
312+
if [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; then
313+
echo "Transient error (HTTP ${HTTP_CODE}), waiting 15 seconds before retry..."
314+
sleep 15
292315
fi
293316
done
294317

0 commit comments

Comments
 (0)