Skip to content

Commit 0862627

Browse files
committed
fix(tests): keep the preview turn-budget test inside its timeout under CPU load
The four-patch turn-budget test drove 2,400 deltas over a ~300 KB base, about 2.4 s of CPU on an idle machine and 11-15 s at load 150, past the 10 s test timeout. Pacing already runs on fake timers; the flake was CPU time, not wall clock. Four 30 s patches at a 500 ms tick still stream ~25 MB uncapped against the 8 MiB budget, so the test still fails when the cap is removed.
1 parent 85402d0 commit 0862627

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎apps/sim/lib/mothership/request/go/file-preview-adapter.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,17 @@ describe('processFilePreviewStreamEvent — preview byte rate', () => {
268268
expect(completed).toBe(true)
269269
})
270270

271+
/**
272+
* Each 30 s patch of the ~300 KB file would stream ~6 MB of snapshots on its own,
273+
* so four of them exceed the turn budget several times over without its cap. The
274+
* 500 ms tick keeps the delta count, and so the test's CPU time, small enough to
275+
* stay far inside the test timeout on a loaded machine.
276+
*/
271277
it('bounds all preview content in a turn of four long patches, and still completes each', async () => {
272278
const turn = newTurn()
273279
let contentBytes = 0
274280
for (let edit = 0; edit < 4; edit++) {
275-
const result = await streamPatch(120_000, 200, { turn, edit })
281+
const result = await streamPatch(30_000, 500, { turn, edit })
276282
expect(result.completed).toBe(true)
277283
contentBytes += result.contentBytes
278284
}

0 commit comments

Comments
 (0)