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
Fix notification queue race test
rcourtmanb0464b6c5923
diff --git a/internal/notifications/queue_test.go b/internal/notifications/queue_test.goindex 31f6ed8485..89c110f937 100644--- a/internal/notifications/queue_test.go+++ b/internal/notifications/queue_test.go@@ -798,6 +798,8 @@ func TestProcessNotification_NoProcessor(t *testing.T) {}defer func() { _ = nq.Stop() }()+ futureRetry := time.Now().Add(1 * time.Hour)+// Enqueue a notification first so IncrementAttemptAndSetStatus worksnotif := &QueuedNotification{ID: "test-no-processor",@@ -805,6 +807,7 @@ func TestProcessNotification_NoProcessor(t *testing.T) {Status: QueueStatusPending,MaxAttempts: 3,Config: []byte(`{}`),+ NextRetryAt: &futureRetry,}if err := nq.Enqueue(notif); err != nil {@@ -826,6 +829,8 @@ func TestProcessNotification_ProcessorSuccess(t *testing.T) {}defer func() { _ = nq.Stop() }()+ futureRetry := time.Now().Add(1 * time.Hour)+// Enqueue a notificationnotif := &QueuedNotification{ID: "test-success",@@ -833,6 +838,7 @@ func TestProcessNotification_ProcessorSuccess(t *testing.T) {Status: QueueStatusPending,MaxAttempts: 3,Config: []byte(`{}`),+ NextRetryAt: &futureRetry,}if err := nq.Enqueue(notif); err != nil {@@ -840,15 +846,20 @@ func TestProcessNotification_ProcessorSuccess(t *testing.T) {}// Set a processor that succeeds- processorCalled := false+ processorCalled := make(chan struct{}, 1)nq.SetProcessor(func(n *QueuedNotification) error {- processorCalled = true+ select {+ case processorCalled <- struct{}{}:+ default:+ }return nil})nq.processNotification(notif)- if !processorCalled {+ select {+ case <-processorCalled:+ default:t.Error("Processor was not called")}}@@ -859,6 +870,9 @@ func TestProcessNotification_ProcessorFailure(t *testing.T) {if err != nil {t.Fatalf("Failed to create notification queue: %v", err)}+ defer func() { _ = nq.Stop() }()++ futureRetry := time.Now().Add(1 * time.Hour)// Enqueue a notification with low max attemptsnotif := &QueuedNotification{@@ -867,6 +881,7 @@ func TestProcessNotification_ProcessorFailure(t *testing.T) {Status: QueueStatusPending,MaxAttempts: 1, // Only 1 attempt, so failure goes to DLQConfig: []byte(`{}`),+ NextRetryAt: &futureRetry,}if err := nq.Enqueue(notif); err != nil {@@ -889,6 +904,9 @@ func TestScanNotification_DLQWithTimestamps(t *testing.T) {if err != nil {t.Fatalf("Failed to create notification queue: %v", err)}+ defer func() { _ = nq.Stop() }()++ futureRetry := time.Now().Add(1 * time.Hour)// Enqueue a notification with max 1 attemptnotif := &QueuedNotification{@@ -897,6 +915,7 @@ func TestScanNotification_DLQWithTimestamps(t *testing.T) {Status: QueueStatusPending,MaxAttempts: 1, // Will go to DLQ on first failureConfig: []byte(`{"url":"http://example.com"}`),+ NextRetryAt: &futureRetry,}if err := nq.Enqueue(notif); err != nil {