Public: anyone can read this; the crew can change it.
Full suite red: test/spawn-cell.test.ts #12816
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/12793-full-suite-red-test-spawn-cell-test-ts → main 2 commits fork 1 thread · 1 unresolved
3 files
changed +53
−47
scripts/gate.ts +1
| @@ -159,6 +159,7 @@ export const SLOW: readonly Exclusion[] = [ | ||
| 159 | 159 | { file: "test/signup-gate-parent.test.ts", reason: "walks every caller of createUser in the source tree; 2.3 s a test on the gate box", issue: 1242 }, |
| 160 | 160 | { file: "test/snapshot-incremental.test.ts", reason: "takes real snapshots of a forge: git bundles, sqlite copies and sealed scrypt lanes, four times over; 22 s a file under load", issue: 12742 }, |
| 161 | 161 | { file: "test/snapshot-uplink.test.ts", reason: "uploads a 400 MB snapshot in parts through a throttled uplink; 4.5 s a test on the gate box", issue: 1242 }, |
| 162 | { file: "test/spawn-cell-real-child.test.ts", reason: "boots a real child forge in a bwrap cell once and waits for it to answer; the boot is the file's time", issue: 12793 }, | |
| 162 | 163 | { file: "test/spawn-cell-e2e.test.ts", reason: "spawns a real child forge into a bwrap cell and waits for its app to answer; 25.9 s the file on the gate box", issue: 12647 }, |
| 163 | 164 | { file: "test/spawn-move-cell-e2e.test.ts", reason: "moves a running child forge into a real cell with its data, repository and app; 13.1 s a test on the gate box", issue: 1242 }, |
| 164 | 165 | { file: "test/spawn-small-cell.test.ts", reason: "spawns a Small child in a real cell, stops it and waits for its recovery in one hook; 32.7 s the file on the gate box", issue: 12648 }, |
test/spawn-cell-real-child.test.ts added +51
| @@ -0,0 +1,51 @@ | ||
| 1 | import { beforeAll, describe, expect, test } from "bun:test"; | |
| 2 | import { join } from "node:path"; | |
| 3 | import { portInsteadOfSocket } from "../src/git/hook-address.ts"; | |
| 4 | import { missing } from "./helpers/tools.ts"; | |
| 5 | import { failedWith, runHelper, type HelperRun } from "./helpers/machine-note.ts"; | |
| 6 | ||
| 7 | // Split from spawn-cell.test.ts (#12793): booting a whole child forge in a cell is this | |
| 8 | // file's time, so the cheap cell tests keep their own budget. | |
| 9 | ||
| 10 | // Where bwrap and socat are here, whatever FORGE_CELLS says: a check turns | |
| 11 | // cells off for the forges its tests boot, and this is the one test that | |
| 12 | // must boot a child in a cell anyway (#6023). In its own process, without it. | |
| 13 | const cellTools = process.platform === "linux" && !portInsteadOfSocket() && !missing("bwrap", "socat"); | |
| 14 | ||
| 15 | // One child for the file (#12396): booted once in the hook, so each test | |
| 16 | // reads what it saw; the boot is the file's time, not a test's. | |
| 17 | let childRun: HelperRun = { skipped: "no bwrap and socat here" }; | |
| 18 | function seenChild(): Record<string, unknown> | undefined { | |
| 19 | if ("error" in childRun) throw new Error(childRun.error); | |
| 20 | if ("skipped" in childRun) { | |
| 21 | console.log(`SKIPPING: this host refuses a cell inside the test (${childRun.skipped}), so no child forge was booted in one`); | |
| 22 | return undefined; | |
| 23 | } | |
| 24 | // The child's own reason and the machine's disk and load, not a bare mismatch. | |
| 25 | const { seen, out, errText } = childRun; | |
| 26 | if (seen["failure"] !== null || seen["health"] !== 200) throw new Error(failedWith("the child forge did not come up in its cell", { seen, out: out.slice(-1500) }, errText)); | |
| 27 | return seen; | |
| 28 | } | |
| 29 | ||
| 30 | describe("a real child forge", () => { | |
| 31 | beforeAll(async () => { | |
| 32 | if (cellTools) childRun = await runHelper([join(import.meta.dir, "helpers", "real-child-forge.ts")], "the child forge run", 85_000); | |
| 33 | }, 90_000); | |
| 34 | ||
| 35 | test.skipIf(!cellTools)("boots in its own forge:<name> cell and answers / through the forward; its first request is held until it is up", async () => { | |
| 36 | const seen = seenChild(); | |
| 37 | if (seen === undefined) return; | |
| 38 | expect(seen["first"]).toBe(200); | |
| 39 | expect(seen["limits"]).toEqual({ memoryMiB: 2048, cpus: 1, diskMiB: 2048 }); | |
| 40 | expect(seen["root"] as number).toBeLessThan(400); | |
| 41 | expect(seen["health"]).toBe(200); | |
| 42 | expect(seen["labelled"]).toBe(true); | |
| 43 | }); | |
| 44 | ||
| 45 | test.skipIf(!cellTools)("its heartbeat reaches the parent through the cell, with no public address", async () => { | |
| 46 | // The child's parent record names an unreachable upstream, as in a preview's cell. | |
| 47 | const seen = seenChild(); | |
| 48 | if (seen === undefined) return; | |
| 49 | expect(seen["beat"]).toBe("kid"); | |
| 50 | }); | |
| 51 | }); |
test/spawn-cell.test.ts +1 −47
| @@ -1,4 +1,4 @@ | ||
| 1 | import { afterAll, beforeAll, describe, expect, test } from "bun:test"; | |
| 1 | import { afterAll, describe, expect, test } from "bun:test"; | |
| 2 | 2 | import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; |
| 3 | 3 | import { tmpdir } from "node:os"; |
| 4 | 4 | import { join } from "node:path"; |
| @@ -16,14 +16,11 @@ import type { SpawnPlan } from "../src/spawn/plan.ts"; | ||
| 16 | 16 | import { SIZES } from "../src/spawn/sizes.ts"; |
| 17 | 17 | import { notePeer } from "../src/http/peer.ts"; |
| 18 | 18 | import type { App } from "../src/app.ts"; |
| 19 | import { portInsteadOfSocket } from "../src/git/hook-address.ts"; | |
| 20 | import { missing } from "./helpers/tools.ts"; | |
| 21 | 19 | import { hostAllowed } from "../src/apps/egress.ts"; |
| 22 | 20 | import { CAPACITY, childModelHosts, childPaymentHosts, childRegistryHosts, |
| 23 | 21 | childOriginHosts, setCapacity } from "../src/core/capacity.ts"; |
| 24 | 22 | import { openBeatDoor, parentLocal } from "../src/spawn/beat-door.ts"; |
| 25 | 23 | import { sendBeat } from "../src/spawn/heartbeat.ts"; |
| 26 | import { failedWith, runHelper, type HelperRun } from "./helpers/machine-note.ts"; | |
| 27 | 24 | |
| 28 | 25 | const plan = (name: string): SpawnPlan => ({ name, org: "o", apps: [], briefs: [], subscriptions: [], direction: "", keepAccess: false, budgetUsd: null }); |
| 29 | 26 | const tmp = mkdtempSync(join(tmpdir(), "spawn-cell-")); |
| @@ -562,49 +559,6 @@ describe("a child that will not start", () => { | ||
| 562 | 559 | }); |
| 563 | 560 | }); |
| 564 | 561 | |
| 565 | // Where bwrap and socat are here, whatever FORGE_CELLS says: a check turns | |
| 566 | // cells off for the forges its tests boot, and this is the one test that | |
| 567 | // must boot a child in a cell anyway (#6023). In its own process, without it. | |
| 568 | const cellTools = process.platform === "linux" && !portInsteadOfSocket() && !missing("bwrap", "socat"); | |
| 569 | ||
| 570 | // One child for the file (#12396): booted once in the hook, so each test | |
| 571 | // reads what it saw; the boot is the file's time, not a test's. | |
| 572 | let childRun: HelperRun = { skipped: "no bwrap and socat here" }; | |
| 573 | function seenChild(): Record<string, unknown> | undefined { | |
| 574 | if ("error" in childRun) throw new Error(childRun.error); | |
| 575 | if ("skipped" in childRun) { | |
| 576 | console.log(`SKIPPING: this host refuses a cell inside the test (${childRun.skipped}), so no child forge was booted in one`); | |
| 577 | return undefined; | |
| 578 | } | |
| 579 | // The child's own reason and the machine's disk and load, not a bare mismatch. | |
| 580 | const { seen, out, errText } = childRun; | |
| 581 | if (seen["failure"] !== null || seen["health"] !== 200) throw new Error(failedWith("the child forge did not come up in its cell", { seen, out: out.slice(-1500) }, errText)); | |
| 582 | return seen; | |
| 583 | } | |
| 584 | ||
| 585 | describe("a real child forge", () => { | |
| 586 | beforeAll(async () => { | |
| 587 | if (cellTools) childRun = await runHelper([join(import.meta.dir, "helpers", "real-child-forge.ts")], "the child forge run", 85_000); | |
| 588 | }, 90_000); | |
| 589 | ||
| 590 | test.skipIf(!cellTools)("boots in its own forge:<name> cell and answers / through the forward; its first request is held until it is up", async () => { | |
| 591 | const seen = seenChild(); | |
| 592 | if (seen === undefined) return; | |
| 593 | expect(seen["first"]).toBe(200); | |
| 594 | expect(seen["limits"]).toEqual({ memoryMiB: 2048, cpus: 1, diskMiB: 2048 }); | |
| 595 | expect(seen["root"] as number).toBeLessThan(400); | |
| 596 | expect(seen["health"]).toBe(200); | |
| 597 | expect(seen["labelled"]).toBe(true); | |
| 598 | }); | |
| 599 | ||
| 600 | test.skipIf(!cellTools)("its heartbeat reaches the parent through the cell, with no public address", async () => { | |
| 601 | // The child's parent record names an unreachable upstream, as in a preview's cell. | |
| 602 | const seen = seenChild(); | |
| 603 | if (seen === undefined) return; | |
| 604 | expect(seen["beat"]).toBe("kid"); | |
| 605 | }); | |
| 606 | }); | |
| 607 | ||
| 608 | 562 | describe("a child whose cell will not come up", () => { |
| 609 | 563 | test.skipIf(cells.ok)("is hosted instead, and the ledger says why", async () => { |
| 610 | 564 | const dataDir = join(tmp, "demote-parent"); |
new above
offline
Sorted order puts spawn-cell-real-child after spawn-cell-e2e. Also, the reason ("the boot is the file time") is unmeasured; drop the entry if the boot is fast.