Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
test: qualify unequal CPU reporting windows and collector replacement
pulse-triage[bot]fc80229b1b0b
diff --git a/internal/hostmetrics/issue1894_interleaved_collectors_test.go b/internal/hostmetrics/issue1894_interleaved_collectors_test.goindex 9821f95084..59ccd5240b 100644--- a/internal/hostmetrics/issue1894_interleaved_collectors_test.go+++ b/internal/hostmetrics/issue1894_interleaved_collectors_test.go@@ -131,4 +131,54 @@ func TestIssue1894InterleavedCollectors(t *testing.T) {if spots != 2 {t.Fatalf("spot samples = %d, want startup only (2)", spots)}++ // Docker now misses a report while host continues. These unequal windows+ // deliberately have different averages: a cached process-wide percentage+ // would pass the equal-cadence checks above but fail here.+ samples = append(samples,+ gocpu.TimesStat{User: 112, Idle: 1168}, // host: 6/60 = 10%+ gocpu.TimesStat{User: 130, Idle: 1210}, // host: 18/60 = 30%+ gocpu.TimesStat{User: 130.8, Idle: 1210.2}, // Docker: 24/120 = 20%+ gocpu.TimesStat{User: 131.6, Idle: 1210.4}, // replacement Docker startup+ gocpu.TimesStat{User: 136, Idle: 1264}, // host: 6/60 = 10%+ gocpu.TimesStat{User: 137.6, Idle: 1264.4}, // replacement: 6/60 = 10%+ )+ check := func(name string, collector *Collector, filtered bool, want float64, wantSpots int) {+ t.Helper()+ var got float64+ if filtered {+ snapshot, err := collector.CollectWithDiskFilters(context.Background(), nil, []string{"/"})+ if err != nil {+ t.Fatal(err)+ }+ got = snapshot.CPUUsagePercent+ } else {+ snapshot, err := collector.Collect(context.Background(), nil)+ if err != nil {+ t.Fatal(err)+ }+ got = snapshot.CPUUsagePercent+ }+ if math.Abs(got-want) > 1e-9 {+ t.Fatalf("%s: CPU = %v, want %v", name, got, want)+ }+ if spots != wantSpots {+ t.Fatalf("%s: spot samples = %d, want %d", name, spots, wantSpots)+ }+ }+ check("host while Docker skips", &host, false, 10, 2)+ check("host next interval", &host, false, 30, 2)+ check("Docker double interval", &docker, true, 20, 2)++ // Replacing one reporting loop must neither inherit its old baseline nor+ // reset the still-running loop. This models module replacement, not a+ // whole-process restart or installed-agent qualification.+ docker = Collector{}+ check("replacement Docker startup", &docker, true, 80, 3)+ check("host survives Docker replacement", &host, false, 10, 3)+ check("replacement Docker full interval", &docker, true, 10, 3)+ if index != len(samples) {+ t.Fatalf("consumed %d samples, want %d", index, len(samples))+ }+}