R-1352: the does-not-answer alarm is not mailed after the restart mail of the same episode. Hub commit only.
gates / gates (push) Successful in 1m56s

This commit is contained in:
admin committed 2026-11-02 23:16:16 +01:00
1 parent a560e69954
commit 2f7e836f68
3 files changed
+74 -1

No files matched your search

@@ -221,3 +221,54 @@ func TestControllerSupervisorChecker_UnresponsiveTextFollowsTheAgent(t *testing.
}
}
}
// R-1352: the alarm and the restart of ONE episode reach the hub in one report (they lie 2 minutes apart, reports 15). The
// restart mail says all of it; the alarm „the agent restarts it in 2 minutes" after it reads backwards and is not mailed.
// Seen live 2026-10-30 (R-1344's proof on Tester 1).
//
// RED-PROOF (2026-11-02): before the fix this fails on „got [controller_unresponsive_restart/warning
// controller_unresponsive/warning]".
func TestR1352_TheAlarmOfAnEpisodeIsNotMailedAfterItsRestart(t *testing.T) {
st := newCapStore(t)
rec := &evRec{}
c := NewControllerSupervisorChecker(st, rec.fn, log.New(io.Discard, "", 0))
st.SaveHostReport("h1", "c1", supReport(`[{"vmid":9201,"restarts_total":0,"crashloop":false,"parked":false}]`), store.HostReportDenorm{})
c.Check()
rec.take()
st.SaveHostReport("h1", "c1", supReport(`[{"vmid":9201,"restarts_total":1,"last_restart_at":"2026-10-30T09:31:22Z","last_reason":"did not answer","crashloop":false,"parked":false,"unresponsive":false,"unresponsive_since":"2026-10-30T09:29:21Z","unresponsive_restart_after_s":120,"unresponsive_restart_at":"2026-10-30T09:31:22Z"}]`), store.HostReportDenorm{})
c.Check()
if evs := rec.take(); len(evs) != 1 || evs[0] != "controller_unresponsive_restart/warning" {
t.Fatalf("got %v, want exactly [controller_unresponsive_restart/warning]", evs)
}
}
// A NEW episode that began after the restart, in the same report, still alarms: it has had no restart yet.
func TestR1352_ANewEpisodeAfterTheRestartStillAlarms(t *testing.T) {
st := newCapStore(t)
rec := &evRec{}
c := NewControllerSupervisorChecker(st, rec.fn, log.New(io.Discard, "", 0))
st.SaveHostReport("h1", "c1", supReport(`[{"vmid":9201,"restarts_total":0,"crashloop":false,"parked":false}]`), store.HostReportDenorm{})
c.Check()
rec.take()
st.SaveHostReport("h1", "c1", supReport(`[{"vmid":9201,"restarts_total":1,"last_restart_at":"2026-10-30T09:31:22Z","last_reason":"did not answer","crashloop":false,"parked":false,"unresponsive":true,"unresponsive_since":"2026-10-30T09:40:00Z","unresponsive_restart_after_s":120,"unresponsive_restart_at":"2026-10-30T09:31:22Z"}]`), store.HostReportDenorm{})
c.Check()
evs := strings.Join(rec.take(), " ")
if !strings.Contains(evs, "controller_unresponsive_restart/warning") || !strings.Contains(evs, "controller_unresponsive/warning") {
t.Fatalf("got %q, want the restart AND the new episode's alarm", evs)
}
}
// An alarm with no restart is unchanged (control).
func TestR1352_AnAlarmAloneStillMails(t *testing.T) {
st := newCapStore(t)
rec := &evRec{}
c := NewControllerSupervisorChecker(st, rec.fn, log.New(io.Discard, "", 0))
st.SaveHostReport("h1", "c1", supReport(`[{"vmid":9201,"restarts_total":0,"crashloop":false,"parked":false}]`), store.HostReportDenorm{})
c.Check()
rec.take()
st.SaveHostReport("h1", "c1", supReport(`[{"vmid":9201,"restarts_total":0,"crashloop":false,"parked":false,"unresponsive":true,"unresponsive_since":"2026-10-30T09:29:21Z","unresponsive_restart_after_s":120}]`), store.HostReportDenorm{})
c.Check()
if evs := rec.take(); len(evs) != 1 || evs[0] != "controller_unresponsive/warning" {
t.Fatalf("got %v, want exactly the alarm", evs)
}
}