feat(reporter): add drift event and heal-attempt counters to state snapshot
This commit is contained in:
1 parent
a2030a71b7
commit
8c7b0768b0
4 files changed
+29
No files matched your search
@@ -69,6 +69,7 @@ class ReporterStateTests(unittest.TestCase):
|
||||
|
||||
reporter.update_status(True, 1, checks_increment=1)
|
||||
reporter.update_status(True, 1, checks_increment=1)
|
||||
reporter.update_status(False, 1, drift_events_increment=1)
|
||||
reporter.update_status(False, 1, heal_result="failed")
|
||||
reporter.update_status(True, 1, heal_result="success")
|
||||
|
||||
@@ -76,6 +77,8 @@ class ReporterStateTests(unittest.TestCase):
|
||||
payload = json.load(f)
|
||||
|
||||
self.assertEqual(2, payload["checks_total"])
|
||||
self.assertEqual(1, payload["drift_events_total"])
|
||||
self.assertEqual(2, payload["drift_heal_attempts_total"])
|
||||
self.assertEqual(2, payload["heals_total"])
|
||||
self.assertEqual(1, payload["heal_failures_total"])
|
||||
self.assertEqual("success", payload["last_heal_result"])
|
||||
@@ -83,6 +86,21 @@ class ReporterStateTests(unittest.TestCase):
|
||||
datetime.fromisoformat(payload["last_heal_timestamp"])
|
||||
self.assertGreaterEqual(payload["uptime_seconds"], 0)
|
||||
|
||||
def test_update_status_can_show_suppressed_heal_gap(self):
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
state_file = os.path.join(tmp_dir, "state.json")
|
||||
reporter = LocalStateReporter(state_file=state_file, node_name="n1")
|
||||
|
||||
reporter.update_status(False, 5, checks_increment=1, drift_events_increment=1)
|
||||
reporter.update_status(False, 5, checks_increment=1, drift_events_increment=1)
|
||||
reporter.update_status(False, 5, heal_result="failed")
|
||||
|
||||
with open(state_file, "r") as f:
|
||||
payload = json.load(f)
|
||||
|
||||
self.assertEqual(2, payload["drift_events_total"])
|
||||
self.assertEqual(1, payload["drift_heal_attempts_total"])
|
||||
|
||||
def test_update_status_preserves_last_heal_timestamp_when_no_new_heal(self):
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
state_file = os.path.join(tmp_dir, "state.json")
|
||||
|
||||
Reference in new issue
Block a user