test: sound backoff-jitter assertions (per-delay band + non-overlapping growth) and scoped import-stub teardown in the pairing regression tests (F5 residual)
This commit is contained in:
1 parent
75fff11d04
commit
d07820cde8
2 files changed
+44
-4
No files matched your search
@@ -211,15 +211,22 @@ class TestReconnectBackoff:
|
||||
manager = _manager(poller)
|
||||
|
||||
delays = []
|
||||
backoffs = []
|
||||
backoff = 5.0
|
||||
for _ in range(7):
|
||||
backoffs.append(backoff)
|
||||
delays.append(await manager._watchdog_cycle(backoff))
|
||||
backoff = min(backoff * 2, 300.0)
|
||||
|
||||
# 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
|
||||
# F5 soundness: the previous ±25 % jitter could flake the claim
|
||||
# delays[1] > delays[0] * 1.5: BACKOFF=10 jittered to 9.17 vs
|
||||
# BACKOFF=5 jittered to 6.25 → 6.25*1.5 = 9.375). Assert only what
|
||||
# jitter guarantees: each delay sits inside ITS OWN backoff's band
|
||||
# (non-overlapping consecutive bands ⇒ delays[1] >= delays[0],
|
||||
# since min next = 7.5 >= max first = 6.25), and never above the cap.
|
||||
for backoff, delay in zip(backoffs, delays, strict=True):
|
||||
assert 0.75 * backoff <= delay <= 1.25 * backoff
|
||||
assert delays[1] >= delays[0]
|
||||
assert delays[-1] <= 300.0 * 1.25
|
||||
|
||||
async def test_repeated_failures_do_not_spam_listeners(self):
|
||||
|
||||
Reference in new issue
Block a user