logpile no longer carries its own archive/vendor parsers or Redfish raw-payload replay/analysis engine. Both now live in git.mchus.pro/reanimator/parser/v13 (already used by the sibling `core` project), reached through parser.NewService().AnalyzeArchivePayload / AnalyzeRedfishRawPayloads. logpile keeps live BMC/Redfish collection, the DB, exporter, server and UI. - Deleted internal/parser/ (interface, registry, archive extraction, all vendor packages), internal/collector/redfish_replay*.go (replay engine, confirmed near-identical to the module's redfish/ package), internal/ingest/ (pure duplicate of the module's Service), internal/models/ (repointed every import to the module's models package instead), and internal/rar5 (only used by the deleted archive extractor). Removed the now-unused third_party/pciids submodule. - internal/collector/redfish.go: Collect() now calls parser.NewService().AnalyzeRedfishRawPayloads(...) at the one place it used to call the local ReplayRedfishFromRawPayloads (an existing "unified tunnel" between live collection and raw import). A deadcode-driven pass then removed ~150 doc-to-model conversion helpers in redfish.go that duplicated the module's redfish/ package and were already unreachable before this change; kept the small generic dedup/scoring helpers the live crawler still calls. - internal/collector/redfishprofile/ stays whole: Collect() depends on it directly for acquisition-time tuning. Its analysis-only methods (ApplyAnalysisProfiles/PostAnalyze) are now dead but left in place rather than splitting the package's single Profile interface. - pciids moved with the module (now a public package there); logpile's live collector and exporter import it from there instead of keeping a local copy. - go.mod: new require on git.mchus.pro/reanimator/parser/v13 v13.0.0 (plain module dependency, not a submodule like reanimator/chart, since this module is independently versioned and shared with core). - bible-local docs rewritten for the new boundary; see ADL-080. See also the companion change in git.mchus.pro/reanimator/parser (tagged v13.0.0): new top-level exports (IsSupportedArchiveFilename/SupportedArchiveExtensions/ ParseInDefaultArchiveLocation/PrivacyScanEnabled) and pciids moved to a public package, both needed to complete this migration. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
958 lines
32 KiB
Go
958 lines
32 KiB
Go
package collector
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"net/url"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.mchus.pro/mchus/logpile/internal/collector/redfishprofile"
|
|
)
|
|
|
|
func testAnalysisPlan(d redfishprofile.AnalysisDirectives) redfishprofile.ResolvedAnalysisPlan {
|
|
return redfishprofile.ResolvedAnalysisPlan{Directives: d}
|
|
}
|
|
|
|
func TestRedfishConnectorCollect(t *testing.T) {
|
|
mux := http.NewServeMux()
|
|
register := func(path string, payload interface{}) {
|
|
mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
_ = json.NewEncoder(w).Encode(payload)
|
|
})
|
|
}
|
|
|
|
register("/redfish/v1", map[string]interface{}{"Name": "ServiceRoot"})
|
|
register("/redfish/v1/Systems/1", map[string]interface{}{
|
|
"Manufacturer": "Supermicro",
|
|
"Model": "SYS-TEST",
|
|
"SerialNumber": "SYS123",
|
|
"BiosVersion": "2.1a",
|
|
})
|
|
register("/redfish/v1/Systems/1/Bios", map[string]interface{}{"Version": "2.1a"})
|
|
register("/redfish/v1/Systems/1/SecureBoot", map[string]interface{}{"SecureBootCurrentBoot": "Enabled"})
|
|
register("/redfish/v1/Systems/1/Processors", map[string]interface{}{
|
|
"Members": []map[string]string{
|
|
{"@odata.id": "/redfish/v1/Systems/1/Processors/CPU1"},
|
|
},
|
|
})
|
|
register("/redfish/v1/Systems/1/Processors/CPU1", map[string]interface{}{
|
|
"Name": "CPU1",
|
|
"Model": "Xeon Gold",
|
|
"TotalCores": 32,
|
|
"TotalThreads": 64,
|
|
"MaxSpeedMHz": 3600,
|
|
})
|
|
register("/redfish/v1/Systems/1/Memory", map[string]interface{}{
|
|
"Members": []map[string]string{
|
|
{"@odata.id": "/redfish/v1/Systems/1/Memory/DIMM1"},
|
|
},
|
|
})
|
|
register("/redfish/v1/Systems/1/Memory/DIMM1", map[string]interface{}{
|
|
"Name": "DIMM A1",
|
|
"CapacityMiB": 32768,
|
|
"MemoryDeviceType": "DDR5",
|
|
"OperatingSpeedMhz": 4800,
|
|
"Status": map[string]interface{}{
|
|
"Health": "OK",
|
|
},
|
|
})
|
|
register("/redfish/v1/Systems/1/Storage", map[string]interface{}{
|
|
"Members": []map[string]string{
|
|
{"@odata.id": "/redfish/v1/Systems/1/Storage/1"},
|
|
},
|
|
})
|
|
register("/redfish/v1/Systems/1/Storage/1", map[string]interface{}{
|
|
"Drives": []map[string]string{
|
|
{"@odata.id": "/redfish/v1/Systems/1/Storage/1/Drives/1"},
|
|
},
|
|
})
|
|
register("/redfish/v1/Systems/1/Storage/1/Drives/1", map[string]interface{}{
|
|
"Name": "Drive1",
|
|
"Model": "NVMe Test",
|
|
"MediaType": "SSD",
|
|
"Protocol": "NVMe",
|
|
"CapacityGB": 960,
|
|
"SerialNumber": "SN123",
|
|
})
|
|
register("/redfish/v1/Systems/1/PCIeDevices", map[string]interface{}{
|
|
"Members": []map[string]string{
|
|
{"@odata.id": "/redfish/v1/Systems/1/PCIeDevices/GPU1"},
|
|
},
|
|
})
|
|
register("/redfish/v1/Systems/1/PCIeDevices/GPU1", map[string]interface{}{
|
|
"Id": "GPU1",
|
|
"Name": "NVIDIA H100",
|
|
"Model": "NVIDIA H100 PCIe",
|
|
"Manufacturer": "NVIDIA",
|
|
"SerialNumber": "GPU-SN-001",
|
|
"PCIeFunctions": map[string]interface{}{
|
|
"@odata.id": "/redfish/v1/Systems/1/PCIeDevices/GPU1/PCIeFunctions",
|
|
},
|
|
})
|
|
register("/redfish/v1/Systems/1/PCIeDevices/GPU1/PCIeFunctions", map[string]interface{}{
|
|
"Members": []map[string]string{
|
|
{"@odata.id": "/redfish/v1/Systems/1/PCIeFunctions/GPU1F0"},
|
|
},
|
|
})
|
|
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",
|
|
})
|
|
register("/redfish/v1/Chassis/1/NetworkAdapters", map[string]interface{}{
|
|
"Members": []map[string]string{
|
|
{"@odata.id": "/redfish/v1/Chassis/1/NetworkAdapters/1"},
|
|
},
|
|
})
|
|
register("/redfish/v1/Chassis/1/Power", map[string]interface{}{
|
|
"PowerSupplies": []map[string]interface{}{
|
|
{
|
|
"MemberId": "PSU1",
|
|
"Name": "PSU Slot 1",
|
|
"Model": "PWS-2K01A-1R",
|
|
"Manufacturer": "Delta",
|
|
"PowerCapacityWatts": 2000,
|
|
"PowerInputWatts": 1600,
|
|
"LastPowerOutputWatts": 1200,
|
|
"LineInputVoltage": 230,
|
|
"Status": map[string]interface{}{
|
|
"Health": "OK",
|
|
"State": "Enabled",
|
|
},
|
|
},
|
|
},
|
|
})
|
|
register("/redfish/v1/Chassis/1/NetworkAdapters/1", map[string]interface{}{
|
|
"Name": "Mellanox",
|
|
"Model": "ConnectX-6",
|
|
"SerialNumber": "NIC123",
|
|
})
|
|
register("/redfish/v1/Managers/1", map[string]interface{}{
|
|
"FirmwareVersion": "1.25",
|
|
})
|
|
register("/redfish/v1/Managers/1/NetworkProtocol", map[string]interface{}{
|
|
"Id": "NetworkProtocol",
|
|
})
|
|
|
|
ts := httptest.NewServer(mux)
|
|
defer ts.Close()
|
|
|
|
c := NewRedfishConnector()
|
|
result, err := c.Collect(context.Background(), Request{
|
|
Host: ts.URL,
|
|
Port: 443,
|
|
Protocol: "redfish",
|
|
Username: "admin",
|
|
AuthType: "password",
|
|
Password: "secret",
|
|
TLSMode: "strict",
|
|
}, nil)
|
|
if err != nil {
|
|
t.Fatalf("collect failed: %v", err)
|
|
}
|
|
|
|
if result.Hardware == nil {
|
|
t.Fatalf("expected hardware config")
|
|
}
|
|
if result.Hardware.BoardInfo.ProductName != "SYS-TEST" {
|
|
t.Fatalf("unexpected board model: %q", result.Hardware.BoardInfo.ProductName)
|
|
}
|
|
if len(result.Hardware.CPUs) != 1 {
|
|
t.Fatalf("expected one CPU, got %d", len(result.Hardware.CPUs))
|
|
}
|
|
if len(result.Hardware.Memory) != 1 {
|
|
t.Fatalf("expected one DIMM, got %d", len(result.Hardware.Memory))
|
|
}
|
|
if len(result.Hardware.Storage) != 1 {
|
|
t.Fatalf("expected one drive, got %d", len(result.Hardware.Storage))
|
|
}
|
|
if len(result.Hardware.NetworkAdapters) != 1 {
|
|
t.Fatalf("expected one nic, got %d", len(result.Hardware.NetworkAdapters))
|
|
}
|
|
if len(result.Hardware.GPUs) != 1 {
|
|
t.Fatalf("expected one gpu, got %d", len(result.Hardware.GPUs))
|
|
}
|
|
if result.Hardware.GPUs[0].BDF != "0000:65:00.0" {
|
|
t.Fatalf("unexpected gpu BDF: %q", result.Hardware.GPUs[0].BDF)
|
|
}
|
|
if len(result.Hardware.PCIeDevices) != 1 {
|
|
t.Fatalf("expected one pcie device, got %d", len(result.Hardware.PCIeDevices))
|
|
}
|
|
if len(result.Hardware.PowerSupply) != 1 {
|
|
t.Fatalf("expected one psu, got %d", len(result.Hardware.PowerSupply))
|
|
}
|
|
if result.Hardware.PowerSupply[0].WattageW != 2000 {
|
|
t.Fatalf("unexpected psu wattage: %d", result.Hardware.PowerSupply[0].WattageW)
|
|
}
|
|
if len(result.Hardware.Firmware) == 0 {
|
|
t.Fatalf("expected firmware entries")
|
|
}
|
|
if result.RawPayloads == nil {
|
|
t.Fatalf("expected raw payloads")
|
|
}
|
|
treeAny, ok := result.RawPayloads["redfish_tree"]
|
|
if !ok {
|
|
t.Fatalf("expected redfish_tree in raw payloads")
|
|
}
|
|
tree, ok := treeAny.(map[string]interface{})
|
|
if !ok || len(tree) == 0 {
|
|
t.Fatalf("expected non-empty redfish_tree, got %#v", treeAny)
|
|
}
|
|
}
|
|
|
|
func TestRedfishConnectorProbe(t *testing.T) {
|
|
mux := http.NewServeMux()
|
|
register := func(path string, payload interface{}) {
|
|
mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
_ = json.NewEncoder(w).Encode(payload)
|
|
})
|
|
}
|
|
|
|
register("/redfish/v1", map[string]interface{}{"Name": "ServiceRoot"})
|
|
register("/redfish/v1/Systems/1", map[string]interface{}{
|
|
"@odata.id": "/redfish/v1/Systems/1",
|
|
"PowerState": "Off",
|
|
"Actions": map[string]interface{}{
|
|
"#ComputerSystem.Reset": map[string]interface{}{
|
|
"target": "/redfish/v1/Systems/1/Actions/ComputerSystem.Reset",
|
|
"ResetType@Redfish.AllowableValues": []interface{}{"On", "ForceOff"},
|
|
},
|
|
},
|
|
})
|
|
ts := httptest.NewTLSServer(mux)
|
|
defer ts.Close()
|
|
|
|
connector := NewRedfishConnector()
|
|
port := 443
|
|
host := ""
|
|
if u, err := url.Parse(ts.URL); err == nil {
|
|
host = u.Hostname()
|
|
if p := u.Port(); p != "" {
|
|
fmt.Sscanf(p, "%d", &port)
|
|
}
|
|
}
|
|
got, err := connector.Probe(context.Background(), Request{
|
|
Host: host,
|
|
Protocol: "redfish",
|
|
Port: port,
|
|
Username: "admin",
|
|
AuthType: "password",
|
|
Password: "secret",
|
|
TLSMode: "insecure",
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("probe failed: %v", err)
|
|
}
|
|
if got == nil || !got.Reachable {
|
|
t.Fatalf("expected reachable probe result, got %+v", got)
|
|
}
|
|
if got.HostPoweredOn {
|
|
t.Fatalf("expected powered off host")
|
|
}
|
|
if got.HostPowerState != "Off" {
|
|
t.Fatalf("expected power state Off, got %q", got.HostPowerState)
|
|
}
|
|
}
|
|
|
|
func TestRedfishConnectorProbe_FallsBackToPowerSummary(t *testing.T) {
|
|
mux := http.NewServeMux()
|
|
register := func(path string, payload interface{}) {
|
|
mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
_ = json.NewEncoder(w).Encode(payload)
|
|
})
|
|
}
|
|
|
|
register("/redfish/v1", map[string]interface{}{"Name": "ServiceRoot"})
|
|
register("/redfish/v1/Systems", map[string]interface{}{
|
|
"Members": []interface{}{
|
|
map[string]interface{}{"@odata.id": "/redfish/v1/Systems/1"},
|
|
},
|
|
})
|
|
register("/redfish/v1/Systems/1", map[string]interface{}{
|
|
"@odata.id": "/redfish/v1/Systems/1",
|
|
"PowerSummary": map[string]interface{}{
|
|
"PowerState": "On",
|
|
},
|
|
"Actions": map[string]interface{}{
|
|
"#ComputerSystem.Reset": map[string]interface{}{
|
|
"target": "/redfish/v1/Systems/1/Actions/ComputerSystem.Reset",
|
|
"ResetType@Redfish.AllowableValues": []interface{}{"On", "ForceOff"},
|
|
},
|
|
},
|
|
})
|
|
ts := httptest.NewTLSServer(mux)
|
|
defer ts.Close()
|
|
|
|
connector := NewRedfishConnector()
|
|
port := 443
|
|
host := ""
|
|
if u, err := url.Parse(ts.URL); err == nil {
|
|
host = u.Hostname()
|
|
if p := u.Port(); p != "" {
|
|
fmt.Sscanf(p, "%d", &port)
|
|
}
|
|
}
|
|
got, err := connector.Probe(context.Background(), Request{
|
|
Host: host,
|
|
Protocol: "redfish",
|
|
Port: port,
|
|
Username: "admin",
|
|
AuthType: "password",
|
|
Password: "secret",
|
|
TLSMode: "insecure",
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("probe failed: %v", err)
|
|
}
|
|
if got == nil || !got.Reachable {
|
|
t.Fatalf("expected reachable probe result, got %+v", got)
|
|
}
|
|
if !got.HostPoweredOn {
|
|
t.Fatalf("expected powered on host from PowerSummary")
|
|
}
|
|
if got.HostPowerState != "On" {
|
|
t.Fatalf("expected power state On, got %q", got.HostPowerState)
|
|
}
|
|
}
|
|
|
|
func TestRedfishCollectionMemberRefs_IncludesOemPublicMembers(t *testing.T) {
|
|
collection := map[string]interface{}{
|
|
"Members": []interface{}{
|
|
map[string]interface{}{"@odata.id": "/redfish/v1/Chassis/1/Drives/OB01"},
|
|
},
|
|
"Oem": map[string]interface{}{
|
|
"Public": map[string]interface{}{
|
|
"Members": []interface{}{
|
|
map[string]interface{}{"@odata.id": "/redfish/v1/Chassis/1/Drives/FP00HDD00"},
|
|
map[string]interface{}{"@odata.id": "/redfish/v1/Chassis/1/Drives/FP00HDD02"},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
got := redfishCollectionMemberRefs(collection)
|
|
if len(got) != 3 {
|
|
t.Fatalf("expected 3 member refs, got %d: %v", len(got), got)
|
|
}
|
|
}
|
|
|
|
func TestRecoverCriticalRedfishDocsPlanB_RetriesMembersFromExistingCollection(t *testing.T) {
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_COOLDOWN", "0s")
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_SLOW_GAP", "0s")
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_PLANB_RETRIES", "1")
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_RETRIES", "1")
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_BACKOFF", "0s")
|
|
|
|
const memberPath = "/redfish/v1/Chassis/1/Drives/FP00HDD00"
|
|
mux := http.NewServeMux()
|
|
mux.HandleFunc(memberPath, func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
_ = json.NewEncoder(w).Encode(map[string]interface{}{
|
|
"Id": "FP00HDD00",
|
|
"Name": "FP00HDD00",
|
|
"Model": "HDD-TEST",
|
|
"MediaType": "HDD",
|
|
"Protocol": "SAS",
|
|
"CapacityBytes": int64(2000398934016),
|
|
"SerialNumber": "HDD-SN-001",
|
|
})
|
|
})
|
|
ts := httptest.NewServer(mux)
|
|
defer ts.Close()
|
|
|
|
rawTree := map[string]interface{}{
|
|
"/redfish/v1/Chassis/1/Drives": map[string]interface{}{
|
|
"Members": []interface{}{
|
|
map[string]interface{}{"@odata.id": "/redfish/v1/Chassis/1/Drives/OB01"},
|
|
},
|
|
"Oem": map[string]interface{}{
|
|
"Public": map[string]interface{}{
|
|
"Members": []interface{}{
|
|
map[string]interface{}{"@odata.id": memberPath},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
fetchErrs := map[string]string{
|
|
memberPath: "Get \"https://example/redfish/v1/Chassis/1/Drives/FP00HDD00\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)",
|
|
}
|
|
|
|
c := NewRedfishConnector()
|
|
recovered := c.recoverCriticalRedfishDocsPlanB(
|
|
context.Background(),
|
|
ts.Client(),
|
|
Request{},
|
|
ts.URL,
|
|
[]string{"/redfish/v1/Chassis/1/Drives"},
|
|
rawTree,
|
|
fetchErrs,
|
|
redfishprofile.AcquisitionTuning{
|
|
RecoveryPolicy: redfishprofile.AcquisitionRecoveryPolicy{
|
|
EnableCriticalCollectionMemberRetry: true,
|
|
EnableCriticalSlowProbe: true,
|
|
},
|
|
},
|
|
nil,
|
|
)
|
|
if recovered == 0 {
|
|
t.Fatalf("expected plan-B to recover at least one document")
|
|
}
|
|
if _, ok := rawTree[memberPath]; !ok {
|
|
t.Fatalf("expected recovered member doc for %s", memberPath)
|
|
}
|
|
if _, ok := fetchErrs[memberPath]; ok {
|
|
t.Fatalf("expected fetch error for %s to be cleared after recovery", memberPath)
|
|
}
|
|
}
|
|
|
|
func TestRecoverCriticalRedfishDocsPlanB_RetriesMembersFromSystemMemoryCollection(t *testing.T) {
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_COOLDOWN", "0s")
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_SLOW_GAP", "0s")
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_PLANB_RETRIES", "1")
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_RETRIES", "1")
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_BACKOFF", "0s")
|
|
|
|
const systemPath = "/redfish/v1/Systems/1"
|
|
const memoryPath = "/redfish/v1/Systems/1/Memory"
|
|
const dimmPath = "/redfish/v1/Systems/1/Memory/CPU1_C1D1"
|
|
|
|
mux := http.NewServeMux()
|
|
mux.HandleFunc(dimmPath, func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "application/json")
|
|
_ = json.NewEncoder(w).Encode(map[string]interface{}{
|
|
"Id": "CPU1_C1D1",
|
|
"Name": "CPU1_C1D1",
|
|
"DeviceLocator": "CPU1_C1D1",
|
|
"CapacityMiB": 65536,
|
|
"MemoryDeviceType": "DDR5",
|
|
"Status": map[string]interface{}{"State": "Enabled", "Health": "OK"},
|
|
"SerialNumber": "DIMM-SN-001",
|
|
"PartNumber": "DIMM-PN-001",
|
|
})
|
|
})
|
|
ts := httptest.NewServer(mux)
|
|
defer ts.Close()
|
|
|
|
rawTree := map[string]interface{}{
|
|
memoryPath: map[string]interface{}{
|
|
"Members": []interface{}{
|
|
map[string]interface{}{"@odata.id": dimmPath},
|
|
},
|
|
},
|
|
}
|
|
fetchErrs := map[string]string{
|
|
dimmPath: `Get "https://example/redfish/v1/Systems/1/Memory/CPU1_C1D1": context deadline exceeded (Client.Timeout exceeded while awaiting headers)`,
|
|
}
|
|
|
|
plan := redfishprofile.BuildAcquisitionPlan(redfishprofile.MatchSignals{})
|
|
match := redfishprofile.MatchProfiles(redfishprofile.MatchSignals{})
|
|
resolved := redfishprofile.ResolveAcquisitionPlan(match, plan, redfishprofile.DiscoveredResources{
|
|
SystemPaths: []string{systemPath},
|
|
}, redfishprofile.MatchSignals{})
|
|
criticalPaths := resolved.CriticalPaths
|
|
hasMemoryPath := false
|
|
for _, p := range criticalPaths {
|
|
if p == memoryPath {
|
|
hasMemoryPath = true
|
|
break
|
|
}
|
|
}
|
|
if !hasMemoryPath {
|
|
t.Fatalf("expected critical endpoints to include %s", memoryPath)
|
|
}
|
|
|
|
c := NewRedfishConnector()
|
|
recovered := c.recoverCriticalRedfishDocsPlanB(
|
|
context.Background(),
|
|
ts.Client(),
|
|
Request{},
|
|
ts.URL,
|
|
criticalPaths,
|
|
rawTree,
|
|
fetchErrs,
|
|
redfishprofile.AcquisitionTuning{
|
|
RecoveryPolicy: redfishprofile.AcquisitionRecoveryPolicy{
|
|
EnableCriticalCollectionMemberRetry: true,
|
|
EnableCriticalSlowProbe: true,
|
|
},
|
|
},
|
|
nil,
|
|
)
|
|
if recovered == 0 {
|
|
t.Fatalf("expected plan-B to recover at least one DIMM document")
|
|
}
|
|
if _, ok := rawTree[dimmPath]; !ok {
|
|
t.Fatalf("expected recovered DIMM doc for %s", dimmPath)
|
|
}
|
|
if _, ok := fetchErrs[dimmPath]; ok {
|
|
t.Fatalf("expected DIMM fetch error for %s to be cleared", dimmPath)
|
|
}
|
|
}
|
|
|
|
func TestRecoverCriticalRedfishDocsPlanB_SkipsMemberRetryWithoutRecoveryPolicy(t *testing.T) {
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_COOLDOWN", "0s")
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_SLOW_GAP", "0s")
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_PLANB_RETRIES", "1")
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_RETRIES", "1")
|
|
t.Setenv("LOGPILE_REDFISH_CRITICAL_BACKOFF", "0s")
|
|
|
|
const memoryPath = "/redfish/v1/Systems/1/Memory"
|
|
const dimmPath = "/redfish/v1/Systems/1/Memory/CPU1_C1D1"
|
|
|
|
rawTree := map[string]interface{}{
|
|
memoryPath: map[string]interface{}{
|
|
"Members": []interface{}{
|
|
map[string]interface{}{"@odata.id": dimmPath},
|
|
},
|
|
},
|
|
}
|
|
fetchErrs := map[string]string{
|
|
dimmPath: `Get "https://example/redfish/v1/Systems/1/Memory/CPU1_C1D1": context deadline exceeded (Client.Timeout exceeded while awaiting headers)`,
|
|
}
|
|
|
|
c := NewRedfishConnector()
|
|
recovered := c.recoverCriticalRedfishDocsPlanB(
|
|
context.Background(),
|
|
http.DefaultClient,
|
|
Request{},
|
|
"https://example",
|
|
[]string{memoryPath},
|
|
rawTree,
|
|
fetchErrs,
|
|
redfishprofile.AcquisitionTuning{},
|
|
nil,
|
|
)
|
|
if recovered != 0 {
|
|
t.Fatalf("expected no recovery without recovery policy, got %d", recovered)
|
|
}
|
|
if _, ok := rawTree[dimmPath]; ok {
|
|
t.Fatalf("did not expect recovered DIMM doc for %s", dimmPath)
|
|
}
|
|
if _, ok := fetchErrs[dimmPath]; !ok {
|
|
t.Fatalf("expected DIMM fetch error for %s to remain", dimmPath)
|
|
}
|
|
}
|
|
|
|
func TestShouldCrawlPath_SkipsJsonSchemas(t *testing.T) {
|
|
if shouldCrawlPath("/redfish/v1/JsonSchemas") {
|
|
t.Fatalf("expected /JsonSchemas to be skipped")
|
|
}
|
|
if shouldCrawlPath("/redfish/v1/JsonSchemas/ComputerSystem.v1_8_0") {
|
|
t.Fatalf("expected JsonSchemas members to be skipped")
|
|
}
|
|
if !shouldCrawlPath("/redfish/v1/Systems/1") {
|
|
t.Fatalf("expected normal hardware path to be crawled")
|
|
}
|
|
}
|
|
|
|
func TestShouldCrawlPath_MemoryAndProcessorMetricsAreAllowed(t *testing.T) {
|
|
if !shouldCrawlPath("/redfish/v1/Systems/1/Memory/CPU0_C0D0") {
|
|
t.Fatalf("expected direct DIMM resource to be crawlable")
|
|
}
|
|
if shouldCrawlPath("/redfish/v1/Systems/1/Memory/CPU0_C0D0/Assembly") {
|
|
t.Fatalf("expected DIMM assembly subresource to be skipped")
|
|
}
|
|
if !shouldCrawlPath("/redfish/v1/Systems/1/Memory/CPU0_C0D0/MemoryMetrics") {
|
|
t.Fatalf("expected DIMM metrics subresource to be crawlable")
|
|
}
|
|
if !shouldCrawlPath("/redfish/v1/Systems/1/Processors/CPU0/ProcessorMetrics") {
|
|
t.Fatalf("expected CPU metrics subresource to be crawlable")
|
|
}
|
|
if shouldCrawlPath("/redfish/v1/Chassis/1/PCIeDevices/0/PCIeFunctions") {
|
|
t.Fatalf("expected broad chassis PCIeFunctions collection to be skipped")
|
|
}
|
|
if !shouldCrawlPath("/redfish/v1/Chassis/1/PCIeDevices/0/PCIeFunctions/1") {
|
|
t.Fatalf("expected direct chassis PCIeFunction member to remain crawlable")
|
|
}
|
|
if !shouldCrawlPath("/redfish/v1/Fabrics/HGX_NVLinkFabric_0/Switches/NVSwitch_0") {
|
|
t.Fatalf("expected NVSwitch fabric resource to be crawlable")
|
|
}
|
|
if !shouldCrawlPath("/redfish/v1/Fabrics/HGX_NVLinkFabric_0/Switches/NVSwitch_0/Ports/NVLink_0/Metrics") {
|
|
t.Fatalf("expected NVLink port metrics to be crawlable")
|
|
}
|
|
}
|
|
|
|
func TestIsRedfishMemoryMemberPath(t *testing.T) {
|
|
cases := []struct {
|
|
path string
|
|
want bool
|
|
}{
|
|
{path: "/redfish/v1/Systems/1/Memory", want: false},
|
|
{path: "/redfish/v1/Systems/1/Memory/CPU0_C0D0", want: true},
|
|
{path: "/redfish/v1/Systems/1/Memory/CPU0_C0D0/Assembly", want: false},
|
|
{path: "/redfish/v1/Systems/1/Memory/CPU0_C0D0/MemoryMetrics", want: false},
|
|
{path: "/redfish/v1/Chassis/1/Memory/CPU0_C0D0", want: false},
|
|
}
|
|
for _, tc := range cases {
|
|
got := isRedfishMemoryMemberPath(tc.path)
|
|
if got != tc.want {
|
|
t.Fatalf("isRedfishMemoryMemberPath(%q) = %v, want %v", tc.path, got, tc.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestRedfishSnapshotBranchKey(t *testing.T) {
|
|
cases := []struct {
|
|
path string
|
|
want string
|
|
}{
|
|
{path: "", want: ""},
|
|
{path: "/redfish/v1", want: ""},
|
|
{path: "/redfish/v1/Systems", want: "/redfish/v1/Systems"},
|
|
{path: "/redfish/v1/Systems/1", want: "/redfish/v1/Systems/1"},
|
|
{path: "/redfish/v1/Systems/1/Memory", want: "/redfish/v1/Systems/1/Memory"},
|
|
{path: "/redfish/v1/Systems/1/Memory/CPU0_C0D0", want: "/redfish/v1/Systems/1/Memory"},
|
|
{path: "/redfish/v1/Systems/1/PCIeDevices/GPU1", want: "/redfish/v1/Systems/1/PCIeDevices"},
|
|
{path: "/redfish/v1/Chassis/1/Sensors/1", want: "/redfish/v1/Chassis/1/Sensors"},
|
|
{path: "/redfish/v1/UpdateService/FirmwareInventory/BIOS", want: "/redfish/v1/UpdateService/FirmwareInventory"},
|
|
}
|
|
for _, tc := range cases {
|
|
got := redfishSnapshotBranchKey(tc.path)
|
|
if got != tc.want {
|
|
t.Fatalf("redfishSnapshotBranchKey(%q) = %q, want %q", tc.path, got, tc.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestShouldPostProbeCollectionPath(t *testing.T) {
|
|
var tuning redfishprofile.AcquisitionTuning
|
|
if shouldPostProbeCollectionPath("/redfish/v1/Chassis/1/Sensors", tuning) {
|
|
t.Fatalf("expected sensors collection to be skipped by default")
|
|
}
|
|
if shouldPostProbeCollectionPath("/redfish/v1/Systems/1/Storage/RAID/Drives", tuning) {
|
|
t.Fatalf("expected drives collection to be skipped without profile policy")
|
|
}
|
|
tuning.PostProbePolicy.EnableNumericCollectionProbe = true
|
|
t.Setenv("LOGPILE_REDFISH_SENSOR_POSTPROBE", "1")
|
|
if !shouldPostProbeCollectionPath("/redfish/v1/Chassis/1/Sensors", tuning) {
|
|
t.Fatalf("expected sensors collection to be post-probed when enabled")
|
|
}
|
|
if !shouldPostProbeCollectionPath("/redfish/v1/Systems/1/Storage/RAID/Drives", tuning) {
|
|
t.Fatalf("expected drives collection to be post-probed")
|
|
}
|
|
if shouldPostProbeCollectionPath("/redfish/v1/Chassis/1/Boards/BOARD1", tuning) {
|
|
t.Fatalf("expected board member resource to be skipped from post-probe")
|
|
}
|
|
if shouldPostProbeCollectionPath("/redfish/v1/Chassis/1/Assembly/Oem/COMMONb/COMMONbAssembly/1", tuning) {
|
|
t.Fatalf("expected assembly member resource to be skipped from post-probe")
|
|
}
|
|
}
|
|
|
|
func TestShouldAdaptivePostProbeCollectionPath(t *testing.T) {
|
|
tuning := redfishprofile.AcquisitionTuning{
|
|
PostProbePolicy: redfishprofile.AcquisitionPostProbePolicy{
|
|
EnableNumericCollectionProbe: true,
|
|
},
|
|
}
|
|
withExplicitNamedMembers := map[string]interface{}{
|
|
"Members": []interface{}{
|
|
map[string]interface{}{"@odata.id": "/redfish/v1/Systems/1/EthernetInterfaces/NIC-0-0"},
|
|
map[string]interface{}{"@odata.id": "/redfish/v1/Systems/1/EthernetInterfaces/NIC-0-1"},
|
|
},
|
|
}
|
|
if shouldAdaptivePostProbeCollectionPath("/redfish/v1/Systems/1/EthernetInterfaces", withExplicitNamedMembers, tuning) {
|
|
t.Fatalf("expected explicit non-numeric members to skip adaptive post-probe")
|
|
}
|
|
|
|
withNumericMembers := map[string]interface{}{
|
|
"Members": []interface{}{
|
|
map[string]interface{}{"@odata.id": "/redfish/v1/Chassis/1/PCIeDevices/1"},
|
|
map[string]interface{}{"@odata.id": "/redfish/v1/Chassis/1/PCIeDevices/2"},
|
|
},
|
|
}
|
|
if !shouldAdaptivePostProbeCollectionPath("/redfish/v1/Chassis/1/PCIeDevices", withNumericMembers, tuning) {
|
|
t.Fatalf("expected numeric members to allow adaptive post-probe")
|
|
}
|
|
|
|
withoutMembers := map[string]interface{}{"Name": "Drives"}
|
|
if !shouldAdaptivePostProbeCollectionPath("/redfish/v1/Chassis/1/Drives", withoutMembers, tuning) {
|
|
t.Fatalf("expected missing members to allow adaptive post-probe")
|
|
}
|
|
|
|
if shouldAdaptivePostProbeCollectionPath("/redfish/v1/Chassis/1/Drives", withoutMembers, redfishprofile.AcquisitionTuning{}) {
|
|
t.Fatalf("expected post-probe to stay disabled without profile policy")
|
|
}
|
|
}
|
|
|
|
func TestShouldAdaptiveNVMeProbe(t *testing.T) {
|
|
withMembers := map[string]interface{}{
|
|
"Members": []interface{}{
|
|
map[string]interface{}{"@odata.id": "/redfish/v1/Chassis/1/Drives/OB01"},
|
|
},
|
|
}
|
|
if shouldAdaptiveNVMeProbe(withMembers) {
|
|
t.Fatalf("expected drives collection with explicit members to skip NVMe probe")
|
|
}
|
|
|
|
withoutMembers := map[string]interface{}{"Name": "Drives"}
|
|
if !shouldAdaptiveNVMeProbe(withoutMembers) {
|
|
t.Fatalf("expected drives collection without members to allow NVMe probe")
|
|
}
|
|
}
|
|
|
|
func TestRedfishAdaptivePrefetchTargets(t *testing.T) {
|
|
tuning := redfishprofile.AcquisitionTuning{
|
|
PrefetchPolicy: redfishprofile.AcquisitionPrefetchPolicy{
|
|
IncludeSuffixes: []string{
|
|
"/Memory",
|
|
"/Processors",
|
|
"/Storage",
|
|
},
|
|
},
|
|
}
|
|
candidates := []string{
|
|
"/redfish/v1/Systems/1/Memory",
|
|
"/redfish/v1/Systems/1/Processors",
|
|
"/redfish/v1/Systems/1/Storage",
|
|
}
|
|
rawTree := map[string]interface{}{
|
|
"/redfish/v1/Systems/1/Memory": map[string]interface{}{
|
|
"Members": []interface{}{
|
|
map[string]interface{}{"@odata.id": "/redfish/v1/Systems/1/Memory/DIMM1"},
|
|
},
|
|
},
|
|
"/redfish/v1/Systems/1/Storage": map[string]interface{}{
|
|
"Members": []interface{}{
|
|
map[string]interface{}{"@odata.id": "/redfish/v1/Systems/1/Storage/1"},
|
|
},
|
|
},
|
|
}
|
|
fetchErrs := map[string]string{
|
|
"/redfish/v1/Systems/1/Memory/DIMM1": "Get \"https://bmc/redfish/v1/Systems/1/Memory/DIMM1\": context deadline exceeded",
|
|
"/redfish/v1/Systems/1/Storage/1": "status 404 from /redfish/v1/Systems/1/Storage/1: not found",
|
|
"/redfish/v1/Systems/1/Processors": "Get \"https://bmc/redfish/v1/Systems/1/Processors\": context deadline exceeded",
|
|
"/redfish/v1/Systems/1/Storage/Volumes": "status 404 from /redfish/v1/Systems/1/Storage/Volumes: not found",
|
|
}
|
|
|
|
got := redfishAdaptivePrefetchTargets(redfishPrefetchTargets(candidates, tuning), rawTree, fetchErrs)
|
|
joined := strings.Join(got, "\n")
|
|
for _, wanted := range []string{
|
|
"/redfish/v1/Systems/1/Memory",
|
|
"/redfish/v1/Systems/1/Processors",
|
|
} {
|
|
if !strings.Contains(joined, wanted) {
|
|
t.Fatalf("expected adaptive prefetch target %q", wanted)
|
|
}
|
|
}
|
|
if strings.Contains(joined, "/redfish/v1/Systems/1/Storage") {
|
|
t.Fatalf("expected storage with only non-retryable missing members to be skipped")
|
|
}
|
|
}
|
|
|
|
func TestResolveAcquisitionPlan_DefaultSkipsNoisyBranches(t *testing.T) {
|
|
signals := redfishprofile.MatchSignals{}
|
|
match := redfishprofile.MatchProfiles(signals)
|
|
plan := redfishprofile.BuildAcquisitionPlan(signals)
|
|
resolved := redfishprofile.ResolveAcquisitionPlan(match, plan, redfishprofile.DiscoveredResources{
|
|
SystemPaths: []string{"/redfish/v1/Systems/1"},
|
|
ChassisPaths: []string{"/redfish/v1/Chassis/1"},
|
|
ManagerPaths: []string{"/redfish/v1/Managers/1"},
|
|
}, signals)
|
|
seeds := resolved.SeedPaths
|
|
joined := strings.Join(seeds, "\n")
|
|
for _, noisy := range []string{
|
|
"/redfish/v1/Fabrics",
|
|
"/redfish/v1/Chassis/1/Backplanes",
|
|
"/redfish/v1/Chassis/1/Boards",
|
|
"/redfish/v1/Chassis/1/Sensors",
|
|
"/redfish/v1/Managers/1/LogServices",
|
|
} {
|
|
if strings.Contains(joined, noisy) {
|
|
t.Fatalf("unexpected noisy seed %q", noisy)
|
|
}
|
|
}
|
|
for _, wanted := range []string{
|
|
"/redfish/v1/Systems/1/Memory",
|
|
"/redfish/v1/Systems/1/PCIeDevices",
|
|
"/redfish/v1/Chassis/1/Drives",
|
|
"/redfish/v1/Chassis/1/NetworkAdapters",
|
|
"/redfish/v1/Managers/1/NetworkProtocol",
|
|
} {
|
|
if !strings.Contains(joined, wanted) {
|
|
t.Fatalf("expected seed %q", wanted)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestShouldPrefetchCriticalPath_UsesPrefetchPolicy(t *testing.T) {
|
|
tuning := redfishprofile.AcquisitionTuning{
|
|
PrefetchPolicy: redfishprofile.AcquisitionPrefetchPolicy{
|
|
IncludeSuffixes: []string{"/Storage", "/Oem/Public"},
|
|
ExcludeContains: []string{"/Assembly"},
|
|
},
|
|
}
|
|
if !shouldPrefetchCriticalPath("/redfish/v1/Systems/1/Storage", tuning) {
|
|
t.Fatal("expected storage path to be prefetched when included by policy")
|
|
}
|
|
if !shouldPrefetchCriticalPath("/redfish/v1/Systems/1/Oem/Public", tuning) {
|
|
t.Fatal("expected OEM public path to be prefetched when included by policy")
|
|
}
|
|
if shouldPrefetchCriticalPath("/redfish/v1/Chassis/1/Assembly", tuning) {
|
|
t.Fatal("expected excluded path to skip prefetch")
|
|
}
|
|
if shouldPrefetchCriticalPath("/redfish/v1/Chassis/1/Power", redfishprofile.AcquisitionTuning{}) {
|
|
t.Fatal("expected empty prefetch policy to disable suffix-based prefetch")
|
|
}
|
|
}
|
|
|
|
func TestRedfishPrefetchTargets_FilterNoisyBranches(t *testing.T) {
|
|
tuning := redfishprofile.AcquisitionTuning{
|
|
PrefetchPolicy: redfishprofile.AcquisitionPrefetchPolicy{
|
|
IncludeSuffixes: []string{
|
|
"/Memory",
|
|
"/Oem/Public/FRU",
|
|
"/Drives",
|
|
"/NetworkProtocol",
|
|
},
|
|
ExcludeContains: []string{
|
|
"/Backplanes",
|
|
"/Sensors",
|
|
"/LogServices",
|
|
},
|
|
},
|
|
}
|
|
critical := []string{
|
|
"/redfish/v1/Systems/1",
|
|
"/redfish/v1/Systems/1/Memory",
|
|
"/redfish/v1/Systems/1/Oem/Public/FRU",
|
|
"/redfish/v1/Chassis/1/Drives",
|
|
"/redfish/v1/Chassis/1/Backplanes",
|
|
"/redfish/v1/Chassis/1/Sensors",
|
|
"/redfish/v1/Managers/1/LogServices",
|
|
"/redfish/v1/Managers/1/NetworkProtocol",
|
|
}
|
|
got := redfishPrefetchTargets(critical, tuning)
|
|
joined := strings.Join(got, "\n")
|
|
for _, wanted := range []string{
|
|
"/redfish/v1/Systems/1",
|
|
"/redfish/v1/Systems/1/Memory",
|
|
"/redfish/v1/Systems/1/Oem/Public/FRU",
|
|
"/redfish/v1/Chassis/1/Drives",
|
|
"/redfish/v1/Managers/1/NetworkProtocol",
|
|
} {
|
|
if !strings.Contains(joined, wanted) {
|
|
t.Fatalf("expected prefetch target %q", wanted)
|
|
}
|
|
}
|
|
for _, noisy := range []string{
|
|
"/redfish/v1/Chassis/1/Backplanes",
|
|
"/redfish/v1/Chassis/1/Sensors",
|
|
"/redfish/v1/Managers/1/LogServices",
|
|
} {
|
|
if strings.Contains(joined, noisy) {
|
|
t.Fatalf("unexpected noisy prefetch target %q", noisy)
|
|
}
|
|
}
|
|
}
|
|
|
|
// TestChassisTypeCanHaveNVMe verifies that non-storage chassis types (GPU modules,
|
|
// RoT components, fabric zones) are excluded from NVMe bay probing, while storage
|
|
// and unclassified chassis types are kept.
|
|
//
|
|
// Regression guard: on Supermicro HGX (SYS-A21GE-NBRT) all 35 sub-chassis (GPUs,
|
|
// NVSwitches, PCIeRetimers, ERoT/IRoT, BMC, FPGA) have ChassisType=Module/Component/Zone
|
|
// and expose empty /Drives collections. Without this filter each chassis triggered
|
|
// 384 HTTP requests → ~22 minutes wasted per collection. (2026-03-12)
|
|
func TestChassisTypeCanHaveNVMe(t *testing.T) {
|
|
cases := []struct {
|
|
chassisType string
|
|
want bool
|
|
}{
|
|
// Non-storage sub-module types — must return false
|
|
{"Module", false}, // GPU SXM, PCIeRetimer, NVLinkManagementNIC
|
|
{"module", false}, // case-insensitive
|
|
{"Component", false}, // ERoT, IRoT, BMC, FPGA sub-chassis
|
|
{"component", false},
|
|
{"Zone", false}, // HGX_Chassis_0 fabric zone
|
|
{"zone", false},
|
|
// Storage-capable and generic types — must return true
|
|
{"Enclosure", true}, // NVMe StorageBackplane
|
|
{"RackMount", true}, // main server chassis
|
|
{"Blade", true}, // blade server chassis
|
|
{"StandAlone", true}, // standalone server
|
|
{"", true}, // unknown type — probe to be safe
|
|
}
|
|
for _, tc := range cases {
|
|
got := chassisTypeCanHaveNVMe(tc.chassisType)
|
|
if got != tc.want {
|
|
t.Errorf("chassisTypeCanHaveNVMe(%q) = %v, want %v", tc.chassisType, got, tc.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
// TestNVMePostProbeSkipsNonStorageChassis verifies that the NVMe bay probe candidate
|
|
// selection skips chassis whose ChassisType indicates they cannot hold NVMe drives.
|
|
//
|
|
// Simulates an HGX topology: one GPU chassis (Module) and one NVMe backplane
|
|
// (Enclosure), both with empty /Drives collections. Only the backplane must be
|
|
// selected as a probe candidate.
|
|
func TestNVMePostProbeSkipsNonStorageChassis(t *testing.T) {
|
|
// Build the out map as collectRawRedfishTree would produce it
|
|
out := map[string]interface{}{
|
|
// GPU chassis — Module type, empty Drives: should be skipped
|
|
"/redfish/v1/Chassis/HGX_GPU_SXM_1": map[string]interface{}{
|
|
"@odata.id": "/redfish/v1/Chassis/HGX_GPU_SXM_1",
|
|
"ChassisType": "Module",
|
|
"Name": "HGX_GPU_SXM_1",
|
|
},
|
|
"/redfish/v1/Chassis/HGX_GPU_SXM_1/Drives": map[string]interface{}{
|
|
"@odata.id": "/redfish/v1/Chassis/HGX_GPU_SXM_1/Drives",
|
|
"Members": []interface{}{},
|
|
"Members@odata.count": 0,
|
|
},
|
|
// NVMe backplane — Enclosure type, empty Drives: must be selected
|
|
"/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane": map[string]interface{}{
|
|
"@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane",
|
|
"ChassisType": "Enclosure",
|
|
"Name": "Backplane",
|
|
},
|
|
"/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives": map[string]interface{}{
|
|
"@odata.id": "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives",
|
|
"Members": []interface{}{},
|
|
"Members@odata.count": 0,
|
|
},
|
|
}
|
|
|
|
// Replicate the candidate selection logic from collectRawRedfishTree
|
|
var selected []string
|
|
for path, docAny := range out {
|
|
normalized := normalizeRedfishPath(path)
|
|
if !strings.HasSuffix(normalized, "/Drives") {
|
|
continue
|
|
}
|
|
doc, _ := docAny.(map[string]interface{})
|
|
if !shouldAdaptiveNVMeProbe(doc) {
|
|
continue
|
|
}
|
|
chassisPath := strings.TrimSuffix(normalized, "/Drives")
|
|
if chassisDocAny, ok := out[chassisPath]; ok {
|
|
if chassisDoc, ok := chassisDocAny.(map[string]interface{}); ok {
|
|
if !chassisTypeCanHaveNVMe(asString(chassisDoc["ChassisType"])) {
|
|
continue
|
|
}
|
|
}
|
|
}
|
|
selected = append(selected, normalized)
|
|
}
|
|
|
|
if len(selected) != 1 {
|
|
t.Fatalf("expected 1 NVMe probe candidate (backplane), got %d: %v", len(selected), selected)
|
|
}
|
|
if !strings.Contains(selected[0], "StorageBackplane") {
|
|
t.Fatalf("expected StorageBackplane to be selected, got %q", selected[0])
|
|
}
|
|
}
|