Public: anyone can read this; the crew can change it.
"a hosted child's apps run in the parent" passes every time on a loaded check machine #5234
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/5203-a-hosted-child-s-apps-run-in-the-parent → main 1 commit fork
1 file
changed +14
−13
test/spawn-child-runs-apps.test.ts +14 −13
| @@ -47,14 +47,13 @@ describe("a hosted child's apps run in the parent", () => { | ||
| 47 | 47 | return (await proxyApp(hit.runtime, request, hit.target, {} as never))!; |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | const get = async (host: string): Promise<Response> => { | |
| 51 | const until = Date.now() + 45_000; | |
| 52 | for (;;) { | |
| 53 | const res = await ask(host); | |
| 54 | if (res.status === 200 || Date.now() > until) return res; | |
| 55 | await res.text(); | |
| 56 | await Bun.sleep(300); | |
| 57 | } | |
| 50 | /** Wait until the child's boot deploys have settled, then say what they came to. */ | |
| 51 | const deployed = async (name: string): Promise<void> => { | |
| 52 | const child = childRuntime(parent, name)!; | |
| 53 | const until = Date.now() + 150_000; | |
| 54 | while (child.startingCount() > 0 && Date.now() < until) await Bun.sleep(100); | |
| 55 | const summary = hostedChildApps(parent, name)!; | |
| 56 | if (summary.running !== summary.total) throw new Error(`${name}: ${JSON.stringify(summary.notRunning)}`); | |
| 58 | 57 | }; |
| 59 | 58 | |
| 60 | 59 | beforeAll(async () => { |
| @@ -99,6 +98,7 @@ describe("a hosted child's apps run in the parent", () => { | ||
| 99 | 98 | if (!spawned.ok) throw new Error(JSON.stringify(spawned.error)); |
| 100 | 99 | childDir = childDirOf(parent, spawned.value.bodyId); |
| 101 | 100 | await bootHostedChild(parent, "maria"); |
| 101 | await deployed("maria"); | |
| 102 | 102 | // A child named like a pull number, with the same app as the parent's. |
| 103 | 103 | const numbered = await spawnForge( |
| 104 | 104 | parent, |
| @@ -114,8 +114,9 @@ describe("a hosted child's apps run in the parent", () => { | ||
| 114 | 114 | if (!numbered.ok) throw new Error(JSON.stringify(numbered.error)); |
| 115 | 115 | numberedDir = childDirOf(parent, numbered.value.bodyId); |
| 116 | 116 | await bootHostedChild(parent, "12"); |
| 117 | await deployed("12"); | |
| 117 | 118 | servers = await serve(parent); |
| 118 | }, 120_000); | |
| 119 | }, 200_000); | |
| 119 | 120 | |
| 120 | 121 | afterAll(async () => { |
| 121 | 122 | await checks?.stop(); |
| @@ -126,13 +127,13 @@ describe("a hosted child's apps run in the parent", () => { | ||
| 126 | 127 | }); |
| 127 | 128 | |
| 128 | 129 | test("<app>--<child>--<parent> answers from the child's app, on the child's own data", async () => { |
| 129 | const res = await get("bakery--maria--forge.test"); | |
| 130 | const res = await ask("bakery--maria--forge.test"); | |
| 130 | 131 | expect(res.status).toBe(200); |
| 131 | 132 | const data = await res.text(); |
| 132 | 133 | // The child's directory, never the parent's or another child's. |
| 133 | 134 | expect(data.startsWith(join(childDir, "apps"))).toBe(true); |
| 134 | 135 | expect(data.startsWith(join(dir, "apps"))).toBe(false); |
| 135 | }, 60_000); | |
| 136 | }); | |
| 136 | 137 | |
| 137 | 138 | test("it is one more tenant of the parent's lanes, and /forges can say it runs", async () => { |
| 138 | 139 | const child = childRuntime(parent, "maria")!; |
| @@ -169,11 +170,11 @@ describe("a hosted child's apps run in the parent", () => { | ||
| 169 | 170 | test("the parent's own preview host wins over a child named like its pull number", async () => { |
| 170 | 171 | if (servers === undefined) throw new Error("the parent's listener did not start"); |
| 171 | 172 | // The child's app is up and would answer this very host if it were asked. |
| 172 | expect((await get("bakery--12--forge.test")).status).toBe(200); | |
| 173 | expect((await ask("bakery--12--forge.test")).status).toBe(200); | |
| 173 | 174 | const res = await fetch(servers.url + "/", { headers: { host: "bakery--12--forge.test" } }); |
| 174 | 175 | expect(res.status).not.toBe(200); |
| 175 | 176 | const body = await res.text(); |
| 176 | 177 | expect(body.startsWith(join(numberedDir, "apps"))).toBe(false); |
| 177 | 178 | expect(body.startsWith(join(childDir, "apps"))).toBe(false); |
| 178 | }, 60_000); | |
| 179 | }); | |
| 179 | 180 | }); |
new above
offline