feat: add standalone server topology view
This commit is contained in:
+23
-12
@@ -390,7 +390,7 @@ func TestParseDellInfiniBandView(t *testing.T) {
|
||||
}
|
||||
|
||||
// TestParseDellCPUAffinity verifies that CPUAffinity is parsed into NUMANode for
|
||||
// NIC, PCIe, and controller views. "Not Applicable" must result in NUMANode=0.
|
||||
// NIC, PCIe, and controller views. Zero is valid; "Not Applicable" is nil.
|
||||
func TestParseDellCPUAffinity(t *testing.T) {
|
||||
const viewXML = `<CIM><MESSAGE><SIMPLEREQ>
|
||||
<VALUE.NAMEDINSTANCE><INSTANCE CLASSNAME="DCIM_SystemView">
|
||||
@@ -439,27 +439,38 @@ func TestParseDellCPUAffinity(t *testing.T) {
|
||||
}
|
||||
|
||||
// NIC CPUAffinity=1 → NUMANode=1
|
||||
nicBySlot := make(map[string]int)
|
||||
nicBySlot := make(map[string]*int)
|
||||
for _, nic := range result.Hardware.NetworkAdapters {
|
||||
nicBySlot[nic.Slot] = nic.NUMANode
|
||||
}
|
||||
if nicBySlot["NIC.Slot.2-1-1"] != 1 {
|
||||
t.Errorf("NIC.Slot.2-1-1 NUMANode = %d, want 1", nicBySlot["NIC.Slot.2-1-1"])
|
||||
if got := nicBySlot["NIC.Slot.2-1-1"]; got == nil || *got != 1 {
|
||||
t.Errorf("NIC.Slot.2-1-1 NUMANode = %v, want 1", got)
|
||||
}
|
||||
if nicBySlot["InfiniBand.Slot.1-1"] != 2 {
|
||||
t.Errorf("InfiniBand.Slot.1-1 NUMANode = %d, want 2", nicBySlot["InfiniBand.Slot.1-1"])
|
||||
if got := nicBySlot["InfiniBand.Slot.1-1"]; got == nil || *got != 2 {
|
||||
t.Errorf("InfiniBand.Slot.1-1 NUMANode = %v, want 2", got)
|
||||
}
|
||||
|
||||
// PCIe device CPUAffinity=2 → NUMANode=2; controller CPUAffinity="Not Applicable" → NUMANode=0
|
||||
pcieBySlot := make(map[string]int)
|
||||
// PCIe device CPUAffinity=2 → NUMANode=2; controller CPUAffinity="Not Applicable" → nil.
|
||||
pcieBySlot := make(map[string]*int)
|
||||
for _, pcie := range result.Hardware.PCIeDevices {
|
||||
pcieBySlot[pcie.Slot] = pcie.NUMANode
|
||||
}
|
||||
if pcieBySlot["Slot.7-1"] != 2 {
|
||||
t.Errorf("Slot.7-1 NUMANode = %d, want 2", pcieBySlot["Slot.7-1"])
|
||||
if got := pcieBySlot["Slot.7-1"]; got == nil || *got != 2 {
|
||||
t.Errorf("Slot.7-1 NUMANode = %v, want 2", got)
|
||||
}
|
||||
if pcieBySlot["RAID.Slot.1-1"] != 0 {
|
||||
t.Errorf("RAID.Slot.1-1 NUMANode = %d, want 0 (Not Applicable)", pcieBySlot["RAID.Slot.1-1"])
|
||||
if got := pcieBySlot["RAID.Slot.1-1"]; got != nil {
|
||||
t.Errorf("RAID.Slot.1-1 NUMANode = %v, want nil (Not Applicable)", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseOptionalIntLoosePreservesZero(t *testing.T) {
|
||||
if got := parseOptionalIntLoose("0"); got == nil || *got != 0 {
|
||||
t.Fatalf("parseOptionalIntLoose(0) = %v, want pointer to 0", got)
|
||||
}
|
||||
for _, value := range []string{"", "N/A", "Not Applicable"} {
|
||||
if got := parseOptionalIntLoose(value); got != nil {
|
||||
t.Fatalf("parseOptionalIntLoose(%q) = %v, want nil", value, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user