From 4932e91517ad04797ae57283a602bd5c2ac92199 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 29 Apr 2026 06:35:00 +0100 Subject: [PATCH] fix(test): wait for Windows gateway recovery --- scripts/e2e/parallels-windows-smoke.sh | 31 +++++++++++++++++----- test/scripts/parallels-smoke-model.test.ts | 11 ++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/scripts/e2e/parallels-windows-smoke.sh b/scripts/e2e/parallels-windows-smoke.sh index 9beaae98033..5c8ddd3450b 100644 --- a/scripts/e2e/parallels-windows-smoke.sh +++ b/scripts/e2e/parallels-windows-smoke.sh @@ -50,8 +50,8 @@ TIMEOUT_UPDATE_POLL_GRACE_S=60 TIMEOUT_VERIFY_S=120 TIMEOUT_ONBOARD_S=600 TIMEOUT_ONBOARD_PHASE_S=$((TIMEOUT_ONBOARD_S + 120)) -# verify_gateway_reachable runs six 30s probes plus short retry sleeps. TIMEOUT_GATEWAY_S=420 +GATEWAY_RECOVERY_AFTER_S="${OPENCLAW_PARALLELS_WINDOWS_GATEWAY_RECOVERY_AFTER_S:-180}" TIMEOUT_AGENT_S="${OPENCLAW_PARALLELS_WINDOWS_AGENT_TIMEOUT_S:-900}" PHASE_STALE_WARN_S=60 @@ -2395,8 +2395,13 @@ verify_gateway() { } verify_gateway_reachable() { - local probe_json attempt - for attempt in 1 2 3 4 5 6; do + local probe_json attempt start_seconds deadline recovery_tried + start_seconds="$SECONDS" + deadline=$((SECONDS + TIMEOUT_GATEWAY_S)) + recovery_tried=0 + attempt=1 + + while (( SECONDS < deadline )); do probe_json="$( guest_run_openclaw "" "" gateway probe --url ws://127.0.0.1:18789 --timeout 30000 --json )" @@ -2411,11 +2416,25 @@ PY then return 0 fi - if (( attempt < 6 )); then - printf 'gateway-reachable retry %s\n' "$attempt" >&2 - sleep 3 + + if [[ "$recovery_tried" -eq 0 && $((SECONDS - start_seconds)) -ge "$GATEWAY_RECOVERY_AFTER_S" ]]; then + printf 'gateway-reachable recovery: gateway start after %ss\n' "$((SECONDS - start_seconds))" >&2 + if ! run_gateway_daemon_action start; then + printf 'gateway-reachable recovery start failed; continuing probes\n' >&2 + fi + recovery_tried=1 fi + + printf 'gateway-reachable retry %s elapsed=%ss\n' "$attempt" "$((SECONDS - start_seconds))" >&2 + attempt=$((attempt + 1)) + sleep 5 done + + if [[ "$recovery_tried" -eq 0 ]]; then + printf 'gateway-reachable recovery: gateway start after timeout\n' >&2 + run_gateway_daemon_action start || true + fi + return 1 } diff --git a/test/scripts/parallels-smoke-model.test.ts b/test/scripts/parallels-smoke-model.test.ts index 1887dde06a2..f5adb749b75 100644 --- a/test/scripts/parallels-smoke-model.test.ts +++ b/test/scripts/parallels-smoke-model.test.ts @@ -40,4 +40,15 @@ describe("Parallels smoke model selection", () => { expect(script).toMatch(/parallels-windows-smoke\.sh"[\s\S]*?--model "\$MODEL_ID"/); expect(script).toMatch(/parallels-linux-smoke\.sh"[\s\S]*?--model "\$MODEL_ID"/); }); + + it("keeps Windows gateway reachability on a real deadline with start recovery", () => { + const script = readFileSync("scripts/e2e/parallels-windows-smoke.sh", "utf8"); + + expect(script).toContain( + 'GATEWAY_RECOVERY_AFTER_S="${OPENCLAW_PARALLELS_WINDOWS_GATEWAY_RECOVERY_AFTER_S:-180}"', + ); + expect(script).toContain("deadline=$((SECONDS + TIMEOUT_GATEWAY_S))"); + expect(script).toContain("while (( SECONDS < deadline )); do"); + expect(script).toContain("run_gateway_daemon_action start"); + }); });