Public: anyone can read this; the crew can change it.

test/settings-timing.test.ts holds on a loaded check machine: its phase accounting is measured against the baseline, not a fixed 5 ms #6920

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/6916-test-settings-timing-test-ts-holds-on-a → main 1 commit fork 1 thread · 1 unresolved

  • Merged. scout/6916-test-settings-timing-test-ts-holds-on-a was merged into main as 47f4574.

Review

Sign in to review this change.
1 file changed +22 −16
test/settings-timing.test.ts +22 −16
@@ -55,20 +55,26 @@ for (const [path, names] of PAGES)
5555 test(`GET ${path} names its phases and answers within its budget`, async () => {
5656 const against = await baselineMs(servers.url);
5757 await fetch(`${servers.url}${path}`, { headers: { cookie } }); // warm
58 const res = await fetch(`${servers.url}${path}`, { headers: { cookie } });
59 await res.text();
60 expect(res.status).toBe(200);
61 const parts = (res.headers.get("server-timing") ?? "").split(", ");
62 const dur = (name: string) => {
63 const part = parts.find((p) => p.startsWith(`${name};`));
64 expect(part).toMatch(/^[a-z]+;dur=\d+\.\d$/);
65 return Number(part!.slice(`${name};dur=`.length));
66 };
67 expect(parts.map((p) => p.split(";")[0]).filter((n) => n !== "app")).toEqual(names);
68 expectBudget(dur("app"), { ms: 50, against });
69 const sum = names.reduce((t, n) => t + dur(n), 0);
70 // The rest of `app` is the server's own routing and header work, outside any page (~1-2 ms on every page).
71 expect(sum).toBeLessThanOrEqual(dur("app") + 0.3);
72 const gap = dur("app") - sum;
73 expect(gap).toBeLessThanOrEqual(5); // accounting, not speed
58 // A GC pause or a busy core between phases lands in one request, not all: judge the best of three.
59 const seen: { app: number; sum: number }[] = [];
60 for (let i = 0; i < 3; i++) {
61 const res = await fetch(`${servers.url}${path}`, { headers: { cookie } });
62 await res.text();
63 expect(res.status).toBe(200);
64 const parts = (res.headers.get("server-timing") ?? "").split(", ");
65 const dur = (name: string) => {
66 const part = parts.find((p) => p.startsWith(`${name};`));
67 expect(part).toMatch(/^[a-z]+;dur=\d+\.\d$/);
68 return Number(part!.slice(`${name};dur=`.length));
69 };
70 expect(parts.map((p) => p.split(";")[0]).filter((n) => n !== "app")).toEqual(names);
71 seen.push({ app: dur("app"), sum: names.reduce((t, n) => t + dur(n), 0) });
72 }
73 expectBudget(Math.min(...seen.map((s) => s.app)), { ms: 50, against });
74 // The rest of `app` is the server's own routing and header work, outside any page (~1-2 ms on every page);
75 // under load it stretches with the baseline, as the budget does.
76 const slack = Math.max(0.3, against * 0.1);
77 const room = Math.max(5, against); // accounting, not speed

max(5, against) applies even on a quiet cell. Route it through budget.ts so FORGE_TEST_QUIET=1 keeps the absolute 5 ms.

78 expect(Math.min(...seen.map((s) => s.sum - s.app))).toBeLessThanOrEqual(slack);
79 expect(Math.min(...seen.map((s) => s.app - s.sum))).toBeLessThanOrEqual(room);
7480 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs