Skip to content

Commit 0362f64

Browse files
committed
fix(qa): pass Mantis desktop runtime env
1 parent 786fdeb commit 0362f64

3 files changed

Lines changed: 56 additions & 33 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Docs: https://docs.openclaw.ai
2121
- Gateway/config: stop Gateway startup and hot reload from auto-restoring invalid config; invalid config now fails closed and `openclaw doctor --fix` owns last-known-good repair.
2222
- Gateway/performance: lazy-load early runtime discovery and shutdown-hook helpers, defer maintenance timers until after readiness, and trim duplicate plugin auto-enable work during Gateway startup.
2323
- QA/Mantis: add a `pnpm openclaw qa mantis discord-smoke` runner and manual GitHub workflow that verify the Mantis Discord bot can see the configured guild/channel, post a smoke message, add a reaction, and upload artifacts.
24+
- QA/Mantis: pass the runtime env through desktop-browser Crabbox and artifact-copy child commands, so embedded Mantis callers can provide Crabbox credentials without mutating the parent process. Thanks @vincentkoc.
2425
- QA/Slack: add a Slack live transport QA runner with canary and mention-gating coverage for the private bot-to-bot harness. Thanks @vincentkoc.
2526
- Gateway/performance: lazy-load the heavy cron runtime after the rest of Gateway startup, defer restart-sentinel refresh after readiness, and let the Gateway startup benchmark write per-run V8 CPU profiles with `--cpu-prof-dir`.
2627
- Gateway/performance: keep raw channel-config schema parsing from discovering bundled plugin runtime metadata, and add `pnpm gateway:watch --benchmark-no-force` for profiling startup without the default port cleanup.

