Files
SnapOtter/tests/unit/api/gpu-boot-line.test.ts
T
SnapOtterandGitHub 890b38a71a fix(api): stop claiming no GPU exists before the first AI bundle install (#682)
A fresh GPU deployment has working passthrough but no torch/ONNX runtime until a bundle installs, so the dispatcher reports gpu=false and the boot banner said no GPU was detected. Add the hardware-present state, driven by the same /dev/nvidia0 check the instance census uses. Fixes #673.
2026-07-30 09:49:45 +08:00

32 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { gpuBootLine } from "../../../apps/api/src/lib/gpu-boot-line.js";
describe("gpuBootLine", () => {
it("announces CUDA when the dispatcher can use the GPU", () => {
expect(gpuBootLine({ ready: true, gpu: true }, true)).toBe(
"[INFO] GPU detected -- AI tools will use CUDA acceleration",
);
});
it("explains the pending-bundle state instead of claiming no GPU exists", () => {
// Fresh GPU deployment: passthrough works, but no torch/ONNX runtime is
// installed until the first AI bundle, so the dispatcher reports gpu=false.
const line = gpuBootLine({ ready: true, gpu: false }, true);
expect(line).toContain("GPU hardware detected");
expect(line).toContain("AI bundle");
expect(line).not.toContain("No GPU detected");
});
it("keeps the plain no-GPU warning for hosts without a GPU", () => {
expect(gpuBootLine({ ready: true, gpu: false }, false)).toBe(
"[WARN] No GPU detected -- AI tools will use CPU (slower)",
);
});
it("keeps the sidecar warning when the dispatcher did not start", () => {
expect(gpuBootLine({ ready: false, gpu: false }, true)).toBe(
"[WARN] AI sidecar did not start -- AI tools will use per-request Python (slower)",
);
});
});