Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
test(harness): keep test servers off the host's container runtime
VNATdev-opsdc57d2ec5c71
diff --git a/server/branching.test.ts b/server/branching.test.tsindex 90868a7838..e1cc7a907c 100644--- a/server/branching.test.ts+++ b/server/branching.test.ts@@ -5,6 +5,7 @@ import { dirname, join } from "node:path";import { fileURLToPath } from "node:url";import { afterAll, beforeAll, describe, expect, it } from "vitest";import { removeTempDir, waitForExit } from "./testing/cleanup.ts";+import { noHostContainerEnv } from "./testing/container-env.ts";import { workerPort } from "./testing/worker-port.ts";@@ -84,6 +85,7 @@ posixOnly("conversation branching e2e (fake ACP fleet)", () => {HOME: home,USERPROFILE: home,OMB_PORT: String(PORT),+ ...noHostContainerEnv(home),};if (process.env.PATH) env.PATH = process.env.PATH;child = spawn(process.execPath, [join(SERVER_DIR, "index.ts")], {diff --git a/server/comms.test.ts b/server/comms.test.tsindex 021d966085..ea16248e68 100644--- a/server/comms.test.ts+++ b/server/comms.test.ts@@ -11,6 +11,7 @@ import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";import { mentionedBots, normalizeGroupDefaultResponder, roomResponders } from "./store.ts";import { removeTempDir, waitForExit } from "./testing/cleanup.ts";+import { noHostContainerEnv } from "./testing/container-env.ts";import { readHandoffs } from "./testing/handoff-rows.ts";import { workerPort } from "./testing/worker-port.ts";@@ -364,6 +365,7 @@ describe("routine comms e2e on the job runtime (fake ACP fleet)", () => {USERPROFILE: home,OMB_PORT: String(PORT),OMB_TEST_INTERNAL_CAPABILITY_KEY: TEST_CAPABILITY_KEY,+ ...noHostContainerEnv(home),};if (process.env.PATH) env.PATH = process.env.PATH;// Without SystemRoot, winsock fails to initialize in the child.diff --git a/server/testing/container-env.test.ts b/server/testing/container-env.test.tsnew file mode 100644index 0000000000..71f872de09--- /dev/null+++ b/server/testing/container-env.test.ts@@ -0,0 +1,23 @@+import { join } from "node:path";+import { describe, expect, it } from "vitest";++import { noHostContainerEnv } from "./container-env.ts";++describe("noHostContainerEnv", () => {+ it("points both container CLIs at sockets inside the throwaway home", () => {+ const home = join("tmp", "omb-test-home");+ expect(noHostContainerEnv(home)).toEqual({+ DOCKER_HOST: `unix://${join(home, "no-docker.sock")}`,+ CONTAINER_HOST: `unix://${join(home, "no-podman.sock")}`,+ });+ });++ it("leaves the runtime alone when a test opts in", () => {+ process.env.OMB_TEST_ALLOW_CONTAINERS = "1";+ try {+ expect(noHostContainerEnv("any-home")).toEqual({});+ } finally {+ delete process.env.OMB_TEST_ALLOW_CONTAINERS;+ }+ });+});diff --git a/server/testing/container-env.ts b/server/testing/container-env.tsnew file mode 100644index 0000000000..6b2f91719e--- /dev/null+++ b/server/testing/container-env.ts@@ -0,0 +1,10 @@+import { join } from "node:path";++/** Test servers never see the developer's container daemon; a test that needs one opts in with OMB_TEST_ALLOW_CONTAINERS=1. */+export function noHostContainerEnv(home: string): Partial<Pick<NodeJS.ProcessEnv, "DOCKER_HOST" | "CONTAINER_HOST">> {+ if (process.env.OMB_TEST_ALLOW_CONTAINERS === "1") return {};+ return {+ DOCKER_HOST: `unix://${join(home, "no-docker.sock")}`,+ CONTAINER_HOST: `unix://${join(home, "no-podman.sock")}`,+ };+}diff --git a/server/testing/setup.ts b/server/testing/setup.tsindex 7c25eb6cf4..127c85170e 100644--- a/server/testing/setup.ts+++ b/server/testing/setup.ts@@ -6,10 +6,13 @@ import { join } from "node:path";import { afterAll, afterEach } from "vitest";import { removeTempDir } from "./cleanup.ts";+import { noHostContainerEnv } from "./container-env.ts";const home = mkdtempSync(join(tmpdir(), "omb-test-home-"));process.env.HOME = home;process.env.USERPROFILE = home;+// A test server with the host's PATH can adopt and recreate the installed app's Local VM.+Object.assign(process.env, noHostContainerEnv(home));// A provider that answers 5xx retries with backoff: no test should wait out real seconds.process.env.FAKE_OPENAI_COMPAT_RETRY_SCALE ??= "0.001";// OMB_DATA_DIR must never escape the throwaway home the suite deletes.