hub 0.167.0 + DooPlex push: the hub DB snapshot every 6 hours (D34, operator yes 2026-10-23, R-232 G5) — slots 02/08/14/20, catch-up 6 h, push :30 after each, refuse a copy older than 2 h; tests red-proved
gates / gates (push) Successful in 16m20s
gates / gates (push) Successful in 16m20s
This commit is contained in:
1 parent
83388c088a
commit
be7e97dc1a
8 files changed
+111
-28
No files matched your search
@@ -8,6 +8,7 @@ was written. Run: python3 scripts/hub-db-backup/test_hub_db_backup.py
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sqlite3
|
||||
import stat
|
||||
@@ -184,6 +185,15 @@ class Push(Base):
|
||||
self.assertEqual(self.pushed(), [])
|
||||
self.assertFalse(self.signal("felhom_hub_db_backup.prom"))
|
||||
|
||||
def test_d34_a_missed_slot_is_not_pushed_again(self):
|
||||
# D34: snapshots every 6 h, so a newest copy 3 h old means the hub missed a slot — refuse, as for a day
|
||||
self.snapshot(age_s=3 * 3600)
|
||||
r = self.run_script(PUSH)
|
||||
self.assertNotEqual(r.returncode, 0)
|
||||
self.assertIn("stopped snapshotting", r.stderr)
|
||||
self.assertEqual(self.pushed(), [])
|
||||
self.assertFalse(self.signal("felhom_hub_db_backup.prom"))
|
||||
|
||||
def test_truncated_copy_is_not_pushed(self):
|
||||
self.snapshot()
|
||||
r = self.run_script(PUSH, FAKE_TRUNCATE="1")
|
||||
@@ -268,7 +278,14 @@ class Units(unittest.TestCase):
|
||||
return open(os.path.join(HERE, n)).read()
|
||||
|
||||
def test_schedules(self):
|
||||
self.assertIn("OnCalendar=*-*-* 02:30:00", self.read("felhom-hub-db-backup.timer"))
|
||||
# D34: the push runs :30 after EVERY hub snapshot slot — read from the hub's own source, so a slot moved on
|
||||
# one side only fails here (RED-PROOF: drop one OnCalendar line, or change a hub slot → fails).
|
||||
src = open(os.path.join(HERE, "..", "..", "hub", "internal", "dbsnap", "dbsnap.go")).read()
|
||||
slots = re.findall(r'"(\d\d):(\d\d)"', re.search(r"var Slots = \[\]string\{([^}]*)\}", src).group(1))
|
||||
self.assertEqual(len(slots), 4)
|
||||
want = sorted("OnCalendar=*-*-* %02d:%02d:00" % (int(h), int(m) + 30) for h, m in slots)
|
||||
got = sorted(l.strip() for l in self.read("felhom-hub-db-backup.timer").splitlines() if l.startswith("OnCalendar="))
|
||||
self.assertEqual(got, want)
|
||||
self.assertIn("OnCalendar=Sun *-*-* 04:30:00", self.read("felhom-hub-db-restore-test.timer"))
|
||||
|
||||
def test_units_run_the_installed_scripts(self):
|
||||
|
||||
Reference in new issue
Block a user