Files
bee/audit/internal/collector/xid_test.go
T
Mikhail ChusavitinandClaude Sonnet 5 1175e6ccd8 gpu: collect reset-required/row-remap status and classify Xid codes by severity
nvidia-smi exposes reset_status.reset_required and remapped_rows.* only on
newer drivers for Ampere+ GPUs; queried via a separate exec call since an
unrecognized field name fails the whole --query-gpu command and would have
wiped out unrelated telemetry (temp/ECC/power) on older drivers otherwise.

Also refines Xid severity in both the ingest dmesg collector and the
always-on kmsg watcher: Xid 64 (row-remap InfoROM write failure) now
escalates to Critical instead of the generic warning every other Xid got,
and fixes the SAT-window flush path which previously hardcoded "Warning"
and ignored pattern severity entirely.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-07 19:28:59 +03:00

54 lines
1.3 KiB
Go

package collector
import "testing"
func TestXidSeverity(t *testing.T) {
tests := []struct {
name string
line string
wantSev string
wantOK bool
}{
{
name: "xid 64 remap write failure is critical",
line: "NVRM: Xid (PCI:0000:65:00): 64, pid=1234, name=python, Row Remapper: New row remapping failed",
wantSev: "critical",
wantOK: true,
},
{
name: "xid 48 uncorrectable ecc is critical",
line: "NVRM: Xid (PCI:0000:65:00): 48, pid=1234, name=python",
wantSev: "critical",
wantOK: true,
},
{
name: "xid 63 remap committed is warning",
line: "NVRM: Xid (PCI:0000:65:00): 63, pid=1234, Class 0x90a0",
wantSev: "warning",
wantOK: true,
},
{
name: "xid 79 unknown code falls back to caller default",
line: "NVRM: Xid (PCI:0000:65:00): 79, pid=1234, GPU has fallen off the bus",
wantOK: false,
},
{
name: "no xid in line",
line: "NVRM: GPU 0000:65:00.0: RmInitAdapter failed",
wantOK: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
sev, ok := XidSeverity(tt.line)
if ok != tt.wantOK {
t.Fatalf("ok: got %v, want %v", ok, tt.wantOK)
}
if ok && sev != tt.wantSev {
t.Fatalf("severity: got %q, want %q", sev, tt.wantSev)
}
})
}
}