From acc1f43aafbbb3592a5b586ccf8b6051fe956ce8 Mon Sep 17 00:00:00 2001 From: "pulse-triage[bot]" <249995291+pulse-triage[bot]@users.noreply.github.com> Date: Sat, 5 Sep 2026 04:03:33 +0100 Subject: [PATCH] test(monitoring): verify firing and recovery webhook identity The powered-off recovery integration test previously discarded the firing payload, so it could pass even when the initial delivery named the wrong incident. Assert the grouped firing envelope contains exactly the active alert before checking recovery identity through the real loopback HTTP receiver. Change-source: pulse-maintainer --- .../monitoring/monitor_alert_handling_test.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/internal/monitoring/monitor_alert_handling_test.go b/internal/monitoring/monitor_alert_handling_test.go index de717819e..7c61f5146 100644 --- a/internal/monitoring/monitor_alert_handling_test.go +++ b/internal/monitoring/monitor_alert_handling_test.go @@ -684,8 +684,21 @@ func TestMonitor_HandleAlertResolved_SendsRecoveryForGuestPoweredOffState(t *tes alertMgr.CheckGuest(vm, vm.Instance) alertMgr.CheckGuest(vm, vm.Instance) + // Firing uses the grouped envelope even with a zero grouping window. + var firingPayload struct { + Grouped bool `json:"grouped"` + Alerts []struct { + ID string `json:"id"` + } `json:"alerts"` + } select { - case <-received: + case body := <-received: + if err := json.Unmarshal(body, &firingPayload); err != nil { + t.Fatalf("failed to parse firing webhook payload: %v", err) + } + if !firingPayload.Grouped || len(firingPayload.Alerts) != 1 { + t.Fatalf("expected one grouped firing alert, got %+v", firingPayload) + } case <-time.After(5 * time.Second): t.Fatalf("timed out waiting for initial powered-off notification webhook") } @@ -695,6 +708,9 @@ func TestMonitor_HandleAlertResolved_SendsRecoveryForGuestPoweredOffState(t *tes t.Fatalf("expected one active powered-off alert, got %#v", activeAlerts) } alertID := activeAlerts[0].ID + if firingPayload.Alerts[0].ID != alertID { + t.Fatalf("expected firing webhook alert ID=%q, got %q", alertID, firingPayload.Alerts[0].ID) + } if activeAlerts[0].LastNotified == nil { t.Fatalf("expected powered-off alert %q to record firing notification time", alertID) }