diff --git a/bin/tests/system/timeouts/setup.sh b/bin/tests/system/timeouts/setup.sh index 2e8fd6a6ba..c4019d2a27 100644 --- a/bin/tests/system/timeouts/setup.sh +++ b/bin/tests/system/timeouts/setup.sh @@ -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 diff --git a/bin/tests/system/timeouts/tests-tcp.py b/bin/tests/system/timeouts/tests-tcp.py index 2c5e99cc1c..e1f19608c8 100644 --- a/bin/tests/system/timeouts/tests-tcp.py +++ b/bin/tests/system/timeouts/tests-tcp.py @@ -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