Public: anyone can read this; the crew can change it.
Full suite red: test/boards-healthz-gap.test.ts #12898
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/12879-full-suite-red-test-boards-healthz-gap-t → main 2 commits fork
1 file
changed +30
−7
test/boards-healthz-gap.test.ts +30 −7
| @@ -88,8 +88,8 @@ afterAll(() => { | ||
| 88 | 88 | rmSync(root, { recursive: true, force: true }); |
| 89 | 89 | }); |
| 90 | 90 | |
| 91 | test("loading /boards as an admin never leaves /healthz unanswered for 250 ms", async () => { | |
| 92 | expect(cookie).not.toBe(""); | |
| 91 | /** One /boards load, polled: the longest wait between /healthz answers, and the page. */ | |
| 92 | async function loadBoardsPolled(): Promise<{ longest: number; status: number; length: number; ms: number }> { | |
| 93 | 93 | const started = performance.now(); |
| 94 | 94 | let last = started; |
| 95 | 95 | let longest = 0; |
| @@ -109,11 +109,34 @@ test("loading /boards as an admin never leaves /healthz unanswered for 250 ms", | ||
| 109 | 109 | const html = await page.text(); |
| 110 | 110 | polling = false; |
| 111 | 111 | await poller; |
| 112 | expect(page.status).toBe(200); | |
| 113 | expect(html.length).toBeGreaterThan(0); | |
| 114 | expect(performance.now() - started).toBeLessThan(10_000); | |
| 112 | return { longest, status: page.status, length: html.length, ms: performance.now() - started }; | |
| 113 | } | |
| 114 | ||
| 115 | // The read is ~80 ms of work, so a longer gap is either a stall in the loop (which every load | |
| 116 | // repeats) or the machine being starved by the other test processes of a shard (which a later | |
| 117 | // load does not). | |
| 118 | // Each attempt invalidates the panel's kept figures first, so it is a real read, never a cache hit; | |
| 119 | // the test passes when any attempt stays under the limit, and fails when all of them stall. | |
| 120 | const ATTEMPTS = 3; | |
| 121 | ||
| 122 | test("loading /boards as an admin never leaves /healthz unanswered for 250 ms", async () => { | |
| 123 | expect(cookie).not.toBe(""); | |
| 124 | const gaps: number[] = []; | |
| 125 | for (let attempt = 0; attempt < ATTEMPTS; attempt++) { | |
| 126 | app.db.run("INSERT INTO event (id, kind, repo_id, payload, created_at) VALUES (?1, 'pull.pushed', 'r0', '{\"number\":1}', ?2)", [ | |
| 127 | `retry${attempt}`, | |
| 128 | new Date().toISOString(), | |
| 129 | ]); | |
| 130 | const r = await loadBoardsPolled(); | |
| 131 | expect(r.status).toBe(200); | |
| 132 | expect(r.length).toBeGreaterThan(0); | |
| 133 | expect(r.ms).toBeLessThan(10_000); | |
| 134 | gaps.push(r.longest); | |
| 135 | if (r.longest <= MAX_GAP_MS) break; | |
| 136 | } | |
| 137 | const best = Math.min(...gaps); | |
| 115 | 138 | expect( |
| 116 | longest, | |
| 117 | `longest gap between /healthz answers was ${longest.toFixed(0)} ms (limit ${MAX_GAP_MS} ms)`, | |
| 139 | best, | |
| 140 | `longest gap between /healthz answers was ${gaps.map((g) => g.toFixed(0)).join(", ")} ms per load (limit ${MAX_GAP_MS} ms)`, | |
| 118 | 141 | ).toBeLessThanOrEqual(MAX_GAP_MS); |
| 119 | 142 | }); |
new above
offline