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: retry live terminal alerts before resolving acceptance fixture

pulse-triage[bot]eb88aa7be27f
diff --git a/tests/qualification/alert-lifecycle/README.md b/tests/qualification/alert-lifecycle/README.md
index a72902622e..16cc2bc93d 100644
--- a/tests/qualification/alert-lifecycle/README.md
+++ b/tests/qualification/alert-lifecycle/README.md
@@ -76,10 +76,12 @@ HTTP redirects are disabled for the authenticated client.
3. Indefinite HTTP503 until a dead-letter audit appears (600s deadline); retain
the exact notification IDs and occurrence-specific incident timeline.
4. Actual operator-owned restart; require retained incident ID and terminal
- audit, then low CPU to clear and high CPU for a distinct recurrence.
+ audit. Keep this occurrence firing for the operator Retry.
5. Global terminal Retry; require the **original terminal notification ID** to
- gain a sent audit and two distinct delivered occurrence start times. Retain
- old and current incident timelines separately.
+ gain a sent audit **before resolution**. Then low CPU clears and high CPU
+ creates a distinct recurrence; require its exact start time at the recipient.
+ Retain old and current timelines separately. Resolution deliberately cancels
+ obsolete terminal firing rows, so do not expect Retry to resurrect them.
6. Disable agent alerts; ingest a fresh high-CPU identity for 30s and require
no CPU alert or successful alert delivery for that identity.
7. Re-enable agent alerts, exhaust that identity (another 600s bound), Dismiss
@@ -96,7 +98,9 @@ escalation and resolved notifications to isolate these scenarios.
A zero exit means only the named assertions passed. The result deliberately
keeps `installed_acceptance_complete: false`. Review all receipt/snapshot files,
-including failures. Do not infer that the entire release is qualified.
+including failures. The original installed probe incorrectly expected replay after
+resolution; retain that failed attempt rather than reclassifying it as a pass.
+Do not infer that the entire release is qualified.
Still separate: recurrence timeline side-effect correctness (historical replay
must not mark the new occurrence delivered), retirement of the visible system
diff --git a/tests/qualification/alert-lifecycle/acceptance.py b/tests/qualification/alert-lifecycle/acceptance.py
index 3bfa0438a2..f15277a781 100644
--- a/tests/qualification/alert-lifecycle/acceptance.py
+++ b/tests/qualification/alert-lifecycle/acceptance.py
@@ -190,6 +190,15 @@ class Driver:
return [e for e in entries if alert["id"] in (e["alertIds"] or [])
and e["outcome"] == outcome]
+ def retry_terminal(self, alert, terminal_ids):
+ retry = self.api("/api/notifications/terminal-failures/retry", {})
+ # Preserve the returned result even when the assertion fails.
+ self.evidence.save("retry-response", retry)
+ check(retry.get("affected", 0) >= 1, "no terminal retry admitted")
+ self.wait("terminal-retry-sent", lambda: any(
+ entry["notificationId"] in terminal_ids
+ for entry in self.delivery(alert, "sent")))
+
def run(self):
# Operator supplies independent immutable image inspection, not an API version claim.
identity = json.loads(Path(self.args.identity).read_text())
@@ -252,22 +261,21 @@ class Driver:
check(self.delivery(old, "dead_letter"), "terminal audit lost at restart")
self.results.append("restart-preserved-terminal-and-incident")
+ # Retry while the occurrence is still firing. Resolution intentionally
+ # cancels obsolete terminal firing rows; a later recurrence cannot revive them.
+ self.recipient.mode(0)
+ self.retry_terminal(old, terminal_ids)
+ self.snapshot("old-occurrence-after-retry", old)
self.wait("resolved", lambda: not self.active(terminal),
tick=lambda: self.ingest(terminal, 10))
current = self.wait("recurrence", lambda: self.active(terminal),
tick=lambda: self.ingest(terminal, 95))
check(current["startTime"] != old["startTime"], "recurrence reused old start")
- self.snapshot("recurrence-before-replay", current)
- self.recipient.mode(0)
- retry = self.api("/api/notifications/terminal-failures/retry", {})
- check(retry.get("affected", 0) >= 1, "no terminal retry admitted")
- self.evidence.save("retry-response", retry)
- self.wait("historical-retry-sent", lambda: any(
- entry["notificationId"] in terminal_ids for entry in self.delivery(old, "sent")))
- self.wait("recurrence-recipient", lambda: len({
- r["payload"]["start"] for r in self.recipient.matching(terminal)}) >= 2)
- self.snapshot("old-occurrence-after-replay", old)
- self.snapshot("current-occurrence-after-replay", current)
+ self.wait("recurrence-recipient", lambda: any(
+ r["payload"]["start"] == current["startTime"]
+ for r in self.recipient.matching(terminal)))
+ self.snapshot("old-occurrence-after-recurrence", old)
+ self.snapshot("current-occurrence-after-recurrence", current)
# Occurrence-side-effect correctness requires review of both retained timelines.
config["disableAllAgents"] = True
self.api("/api/alerts/config", config, "PUT")
diff --git a/tests/qualification/alert-lifecycle/test_acceptance.py b/tests/qualification/alert-lifecycle/test_acceptance.py
index 1a25e49708..15df21919c 100644
--- a/tests/qualification/alert-lifecycle/test_acceptance.py
+++ b/tests/qualification/alert-lifecycle/test_acceptance.py
@@ -1,4 +1,7 @@
import argparse
+import ast
+import inspect
+import textwrap
import json
import io
import os
@@ -77,6 +80,44 @@ class AcceptanceContractTests(unittest.TestCase):
with patch.dict(os.environ, {"PULSE_ACCEPTANCE_TOKEN": "synthetic-secret"}):
return a.Driver(args, self.evidence, a.Recipient(self.evidence))
+ def test_retry_precedes_resolution_in_scenario(self):
+ # Guard scenario ordering separately from the recipient/identity proof.
+ tree = ast.parse(textwrap.dedent(inspect.getsource(a.Driver.run)))
+ retry_lines = [n.lineno for n in ast.walk(tree) if isinstance(n, ast.Call)
+ and isinstance(n.func, ast.Attribute)
+ and n.func.attr == "retry_terminal"]
+ resolved_lines = [n.lineno for n in ast.walk(tree) if isinstance(n, ast.Call)
+ and isinstance(n.func, ast.Attribute) and n.func.attr == "wait"
+ and n.args and isinstance(n.args[0], ast.Constant)
+ and n.args[0].value == "resolved"]
+ self.assertEqual(len(retry_lines), 1)
+ self.assertEqual(len(resolved_lines), 1)
+ self.assertLess(retry_lines[0], resolved_lines[0])
+
+ def test_retry_retains_zero_response_before_failure(self):
+ driver = self.driver()
+ with patch.object(driver, "api", return_value={"success": True, "affected": 0}):
+ with self.assertRaisesRegex(AssertionError, "no terminal retry admitted"):
+ driver.retry_terminal({"id": "alert"}, {"original"})
+ files = list(self.evidence.directory.glob("*retry-response.json"))
+ self.assertEqual(len(files), 1)
+ self.assertEqual(json.loads(files[0].read_text())["affected"], 0)
+
+ def test_retry_requires_original_notification_identity(self):
+ driver = self.driver()
+ with patch.object(driver, "api", return_value={"success": True, "affected": 1}), \
+ patch.object(driver, "delivery", return_value=[{"notificationId": "other"}]), \
+ patch.object(a.time, "monotonic", side_effect=[0, 100]):
+ with self.assertRaises(TimeoutError):
+ driver.retry_terminal({"id": "alert"}, {"original"})
+
+ def test_retry_original_notification_succeeds(self):
+ driver = self.driver()
+ with patch.object(driver, "api", return_value={"success": True, "affected": 1}), \
+ patch.object(driver, "delivery", return_value=[{"notificationId": "original"}]):
+ driver.retry_terminal({"id": "alert"}, {"original"})
+ self.assertIn("terminal-retry-sent", driver.results)
+
def test_deadline_fails_instead_of_passing_empty_observation(self):
driver = self.driver()
with patch.object(a.time, "monotonic", side_effect=[0, 2]):