Implement audit enrichments, TUI workflows, and production ISO scaffold
This commit is contained in:
57
audit/internal/collector/vroc_test.go
Normal file
57
audit/internal/collector/vroc_test.go
Normal file
@@ -0,0 +1,57 @@
|
||||
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 TestHasVROCController(t *testing.T) {
|
||||
intel := vendorIntel
|
||||
model := "Volume Management Device NVMe RAID Controller"
|
||||
class := "RAID bus controller"
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user