Fix flaky unit test on merge-triggered CI runs #7

Merged
Djeex merged 1 commits from fix-flaky-test-timing into main 2026-08-26 15:58:37 +02:00
2 changed files with 6 additions and 2 deletions
+1 -1
View File
@@ -145,7 +145,7 @@ fi
log "[~] Testing connection to target..." log "[~] Testing connection to target..."
# Test if we can reach the target before starting socat # Test if we can reach the target before starting socat
if ! nc -z "$TARGET_HOST" "$TARGET_PORT" 2>/dev/null; then if ! nc -z -w 2 "$TARGET_HOST" "$TARGET_PORT" 2>/dev/null; then
log "[!] Cannot connect to $TARGET_HOST:$TARGET_PORT - socat will retry automatically" log "[!] Cannot connect to $TARGET_HOST:$TARGET_PORT - socat will retry automatically"
else else
log "[✓] Connection to $TARGET_HOST:$TARGET_PORT is working" log "[✓] Connection to $TARGET_HOST:$TARGET_PORT is working"
+5 -1
View File
@@ -58,7 +58,11 @@ socat_pid() {
wait_for_log() { wait_for_log() {
pattern="$1" pattern="$1"
tries=0 tries=0
while [ "$tries" -lt 20 ]; do # 40 * 0.25s = 10s — merge-triggered runs can land on a cold runner
# (evicted Docker cache, first container start), pushing the very first
# backgrounded entrypoint.sh past a tighter budget even though nothing's
# actually wrong; a rerun on a warm runner always passes.
while [ "$tries" -lt 40 ]; do
grep -qE "$pattern" "$LOG" 2>/dev/null && return 0 grep -qE "$pattern" "$LOG" 2>/dev/null && return 0
tries=$((tries + 1)) tries=$((tries + 1))
sleep 0.25 sleep 0.25