‎extensions/qa-lab/src/mantis/desktop-browser-smoke.runtime.test.ts‎

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,51 @@ describe("mantis desktop browser smoke runtime", () => {
1818
it("leases a desktop box, runs a visible browser, copies artifacts, and stops on pass", async () => {
1919
await fs.mkdir(path.join(repoRoot, "qa-artifacts"), { recursive: true });
2020
await fs.writeFile(path.join(repoRoot, "qa-artifacts", "timeline.html"), "<h1>Mantis</h1>");
21-
const commands: { args: readonly string[]; command: string }[] = [];
22-
const runner = vi.fn(async (command: string, args: readonly string[]) => {
23-
commands.push({ command, args });
24-
if (command === "/tmp/crabbox" && args[0] === "warmup") {
25-
return { stdout: "ready lease cbx_abc123\n", stderr: "" };
26-
}
27-
if (command === "/tmp/crabbox" && args[0] === "inspect") {
28-
return {
29-
stdout: `${JSON.stringify({
30-
host: "203.0.113.10",
31-
id: "cbx_abc123",
32-
provider: "hetzner",
33-
slug: "brisk-mantis",
34-
sshKey: "/tmp/key",
35-
sshPort: "2222",
36-
sshUser: "crabbox",
37-
state: "active",
38-
})}\n`,
39-
stderr: "",
40-
};
41-
}
42-
if (command === "rsync") {
43-
const outputDir = args.at(-1);
44-
expect(outputDir).toBeTypeOf("string");
45-
await fs.mkdir(outputDir as string, { recursive: true });
46-
await fs.writeFile(path.join(outputDir as string, "desktop-browser-smoke.png"), "png");
47-
await fs.writeFile(path.join(outputDir as string, "remote-metadata.json"), "{}\n");
48-
await fs.writeFile(path.join(outputDir as string, "chrome.log"), "chrome\n");
21+
const commands: { args: readonly string[]; command: string; env?: NodeJS.ProcessEnv }[] = [];
22+
const runtimeEnv = {
23+
PATH: process.env.PATH,
24+
CRABBOX_COORDINATOR_TOKEN: "runtime-token",
25+
OPENCLAW_MANTIS_CRABBOX_PROVIDER: "hetzner",
26+
};
27+
const runner = vi.fn(
28+
async (command: string, args: readonly string[], options: { env?: NodeJS.ProcessEnv }) => {
29+
commands.push({ command, args, env: options.env });
30+
if (command === "/tmp/crabbox" && args[0] === "warmup") {
31+
return { stdout: "ready lease cbx_abc123\n", stderr: "" };
32+
}
33+
if (command === "/tmp/crabbox" && args[0] === "inspect") {
34+
return {
35+
stdout: `${JSON.stringify({
36+
host: "203.0.113.10",
37+
id: "cbx_abc123",
38+
provider: "hetzner",
39+
slug: "brisk-mantis",
40+
sshKey: "/tmp/key",
41+
sshPort: "2222",
42+
sshUser: "crabbox",
43+
state: "active",
44+
})}\n`,
45+
stderr: "",
46+
};
47+
}
48+
if (command === "rsync") {
49+
const outputDir = args.at(-1);
50+
expect(outputDir).toBeTypeOf("string");
51+
await fs.mkdir(outputDir as string, { recursive: true });
52+
await fs.writeFile(path.join(outputDir as string, "desktop-browser-smoke.png"), "png");
53+
await fs.writeFile(path.join(outputDir as string, "remote-metadata.json"), "{}\n");
54+
await fs.writeFile(path.join(outputDir as string, "chrome.log"), "chrome\n");
55+
return { stdout: "", stderr: "" };
56+
}
4957
return { stdout: "", stderr: "" };
50-
}
51-
return { stdout: "", stderr: "" };
52-
});
58+
},
59+
);
5360

5461
const result = await runMantisDesktopBrowserSmoke({
5562
browserUrl: "https://openclaw.ai/docs",
5663
commandRunner: runner,
5764
crabboxBin: "/tmp/crabbox",
65+
env: runtimeEnv,
5866
htmlFile: "qa-artifacts/timeline.html",
5967
now: () => new Date("2026-05-04T12:00:00.000Z"),
6068
outputDir: ".artifacts/qa-e2e/mantis/desktop-browser-test",
@@ -69,6 +77,7 @@ describe("mantis desktop browser smoke runtime", () => {
6977
["rsync", "-az"],
7078
["/tmp/crabbox", "stop"],
7179
]);
80+
expect(commands.every((entry) => entry.env === runtimeEnv)).toBe(true);
7281
const rsyncArgs = commands.find((entry) => entry.command === "rsync")?.args ?? [];
7382
expect(rsyncArgs).not.toContain("--delete");
7483
expect(rsyncArgs).toEqual(

‎extensions/qa-lab/src/mantis/desktop-browser-smoke.runtime.ts‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,19 +303,21 @@ async function runCommand(params: {
303303
args: readonly string[];
304304
command: string;
305305
cwd: string;
306+
env: NodeJS.ProcessEnv;
306307
runner: CommandRunner;
307308
stdio?: "inherit" | "pipe";
308309
}) {
309310
return params.runner(params.command, params.args, {
310311
cwd: params.cwd,
311-
env: process.env,
312+
env: params.env,
312313
stdio: params.stdio ?? "pipe",
313314
});
314315
}
315316

316317
async function warmupCrabbox(params: {
317318
crabboxBin: string;
318319
cwd: string;
320+
env: NodeJS.ProcessEnv;
319321
idleTimeout: string;
320322
machineClass: string;
321323
provider: string;
@@ -338,6 +340,7 @@ async function warmupCrabbox(params: {
338340
params.ttl,
339341
],
340342
cwd: params.cwd,
343+
env: params.env,
341344
runner: params.runner,
342345
stdio: "inherit",
343346
});
@@ -351,6 +354,7 @@ async function warmupCrabbox(params: {
351354
async function inspectCrabbox(params: {
352355
crabboxBin: string;
353356
cwd: string;
357+
env: NodeJS.ProcessEnv;
354358
leaseId: string;
355359
provider: string;
356360
runner: CommandRunner;
@@ -359,13 +363,15 @@ async function inspectCrabbox(params: {
359363
command: params.crabboxBin,
360364
args: ["inspect", "--provider", params.provider, "--id", params.leaseId, "--json"],
361365
cwd: params.cwd,
366+
env: params.env,
362367
runner: params.runner,
363368
});
364369
return JSON.parse(result.stdout) as CrabboxInspect;
365370
}
366371

367372
async function copyRemoteArtifacts(params: {
368373
cwd: string;
374+
env: NodeJS.ProcessEnv;
369375
inspect: CrabboxInspect;
370376
outputDir: string;
371377
remoteOutputDir: string;
@@ -401,13 +407,15 @@ async function copyRemoteArtifacts(params: {
401407
`${params.outputDir}/`,
402408
],
403409
cwd: params.cwd,
410+
env: params.env,
404411
runner: params.runner,
405412
});
406413
}
407414

408415
async function stopCrabbox(params: {
409416
crabboxBin: string;
410417
cwd: string;
418+
env: NodeJS.ProcessEnv;
411419
leaseId: string;
412420
provider: string;
413421
runner: CommandRunner;
@@ -416,6 +424,7 @@ async function stopCrabbox(params: {
416424
command: params.crabboxBin,
417425
args: ["stop", "--provider", params.provider, params.leaseId],
418426
cwd: params.cwd,
427+
env: params.env,
419428
runner: params.runner,
420429
stdio: "inherit",
421430
});
@@ -471,6 +480,7 @@ export async function runMantisDesktopBrowserSmoke(
471480
(await warmupCrabbox({
472481
crabboxBin,
473482
cwd: repoRoot,
483+
env,
474484
idleTimeout,
475485
machineClass,
476486
provider,
@@ -480,6 +490,7 @@ export async function runMantisDesktopBrowserSmoke(
480490
const inspected = await inspectCrabbox({
481491
crabboxBin,
482492
cwd: repoRoot,
493+
env,
483494
leaseId,
484495
provider,
485496
runner,
@@ -500,11 +511,13 @@ export async function runMantisDesktopBrowserSmoke(
500511
renderRemoteScript({ browserUrl, htmlBase64, remoteOutputDir }),
501512
],
502513
cwd: repoRoot,
514+
env,
503515
runner,
504516
stdio: "inherit",
505517
});
506518
await copyRemoteArtifacts({
507519
cwd: repoRoot,
520+
env,
508521
inspect: inspected,
509522
outputDir,
510523
remoteOutputDir,
@@ -582,7 +595,7 @@ export async function runMantisDesktopBrowserSmoke(
582595
await fs.writeFile(reportPath, renderReport(summary), "utf8");
583596
}
584597
if (summary?.status === "pass" && createdLease && leaseId && !keepLease) {
585-
await stopCrabbox({ crabboxBin, cwd: repoRoot, leaseId, provider, runner });
598+
await stopCrabbox({ crabboxBin, cwd: repoRoot, env, leaseId, provider, runner });
586599
}
587600
}
588601
}

0 commit comments

Comments
 (0)