Skip to content

Commit def2ead

Browse files
committed
feat: add multipass runner to qa suite
1 parent 8cf02e7 commit def2ead

5 files changed

Lines changed: 854 additions & 0 deletions

File tree

‎extensions/qa-lab/src/cli.runtime.test.ts‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const {
55
runQaManualLane,
66
runQaSuite,
77
runQaCharacterEval,
8+
runQaMultipass,
89
startQaLabServer,
910
writeQaDockerHarnessFiles,
1011
buildQaDockerHarnessImage,
@@ -13,6 +14,7 @@ const {
1314
runQaManualLane: vi.fn(),
1415
runQaSuite: vi.fn(),
1516
runQaCharacterEval: vi.fn(),
17+
runQaMultipass: vi.fn(),
1618
startQaLabServer: vi.fn(),
1719
writeQaDockerHarnessFiles: vi.fn(),
1820
buildQaDockerHarnessImage: vi.fn(),
@@ -31,6 +33,10 @@ vi.mock("./character-eval.js", () => ({
3133
runQaCharacterEval,
3234
}));
3335

36+
vi.mock("./multipass.runtime.js", () => ({
37+
runQaMultipass,
38+
}));
39+
3440
vi.mock("./lab-server.js", () => ({
3541
startQaLabServer,
3642
}));
@@ -62,6 +68,7 @@ describe("qa cli runtime", () => {
6268
runQaSuite.mockReset();
6369
runQaCharacterEval.mockReset();
6470
runQaManualLane.mockReset();
71+
runQaMultipass.mockReset();
6572
startQaLabServer.mockReset();
6673
writeQaDockerHarnessFiles.mockReset();
6774
buildQaDockerHarnessImage.mockReset();
@@ -81,6 +88,16 @@ describe("qa cli runtime", () => {
8188
reply: "done",
8289
watchUrl: "http://127.0.0.1:43124",
8390
});
91+
runQaMultipass.mockResolvedValue({
92+
outputDir: "/tmp/multipass",
93+
reportPath: "/tmp/multipass/qa-suite-report.md",
94+
summaryPath: "/tmp/multipass/qa-suite-summary.json",
95+
hostLogPath: "/tmp/multipass/multipass-host.log",
96+
bootstrapLogPath: "/tmp/multipass/multipass-guest-bootstrap.log",
97+
guestScriptPath: "/tmp/multipass/multipass-guest-run.sh",
98+
vmName: "openclaw-qa-test",
99+
scenarioIds: ["channel-chat-baseline"],
100+
});
84101
startQaLabServer.mockResolvedValue({
85102
baseUrl: "http://127.0.0.1:58000",
86103
runSelfCheck: vi.fn().mockResolvedValue({
@@ -267,6 +284,68 @@ describe("qa cli runtime", () => {
267284
});
268285
});
269286

287+
it("routes suite runs through multipass when the runner is selected", async () => {
288+
await runQaSuiteCommand({
289+
repoRoot: "/tmp/openclaw-repo",
290+
outputDir: ".artifacts/qa-multipass",
291+
runner: "multipass",
292+
providerMode: "mock-openai",
293+
scenarioIds: ["channel-chat-baseline"],
294+
image: "lts",
295+
cpus: 2,
296+
memory: "4G",
297+
disk: "24G",
298+
});
299+
300+
expect(runQaMultipass).toHaveBeenCalledWith({
301+
repoRoot: path.resolve("/tmp/openclaw-repo"),
302+
outputDir: path.resolve("/tmp/openclaw-repo", ".artifacts/qa-multipass"),
303+
providerMode: "mock-openai",
304+
primaryModel: undefined,
305+
alternateModel: undefined,
306+
fastMode: undefined,
307+
scenarioIds: ["channel-chat-baseline"],
308+
image: "lts",
309+
cpus: 2,
310+
memory: "4G",
311+
disk: "24G",
312+
});
313+
expect(runQaSuite).not.toHaveBeenCalled();
314+
});
315+
316+
it("passes live suite selection through to the multipass runner", async () => {
317+
await runQaSuiteCommand({
318+
repoRoot: "/tmp/openclaw-repo",
319+
runner: "multipass",
320+
providerMode: "live-frontier",
321+
primaryModel: "openai/gpt-5.4",
322+
alternateModel: "openai/gpt-5.4",
323+
fastMode: true,
324+
scenarioIds: ["channel-chat-baseline"],
325+
});
326+
327+
expect(runQaMultipass).toHaveBeenCalledWith(
328+
expect.objectContaining({
329+
repoRoot: path.resolve("/tmp/openclaw-repo"),
330+
providerMode: "live-frontier",
331+
primaryModel: "openai/gpt-5.4",
332+
alternateModel: "openai/gpt-5.4",
333+
fastMode: true,
334+
scenarioIds: ["channel-chat-baseline"],
335+
}),
336+
);
337+
});
338+
339+
it("rejects multipass-only suite flags on the host runner", async () => {
340+
await expect(
341+
runQaSuiteCommand({
342+
repoRoot: "/tmp/openclaw-repo",
343+
runner: "host",
344+
image: "lts",
345+
}),
346+
).rejects.toThrow("--image, --cpus, --memory, and --disk require --runner multipass.");
347+
});
348+
270349
it("defaults manual mock runs onto the mock-openai model lane", async () => {
271350
await runQaManualLaneCommand({
272351
repoRoot: "/tmp/openclaw-repo",

‎extensions/qa-lab/src/cli.runtime.ts‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { runQaDockerUp } from "./docker-up.runtime.js";
55
import { startQaLabServer } from "./lab-server.js";
66
import { runQaManualLane } from "./manual-lane.runtime.js";
77
import { startQaMockOpenAiServer } from "./mock-openai-server.js";
8+
import { runQaMultipass } from "./multipass.runtime.js";
89
import { normalizeQaThinkingLevel, type QaThinkingLevel } from "./qa-gateway-config.js";
910
import {
1011
defaultQaModelForMode,
@@ -193,14 +194,53 @@ export async function runQaLabSelfCheckCommand(opts: { repoRoot?: string; output
193194
export async function runQaSuiteCommand(opts: {
194195
repoRoot?: string;
195196
outputDir?: string;
197+
runner?: string;
196198
providerMode?: QaProviderModeInput;
197199
primaryModel?: string;
198200
alternateModel?: string;
199201
fastMode?: boolean;
200202
scenarioIds?: string[];
203+
image?: string;
204+
cpus?: number;
205+
memory?: string;
206+
disk?: string;
201207
}) {
202208
const repoRoot = path.resolve(opts.repoRoot ?? process.cwd());
209+
const runner = (opts.runner ?? "host").trim().toLowerCase();
210+
if (runner !== "host" && runner !== "multipass") {
211+
throw new Error(`--runner must be one of host or multipass, got "${opts.runner}".`);
212+
}
203213
const providerMode = normalizeQaProviderMode(opts.providerMode);
214+
if (
215+
runner === "host" &&
216+
(opts.image !== undefined ||
217+
opts.cpus !== undefined ||
218+
opts.memory !== undefined ||
219+
opts.disk !== undefined)
220+
) {
221+
throw new Error("--image, --cpus, --memory, and --disk require --runner multipass.");
222+
}
223+
if (runner === "multipass") {
224+
const result = await runQaMultipass({
225+
repoRoot,
226+
outputDir: opts.outputDir ? path.resolve(repoRoot, opts.outputDir) : undefined,
227+
providerMode,
228+
primaryModel: opts.primaryModel,
229+
alternateModel: opts.alternateModel,
230+
fastMode: opts.fastMode,
231+
scenarioIds: opts.scenarioIds,
232+
image: opts.image,
233+
cpus: parseQaPositiveIntegerOption("--cpus", opts.cpus),
234+
memory: opts.memory,
235+
disk: opts.disk,
236+
});
237+
process.stdout.write(`QA Multipass dir: ${result.outputDir}\n`);
238+
process.stdout.write(`QA Multipass report: ${result.reportPath}\n`);
239+
process.stdout.write(`QA Multipass summary: ${result.summaryPath}\n`);
240+
process.stdout.write(`QA Multipass host log: ${result.hostLogPath}\n`);
241+
process.stdout.write(`QA Multipass bootstrap log: ${result.bootstrapLogPath}\n`);
242+
return;
243+
}
204244
const result = await runQaSuite({
205245
repoRoot,
206246
outputDir: opts.outputDir ? path.resolve(repoRoot, opts.outputDir) : undefined,

‎extensions/qa-lab/src/cli.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ async function runQaSuite(opts: {
2323
alternateModel?: string;
2424
fastMode?: boolean;
2525
scenarioIds?: string[];
26+
runner?: string;
27+
image?: string;
28+
cpus?: number;
29+
memory?: string;
30+
disk?: string;
2631
}) {
2732
const runtime = await loadQaLabCliRuntime();
2833
await runtime.runQaSuiteCommand(opts);
@@ -138,6 +143,7 @@ export function registerQaLabCli(program: Command) {
138143
.description("Run repo-backed QA scenarios against the QA gateway lane")
139144
.option("--repo-root <path>", "Repository root to target when running from a neutral cwd")
140145
.option("--output-dir <path>", "Suite artifact directory")
146+
.option("--runner <kind>", "Execution runner: host or multipass", "host")
141147
.option(
142148
"--provider-mode <mode>",
143149
"Provider mode: mock-openai or live-frontier (legacy live-openai still works)",
@@ -147,24 +153,38 @@ export function registerQaLabCli(program: Command) {
147153
.option("--alt-model <ref>", "Alternate provider/model ref")
148154
.option("--scenario <id>", "Run only the named QA scenario (repeatable)", collectString, [])
149155
.option("--fast", "Enable provider fast mode where supported", false)
156+
.option("--image <alias>", "Multipass image alias")
157+
.option("--cpus <count>", "Multipass vCPU count", (value: string) => Number(value))
158+
.option("--memory <size>", "Multipass memory size")
159+
.option("--disk <size>", "Multipass disk size")
150160
.action(
151161
async (opts: {
152162
repoRoot?: string;
153163
outputDir?: string;
164+
runner?: string;
154165
providerMode?: QaProviderModeInput;
155166
model?: string;
156167
altModel?: string;
157168
scenario?: string[];
158169
fast?: boolean;
170+
image?: string;
171+
cpus?: number;
172+
memory?: string;
173+
disk?: string;
159174
}) => {
160175
await runQaSuite({
161176
repoRoot: opts.repoRoot,
162177
outputDir: opts.outputDir,
178+
runner: opts.runner,
163179
providerMode: opts.providerMode,
164180
primaryModel: opts.model,
165181
alternateModel: opts.altModel,
166182
fastMode: opts.fast,
167183
scenarioIds: opts.scenario,
184+
image: opts.image,
185+
cpus: opts.cpus,
186+
memory: opts.memory,
187+
disk: opts.disk,
168188
});
169189
},
170190
);
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import path from "node:path";
2+
import { afterEach, describe, expect, it, vi } from "vitest";
3+
import { createQaMultipassPlan, renderQaMultipassGuestScript } from "./multipass.runtime.js";
4+
5+
describe("qa multipass runtime", () => {
6+
afterEach(() => {
7+
vi.unstubAllEnvs();
8+
});
9+
10+
it("reuses suite scenario semantics and resolves mounted artifact paths", () => {
11+
const repoRoot = process.cwd();
12+
const outputDir = path.join(repoRoot, ".artifacts", "qa-e2e", "multipass-test");
13+
const plan = createQaMultipassPlan({
14+
repoRoot,
15+
outputDir,
16+
});
17+
18+
expect(plan.outputDir).toBe(outputDir);
19+
expect(plan.scenarioIds).toEqual([]);
20+
expect(plan.qaCommand).not.toContain("--scenario");
21+
expect(plan.guestOutputDir).toBe("/workspace/openclaw-host/.artifacts/qa-e2e/multipass-test");
22+
expect(plan.reportPath).toBe(path.join(outputDir, "qa-suite-report.md"));
23+
expect(plan.summaryPath).toBe(path.join(outputDir, "qa-suite-summary.json"));
24+
});
25+
26+
it("renders a guest script that runs the mock qa suite with explicit scenarios", () => {
27+
const plan = createQaMultipassPlan({
28+
repoRoot: process.cwd(),
29+
outputDir: path.join(process.cwd(), ".artifacts", "qa-e2e", "multipass-test"),
30+
scenarioIds: ["channel-chat-baseline", "thread-follow-up"],
31+
});
32+
33+
const script = renderQaMultipassGuestScript(plan);
34+
35+
expect(script).toContain("pnpm install --frozen-lockfile");
36+
expect(script).toContain("pnpm build");
37+
expect(script).toContain("'pnpm' 'openclaw' 'qa' 'suite' '--provider-mode' 'mock-openai'");
38+
expect(script).toContain("'--scenario' 'channel-chat-baseline'");
39+
expect(script).toContain("'--scenario' 'thread-follow-up'");
40+
expect(script).toContain("/workspace/openclaw-host/.artifacts/qa-e2e/multipass-test");
41+
});
42+
43+
it("carries live suite flags and forwarded auth env into the guest command", () => {
44+
vi.stubEnv("OPENAI_API_KEY", "test-openai-key");
45+
const plan = createQaMultipassPlan({
46+
repoRoot: process.cwd(),
47+
outputDir: path.join(process.cwd(), ".artifacts", "qa-e2e", "multipass-live-test"),
48+
providerMode: "live-frontier",
49+
primaryModel: "openai/gpt-5.4",
50+
alternateModel: "openai/gpt-5.4",
51+
fastMode: true,
52+
scenarioIds: ["channel-chat-baseline"],
53+
});
54+
55+
const script = renderQaMultipassGuestScript(plan);
56+
57+
expect(plan.qaCommand).toEqual(
58+
expect.arrayContaining([
59+
"--provider-mode",
60+
"live-frontier",
61+
"--model",
62+
"openai/gpt-5.4",
63+
"--alt-model",
64+
"openai/gpt-5.4",
65+
"--fast",
66+
]),
67+
);
68+
expect(plan.forwardedEnv.OPENAI_API_KEY).toBe("test-openai-key");
69+
expect(script).toContain("OPENAI_API_KEY='test-openai-key'");
70+
expect(script).toContain("'pnpm' 'openclaw' 'qa' 'suite' '--provider-mode' 'live-frontier'");
71+
});
72+
});

0 commit comments

Comments
 (0)