Public: anyone can read this; the crew can change it.
Full suite red: test/boot-production.test.ts #13094
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13089-full-suite-red-test-boot-production-test → main 1 commit fork 1 thread · 1 unresolved
1 file
changed +17
−9
test/boot-production.test.ts +17 −9
| @@ -71,7 +71,7 @@ async function boot(name: string, engine: string | undefined): Promise<Boot> { | ||
| 71 | 71 | else env["FORGE_ENGINE"] = engine; |
| 72 | 72 | // Where this test runs, not what production sets: a home, a temp directory, and how a check |
| 73 | 73 | // contains the forges its tests boot. |
| 74 | for (const key of ["HOME", "TMPDIR", "FORGE_CELLS"]) { | |
| 74 | for (const key of ["HOME", "TMPDIR", "FORGE_CELLS", "FORGE_TEST_SOCKET"]) { | |
| 75 | 75 | const value = process.env[key]; |
| 76 | 76 | if (value !== undefined && value !== "") env[key] = value; |
| 77 | 77 | } |
| @@ -96,14 +96,22 @@ async function boot(name: string, engine: string | undefined): Promise<Boot> { | ||
| 96 | 96 | while (performance.now() - started < HOLD_MS && child.exitCode === null) |
| 97 | 97 | await Bun.sleep(250); // real-timer: a real forge in a child process, held up for the length of a real boot |
| 98 | 98 | const alive = child.exitCode === null; |
| 99 | const health = alive | |
| 100 | ? await fetch(`http://127.0.0.1:${port}/healthz`, { | |
| 101 | signal: AbortSignal.timeout(5_000), | |
| 102 | }).then( | |
| 103 | (r) => r.status, | |
| 104 | () => 0, | |
| 105 | ) | |
| 106 | : 0; | |
| 99 | // A loaded machine (the full suite runs files side by side) can leave a boot slow to answer: | |
| 100 | // ask again for up to twenty seconds, and report the last answer. | |
| 101 | let health = 0; | |
| 102 | for ( | |
| 103 | const asked = performance.now(); | |
| 104 | alive && health !== 200 && performance.now() - asked < 20_000; | |
| 105 | ||
| 106 | ) { | |
| 107 | health = await fetch(`http://127.0.0.1:${port}/healthz`, { | |
| 108 | signal: AbortSignal.timeout(5_000), | |
| 109 | }).then( | |
| 110 | (r) => r.status, | |
| 111 | () => 0, | |
| 112 | ); | |
| 113 | if (health !== 200) await Bun.sleep(500); // real-timer: a loaded machine's boot gets time to answer | |
| 114 | } | |
| 107 | 115 | return { name, alive, exitCode: child.exitCode, health, output }; |
| 108 | 116 | } finally { |
| 109 | 117 | // A person's stop: no linger for routers. Killed if it has not gone in four seconds. |
new above
offline
Optional: a while loop with a deadline is clearer than a for with an empty update clause.