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.

Match history compaction fixtures to existing canonical identity

pulse-triage[bot]9eb7f707f506
diff --git a/internal/alerts/history_retention_storage_test.go b/internal/alerts/history_retention_storage_test.go
index affada4416..33a4aee73d 100644
--- a/internal/alerts/history_retention_storage_test.go
+++ b/internal/alerts/history_retention_storage_test.go
@@ -13,7 +13,7 @@ import (
)
func retainedHistoryEntry(id string, at time.Time) HistoryEntry {
- return HistoryEntry{
+ entry := HistoryEntry{
Alert: Alert{
ID: id, CanonicalState: id, Type: "cpu", ResourceID: "guest-1",
Level: AlertLevelWarning, StartTime: at, LastSeen: at,
@@ -21,6 +21,11 @@ func retainedHistoryEntry(id string, at time.Time) HistoryEntry {
},
Timestamp: at,
}
+ // Compaction already backfills these scalar identity fields on changed
+ // histories. Compare like-for-like evidence, not a pre-normalized fixture
+ // with an intentionally normalized result.
+ backfillCanonicalIdentity(&entry.Alert)
+ return entry
}
func TestHistoryCleanupReleasesRemovedRowStorage(t *testing.T) {
@@ -112,7 +117,11 @@ func TestHistoryRemovalReleasesRemovedRowStorage(t *testing.T) {
func TestHistoryCompactionNoOpKeepsStorage(t *testing.T) {
hm := newTestHistoryManager(t)
- hm.history = []HistoryEntry{retainedHistoryEntry("current", time.Now())}
+ hm.history = []HistoryEntry{
+ retainedHistoryEntry("current", time.Now()),
+ {Alert: Alert{ID: "legacy", ResourceID: "guest-2", Type: "cpu"}, Timestamp: time.Now()},
+ }
+ want := append([]HistoryEntry(nil), hm.history...)
before := &hm.history[0]
hm.cleanOldEntries()
hm.RemoveAlert("absent")
@@ -120,6 +129,9 @@ func TestHistoryCompactionNoOpKeepsStorage(t *testing.T) {
if &hm.history[0] != before {
t.Fatal("unchanged cleanup replaced the current array")
}
+ if !reflect.DeepEqual(hm.history, want) {
+ t.Fatal("no-op compaction normalized or changed untouched occurrences")
+ }
}
func TestHistoryLoadCompactsRecoverySourcesWithoutWriting(t *testing.T) {