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,