Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/e2e/live/gpu-e2e-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { type SandboxClient, validateSandboxName } from "../fixtures/clients/san
import { expect } from "../fixtures/e2e-test.ts";
import { CLI_ENTRYPOINT, REPO_ROOT } from "../fixtures/paths.ts";
import type { ShellProbeResult } from "../fixtures/shell-probe.ts";
import { stripAnsi } from "./json-envelope.ts";

export { REPO_ROOT };

Expand Down Expand Up @@ -117,6 +118,14 @@ export function chatContent(raw: string): string {
);
}

export function hasExactReadyPhase(output: string): boolean {
const phaseLines = stripAnsi(output)
.split(/\r?\n/)
.map((line) => line.trim())
.filter((line) => line.startsWith("Phase:"));
return phaseLines.length === 1 && phaseLines[0] === "Phase: Ready";
}

function asRecord(value: unknown): Record<string, unknown> | undefined {
return value && typeof value === "object" && !Array.isArray(value)
? (value as Record<string, unknown>)
Expand Down
61 changes: 60 additions & 1 deletion test/e2e/live/gpu-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
detectOllamaModel,
ensureOllama,
env,
hasExactReadyPhase,
ollamaProxyTokenFile,
openClawModelConfigProjectionScript,
PROXY_PORT,
Expand Down Expand Up @@ -184,7 +185,54 @@ test("GPU Ollama onboard enables CUDA, auth proxy, and sandbox inference", {
expect(resultText(status)).toMatch(/CUDA verified|CUDA unverified|last CUDA proof failed/i);
expect(resultText(status)).not.toMatch(/last CUDA proof failed|CUDA unverified/i);

assertGpuInstallProofs(resultText(install));
const installLog = resultText(install);
assertGpuInstallProofs(installLog);
expect(installLog).toContain(
"Direct sandbox GPU enabled; allowing OpenShell GPU policy enrichment.",
);
expect(installLog).not.toContain(
"Recreating OpenShell Docker sandbox container with NVIDIA GPU access",
);
expect(installLog).not.toContain("Docker GPU mode selected");

const sandboxContainers = await host.command(
"docker",
[
"ps",
"-a",
"--filter",
`label=openshell.ai/sandbox-name=${SANDBOX_NAME}`,
"--format",
"{{json .}}",
],
{
artifactName: "gpu-native-route-sandbox-containers",
env: buildAvailabilityProbeEnv(),
timeoutMs: 30_000,
},
);
expect(sandboxContainers.exitCode, resultText(sandboxContainers)).toBe(0);
const sandboxContainerInventory = sandboxContainers.stdout
.split(/\r?\n/)
.map((line) => line.trim())
.filter(Boolean)
.map(
(line) =>
JSON.parse(line) as {
Names?: string;
State?: string;
Status?: string;
},
);
expect(
sandboxContainerInventory,
`native GPU route must retain exactly one sandbox container; got ${sandboxContainers.stdout}`,
).toHaveLength(1);
const retainedSandboxContainer = sandboxContainerInventory[0];
expect(retainedSandboxContainer.Names).not.toContain("-nemoclaw-gpu-backup-");
expect(retainedSandboxContainer.State).toBe("running");
expect(retainedSandboxContainer.Status).toMatch(/\(healthy\)/i);

Comment thread
coderabbitai[bot] marked this conversation as resolved.
const route = await sandbox.openshell(["inference", "get"], {
artifactName: "openshell-inference-route",
env: env(),
Expand Down Expand Up @@ -255,6 +303,17 @@ test("GPU Ollama onboard enables CUDA, auth proxy, and sandbox inference", {
expect(chat.exitCode, resultText(chat)).toBe(0);
expect(chatContent(chat.stdout)).toMatch(/pong/i);

const readySandbox = await sandbox.openshell(["sandbox", "get", SANDBOX_NAME], {
artifactName: "openshell-sandbox-ready-after-inference",
env: buildAvailabilityProbeEnv(),
timeoutMs: 30_000,
});
expect(readySandbox.exitCode, resultText(readySandbox)).toBe(0);
expect(
hasExactReadyPhase(readySandbox.stdout),
`OpenShell sandbox must be exactly Ready after routed inference; got ${resultText(readySandbox)}`,
).toBe(true);

const restart = await host.command(
"bash",
[
Expand Down
18 changes: 18 additions & 0 deletions test/e2e/support/gpu-e2e-helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { describe, expect, it } from "vitest";
import {
assertAgentExecutionSucceeded,
env,
hasExactReadyPhase,
openClawModelConfigProjectionScript,
} from "../live/gpu-e2e-helpers.ts";

Expand Down Expand Up @@ -139,6 +140,23 @@ describe("GPU E2E helpers", () => {
);
});

it("accepts an ANSI-colored exact Ready sandbox phase", () => {
expect(hasExactReadyPhase("Sandbox:\n \u001b[2mPhase:\u001b[0m Ready\n")).toBe(true);
});

it("rejects an ANSI-colored non-Ready sandbox phase", () => {
expect(hasExactReadyPhase("Sandbox:\n \u001b[2mPhase:\u001b[0m Error\n")).toBe(false);
});

it.each([
["Error before Ready", "Phase: Error\nPhase: Ready\n"],
["Ready before Error", "Phase: Ready\nPhase: Error\n"],
["prefixed Ready", "Current Phase: Ready\n"],
["suffixed Ready", "Phase: Ready (stale)\n"],
])("rejects %s output", (_case, output) => {
expect(hasExactReadyPhase(output)).toBe(false);
});

it("accepts successful execution proof when the model suppresses visible text", () => {
expect(() =>
assertAgentExecutionSucceeded(agentOutput(), "inference", GPU_MODEL),
Expand Down