Files
bee/audit/internal/collector/vroc_test.go
Mikhail Chusavitin 2c22b01fe3 Fix IPMI hangs, add VROC license, fix blackbox service, drop qrencode
IPMI hang fix (Lenovo XCC SR650 V3):
- Add pluggable ipmi_profile system with per-vendor timeouts and fruEarlyExit flag
- Lenovo profile: 90s FRU timeout, streaming early-exit stops after PSU blocks found
- collectFRUEarlyExit streams ipmitool fru print and kills process once PSU blocks
  are followed by a non-PSU header (~6s instead of ~108s on 54-device FRU list)
- collectBMCFirmware and collectPSUs accept manufacturer and apply profile timeouts

VROC license detection:
- Detect VMD/VROC controller in PCIe list, run mdadm --detail-platform
- Parse "License:" line; store as snap.VROCLicense in HardwareSnapshot

Blackbox service fix:
- bee-blackbox.service was missing from systemctl enable list in ISO build hook
- Service never started on boot; state file never written; UI button stayed "Enable"

Drop qrencode:
- Remove from package list, standardTools API check, and runtime-flows doc

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-30 10:46:59 +03:00

87 lines
2.1 KiB
Go

package collector
import (
"bee/audit/internal/schema"
"testing"
)
func TestParseMDStatArrays(t *testing.T) {
raw := `Personalities : [raid1]
md126 : active raid1 nvme0n1[0] nvme1n1[1]
976630464 blocks super external:/md127/0 [2/2] [UU]
md125 : active raid1 nvme2n1[0] nvme3n1[1]
976630464 blocks super external:/md127/1 [2/1] [U_]
`
arrays := parseMDStatArrays(raw)
if len(arrays) != 2 {
t.Fatalf("expected 2 arrays, got %d", len(arrays))
}
if arrays[0].Name != "md126" || arrays[0].Degraded {
t.Fatalf("unexpected array0: %+v", arrays[0])
}
if len(arrays[0].Members) != 2 || arrays[0].Members[0] != "nvme0n1" {
t.Fatalf("unexpected members array0: %+v", arrays[0].Members)
}
if arrays[1].Name != "md125" || !arrays[1].Degraded {
t.Fatalf("unexpected array1: %+v", arrays[1])
}
}
func TestParseMDAdmPlatformLicense(t *testing.T) {
premium := `Platform : Intel(R) Virtual RAID on CPU
Version : 1.3.0.1138
RAID Levels : raid0 raid1 raid5 raid10
Total Disks : 4
License : Premium
`
got := parseMDAdmPlatformLicense(premium)
if got == nil || *got != "premium" {
t.Fatalf("expected 'premium', got %v", got)
}
standard := `Platform : Intel(R) Virtual RAID on CPU
License : Standard
`
got = parseMDAdmPlatformLicense(standard)
if got == nil || *got != "standard" {
t.Fatalf("expected 'standard', got %v", got)
}
noLicense := `Platform : Intel(R) Virtual RAID on CPU
Version : 1.0.0
`
got = parseMDAdmPlatformLicense(noLicense)
if got != nil {
t.Fatalf("expected nil, got %v", *got)
}
}
func TestHasVROCController(t *testing.T) {
intel := vendorIntel
model := "Volume Management Device NVMe RAID Controller"
class := "MassStorageController"
tests := []struct {
name string
pcie []schema.HardwarePCIeDevice
want bool
}{
{
name: "intel vroc",
pcie: []schema.HardwarePCIeDevice{{VendorID: &intel, Model: &model, DeviceClass: &class}},
want: true,
},
{
name: "non-intel raid",
pcie: []schema.HardwarePCIeDevice{{}},
want: false,
},
}
for _, tt := range tests {
got := hasVROCController(tt.pcie)
if got != tt.want {
t.Fatalf("%s: got %v want %v", tt.name, got, tt.want)
}
}
}