Improve Redfish raw replay recovery and GUI diagnostics
This commit is contained in:
@@ -44,9 +44,9 @@ func TestRedfishConnectorCollect(t *testing.T) {
|
||||
},
|
||||
})
|
||||
register("/redfish/v1/Systems/1/Memory/DIMM1", map[string]interface{}{
|
||||
"Name": "DIMM A1",
|
||||
"CapacityMiB": 32768,
|
||||
"MemoryDeviceType": "DDR5",
|
||||
"Name": "DIMM A1",
|
||||
"CapacityMiB": 32768,
|
||||
"MemoryDeviceType": "DDR5",
|
||||
"OperatingSpeedMhz": 4800,
|
||||
"Status": map[string]interface{}{
|
||||
"Health": "OK",
|
||||
@@ -91,14 +91,14 @@ func TestRedfishConnectorCollect(t *testing.T) {
|
||||
},
|
||||
})
|
||||
register("/redfish/v1/Systems/1/PCIeFunctions/GPU1F0", map[string]interface{}{
|
||||
"FunctionId": "0000:65:00.0",
|
||||
"VendorId": "0x10DE",
|
||||
"DeviceId": "0x2331",
|
||||
"ClassCode": "0x030200",
|
||||
"CurrentLinkWidth": 16,
|
||||
"CurrentLinkSpeed": "16.0 GT/s",
|
||||
"MaxLinkWidth": 16,
|
||||
"MaxLinkSpeed": "16.0 GT/s",
|
||||
"FunctionId": "0000:65:00.0",
|
||||
"VendorId": "0x10DE",
|
||||
"DeviceId": "0x2331",
|
||||
"ClassCode": "0x030200",
|
||||
"CurrentLinkWidth": 16,
|
||||
"CurrentLinkSpeed": "16.0 GT/s",
|
||||
"MaxLinkWidth": 16,
|
||||
"MaxLinkSpeed": "16.0 GT/s",
|
||||
})
|
||||
register("/redfish/v1/Chassis/1/NetworkAdapters", map[string]interface{}{
|
||||
"Members": []map[string]string{
|
||||
@@ -239,6 +239,68 @@ func TestParsePCIeDeviceSlot_EmptyMapFallsBackToID(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestReplayRedfishFromRawPayloads_FallbackCollectionMembersByPrefix(t *testing.T) {
|
||||
raw := map[string]any{
|
||||
"redfish_tree": map[string]interface{}{
|
||||
"/redfish/v1": map[string]interface{}{
|
||||
"Systems": map[string]interface{}{"@odata.id": "/redfish/v1/Systems"},
|
||||
"Chassis": map[string]interface{}{"@odata.id": "/redfish/v1/Chassis"},
|
||||
"Managers": map[string]interface{}{"@odata.id": "/redfish/v1/Managers"},
|
||||
},
|
||||
"/redfish/v1/Systems": map[string]interface{}{
|
||||
"Members": []interface{}{
|
||||
map[string]interface{}{"@odata.id": "/redfish/v1/Systems/1"},
|
||||
},
|
||||
},
|
||||
"/redfish/v1/Systems/1": map[string]interface{}{
|
||||
"Manufacturer": "Supermicro",
|
||||
"Model": "SYS-TEST",
|
||||
"SerialNumber": "SYS123",
|
||||
},
|
||||
// Intentionally missing /redfish/v1/Systems/1/Processors collection.
|
||||
"/redfish/v1/Systems/1/Processors/CPU1": map[string]interface{}{
|
||||
"Id": "CPU1",
|
||||
"Model": "Xeon Gold",
|
||||
"TotalCores": 32,
|
||||
"TotalThreads": 64,
|
||||
},
|
||||
"/redfish/v1/Chassis": map[string]interface{}{
|
||||
"Members": []interface{}{
|
||||
map[string]interface{}{"@odata.id": "/redfish/v1/Chassis/1"},
|
||||
},
|
||||
},
|
||||
"/redfish/v1/Chassis/1": map[string]interface{}{
|
||||
"Id": "1",
|
||||
},
|
||||
"/redfish/v1/Managers": map[string]interface{}{
|
||||
"Members": []interface{}{
|
||||
map[string]interface{}{"@odata.id": "/redfish/v1/Managers/1"},
|
||||
},
|
||||
},
|
||||
"/redfish/v1/Managers/1": map[string]interface{}{
|
||||
"Id": "1",
|
||||
},
|
||||
},
|
||||
"redfish_fetch_errors": []map[string]interface{}{
|
||||
{"path": "/redfish/v1/Systems/1/Processors", "error": "status 500"},
|
||||
},
|
||||
}
|
||||
|
||||
got, err := ReplayRedfishFromRawPayloads(raw, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("replay failed: %v", err)
|
||||
}
|
||||
if got.Hardware == nil {
|
||||
t.Fatalf("expected hardware")
|
||||
}
|
||||
if len(got.Hardware.CPUs) != 1 {
|
||||
t.Fatalf("expected one CPU via prefix fallback, got %d", len(got.Hardware.CPUs))
|
||||
}
|
||||
if _, ok := got.RawPayloads["redfish_fetch_errors"]; !ok {
|
||||
t.Fatalf("expected raw payloads to preserve redfish_fetch_errors")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnrichNICFromPCIeFunctions(t *testing.T) {
|
||||
nic := parseNIC(map[string]interface{}{
|
||||
"Id": "1",
|
||||
@@ -333,7 +395,7 @@ func TestReplayCollectStorage_ProbesSupermicroNVMeDiskBayWhenCollectionEmpty(t *
|
||||
},
|
||||
"/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives": map[string]interface{}{
|
||||
"Members@odata.count": 0,
|
||||
"Members": []interface{}{},
|
||||
"Members": []interface{}{},
|
||||
},
|
||||
"/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.0": map[string]interface{}{
|
||||
"Id": "Disk.Bay.0",
|
||||
|
||||
Reference in New Issue
Block a user