collector/redfish: fix server model fallback and GPU/NVMe regressions
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"git.mchus.pro/mchus/logpile/internal/models"
|
||||
)
|
||||
|
||||
func TestRedfishConnectorCollect(t *testing.T) {
|
||||
@@ -691,3 +693,78 @@ func TestReplayCollectGPUs_SkipsModelOnlyDuplicateFromGraphicsControllers(t *tes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplyBoardInfoFallbackFromDocs_SkipsComponentProductNames(t *testing.T) {
|
||||
board := models.BoardInfo{
|
||||
SerialNumber: "23E100051",
|
||||
}
|
||||
docs := []map[string]interface{}{
|
||||
{
|
||||
"Model": "DDR5 DIMM",
|
||||
"Manufacturer": "DELTA",
|
||||
"SerialNumber": "802C1A2507D284B001",
|
||||
},
|
||||
{
|
||||
"ProductName": "NF5688M7",
|
||||
"Manufacturer": "Inspur",
|
||||
"PartNumber": "YZMB-00001",
|
||||
},
|
||||
}
|
||||
|
||||
applyBoardInfoFallbackFromDocs(&board, docs)
|
||||
if board.ProductName != "NF5688M7" {
|
||||
t.Fatalf("expected server model from fallback docs, got %q", board.ProductName)
|
||||
}
|
||||
if board.Manufacturer != "Inspur" {
|
||||
t.Fatalf("expected manufacturer from server fallback doc, got %q", board.Manufacturer)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDedupeStorage_IgnoresPlaceholderSerial(t *testing.T) {
|
||||
in := []models.Storage{
|
||||
{Slot: "OB01", Model: "N/A", SerialNumber: "N/A"},
|
||||
{Slot: "OB02", Model: "N/A", SerialNumber: "N/A"},
|
||||
{Slot: "OB03", Model: "N/A", SerialNumber: "N/A"},
|
||||
{Slot: "OB04", Model: "N/A", SerialNumber: "N/A"},
|
||||
}
|
||||
|
||||
out := dedupeStorage(in)
|
||||
if len(out) != 4 {
|
||||
t.Fatalf("expected all placeholder-serial NVMe drives to be kept by slot key, got %d", len(out))
|
||||
}
|
||||
}
|
||||
|
||||
func TestReplayCollectGPUs_DropsModelOnlyPlaceholderWhenConcreteDiscoveredLater(t *testing.T) {
|
||||
r := redfishSnapshotReader{tree: map[string]interface{}{
|
||||
"/redfish/v1/Systems/1/GraphicsControllers": map[string]interface{}{
|
||||
"Members": []interface{}{
|
||||
map[string]interface{}{"@odata.id": "/redfish/v1/Systems/1/GraphicsControllers/GPU0"},
|
||||
},
|
||||
},
|
||||
"/redfish/v1/Systems/1/GraphicsControllers/GPU0": map[string]interface{}{
|
||||
"Id": "GPU0",
|
||||
"Name": "H200-SXM5-141G",
|
||||
"Model": "H200-SXM5-141G",
|
||||
},
|
||||
"/redfish/v1/Chassis/1/PCIeDevices": map[string]interface{}{
|
||||
"Members": []interface{}{
|
||||
map[string]interface{}{"@odata.id": "/redfish/v1/Chassis/1/PCIeDevices/4"},
|
||||
},
|
||||
},
|
||||
"/redfish/v1/Chassis/1/PCIeDevices/4": map[string]interface{}{
|
||||
"Id": "4",
|
||||
"Name": "PCIeCard4",
|
||||
"Model": "H200-SXM5-141G",
|
||||
"Manufacturer": "NVIDIA",
|
||||
"BDF": "0000:0f:00.0",
|
||||
},
|
||||
}}
|
||||
|
||||
got := r.collectGPUs([]string{"/redfish/v1/Systems/1"}, []string{"/redfish/v1/Chassis/1"})
|
||||
if len(got) != 1 {
|
||||
t.Fatalf("expected generic graphics placeholder to be dropped, got %d GPUs", len(got))
|
||||
}
|
||||
if got[0].Slot != "PCIeCard4" {
|
||||
t.Fatalf("expected concrete PCIe GPU to remain, got slot=%q", got[0].Slot)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user