feat(reporter): add uptime and fleet counters to state snapshot
This commit is contained in:
1 parent
7f323ed78b
commit
3b1e25d5cd
6 files changed
+55
-6
No files matched your search
@@ -61,6 +61,25 @@ class ReporterStateTests(unittest.TestCase):
|
||||
self.assertEqual("success", payload["last_heal_result"])
|
||||
self.assertEqual("", payload["last_drift_fingerprint"])
|
||||
|
||||
def test_update_status_tracks_checks_and_heal_counters(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(True, 1, checks_increment=1)
|
||||
reporter.update_status(True, 1, checks_increment=1)
|
||||
reporter.update_status(False, 1, heal_result="failed")
|
||||
reporter.update_status(True, 1, heal_result="success")
|
||||
|
||||
with open(state_file, "r") as f:
|
||||
payload = json.load(f)
|
||||
|
||||
self.assertEqual(2, payload["checks_total"])
|
||||
self.assertEqual(2, payload["heals_total"])
|
||||
self.assertEqual(1, payload["heal_failures_total"])
|
||||
self.assertEqual("success", payload["last_heal_result"])
|
||||
self.assertGreaterEqual(payload["uptime_seconds"], 0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user