diff --git a/bin/tests/system/timeouts/tests_tcp_timeouts.py b/bin/tests/system/timeouts/tests_tcp_timeouts.py index 0d0660bd81..3443b38140 100644 --- a/bin/tests/system/timeouts/tests_tcp_timeouts.py +++ b/bin/tests/system/timeouts/tests_tcp_timeouts.py @@ -15,6 +15,7 @@ import socket import time import dns.edns +import dns.exception import dns.message import dns.name import dns.query @@ -202,10 +203,21 @@ def test_send_timeout(named_port): # above the interval time.sleep(6) + # named may be slow to enforce the send timeout under load; keep + # sending (without draining, to keep buffer pressure) until it closes. + deadline = time.time() + 30 with pytest.raises(EOFError): try: - dns.query.send_tcp(sock, msg, timeout()) - dns.query.receive_tcp(sock, timeout()) + while time.time() < deadline: + try: + dns.query.send_tcp(sock, msg, timeout()) + except dns.exception.Timeout: + # a blocked send is backpressure from named, not the + # close we are waiting for; keep probing + pass + # pace the probes; the pressure comes from the unread + # responses, not from the send rate + time.sleep(0.5) except ConnectionError as e: raise EOFError from e