mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
Add TCP write timeout system test
Extend the timeouts system test that bursts the queries for large TXT record and never read any responses back filling up the server TCP write buffer. The test should work with the default wmem_max value on Linux (208k).
This commit is contained in:
@@ -20,6 +20,11 @@ copy_setports ns1/named.conf.in ns1/named.conf
|
||||
# tcp-initial-timeout interval
|
||||
#
|
||||
$PYTHON -c "
|
||||
print('large IN TXT', end=' ')
|
||||
for a in range(128):
|
||||
print('\"%s\"' % ('A' * 240), end=' ')
|
||||
print('')
|
||||
|
||||
for a in range(150000):
|
||||
print('%s IN NS a' % (a))
|
||||
print('%s IN NS b' % (a))" > ns1/large.db
|
||||
|
@@ -51,7 +51,7 @@ def test_initial_timeout(port):
|
||||
try:
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
except ConnectionResetError as e:
|
||||
except ConnectionError as e:
|
||||
raise EOFError from e
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ def test_idle_timeout(port):
|
||||
try:
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
except ConnectionResetError as e:
|
||||
except ConnectionError as e:
|
||||
raise EOFError from e
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ def test_pipelining_timeout(port):
|
||||
try:
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
except ConnectionResetError as e:
|
||||
except ConnectionError as e:
|
||||
raise EOFError from e
|
||||
|
||||
|
||||
@@ -190,3 +190,33 @@ def test_long_axfr(port):
|
||||
if soa is not None:
|
||||
break
|
||||
assert soa is not None
|
||||
|
||||
|
||||
@pytest.mark.dnspython
|
||||
@pytest.mark.dnspython2
|
||||
def test_send_timeout(port):
|
||||
import dns.query
|
||||
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
||||
sock.connect(("10.53.0.1", port))
|
||||
|
||||
# Send and receive single large RDATA over TCP
|
||||
msg = create_msg("large.example.", "TXT")
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
|
||||
# Send and receive 28 large (~32k) DNS queries that should
|
||||
# fill the default maximum 208k TCP send buffer
|
||||
for n in range(28):
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
|
||||
# configure idle interval is 5 seconds, sleep 6 to make sure we are
|
||||
# above the interval
|
||||
time.sleep(6)
|
||||
|
||||
with pytest.raises(EOFError):
|
||||
try:
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
except ConnectionError as e:
|
||||
raise EOFError from e
|
||||
|
Reference in New Issue
Block a user