test(web_server): assert ws-ping invariant, not frozen 20.0 literal

The loopback ws-ping window is now 30s/60s (#48445/#50005), so the
hardcoded == 20.0 assertion was a change-detector that broke the moment
the loopback tuning landed. Assert the behavioral contract instead: ping
stays enabled (positive) and timeout >= interval.
This commit is contained in:
teknium1 2026-06-30 02:31:38 -07:00 committed by Teknium
parent db880186f2
commit eeb4735078

View file

@ -71,14 +71,21 @@ def _stub_uvicorn(monkeypatch):
def test_start_server_enables_ws_ping_for_half_open_detection(monkeypatch):
"""WS ping must be configured so half-open connections (reverse-proxy 524,
dropped tunnels) raise WebSocketDisconnect into the reaping path (#32377)."""
dropped tunnels) raise WebSocketDisconnect into the reaping path (#32377).
Loopback binds (the Desktop case) get a longer window to ride out
GIL-pressure event-loop stalls (#48445/#50005). The invariant asserted
here is that ping stays enabled (non-None, positive) and the timeout is
never shorter than the interval not a frozen literal, which churns every
time the window is retuned."""
captured = _stub_uvicorn(monkeypatch)
# Loopback bind => no auth gate, so this reaches the Config constructor.
web_server.start_server(host="127.0.0.1", port=0, open_browser=False)
assert captured["ws_ping_interval"] == 20.0
assert captured["ws_ping_timeout"] == 20.0
assert captured["ws_ping_interval"] and captured["ws_ping_interval"] > 0
assert captured["ws_ping_timeout"] and captured["ws_ping_timeout"] > 0
assert captured["ws_ping_timeout"] >= captured["ws_ping_interval"]
def test_start_server_runs_on_uvicorns_loop_factory(monkeypatch):