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.

Fix monitoring test panic and goroutine leaks

rcourtman754e9d1abda6
diff --git a/internal/monitoring/monitor_docker_test.go b/internal/monitoring/monitor_docker_test.go
index 33547e2130..575c585673 100644
--- a/internal/monitoring/monitor_docker_test.go
+++ b/internal/monitoring/monitor_docker_test.go
@@ -13,7 +13,7 @@ import (
func newTestMonitor(t *testing.T) *Monitor {
t.Helper()
- return &Monitor{
+ m := &Monitor{
state: models.NewState(),
alertManager: alerts.NewManager(),
removedDockerHosts: make(map[string]time.Time),
@@ -21,6 +21,8 @@ func newTestMonitor(t *testing.T) *Monitor {
dockerTokenBindings: make(map[string]string),
dockerMetadataStore: config.NewDockerMetadataStore(t.TempDir()),
}
+ t.Cleanup(func() { m.alertManager.Stop() })
+ return m
}
func TestApplyDockerReportGeneratesUniqueIDsForCollidingHosts(t *testing.T) {
diff --git a/internal/monitoring/monitor_memory_test.go b/internal/monitoring/monitor_memory_test.go
index d3a850aa3d..c610640a9e 100644
--- a/internal/monitoring/monitor_memory_test.go
+++ b/internal/monitoring/monitor_memory_test.go
@@ -191,6 +191,7 @@ func TestPollPVEInstanceUsesRRDMemUsedFallback(t *testing.T) {
dlqInsightMap: make(map[string]*dlqInsight),
authFailures: make(map[string]int),
lastAuthAttempt: make(map[string]time.Time),
+ nodeLastOnline: make(map[string]time.Time),
}
defer mon.alertManager.Stop()
defer mon.notificationMgr.Stop()