Skip to content

Commit 79fff37

Browse files
committed
Reduce flakiness of test_keepalive.
1 parent a4ca796 commit 79fff37

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

‎tests/asyncio/test_connection.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,14 +1051,14 @@ async def test_pong_unsupported_type(self):
10511051
async def test_keepalive(self, getrandbits):
10521052
"""keepalive sends pings at ping_interval and measures latency."""
10531053
getrandbits.side_effect = itertools.count(1918987876)
1054-
self.connection.ping_interval = 3 * MS
1054+
self.connection.ping_interval = 4 * MS
10551055
self.connection.start_keepalive()
10561056
self.assertIsNotNone(self.connection.keepalive_task)
10571057
self.assertEqual(self.connection.latency, 0)
1058-
# 3 ms: keepalive() sends a ping frame.
1059-
# 3.x ms: a pong frame is received.
1060-
await asyncio.sleep(5 * MS)
1061-
# 5 ms: check that the ping frame was sent.
1058+
# 4 ms: keepalive() sends a ping frame.
1059+
# 4.x ms: a pong frame is received.
1060+
await asyncio.sleep(6 * MS)
1061+
# 6 ms: check that the ping frame was sent.
10621062
await self.assertFrameSent(Frame(PING, b"rand"))
10631063
self.assertGreater(self.connection.latency, 0)
10641064
self.assertLess(self.connection.latency, MS)

‎tests/sync/test_connection.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -787,14 +787,14 @@ def test_pong_unsupported_type(self):
787787
def test_keepalive(self, getrandbits):
788788
"""keepalive sends pings at ping_interval and measures latency."""
789789
getrandbits.side_effect = itertools.count(1918987876)
790-
self.connection.ping_interval = 3 * MS
790+
self.connection.ping_interval = 4 * MS
791791
self.connection.start_keepalive()
792792
self.assertIsNotNone(self.connection.keepalive_thread)
793793
self.assertEqual(self.connection.latency, 0)
794-
# 3 ms: keepalive() sends a ping frame.
795-
# 3.x ms: a pong frame is received.
796-
time.sleep(5 * MS)
797-
# 5 ms: check that the ping frame was sent.
794+
# 4 ms: keepalive() sends a ping frame.
795+
# 4.x ms: a pong frame is received.
796+
time.sleep(6 * MS)
797+
# 6 ms: check that the ping frame was sent.
798798
self.assertFrameSent(Frame(PING, b"rand"))
799799
self.assertGreater(self.connection.latency, 0)
800800
self.assertLess(self.connection.latency, MS)

‎tests/trio/test_connection.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -978,14 +978,14 @@ def keepalive_task_is_running(self):
978978
async def test_keepalive(self, getrandbits):
979979
"""keepalive sends pings at ping_interval and measures latency."""
980980
getrandbits.side_effect = itertools.count(1918987876)
981-
self.connection.ping_interval = 3 * MS
981+
self.connection.ping_interval = 4 * MS
982982
self.connection.start_keepalive()
983983
self.assertTrue(self.keepalive_task_is_running())
984984
self.assertEqual(self.connection.latency, 0)
985-
# 3 ms: keepalive() sends a ping frame.
986-
# 3.x ms: a pong frame is received.
987-
await trio.sleep(5 * MS)
988-
# 5 ms: check that the ping frame was sent.
985+
# 4 ms: keepalive() sends a ping frame.
986+
# 4.x ms: a pong frame is received.
987+
await trio.sleep(6 * MS)
988+
# 6 ms: check that the ping frame was sent.
989989
await self.assertFrameSent(Frame(PING, b"rand"))
990990
self.assertGreater(self.connection.latency, 0)
991991
self.assertLess(self.connection.latency, MS)

0 commit comments

Comments
 (0)