fix(server): restore keeps connectivity alert for connections dropped to unknown
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uc9V1v7iXruubpoLiSE24M
This commit is contained in:
@@ -171,3 +171,49 @@ def test_restore_skips_absent_and_sets_no_alert_for_simplex():
|
||||
c.cancel_overdue_timer()
|
||||
|
||||
asyncio.run(scenario())
|
||||
|
||||
|
||||
def _past_drop(conn):
|
||||
conn.state, conn.statetime = C.OVERDUE, time.time() - (udp.DROPOVERDUE + 10)
|
||||
|
||||
|
||||
def test_restore_past_drop_window_keeps_alert_single_family():
|
||||
ctx = _ctx()
|
||||
|
||||
async def scenario():
|
||||
_fresh("pres-drop-single")
|
||||
_send("pres-drop-single", "127.0.0.1", ctx)
|
||||
h = hbdclass.Host.hosts["pres-drop-single"]
|
||||
_past_drop(h.connections["IPv4"])
|
||||
udp.restore_connection_timers(hbdclass, ctx)
|
||||
assert h.connections["IPv4"].state == C.UNKNOWN
|
||||
assert "connectivity.IPv4" in h.alert_states
|
||||
|
||||
asyncio.run(scenario())
|
||||
|
||||
|
||||
def test_restore_past_drop_window_keeps_alerts_dual_family():
|
||||
ctx = _ctx()
|
||||
|
||||
async def scenario():
|
||||
h = _dual_stack("pres-drop-dual", ctx)
|
||||
for c in h.connections.values():
|
||||
_past_drop(c)
|
||||
udp.restore_connection_timers(hbdclass, ctx)
|
||||
assert {"connectivity.IPv4", "connectivity.IPv6"} <= set(h.alert_states)
|
||||
|
||||
asyncio.run(scenario())
|
||||
|
||||
|
||||
def test_v4_only_host_overdue_is_single_critical(monkeypatch):
|
||||
events = _events(monkeypatch)
|
||||
ctx = _ctx()
|
||||
_fresh("pres-v4only")
|
||||
_send("pres-v4only", "127.0.0.1", ctx)
|
||||
h = hbdclass.Host.hosts["pres-v4only"]
|
||||
on_overdue, _ = udp._make_timer_callbacks("pres-v4only", h, ctx)
|
||||
asyncio.run(on_overdue(h.connections["IPv4"]))
|
||||
assert [e for e in events if e[0] == "CRITICAL"] == [("CRITICAL", "IPv4 overdue")]
|
||||
assert "connectivity.IPv4" in h.alert_states
|
||||
asyncio.run(on_overdue(h.connections["IPv4"]))
|
||||
assert len([e for e in events if e[0] == "CRITICAL"]) == 1
|
||||
|
||||
Reference in New Issue
Block a user