From 02ae7553d4c42d1b68d1ab13c8f7509ddce6e229 Mon Sep 17 00:00:00 2001 From: Bartek Igielski Date: Thu, 5 Nov 2026 18:02:20 +0100 Subject: [PATCH] test(server): cut the local server suite from ~63 to ~12-16 minutes The full apps/server suite ran files one at a time, and most of its plugin integration time was real-time waiting rather than work: - The pipe-backed PTY stand-in never showed a line-editor prompt, so every setup script waited out ProjectSetupScriptRunner's 3s quiet fallback and its 1s prompt-return timeout. It now echoes input and prints a prompt the way an interactive terminal does. - Every test server boot spawned the user's login shell synchronously (~1s, host-dependent). Test configs now mark the shell environment as prepared. - Test servers posted analytics to the real ingest host and waited on the shutdown flush. Server tests now disable telemetry. - Files run in parallel at 75% of cores. Two workflow tests lifted their simulated outage while a scheduler-tick drain could still hold a launch validated against the old provider or skill; they now reconcile (drains are serialized) before lifting it. Co-Authored-By: Claude Opus 5.5 --- apps/server/src/config.ts | 2 ++ .../orchestration-v2/testkit/ProviderReplayHarness.ts | 2 ++ apps/server/src/plugins/PluginHost.testkit.ts | 9 +++++++-- .../src/plugins/WorkflowsProvider.integration.test.ts | 2 ++ .../src/plugins/WorkflowsSkill.integration.test.ts | 2 ++ apps/server/src/testUtils/telemetry.setup.ts | 2 ++ apps/server/vite.config.ts | 5 +++-- 7 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 apps/server/src/testUtils/telemetry.setup.ts diff --git a/apps/server/src/config.ts b/apps/server/src/config.ts index bbec735e134e7..83cc1cb3f23cb 100644 --- a/apps/server/src/config.ts +++ b/apps/server/src/config.ts @@ -244,6 +244,8 @@ const makeTest = Effect.fn("ServerConfig.makeTest")(function* ( baseDir, ...derivedPaths, mode: "web", + // The test process already has its PATH; a login-shell probe blocks each boot for ~1s. + shellEnvironmentPrepared: true, autoBootstrapProjectFromCwd: false, logWebSocketEvents: false, tailscaleServeEnabled: false, diff --git a/apps/server/src/orchestration-v2/testkit/ProviderReplayHarness.ts b/apps/server/src/orchestration-v2/testkit/ProviderReplayHarness.ts index 72b39295bc3e7..f919ce3f12a3c 100644 --- a/apps/server/src/orchestration-v2/testkit/ProviderReplayHarness.ts +++ b/apps/server/src/orchestration-v2/testkit/ProviderReplayHarness.ts @@ -140,6 +140,8 @@ export function makeReplayServerConfig( tailscaleServeEnabled: false, tailscaleServePort: 443, desktopBootstrapToken: undefined, + // The test process already has its PATH; a login-shell probe blocks each boot for ~1s. + shellEnvironmentPrepared: true, autoBootstrapProjectFromCwd: false, logWebSocketEvents: false, stateDir, diff --git a/apps/server/src/plugins/PluginHost.testkit.ts b/apps/server/src/plugins/PluginHost.testkit.ts index 1ae9d0f2deebc..c541638b8d656 100644 --- a/apps/server/src/plugins/PluginHost.testkit.ts +++ b/apps/server/src/plugins/PluginHost.testkit.ts @@ -51,8 +51,10 @@ const encode = Schema.encodeSync(Schema.fromJsonString(Schema.Unknown)); /** * Pipe-backed stand-in for Bun's PTY. The shell leads its own process group so * signals reach the scripts it runs, as a terminal session's hangup does; - * signalling only the shell would orphan a script blocked on a gate. + * signalling only the shell would orphan a script blocked on a gate. It echoes input and + * prints a line-editor prompt like a terminal, or the setup runner waits on real timers. */ +const PROMPT = "printf '\\033[?2004h$ '\n"; const scriptRuntime: typeof BunPtyRuntime.Service = { spawn: (command, options) => { const child = NodeChildProcess.spawn(command[0]!, command.slice(1), { @@ -76,12 +78,15 @@ const scriptRuntime: typeof BunPtyRuntime.Service = { child.once("exit", () => signalGroup("SIGHUP")); const terminal = { write: (data: string) => { - child.stdin.write(data.replaceAll("\r", "\n")); + const input = data.replaceAll("\r", "\n"); + options.terminal.data(terminal, Buffer.from(input)); + child.stdin.write(input.endsWith("\n") ? input + PROMPT : input); return Buffer.byteLength(data); }, resize: () => {}, close: () => child.stdin.end(), }; + child.stdin.write(PROMPT); child.stdout.on("data", (data: Buffer) => options.terminal.data(terminal, data)); child.stderr.on("data", (data: Buffer) => options.terminal.data(terminal, data)); const exited = new Promise((resolve, reject) => { diff --git a/apps/server/src/plugins/WorkflowsProvider.integration.test.ts b/apps/server/src/plugins/WorkflowsProvider.integration.test.ts index 14345a1558518..42e5d41ed49fd 100644 --- a/apps/server/src/plugins/WorkflowsProvider.integration.test.ts +++ b/apps/server/src/plugins/WorkflowsProvider.integration.test.ts @@ -133,6 +133,8 @@ it.live.each([ supported = !scenario.startsWith("unsupported"); available = !scenario.startsWith("unavailable"); modeAllowed = scenario !== "runtime-mode-startup"; + // Drains are serialized: settle any that validated the old providers while launches still fail. + if (scenario.endsWith("direct")) yield* runtime.invoke("reconcile", test.scope); outage = false; if (!scenario.endsWith("direct")) { runtime = yield* test.boot(host, selected); diff --git a/apps/server/src/plugins/WorkflowsSkill.integration.test.ts b/apps/server/src/plugins/WorkflowsSkill.integration.test.ts index 0a5ca912aea4f..3da15978531be 100644 --- a/apps/server/src/plugins/WorkflowsSkill.integration.test.ts +++ b/apps/server/src/plugins/WorkflowsSkill.integration.test.ts @@ -136,6 +136,8 @@ it.live.each([ yield* fs.writeFileString(path, "# Skill\nOriginal work"); } if (scenario === "disabled") enabled = false; + // Drains are serialized: settle any that validated the old skill while launches still fail. + if (scenario === "changed-source-direct") yield* runtime.invoke("reconcile", test.scope); unavailable = false; if (scenario !== "changed-source-direct") { runtime = yield* test.boot(host); diff --git a/apps/server/src/testUtils/telemetry.setup.ts b/apps/server/src/testUtils/telemetry.setup.ts new file mode 100644 index 0000000000000..e781b6f42dfde --- /dev/null +++ b/apps/server/src/testUtils/telemetry.setup.ts @@ -0,0 +1,2 @@ +// Servers booted by tests would otherwise post analytics to the real ingest host and wait on its shutdown flush. +process.env.T3CODE_TELEMETRY_ENABLED = "false"; diff --git a/apps/server/vite.config.ts b/apps/server/vite.config.ts index 40a2801c84732..abd7bb3911712 100644 --- a/apps/server/vite.config.ts +++ b/apps/server/vite.config.ts @@ -86,12 +86,13 @@ export default mergeConfig( }, }, test: { - // Parallel sqlite/git/worktree/orchestration tests introduce load-sensitive flakes. - fileParallelism: false, + // Real git, sqlite and server fixtures; leave headroom so load does not stretch their waits. + maxWorkers: "75%", sequence: { sequencer: WeightedShardSequencer }, setupFiles: [ "./src/testUtils/gitConfig.setup.ts", "./src/testUtils/managedServiceEnv.setup.ts", + "./src/testUtils/telemetry.setup.ts", ], hookTimeout: 120_000, testTimeout: 120_000,