Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

test(alerts): cover storage recurrence across persistent restarts

pulse-triage[bot]5aa9d44b0a3f
diff --git a/internal/alerts/storage_restart_test.go b/internal/alerts/storage_restart_test.go
index dd7b9d5853..5e1a7ae717 100644
--- a/internal/alerts/storage_restart_test.go
+++ b/internal/alerts/storage_restart_test.go
@@ -79,6 +79,48 @@ func TestStorageRecoveryAcrossRestart(t *testing.T) {
if testHasActiveAlert(t, m, id) {
t.Fatal("empty observation recreated resolved incident")
}
+
+ // Metric recovery followed by renewed pressure starts a fresh
+ // occurrence; discrete-alert refire retention does not apply.
+ s.Usage, s.Used, s.Free = 90, 900, 100
+ for range 5 {
+ m.CheckStorage(s)
+ }
+ recurrent := testRequireActiveAlert(t, m, id)
+ if !recurrent.StartTime.After(original.StartTime) || recurrent.Value != 90 {
+ t.Fatalf("recurrence reused the resolved start or lost fresh measurement: %+v", recurrent)
+ }
+ if got := len(m.GetActiveAlerts()); got != 1 {
+ t.Fatalf("recurrence created %d active incidents, want 1", got)
+ }
+ recurrenceStart := recurrent.StartTime
+ if err := m.SaveActiveAlerts(); err != nil {
+ t.Fatal(err)
+ }
+ m.Stop()
+
+ m = start()
+ recurrent = testRequireActiveAlert(t, m, id)
+ if !recurrent.StartTime.Equal(recurrenceStart) || recurrent.Value != 90 {
+ t.Fatalf("recurrent incident did not survive another restart: %+v", recurrent)
+ }
+ s.Usage, s.Total, s.Used, s.Free = 0, 0, 0, 0
+ for range 5 {
+ m.CheckStorage(s)
+ }
+ if retained := testRequireActiveAlert(t, m, id); !retained.StartTime.Equal(recurrenceStart) || retained.Value != 90 {
+ t.Fatalf("missing capacity changed recurrent incident: %+v", retained)
+ }
+ s.Total, s.Free = 1000, 1000
+ for range 5 {
+ m.CheckStorage(s)
+ }
+ if testHasActiveAlert(t, m, id) {
+ t.Fatal("confirmed empty capacity did not resolve recurrence")
+ }
+ if resolved := m.GetResolvedAlert(id); resolved == nil || !resolved.StartTime.Equal(recurrenceStart) || resolved.Value != 0 {
+ t.Fatalf("recovery resolved the wrong occurrence: %+v", resolved)
+ }
})
}
}