Repository navigation
fix(tests): intermittent CI failures when hosted runners are under load - #2129
Conversation
Fix the causes of five non-UI test flakes seen on main and PR runs: - Tests that block a thread on a handoff now start the contending work on dedicated (LongRunning) threads instead of Task.Run, so a starved shared thread pool cannot miss their 2-5 s waits. Hang guards use named, environment-overridable timeouts. - The MCP bearer-rotation regression keeps its deliberately blocking rotation off the thread pool that the server under test needs. - Windows PowerShell 5.1 uninstall-helper runs get the same 120 s cold-start bound already used by the gateway cleanup tests. - Gateway fixture startup tests prove listener release by owner PID instead of rebinding a dynamic-range port another host process may claim, and retry readiness when the foreign child loses its port to such a process. Co-authored-by: Copilot App <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR isolates blocking test work from the shared thread pool, adjusts test deadlines, and checks fixture listener cleanup by process ownership. Example: The shared thread pool is saturated while the settings-permission concurrency test starts its disabling caller.
Review scores
ProductKind: Test only · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR contains useful test stabilization absent from main, and inspection found no introduced defect. The failed Shared-test CI step remains unattributed. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe changed test suites exercise MCP token rotation, settings serialization, restart-file coordination, uninstall helpers, and Gateway fixture resource cleanup; they produce assertions and CI results without changing shipped behavior. flowchart LR
A[CI test runner] --> B[Dedicated test workers]
A --> C[Gateway fixture processes]
B --> D[Existing production owners]
C --> E[Loopback listeners]
E --> F[Process ownership assertions]
D --> G[Contract assertions]
Technical reviewBest possible solution: Retain the focused scheduling, deadline, and listener-ownership repairs within the existing tests while preserving their behavioral assertions. Do we have a high-confidence way to reproduce the issue? Main contains pool-dependent work paired with blocking handoff waits and cleanup assertions that rebind released dynamic ports; the PR reports targeted before/after reproductions, which this read-only review did not execute. Is this the best way to solve the issue? The patch addresses test-owned scheduling and observation failures using existing owners, preserves ordering and rejection checks, and limits readiness retries to the fixture child's documented bind-failure result. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3d5f14270dd6. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 12, 2026, 3:59 PM ET / 20:59 UTC. |
…start Replace 35 literal 2/3/5 s hang guards on event-driven loopback steps in OpenClawGatewayClientTests with the file's existing named StepTimeout (OPENCLAW_TEST_GATEWAY_STEP_TIMEOUT_SECONDS, default 15 s). PR CI failed ChatMessageRead_RejectsInvalidRequestBeforeSending at a 2 s probe-frame guard 7 s into the suite, while sibling cases took 0.5-1 s instead of about 10 ms. Assertions and awaited operations are unchanged; the 300 ms negative wait, CloseHandshakeTimeout and SessionRefreshQuietInterval stay. Co-authored-by: Copilot App <[email protected]>
What Problem This Solves
Fixes: Core/CLI, Tray and Tray integration test jobs fail intermittently and need reruns when hosted runners are under load.
User Impact
User impact: no user-visible change. Contributors and maintainers get first-attempt green runs for these tests without reruns. Only test code and test documentation change.
Why This Change Was Made
Each flake had a test-side cause, and no product behavior was wrong:
McpFileTransportTests.RequestDuringBearerRotationCannotAcquireTheReplacementEpoch(5 sTimeoutException)OPENCLAW_TEST_MCP_STEP_TIMEOUT_SECONDS(30 s).SettingsChangeCoordinatorTests.Apply_ConcurrentPermissionChanges_PreserveFinalDisabledOrder(Assert.True, line 218)Task.Runcaller was not scheduled within 2 s while the test thread blocked.SettingsChangeCoordinatorserializes correctly.OPENCLAW_TRAY_TEST_CONCURRENCY_TIMEOUT_SECONDS(15 s).NativeRestartAdmissionTests.InvalidRestartCleanupCannotDeleteNewerCooperatingHandle(Assert.True, line 43)UninstallGatewayCleanupHelperTests.RegistryCleanup_*(30 sTimeoutException)OPENCLAW_UNINSTALL_SCRIPT_TEST_TIMEOUT_SECONDS, matchingGatewayPackageCleanupTests.GatewayFixtureStartupTests.BrowserControlStartup_TransfersLiveResources(foreign: True)(WSAEACCESon rebind)AddressAlreadyInUse, notWSAEACCES.WindowsTcpListenerSnapshot. The test also checks that its own process owns the listener while it is live.GatewayFixtureStartupTests.ForeignControlReadinessFailure_*(found during the loops; same signature as a Nov 8 CI failure)false, so startup retries with a new gateway, as the default path already does. Any other exit still fails. The test also asserts that it reached its injected failure.OpenClawGatewayClientTests.ChatMessageRead_RejectsInvalidRequestBeforeSending(this PR's first CI run, job)StepTimeout(OPENCLAW_TEST_GATEWAY_STEP_TIMEOUT_SECONDS, 15 s). Assertions and awaited operations are unchanged. The 300 ms negative wait,CloseHandshakeTimeoutandSessionRefreshQuietIntervalstay as they are.The
GatewayErrorClassifierport-digit flake was already fixed by #2023. A sweep of all 65,535 ports in four refusal formats passes onmainand fails on the classifier before #2023, so this PR does not change the classifier.Evidence
Deterministic RED/GREEN (temporary scaffolding, not committed):
Thread-pool saturation. A temporary helper blocked the pool's minimum worker count plus 16 more work items, before each of the 3 tests below ran:
SettingsChangeCoordinatorTestsNativeRestartAdmissionTestsMcpFileTransportTestsTimeoutExceptionon a pool-dependent waitWith +32 blocked items, all three still passed (the MCP test in 30 s).
Repeated under the same saturation: Tray 40/40 and Shared 10/10 passed.
Foreign port claim. After the fixture released its control port, a temporary socket claimed that port with an exclusive wildcard bind. The old rebind assertion threw
AccessDenied, the exact CI error. The new ownership assertion passed.Classifier sweep. All 65,535 ports in 4 formats passed on
main. The same sweep failed on the classifier before fix: keep refused Gateway connections classified as network failures #2023 (ports 401, 429 and others).Repeated runs on the final tree (Shared, Tray and Integration loops ran concurrently, alongside other sessions' test runs on the same host):
RequestDuringBearerRotation…,RefusedTransport_ReportsNetwork…)SettingsChangeCoordinatorTests,NativeRestartAdmissionTests,UninstallGatewayCleanupHelperTests)GatewayFixtureStartupTests)Before the readiness-retry fix, the same integration loop failed
ForeignControlReadinessFailurein 6 of 100 runs.Review:
claude-opus-5.5(high) andgpt-6-astra(long_context, high), plus two delta rounds on the final diff.Gaps: Margins under real CI load are inferred from the reproductions.
Second commit (
dc64206d, gateway client guards):OnConnectedAsyncis awaited beforeConnectAsyncreturns.SessionMutationConnectionEpoch!.Valuewould have thrown one line earlier if the connection were not ready.OpenClawGatewayClientTests50×: 22,000/22,000 passed.Change Type
Scope
winnodeRequired proof pools
none: this changes only test code and test documentation, with no product, UI, MCP, Gateway orsystem.runbehavior.Validation
All runs used the committed tree (diff SHA256
A8231DF8…962DBagainst3d5f1427). Tray runs set the isolatedOPENCLAW_TRAY_DATA_DIR,OPENCLAW_TRAY_APPDATA_DIRandOPENCLAW_TRAY_LOCALAPPDATA_DIR../build.ps1: passed; all projects built.dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore --no-build: 5847 passed, 29 skipped, 0 failed (5876 total).dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore --no-build: 6347 passed, 0 failed.dotnet test ./tests/OpenClaw.Tray.IntegrationTests/OpenClaw.Tray.IntegrationTests.csproj --filter FullyQualifiedName~GatewayFixtureStartupTests: 7 passed per run; 50× twice, all passed../scripts/validate-docs.ps1: passed (73 Markdown files).git diff --check: clean.dc64206d, on that exact tree:dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore --no-build: 5847 passed, 29 skipped, 0 failed.--filter FullyQualifiedName~OpenClaw.Shared.Tests.OpenClawGatewayClientTests, 50×: 22,000 passed.Real Behavior Proof
3d5f14270dd6, whose diff (SHA256A8231DF8…962DB) is byte-identical to commit04c83900f108.121995FE…19B6) is byte-identical todc64206d2b5b.Yes/No/N/A): N/A (test-only change; outputs are summarized above).04c83900(run 43303557148):FileWorkerManifestTestshas the same 30 s Windows PowerShell 5.1 bound but no observed failure, so it is left unchanged.Security Impact
Yes/No): NoYes/No): NoYes/No): NoYes/No): NoYes/No): NoYes, explain the risk and mitigation: N/ACompatibility and Migration
Yes/No): YesYes/No): No. The new optional test-only timeout overrides are documented indocs/TEST_COVERAGE.md.Yes/No): NoReview Conversations