Files
logpile/internal/parser/vendors/inspur/diagnose_test.go
T
mchusandClaude Sonnet 5 74e6bf0578 fix(parser): support Inspur HGX dump_<serial>_<timestamp>/ onekeylog layout
Fixes #20. This onekeylog variant has no devicefrusdr.log at all: FRU/sensors
come from raw ipmitool text output, PCIe/GPU presence has a dedicated
structural snapshot, SEL lives at a different path, and BMC component
failures are logged separately from SEL/IDL.

- Fall back to component/fru.txt (same FRU block format as devicefrusdr.log)
  and component/sensor.txt / sdr.txt (ipmitool sensor list / sdr elist)
  when devicefrusdr.log is absent.
- Parse log/bmc/diagnose/OtrdDiagnoseComponent.json's PCIe Device Info array
  for GPU/PCIe presence and link state, independent of SEL/IDL alarm
  history; flag devices running below their negotiated max link
  speed/width as degraded with a Warning event.
- Fall back to log/sel.csv (same format as selelist.csv) when selelist.csv
  is absent.
- Parse log/bmc/commer-comp/{commerslot,commerhmc,commerswvr,commerswcpld}
  logs (including rotated *.tar.gz.N parts) into failure events, filtering
  known-noisy lines.
- Collapse SEL events duplicated across sources by
  (timestamp, event_type, description).
- Surface a CollectionError when FRU/sensors are still empty after all
  fallbacks, instead of silently returning an empty inventory.
- Fix ParseFRU: a later placeholder "Product Serial : 0" / "Product Part
  Number : NULL" line in the same FRU block (e.g. SCM_FRU) was overwriting
  an already-parsed real Board Serial/Part Number.

Verified against dump_23DB01633_20260727-1359.tar.gz (HGX B200, KR9288-X3):
fru 0→21, sensors 0→303, 8 GPUs present at Gen5 x16 in slots 100-107.

Deferred (not covered by this change): BIOS-change-settings context and
BIOS POST codes from the same layout — see bible-local/10-decisions.md
ADL-048.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-29 10:05:58 +03:00

71 lines
1.8 KiB
Go

package inspur
import "testing"
const diagnoseJSONFixture = `{
"Pcie Device Info": [
{
"LocString": "#GPU0",
"PcieSlot": 100,
"PresentStatus": 1,
"VendorId": 4318,
"DeviceId": 10497,
"BusNumber": 23,
"DeviceNumber": 0,
"FunctionNumber": 0,
"CurrentLinkSpeed": 5,
"MaxLinkSpeed": 5,
"NegotiatedLinkWidth": 16,
"MaxLinkWidth": 16
},
{
"LocString": "#GPU6",
"PcieSlot": 106,
"PresentStatus": 1,
"VendorId": 4318,
"DeviceId": 10497,
"BusNumber": 220,
"DeviceNumber": 0,
"FunctionNumber": 0,
"CurrentLinkSpeed": 2,
"MaxLinkSpeed": 5,
"NegotiatedLinkWidth": 8,
"MaxLinkWidth": 16
}
]
}`
func TestParseOtrdDiagnosePCIe(t *testing.T) {
devices := ParseOtrdDiagnosePCIe([]byte(diagnoseJSONFixture))
if len(devices) != 2 {
t.Fatalf("expected 2 devices, got %d", len(devices))
}
gpu0 := devices[0]
if gpu0.Slot != "#GPU0" || gpu0.Present == nil || !*gpu0.Present {
t.Fatalf("expected GPU0 present, got %+v", gpu0)
}
if gpu0.Status == "Link Degraded" {
t.Fatalf("GPU0 should not be flagged as degraded: %+v", gpu0)
}
if gpu0.LinkSpeed != "GEN5" || gpu0.MaxLinkSpeed != "GEN5" || gpu0.LinkWidth != 16 {
t.Fatalf("unexpected GPU0 link info: %+v", gpu0)
}
gpu6 := devices[1]
if gpu6.Status != "Link Degraded" {
t.Fatalf("expected GPU6 to be flagged as degraded, got %+v", gpu6)
}
}
func TestBuildPCIeLinkDegradationEvents(t *testing.T) {
devices := ParseOtrdDiagnosePCIe([]byte(diagnoseJSONFixture))
events := BuildPCIeLinkDegradationEvents(devices)
if len(events) != 1 {
t.Fatalf("expected 1 degradation event, got %d", len(events))
}
if events[0].Severity != "warning" {
t.Fatalf("expected warning severity, got %q", events[0].Severity)
}
}