Skip to content

Commit

Permalink
Try to fix retransmission test flakiness
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaine committed Jul 6, 2024
1 parent 2f2a77a commit 7ee141f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,17 @@ def roundtrip(sender, receiver):
return (transfer(sender, receiver), transfer(receiver, sender))


def roundtrip_until_done(sender, receiver):
"""
Send datagrams from `sender` to `receiver` and back
repeatedly until no more datagrams are exchanged.
"""
rounds = 0
while roundtrip(sender, receiver) != (0, 0):
rounds += 1
assert rounds < 10, "Too many roundtrips!"


def transfer(sender, receiver):
"""
Send datagrams from `sender` to `receiver`.
Expand Down Expand Up @@ -2817,7 +2828,7 @@ def test_send_max_data_retransmit(self):
self.assertEqual(client._local_max_data.value, 2097152)

# MAX_DATA is retransmitted and acked
self.assertEqual(roundtrip(client, server), (1, 1))
roundtrip_until_done(client, server)
self.assertEqual(client._local_max_data.sent, 2097152)
self.assertEqual(client._local_max_data.used, 1048576)
self.assertEqual(client._local_max_data.value, 2097152)
Expand Down Expand Up @@ -2852,8 +2863,7 @@ def test_send_max_stream_data_retransmit(self):
self.assertEqual(stream.max_stream_data_local_sent, 0)

# MAX_STREAM_DATA is retransmitted and acked
for i in range(2): # allow two round-trips to fix flakiness on Windows
roundtrip(client, server)
roundtrip_until_done(client, server)
self.assertEqual(stream.max_stream_data_local, 2097152)
self.assertEqual(stream.max_stream_data_local_sent, 2097152)

Expand Down Expand Up @@ -2884,7 +2894,7 @@ def test_send_max_streams_retransmit(self):
self.assertEqual(server._local_max_streams_bidi.value, 256)

# MAX_STREAMS is retransmitted and acked
self.assertEqual(roundtrip(server, client), (1, 1))
roundtrip_until_done(server, client)
self.assertEqual(client._remote_max_streams_bidi, 256)
self.assertEqual(server._local_max_streams_bidi.sent, 256)
self.assertEqual(server._local_max_streams_bidi.used, 65)
Expand Down

0 comments on commit 7ee141f

Please sign in to comment.