package fleetmetrics import ( "strings" "testing" "time" "gitea.mynodes.xyz/ilker/llmgw/internal/agent/discovery" "gitea.mynodes.xyz/ilker/llmgw/internal/control/inventory" ) func TestAMIGInstanceHasItsOwnMemoryItsCardsHeatAndNoUtilisation(t *testing.T) { // Card 0 in MIG mode: the sensor sample is the card's, 60 GB used across // both instances and a utilisation the driver does not give per instance. inst := discovery.GPU{Index: 1001, Name: "NVIDIA A100-SXM4-80GB MIG 3g.40gb", MemoryTotalMB: 40192, MemoryUsedMB: 21000, MIG: &discovery.MIGDevice{ParentIndex: 0, ParentMemoryTotalMB: 81920, Device: 1, Profile: "3g.40gb"}} n := inventory.Node{ID: "g1", State: inventory.Ready, GPUs: []discovery.GPU{inst}, Load: &inventory.Load{At: time.Now(), GPUs: []inventory.GPUSensor{{Index: 0, TempC: 61, PowerW: 250, UtilPercent: 0, MemoryUsedMB: 60000, MemoryTotalMB: 81920}}}} out := gather(t, fakeSource{nodes: []inventory.Node{n}}) labels := "class=a100-80g-mig-3g.40gb gpu=1001 node=g1" for _, want := range []string{ "llmgw_gpu_memory_used_bytes " + labels + " -> 22020096000\n", "llmgw_gpu_memory_total_bytes " + labels + " -> 42144366592\n", "llmgw_gpu_temperature_celsius " + labels + " -> 61\n", "llmgw_gpu_power_watts " + labels + " -> 250\n", } { if !strings.Contains(out, want) { t.Errorf("missing %s in:\n%s", want, out) } } // Not the card's zero, not anything: absent. if strings.Contains(out, "llmgw_gpu_utilization_percent "+labels) { t.Errorf("a utilisation was published for a MIG instance:\n%s", out) } }