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

This commit is contained in:
admin committed 2026-10-23 09:12:08 +02:00
1 parent 83388c088a
commit be7e97dc1a
8 files changed
+111 -28

No files matched your search

+9
View File
@@ -26,6 +26,15 @@ import (
// grown to 2 GiB for it, operator choice 2026-10-05).
const Keep = 2
// Slots are the Budapest times the hub writes a snapshot — every 6 hours (D34, operator yes 2026-10-23, R-232 G5).
// DooPlex's felhom-hub-db-backup.timer pushes the newest at :30 after each slot, so the off-site copy is at most
// about 6.5 h old instead of a day. Pinned by TestD34_SlotsAreEverySixHours and cmd/hub TestR173_MainSchedulesTheDBSnapshot.
var Slots = []string{"02:00", "08:00", "14:00", "20:00"}
// CatchUpAge is the start-up catch-up limit: a pod that was down at a slot writes one at start when the newest is
// older than one slot gap. Pinned by TestD34_SlotsAreEverySixHours.
const CatchUpAge = 6 * time.Hour
// Prefix and Suffix make a snapshot's file name: hub-20261005T020000Z.db.
const (
Prefix = "hub-"
+40
View File
@@ -206,3 +206,43 @@ func TestNeedsCatchUp(t *testing.T) {
t.Error("25 h old: want catch-up")
}
}
// D34 (operator yes 2026-10-23): a snapshot every 6 hours. The consequence pinned: no gap between two slots — the
// wrap past midnight included — is longer than CatchUpAge, so the off-site copy (pushed :30 after each slot) is never
// more than one slot gap behind; 02:00 stays a slot (the nightly restore test and the runbook read it); the start-up
// catch-up fires for a pod that missed exactly one slot. RED-PROOF: drop a slot, or set CatchUpAge to 24 h → fails.
func TestD34_SlotsAreEverySixHours(t *testing.T) {
if len(Slots) != 4 {
t.Fatalf("Slots = %v, want 4 (every 6 h)", Slots)
}
var mins []int
has0200 := false
for _, s := range Slots {
tm, err := time.Parse("15:04", s)
if err != nil {
t.Fatalf("slot %q: %v", s, err)
}
mins = append(mins, tm.Hour()*60+tm.Minute())
has0200 = has0200 || s == "02:00"
}
if !has0200 {
t.Error("02:00 is not a slot")
}
for i := range mins {
next := mins[(i+1)%len(mins)]
if i == len(mins)-1 {
next += 24 * 60
}
if gap := time.Duration(next-mins[i]) * time.Minute; gap <= 0 || gap > CatchUpAge {
t.Errorf("gap after %s is %s (want 0 < gap <= %s)", Slots[i], gap, CatchUpAge)
}
}
dir := t.TempDir()
_ = os.WriteFile(filepath.Join(dir, "hub-20261023T000000Z.db"), nil, 0o600) // 02:00 Budapest (CEST)
if !NeedsCatchUp(dir, time.Date(2026, 10, 23, 7, 0, 1, 0, time.UTC), CatchUpAge) {
t.Error("a pod up at 09:00 CEST that missed the 08:00 slot (newest 7 h old): want catch-up")
}
if NeedsCatchUp(dir, time.Date(2026, 10, 23, 5, 0, 0, 0, time.UTC), CatchUpAge) {
t.Error("newest 5 h old: want no catch-up")
}
}