Repository navigation
test(cli): the upload cut test stops failing on busy Windows runners - #7843
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at d5921bc03d023b58882a8deafb060a123275f5f8.
No blocker found. This changes the simulated cut timing, not the production tolerance or retry policy. At the longer cut age, the deliberate 150 ms first-attempt delay fits the existing 20% comparison window; the 16 MiB throttled body is still cut mid-transfer. The assertion still requires the repeated-cut message and exactly two requests. The larger test timeout only accommodates the longer fixture.
Validation: full build and 29 upload/uploadParts tests pass. Restoring only the 400 ms cut makes the delayed-start test fail with expected 3 to be 2. Disabling the production repeated-cut guard makes the same test fail with the four-attempt exhaustion error. Thus it still detects a real behavior regression.
Nit: this increases timing headroom rather than making the test deterministic. Extreme scheduling delay can still exceed the relative tolerance. I did not verify a Windows load loop; the Windows engine-cli job was still pending when checked.
Need: yes · Size: ok · Reuse: existing real-socket fixture and production cut comparison · Simpler: already minimal · Structure: fine (checked uploadPut and multipart timing fixtures; no split)
Risk: low — test-only change.
Verdict: APPROVE
Reasoning: The fixture better represents the intended timing relationship and retains a mutation-verified behavioral assertion.
— Rames
jrusso1020
left a comment
There was a problem hiding this comment.
Approve. Re-reviewed at ce16f29d9dfe0d1528918d12c6bb833ae5ea388a. The only change since the last approval (d5921bc0) is CUT_MS going from 1200 to 1600, plus its comment. No source change.
The test still fails when upload-cut handling regresses. I ran it at this head with mutations to uploadPut.ts:
- Head: passes three runs in a row, and the whole
upload.test.tsfile passes (20/20). repeatedCutalwaysundefined(the second identical cut no longer stops the upload): fails.isSameCuttolerance 0.2 down to 0.05: fails.- Tolerance 0.2 down to 0.1: passes. That's expected, since 150 ms over about 1750 ms is about 8.6%. At 1200 ms the 150 ms late start was about 11% of the cut age, so that mutation would have failed. The slow-start leg now catches a tolerance tightened below about 8.6% instead of about 11%. Non-blocking: that is still far from 20%, and the test's job is the stop itself.
It doesn't hide a real problem either. The drain sleeps ceil(len/8192) ms per chunk, so the 16 MB body needs at least 2 s, and a slower runner only makes that longer. A 1.6 s cut, or 1.75 s for the late try, always lands first, so both tries are real cuts with bytes sent.
— Rames
* chore: release v0.9.53 * chore: release v0.9.53 notes include heygen-com#7836 and heygen-com#7839 * chore: release v0.9.53 notes include heygen-com#7840 and heygen-com#7843
What
The
upload.test.tstest "stops after a second identical cut" no longer fails on busy Windows runners. Its test server now drops the connection 1,600 ms after it starts reading, not 400 ms. The test also covers the case that broke it: a first try that is slow to start.Why
It was the most frequent failure in recent red Windows runs. It failed the
engine-cli-1lane withexpected 3 to be 2(three tries where two are expected), and that knocks PRs out of the merge queue.The upload counts two cuts as the same cut when their ages are within 20% of each other (
isSameCutinuploadPut.ts). The client measures a try's age from before it connects; the test server measures the cut from when it starts reading. I logged both, 40 loops on awindows-latestrunner, half of them with 4 CPU-burning jobs:The real lane runs the engine and CLI suites at once, so the gap goes over and a third try follows. The upload code is right: a real link's cut comes seconds in, where tens of ms of setup are noise. The test left itself no room.
Related work
None.
uploadParts.test.ts's cut tests cut at 1,200 ms and are not in the Windows failures.How
CUT_MS = 1600, used by thedrainfixture, gives about 380 ms of tolerance. The fixture's per-chunk wait caps the 16 MB body at 8 MB/s, so it takes at least 2 s and the cut still comes before the end.windows-latest, 20 of them with 8 CPU-burning jobs, it passed every time, but the closest loop had only 7 ms to spare. The first try's extra delay reached 145 ms on top of the 150 ms the test adds on purpose."late cut"plan answer waits 150 ms before it starts reading, so the first try is slow to start the same way it was on the runner. The test's plan is["late cut", "cut"].Test plan
packages/cli/src/cloud/upload.test.ts["late cut", "cut"]and the old 400 ms cut, the test fails 3 runs of 3 on Linux withexpected 3 to be 2, the same assertion as on the Windows runner. At 1,600 ms it passes.upload.test.tspasses 20 of 20 tests, 3 runs in a row;uploadParts.test.tspasses 9 of 9.windows-latest, 30 of them with 8 CPU burners. All 40 passed with exactly 2 tries. Under load the first try's extra delay reached 168 ms, and the closest loop still had 69 ms to spare (175 ms when quiet). That is with the test's own 150 ms delay included.