fix(connection): reconnect decision closes the failed socket (health_check's documented role) + symmetric backoff-bound test assertion (F3, F5)
This commit is contained in:
1 parent
24981d84a8
commit
9c409b3805
2 files changed
+27
-5
No files matched your search
@@ -219,8 +219,8 @@ class TestReconnectBackoff:
|
||||
# 5→10→20→40→80→160→300 growth with easing; the last must not exceed
|
||||
# the cap (with jitter).
|
||||
assert max(delays) <= 300.0 * 1.25
|
||||
assert delays[1] > delays[0] * 1.5
|
||||
assert delays[-1] < 300.0 * 1.25
|
||||
assert delays[1] >= delays[0] * 1.5
|
||||
assert delays[-1] <= 300.0 * 1.25
|
||||
|
||||
async def test_repeated_failures_do_not_spam_listeners(self):
|
||||
poller = FakePoller()
|
||||
@@ -245,6 +245,21 @@ class TestReconnectBackoff:
|
||||
assert manager._failures == 0
|
||||
assert await manager._watchdog_cycle(5.0) == ADB_POLL_INTERVAL
|
||||
|
||||
async def test_failed_wake_poll_forces_reconnect(self):
|
||||
"""health_check drives the reconnect decision: a cycle where is_awake
|
||||
fails closes the socket so the next cycle reconnects from scratch."""
|
||||
poller = FakePoller()
|
||||
poller.connected = True
|
||||
poller.awake = None # wake poll fails while the flag says "connected"
|
||||
manager = _manager(poller)
|
||||
|
||||
delay = await manager._watchdog_cycle(5.0)
|
||||
|
||||
assert 5.0 * 0.75 <= delay <= 5.0 * 1.25 # F5-style symmetric bound
|
||||
assert poller.disconnect_calls == 1
|
||||
assert poller.connected is False
|
||||
assert manager._failures == 1
|
||||
|
||||
async def test_connect_failure_clears_stale_store_state(self):
|
||||
poller = FakePoller()
|
||||
poller.connect_failures = 1
|
||||
|
||||
Reference in new issue
Block a user