Repository navigation
test(machine-herdr-switch-retry): a failed switch asks no real ssh whether the PC is Windows, and a stalled wait restores its spies - #3903
Conversation
…ether the PC is Windows, and a stalled wait restores its spies When B's inspection fails, detectHost asks windowsHost.inspect next. The test left that unmocked, so each "then the switch is failed" case ran a real `ssh ... -T fixture-only powershell ...` and waited for it to exit. On a GitHub-hosted runner that ssh outlasted the 5 s deadline (run 43717080636). windowsHost.inspect now rejects as a non-Windows PC does, so B's own refusal stays the job's error. The test's 5 s waits also tied bun's default 5 s test timeout. When bun won, the case reported a bare timeout and skipped `finally`, so its spies stayed installed and the next case overflowed the stack in the stacked clearTimeout spy. The test now outlasts its three waits in a row, so a stalled wait names what it waited for and the spies are restored.
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
A switch that ended before it inspected B (run(b) settles as failed) left `await reached.promise` pending until the runner's test timeout, so `finally` never ran and the next case broke on the spies left installed. The wait now gets its own SETTLE_MS deadline and says "The switch never asked B". It starts with run(b)'s own deadline, so the test's timeout still outlasts its waits in a row.
Merge passMerged head
One reviewer: test-only. Test-only, one file. Two faults in the test, both reproduced by its author by forcing (a stand-in ssh that sleeps 6 s): the unmocked The first review found that the wait for the switch to ask B had no deadline of its own, so a switch failing earlier ran to the runner timeout and skipped Review reports: ~/.cache/ovis-tmp/reports/ |
Why
Hosted Fast checks on #3738 (run 43717080636, job 132820955312) failed in
server/machine-herdr-switch-retry.test.tswith "pauses old retries when the link drops before a switch, then the switch is failed":setup did not settleat 5016 ms. The other three cases took 30-75 ms.Cause
In both "then the switch is failed" cases, the
posixHost.inspectstand-in throws "B refused connection".detectHost(server/remote-host.ts) then askswindowsHost.inspect, which the test left unmocked. That runsssh.runPowerShell, and withSshConnection.startmocked there is no master, so a realssh -S control ... -T fixture-only powershell ...starts. The job settles only when that process exits, and the product bounds it only byConnectTimeout=15and the 90 srundeadline. A local stand-in for ssh recorded two such calls per run, one in each failed case. On the hosted runner the first one outlasted the test's 5 s wait; why that runner's ssh tofixture-onlywas slow (likely name resolution) was not proven.There is a second, related flaw. The test's own bounded waits (5 s) are as long as bun's default test timeout (5 s). When bun's timeout wins, the case reports a bare "this test timed out",
finallynever runs, and its spies stay installed. The next case then fails withRangeError: Maximum call stack size exceededin the stackedclearTimeoutspy.Change (test only)
windowsHost.inspectrejects as it would for a PC that is not Windows. B's own refusal stays the job's error, as the test asserts, and the test starts no external process.SETTLE_MS. The test's timeout is4 * SETTLE_MS, so it outlasts its three sequential waits. A stall then reports what it waited for, andfinallyrestores the spies. The bound itself is unchanged: with ssh out of the way, every answer in this fixture is in-process or on loopback (measured 10-40 ms a case).SETTLE_MSdeadline ("The switch never asked B"). Without it, a switch that ends beforeposixHost.inspectleavesawait reached.promisepending until the runner's timeout, sofinallyis skipped. That deadline starts together withrun(b)'s, so the test still outlasts its waits in a row.Timers: the test already holds the product's retry delays (1-60 s) and fires them itself. The other timers stay real; none of them sits on the path being waited for.
Validation
Forcing: an
OVIS_SSHstand-in that logs its arguments and sleepsFAKE_SSH_DELAYseconds before failing as an unresolvable host would.FAKE_SSH_DELAY=6): "before ... failed" fails at 5000 ms ("this test timed out after 5000ms"), and "during ... failed" then fails at 11 ms withMaximum call stack size exceeded. WithFAKE_SSH_DELAY=0the stand-in logged 2 ssh calls (... -T fixture-only powershell ...).bun test --rerun-each 20 ./server/machine-herdr-switch-retry.test.tsunforced: 80 pass, 0 fail.server/machines.ts(not committed): a failed switch no longer callsretryLater(existing). Both failed cases go red with "Old PC retries did not resume".windowsHostmock removed and the 6 s stand-in: both failed cases report "setup did not settle" at about 5009 ms. No cascade into the next case.bun run check fast: exit 0 in a 2-core heavy slot (typecheck, build, unit tests: 17383 pass, 0 fail). The fixed file also ran on one core beside a busy loop:--rerun-each 5, 20 pass.Maximum call stack size exceeded.bun test --rerun-each 20on the file at 394f09a: 80 pass, 0 fail.bun run check fastat 394f09a: exit 0 (17383 pass, 0 fail).Skipped:
bun run check fulland the integration/browser suites (test-only change to one unit test file).