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

Merged opened this

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

Merged

scout/forge:scout/5203-a-hosted-child-s-apps-run-in-the-parent → main 1 commit fork

  • Merged. scout/5203-a-hosted-child-s-apps-run-in-the-parent was merged into main as 3ac47c5.

Review

Sign in to review this change.
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", () => {
4747 return (await proxyApp(hit.runtime, request, hit.target, {} as never))!;
4848 };
4949
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)}`);
5857 };
5958
6059 beforeAll(async () => {
@@ -99,6 +98,7 @@ describe("a hosted child's apps run in the parent", () => {
9998 if (!spawned.ok) throw new Error(JSON.stringify(spawned.error));
10099 childDir = childDirOf(parent, spawned.value.bodyId);
101100 await bootHostedChild(parent, "maria");
101 await deployed("maria");
102102 // A child named like a pull number, with the same app as the parent's.
103103 const numbered = await spawnForge(
104104 parent,
@@ -114,8 +114,9 @@ describe("a hosted child's apps run in the parent", () => {
114114 if (!numbered.ok) throw new Error(JSON.stringify(numbered.error));
115115 numberedDir = childDirOf(parent, numbered.value.bodyId);
116116 await bootHostedChild(parent, "12");
117 await deployed("12");
117118 servers = await serve(parent);
118 }, 120_000);
119 }, 200_000);
119120
120121 afterAll(async () => {
121122 await checks?.stop();
@@ -126,13 +127,13 @@ describe("a hosted child's apps run in the parent", () => {
126127 });
127128
128129 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");
130131 expect(res.status).toBe(200);
131132 const data = await res.text();
132133 // The child's directory, never the parent's or another child's.
133134 expect(data.startsWith(join(childDir, "apps"))).toBe(true);
134135 expect(data.startsWith(join(dir, "apps"))).toBe(false);
135 }, 60_000);
136 });
136137
137138 test("it is one more tenant of the parent's lanes, and /forges can say it runs", async () => {
138139 const child = childRuntime(parent, "maria")!;
@@ -169,11 +170,11 @@ describe("a hosted child's apps run in the parent", () => {
169170 test("the parent's own preview host wins over a child named like its pull number", async () => {
170171 if (servers === undefined) throw new Error("the parent's listener did not start");
171172 // 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);
173174 const res = await fetch(servers.url + "/", { headers: { host: "bakery--12--forge.test" } });
174175 expect(res.status).not.toBe(200);
175176 const body = await res.text();
176177 expect(body.startsWith(join(numberedDir, "apps"))).toBe(false);
177178 expect(body.startsWith(join(childDir, "apps"))).toBe(false);
178 }, 60_000);
179 });
179180 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs