feat(inventory): deep hardware capture + per-probe substeps + verbose logs
Extend Inventory stage from a one-liner summary to a per-probe substep emitter with ~20-30 narrative log lines per run. - spec: per-DIMM memory (slot/size/speed/manufacturer/part_number), richer CPU (vendor/stepping/physical_cores/flags), disk model/transport/rotational, NIC driver/pci_addr, GPU vram/pci/driver, new System/Baseboard/PSU/OS top-level sections. All fields omitempty so existing expected-spec YAML and artifacts stay compatible. - spec.Diff: new diffDIMMs/diffSystem/diffBaseboard/diffPSU/diffOS helpers; extended diffDisks/diffNICs/diffGPUs for new fields. GPU diff gains PCIAddr-pinned matching alongside count-by-model. - agent/probes/inventory: CPU (/proc/cpuinfo extended), Memory (dmidecode -t 17 multi-block), Disks (+model/transport/rotational), NICs (+driver/pci from sysfs), GPUs (VRAM from lspci -vv), new System/Baseboard (dmidecode -t system/baseboard), PSU (dmidecode -t 39), OS (/proc/sys/kernel/osrelease + /etc/os-release). All probes accept a Logger and emit per-finding info/warn lines. - agent/probes/firmware: parseDmidecodeAllSections for multi-block fixtures (memory / PSU). - agent/runner: Inventory case becomes 9 substep rows (CPU / Memory / Disks / NICs / GPUs / System / Baseboard / PSU / OS) with per-probe start/complete timestamps. - report: new Inventory HTML section between Stages and Firmware; resolveReporting loads the inventory.json artifact. - agent/tests/fakes/dmidecode: dispatches on -t flag to serve bios / memory / system / baseboard / 39 fixtures for unit tests. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -212,3 +212,164 @@ func TestDiffFirmwareCaseInsensitive(t *testing.T) {
|
||||
t.Fatalf("case-insensitive match expected, got %+v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiffDIMMMissingSlot(t *testing.T) {
|
||||
exp := &Spec{Memory: &MemorySpec{Modules: []DIMMSpec{
|
||||
{Slot: "DIMM_A1", SizeGB: 16, PartNumber: "8ATF2G64AZ-3G2E1", Populated: true},
|
||||
{Slot: "DIMM_B1", SizeGB: 16, PartNumber: "8ATF2G64AZ-3G2E1", Populated: true},
|
||||
}}}
|
||||
act := &Inventory{Memory: MemorySpec{Modules: []DIMMSpec{
|
||||
{Slot: "DIMM_A1", SizeGB: 16, PartNumber: "8ATF2G64AZ-3G2E1", Populated: true},
|
||||
}}}
|
||||
d := Diff(exp, act)
|
||||
got := map[string]bool{}
|
||||
for _, row := range d {
|
||||
got[row.Field] = true
|
||||
}
|
||||
if !got["memory.modules[DIMM_B1].present"] {
|
||||
t.Fatalf("expected missing DIMM_B1; got %+v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiffDIMMPartNumberMismatch(t *testing.T) {
|
||||
exp := &Spec{Memory: &MemorySpec{Modules: []DIMMSpec{
|
||||
{Slot: "DIMM_A1", PartNumber: "8ATF2G64AZ-3G2E1", Populated: true},
|
||||
}}}
|
||||
act := &Inventory{Memory: MemorySpec{Modules: []DIMMSpec{
|
||||
{Slot: "DIMM_A1", PartNumber: "HMA82GR7AFR8N-UH", Populated: true},
|
||||
}}}
|
||||
d := Diff(exp, act)
|
||||
if len(d) != 1 || d[0].Field != "memory.modules[DIMM_A1].part_number" || d[0].Severity != "critical" {
|
||||
t.Fatalf("expected part_number critical, got %+v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiffDIMMUnexpectedPopulated(t *testing.T) {
|
||||
exp := &Spec{Memory: &MemorySpec{Modules: []DIMMSpec{
|
||||
{Slot: "DIMM_A1", Populated: true},
|
||||
}}}
|
||||
act := &Inventory{Memory: MemorySpec{Modules: []DIMMSpec{
|
||||
{Slot: "DIMM_A1", Populated: true},
|
||||
{Slot: "DIMM_B1", Populated: true, SizeGB: 8},
|
||||
}}}
|
||||
d := Diff(exp, act)
|
||||
got := map[string]bool{}
|
||||
for _, row := range d {
|
||||
got[row.Field] = true
|
||||
}
|
||||
if !got["memory.modules[unexpected DIMM_B1]"] {
|
||||
t.Fatalf("expected unexpected-DIMM_B1; got %+v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiffDIMMEmptySlotsIgnoredWhenNotExpected(t *testing.T) {
|
||||
// Actual has two empty slots; expected only lists the populated one.
|
||||
// Empty extras must not produce an unexpected-populated diff.
|
||||
exp := &Spec{Memory: &MemorySpec{Modules: []DIMMSpec{
|
||||
{Slot: "DIMM_A1", Populated: true, SizeGB: 16},
|
||||
}}}
|
||||
act := &Inventory{Memory: MemorySpec{Modules: []DIMMSpec{
|
||||
{Slot: "DIMM_A1", Populated: true, SizeGB: 16},
|
||||
{Slot: "DIMM_A2"},
|
||||
{Slot: "DIMM_B1"},
|
||||
}}}
|
||||
if d := Diff(exp, act); len(d) != 0 {
|
||||
t.Fatalf("empty extra slots must not diff; got %+v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiffDiskTransport(t *testing.T) {
|
||||
exp := &Spec{Disks: []DiskSpec{
|
||||
{Serial: "A", SizeGB: 1000, Transport: "nvme", Model: "SN850X"},
|
||||
}}
|
||||
act := &Inventory{Disks: []DiskSpec{
|
||||
{Serial: "A", SizeGB: 1000, Transport: "sata", Model: "860 EVO"},
|
||||
}}
|
||||
d := Diff(exp, act)
|
||||
got := map[string]bool{}
|
||||
for _, r := range d {
|
||||
got[r.Field] = true
|
||||
}
|
||||
if !got["disks[A].transport"] || !got["disks[A].model"] {
|
||||
t.Fatalf("expected transport + model diffs; got %+v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiffSystem(t *testing.T) {
|
||||
exp := &Spec{System: &SystemSpec{Manufacturer: "Beelink", ProductName: "Mini S12 Pro"}}
|
||||
act := &Inventory{System: SystemSpec{Manufacturer: "Beelink", ProductName: "Mini S11"}}
|
||||
d := Diff(exp, act)
|
||||
if len(d) != 1 || d[0].Field != "system.product_name" {
|
||||
t.Fatalf("expected system.product_name; got %+v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiffBaseboard(t *testing.T) {
|
||||
exp := &Spec{Baseboard: &BaseboardSpec{SerialNumber: "BB-0001"}}
|
||||
act := &Inventory{Baseboard: BaseboardSpec{SerialNumber: "BB-9999"}}
|
||||
d := Diff(exp, act)
|
||||
if len(d) != 1 || d[0].Field != "baseboard.serial_number" {
|
||||
t.Fatalf("expected baseboard.serial_number; got %+v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiffPSUMissing(t *testing.T) {
|
||||
exp := &Spec{PSU: []PowerSupplySpec{{Slot: "PSU1", MaxWatts: 760}, {Slot: "PSU2", MaxWatts: 760}}}
|
||||
act := &Inventory{PSU: []PowerSupplySpec{{Slot: "PSU1", MaxWatts: 760}}}
|
||||
d := Diff(exp, act)
|
||||
got := map[string]bool{}
|
||||
for _, r := range d {
|
||||
got[r.Field] = true
|
||||
}
|
||||
if !got["psu[PSU2].present"] {
|
||||
t.Fatalf("expected PSU2 missing; got %+v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiffOSKernel(t *testing.T) {
|
||||
exp := &Spec{OS: &OSSpec{Kernel: "6.1.0-17-amd64"}}
|
||||
act := &Inventory{OS: OSSpec{Kernel: "6.1.0-22-amd64"}}
|
||||
d := Diff(exp, act)
|
||||
if len(d) != 1 || d[0].Field != "os.kernel" {
|
||||
t.Fatalf("expected os.kernel; got %+v", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiffCPUExtendedFields(t *testing.T) {
|
||||
exp := &Spec{CPU: &CPUSpec{
|
||||
PhysicalCores: 8,
|
||||
Vendor: "GenuineIntel",
|
||||
Flags: []string{"vmx", "aes"},
|
||||
}}
|
||||
act := &Inventory{CPU: CPUSpec{
|
||||
PhysicalCores: 4,
|
||||
Vendor: "AuthenticAMD",
|
||||
Flags: []string{"aes"}, // missing vmx
|
||||
}}
|
||||
d := Diff(exp, act)
|
||||
got := map[string]bool{}
|
||||
for _, r := range d {
|
||||
got[r.Field] = true
|
||||
}
|
||||
for _, want := range []string{"cpu.physical_cores", "cpu.vendor", "cpu.flags[vmx]"} {
|
||||
if !got[want] {
|
||||
t.Fatalf("expected %s diff; got %+v", want, d)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDiffGPUByPCIAddr(t *testing.T) {
|
||||
exp := &Spec{GPUs: []GPUSpec{{PCIAddr: "0000:01:00.0", VRAMGiB: 8, Driver: "nvidia"}}}
|
||||
act := &Inventory{GPUs: []GPUSpec{{PCIAddr: "0000:01:00.0", VRAMGiB: 4, Driver: "nouveau"}}}
|
||||
d := Diff(exp, act)
|
||||
got := map[string]bool{}
|
||||
for _, r := range d {
|
||||
got[r.Field] = true
|
||||
}
|
||||
for _, want := range []string{"gpus[0000:01:00.0].vram_gib", "gpus[0000:01:00.0].driver"} {
|
||||
if !got[want] {
|
||||
t.Fatalf("expected %s; got %+v", want, d)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user