feat(reporter): track last_heal_timestamp in state snapshot
This commit is contained in:
1 parent
3b1e25d5cd
commit
a2030a71b7
2 files changed
+28
No files matched your search
@@ -2,6 +2,7 @@ import json
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
from datetime import datetime
|
||||
|
||||
from reporter import LocalStateReporter
|
||||
|
||||
@@ -78,8 +79,26 @@ class ReporterStateTests(unittest.TestCase):
|
||||
self.assertEqual(2, payload["heals_total"])
|
||||
self.assertEqual(1, payload["heal_failures_total"])
|
||||
self.assertEqual("success", payload["last_heal_result"])
|
||||
self.assertIn("last_heal_timestamp", payload)
|
||||
datetime.fromisoformat(payload["last_heal_timestamp"])
|
||||
self.assertGreaterEqual(payload["uptime_seconds"], 0)
|
||||
|
||||
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")
|
||||
reporter = LocalStateReporter(state_file=state_file, node_name="n1")
|
||||
|
||||
reporter.update_status(False, 1, heal_result="failed")
|
||||
with open(state_file, "r") as f:
|
||||
first_payload = json.load(f)
|
||||
first_ts = first_payload["last_heal_timestamp"]
|
||||
|
||||
reporter.update_status(True, 1, checks_increment=1)
|
||||
with open(state_file, "r") as f:
|
||||
second_payload = json.load(f)
|
||||
|
||||
self.assertEqual(first_ts, second_payload["last_heal_timestamp"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user