Keep probing for the send timeout under load

One shot raced named; keep sending until it closes the connection.

Assisted-by: Claude:claude-opus-4-8
This commit is contained in:
Michal Nowak 2026-06-02 15:46:29 +00:00
parent 842a0fa289
commit 9fd01e5121

View file

@ -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