Files
llmgw/internal/agent/discovery/host_driver_test.go
T
Ilker ManapandClaude Fable 5.1 c2fedeb326
CI / test (push) Failing after 9m12s
An NVIDIA card with no driver is reported, not onboarded as a CPU node
The agent found GPUs through nvidia-smi alone, so a machine whose driver
was never installed looked exactly like one with no card and joined
quietly as a CPU node. Only init looked at the PCI bus.

The host discovery now reads the bus too (vendor 0x10de, class 0x03) and
carries it to the control plane. The doctor fails the pre-install checks
on a card without a driver, with the install and the reboot named, and
tells a driver that is installed but not loaded (Secure Boot, nouveau)
apart from a missing one. A node already in shows the warning in ctl
nodes and the console. init uses the same check.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-19 12:29:02 +01:00

58 lines
2.0 KiB
Go

package discovery
import (
"os"
"path/filepath"
"testing"
)
func TestNVIDIADriverFrom(t *testing.T) {
for _, tc := range []struct{ text, want string }{
{"NVRM version: NVIDIA UNIX x86_64 Kernel Module 570.86.15 Thu Jan 23 21:30:38 UTC 2025\nGCC version: gcc version 12.2.0\n", "570.86.15"},
{"NVRM version: NVIDIA UNIX Open Kernel Module for x86_64 580.82.07 Release Build (dvs-builder@U16-I3-B03-4-3) Wed Aug 27 00:51:12 UTC 2025\n", "580.82.07"},
{"NVRM version: NVIDIA UNIX Open Kernel Module for aarch64 580.95.05 Release Build\n", "580.95.05"},
{"NVRM version: NVIDIA UNIX x86_64 Kernel Module 535.54 Mon\n", "535.54"},
{"something else\n", ""},
} {
p := filepath.Join(t.TempDir(), "version")
if err := os.WriteFile(p, []byte(tc.text), 0o600); err != nil {
t.Fatal(err)
}
if got := nvidiaDriverFrom(p); got != tc.want {
t.Errorf("%q: got %q, want %q", tc.text, got, tc.want)
}
}
}
func TestACardOnTheBusIsSeenWithoutADriver(t *testing.T) {
root := t.TempDir()
dev := func(name, vendor, class string) {
d := filepath.Join(root, name)
if err := os.MkdirAll(d, 0o750); err != nil {
t.Fatal(err)
}
_ = os.WriteFile(filepath.Join(d, "vendor"), []byte(vendor+"\n"), 0o600)
_ = os.WriteFile(filepath.Join(d, "class"), []byte(class+"\n"), 0o600)
}
dev("0000:00:1f.0", "0x8086", "0x060100") // the chipset
if hasNVIDIADeviceIn(root) {
t.Fatal("a machine with no NVIDIA device said it had one")
}
dev("0000:01:00.1", "0x10de", "0x040300") // the card's HDMI audio alone is not a GPU
if hasNVIDIADeviceIn(root) {
t.Fatal("NVIDIA's audio device was taken for a GPU")
}
dev("0000:01:00.0", "0x10de", "0x030000")
if !hasNVIDIADeviceIn(root) {
t.Fatal("a VGA controller of NVIDIA's was not seen")
}
h := Host{NVIDIADevice: true}
if !h.CardWithoutDriver() {
t.Error("a card with no driver version is a card without a driver")
}
h.NVIDIADriver = "580.82.07"
if h.CardWithoutDriver() {
t.Error("a card with a driver was reported as without one")
}
}