MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / setup

Function setup

e2e/setup/cloud.globalsetup.ts:27–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25 : resolve(RUNS_DIR, "cloud", "server-logs", "boot.log");
26
27export default async function setup(): Promise<(() => Promise<void>) | void> {
28 if (process.env.E2E_CLOUD_URL) {
29 await waitForHttp(process.env.E2E_CLOUD_URL);
30 return;
31 }
32
33 if (bootLogFile) mkdirSync(resolve(bootLogFile, ".."), { recursive: true });
34
35 // Suite-owned trace store — every run captures distributed traces. Booted
36 // once outside the retry: it binds its own OS-assigned port (not a claimed
37 // one), so an EADDRINUSE on the claimed block doesn't implicate it.
38 const motel = await bootMotel();
39 // Publish to the test workers (they inherit this process's env): scenarios
40 // that assert on exported spans yield the Telemetry service, which exists
41 // only when this is set. No motel → those scenarios skip, never fail.
42 if (motel) process.env.E2E_MOTEL_URL = motel.url;
43
44 // Claim a free port block (preferred block first, walk forward past
45 // squatters/colliding checkouts), boot the stack, and retry on EADDRINUSE —
46 // on Linux CI an ephemeral outbound socket can still grab a claimed port
47 // between probe and bind, so re-claim the next block and retry. claimAndBoot
48 // publishes the claimed ports via env (E2E_*_PORT) so the test workers —
49 // spawned after this — derive the same URLs; the imported targets/cloud
50 // constants were computed BEFORE the claim, so use the claimed values here.
51 let booted;
52 try {
53 booted = await claimAndBoot(
54 [
55 { envVar: "E2E_CLOUD_PORT", offset: 0, label: "cloud vite dev" },
56 { envVar: "E2E_CLOUD_DB_PORT", offset: 1, label: "cloud dev-db (PGlite)" },
57 { envVar: "E2E_WORKOS_EMULATOR_PORT", offset: 2, label: "WorkOS emulator" },
58 { envVar: "E2E_AUTUMN_EMULATOR_PORT", offset: 3, label: "Autumn emulator" },
59 ],
60 async (ports) => {
61 const publicUrl = `http://localhost:${ports.E2E_CLOUD_PORT!}`;
62 const cloud = await bootCloud({
63 cloudPort: ports.E2E_CLOUD_PORT!,
64 dbPort: ports.E2E_CLOUD_DB_PORT!,
65 workosPort: ports.E2E_WORKOS_EMULATOR_PORT!,
66 autumnPort: ports.E2E_AUTUMN_EMULATOR_PORT!,
67 workosClientId: E2E_WORKOS_CLIENT_ID,
68 cookiePassword: E2E_COOKIE_PASSWORD,
69 publicUrl,
70 logFile: bootLogFile,
71 // Server + browser spans → the suite's motel. The app's exporter is
72 // endpoint-agnostic, so the same layer that ships prod traces to
73 // Axiom ships e2e traces to the suite store — "why was that page
74 // slow" gets a span waterfall, not a guess.
75 extraEnv: motelExporterEnv(motel, publicUrl),
76 });
77 return { teardown: cloud.teardown, value: cloud };
78 },
79 { label: "cloud" },
80 );
81 // Publish the Autumn emulator URL to the test workers (they inherit this
82 // process's env): scenarios that assert on tracked usage yield the Autumn
83 // service, which exists only when this is set. No emulator → those scenarios
84 // skip, never fail. (Cloud-only; selfhost never boots Autumn.)

Callers

nothing calls this directly

Calls 6

waitForHttpFunction · 0.90
bootMotelFunction · 0.90
claimAndBootFunction · 0.90
bootCloudFunction · 0.90
motelExporterEnvFunction · 0.90
resolveFunction · 0.85

Tested by

no test coverage detected