23c689aa5b
Ships all five phases of the deep-profile overhaul together. Runs now carry a profile (quick/deep/soak); every profile walks the same 11-stage order — Inventory → Firmware → SpecValidate → SMART → CPUStress → Storage → Network → Burn → GPU → PSU → Reporting — with only per-stage durations and concurrency scaled. Phase 1: profiles.ProfileRegistry loaded from vetting.yaml; runs.profile column + CreateWithProfile; threshold table + evaluator seeded per-run from the shared vetting.thresholds block; breach flips result at /sensor + /result. Phase 2: upgraded CPUStress (stress-ng --cpu-method=all --verify + EDAC/MCE poll), Storage (fio --verify=md5 + SMART start/end delta), Network (sustained iperf + /proc/net/dev deltas) with per-profile knobs from Deps. Phase 3: Burn super-stage with goroutine fan-out for CPU + memory + fio + iperf, PSU rails sampled across the Burn window, SensorMux (2 s flush, 500-sample cap) to absorb backpressure. Phase 4: Firmware stage + firmware_snapshots table; probes dmidecode (BIOS), ipmitool (BMC), ethtool -i (NIC), nvme (sysfs + id-ctrl), lspci (HBA), /proc/cpuinfo (microcode). spec.DiffFirmware folds into SpecValidate with pin-by-identifier and fan-out-across-component matching; mismatches park the run in FailedHolding. Phase 5: profile radio on the host start form, profile chip on the run header, Firmware section in the HTML report, coverage artifact uploaded from CI, agent/tests/fakes/ scaffold with Deps.LookPath seam + stress_ng and dmidecode example fakes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
85 lines
2.9 KiB
Go
85 lines
2.9 KiB
Go
package probes
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestParseNetDev_RealSample exercises parseNetDev against a synthetic
|
|
// /proc/net/dev fixture with the full 16-column layout. Confirms the
|
|
// loopback interface is dropped, headers are skipped, and each of the
|
|
// six curated counters lands in the right field.
|
|
func TestParseNetDev_RealSample(t *testing.T) {
|
|
// Columns after "iface:":
|
|
// 0 rx_bytes 1 rx_packets 2 rx_errs 3 rx_drop
|
|
// 4 fifo 5 frame 6 compressed 7 multicast
|
|
// 8 tx_bytes 9 tx_packets 10 tx_errs 11 tx_drop
|
|
// 12 fifo 13 colls 14 carrier 15 compressed
|
|
fixture := `Inter-| Receive | Transmit
|
|
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
|
|
lo: 1000000 10000 0 0 0 0 0 0 1000000 10000 0 0 0 0 0 0
|
|
eth0: 50000000 100000 7 12 0 0 0 0 40000000 90000 3 5 0 0 0 0
|
|
eth1: 12345 200 0 0 0 0 0 0 54321 180 0 0 0 0 0 0
|
|
`
|
|
snaps := parseNetDev(strings.NewReader(fixture))
|
|
if len(snaps) != 2 {
|
|
t.Fatalf("got %d snapshots, want 2 (lo should be dropped)", len(snaps))
|
|
}
|
|
byIface := map[string]NetDevSnapshot{}
|
|
for _, s := range snaps {
|
|
byIface[s.Iface] = s
|
|
}
|
|
eth0, ok := byIface["eth0"]
|
|
if !ok {
|
|
t.Fatalf("eth0 missing from parsed snapshots")
|
|
}
|
|
if eth0.RxBytes != 50000000 {
|
|
t.Errorf("eth0 RxBytes=%d, want 50000000", eth0.RxBytes)
|
|
}
|
|
if eth0.RxErrs != 7 {
|
|
t.Errorf("eth0 RxErrs=%d, want 7", eth0.RxErrs)
|
|
}
|
|
if eth0.RxDrop != 12 {
|
|
t.Errorf("eth0 RxDrop=%d, want 12", eth0.RxDrop)
|
|
}
|
|
if eth0.TxBytes != 40000000 {
|
|
t.Errorf("eth0 TxBytes=%d, want 40000000", eth0.TxBytes)
|
|
}
|
|
if eth0.TxErrs != 3 {
|
|
t.Errorf("eth0 TxErrs=%d, want 3", eth0.TxErrs)
|
|
}
|
|
if eth0.TxDrop != 5 {
|
|
t.Errorf("eth0 TxDrop=%d, want 5", eth0.TxDrop)
|
|
}
|
|
if _, ok := byIface["lo"]; ok {
|
|
t.Errorf("lo should have been filtered out")
|
|
}
|
|
}
|
|
|
|
// TestParseNetDev_Empty: an empty reader returns no snapshots, not a
|
|
// crash. Callers treat nil as "no data" and skip the delta step.
|
|
func TestParseNetDev_Empty(t *testing.T) {
|
|
snaps := parseNetDev(strings.NewReader(""))
|
|
if len(snaps) != 0 {
|
|
t.Errorf("got %d snapshots from empty reader, want 0", len(snaps))
|
|
}
|
|
}
|
|
|
|
// TestParseNetDev_MalformedRow skips rows that don't have the expected
|
|
// 16 columns rather than panicking. A truncated line shouldn't hide the
|
|
// good rows that follow.
|
|
func TestParseNetDev_MalformedRow(t *testing.T) {
|
|
fixture := `header line 1
|
|
header line 2
|
|
bad0: 123 456
|
|
eth0: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
|
`
|
|
snaps := parseNetDev(strings.NewReader(fixture))
|
|
if len(snaps) != 1 {
|
|
t.Fatalf("got %d snapshots, want 1 (bad0 should be dropped)", len(snaps))
|
|
}
|
|
if snaps[0].Iface != "eth0" {
|
|
t.Errorf("got iface=%q, want eth0", snaps[0].Iface)
|
|
}
|
|
}
|