Skip to content

Commit bc10b1e

Browse files
committed
test(rest): give the import-template parity case a measured per-shape budget
The parity case in import-template-route.test.ts loops over 20 default shapes. The loop is 98% of the case under every load measured, and the engine boot is warm by the time the case runs. So the case gets an explicit timeout of 1000ms per shape (20000ms for 20 shapes), with the measured timings and the arithmetic in a comment above it. No assertion changes. Claude-Session: https://claude.ai/code/session_016GiHYRmLSNWTfbX9gVQkpz Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4c8363f commit bc10b1e

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

‎packages/rest/src/import-template-route.test.ts‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,36 @@ const PARITY: Record<string, { def: Record<string, unknown>; blank: 'refused' |
507507
},
508508
};
509509

510+
/**
511+
* The parity case's own budget (#21428): {@link PARITY_MS_PER_SHAPE} per shape,
512+
* so it grows with the battery. Vitest's default 5000ms is one budget for the
513+
* whole case, and this case is a loop. It ran past 5000ms twice on a loaded
514+
* Test Core shard.
515+
*
516+
* Measured with phase timers in a throwaway copy of this file, on a 4-vCPU box
517+
* that other jobs shared. The whole file ran each time, so this case ran after
518+
* the 25 cases above it, as it does in CI.
519+
*
520+
* load whole case boot register+sync loop
521+
* idle, 5 runs 941-1085ms 5-6ms 14-15ms 920-1063ms
522+
* 2 runs of the file at once 1105-1671ms 5-7ms 15-21ms 1084-1642ms
523+
* 8 busy loops, 3 runs 2232-2632ms 9-10ms 31-46ms 2190-2576ms
524+
* 24 busy loops, 3 runs 7654-8371ms 36-44ms 91-142ms 7525-8165ms
525+
*
526+
* The loop is 98% of the case under every load, and its cost is the work this
527+
* case asserts on. Each shape builds a template through the real route, parses
528+
* the workbook, and imports a row through the real import door, about a third
529+
* of the loop each. The engine boot is already warm at this point in the file,
530+
* and boot plus registering and syncing the 20 objects is 2% of the case, so
531+
* moving the boot into a `beforeAll` would not fix this.
532+
*
533+
* The budget per shape: the slowest per-shape cost measured above is 419ms
534+
* (8371ms / 20, at 24 busy loops). 1000ms is about 2.4x that, and about 18x the
535+
* slowest idle cost (1085ms / 20 = 54ms). For the 20 shapes here the case gets
536+
* 20000ms.
537+
*/
538+
const PARITY_MS_PER_SHAPE = 1_000;
539+
510540
describe('the `*` agrees with the engine: starred exactly when the import door refuses a blank', () => {
511541
it('for every shape of default the engine reads', async () => {
512542
const { get, importRoute, engine } = await boot();
@@ -546,7 +576,7 @@ describe('the `*` agrees with the engine: starred exactly when the import door r
546576
}
547577
}
548578
expect(disagreements).toEqual([]);
549-
});
579+
}, Object.keys(PARITY).length * PARITY_MS_PER_SHAPE);
550580
});
551581

552582
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)