diff --git a/bin/tests/system/timeouts/ns1/named.conf.in b/bin/tests/system/timeouts/ns1/named.conf.in index 7923524985..ddd82535a0 100644 --- a/bin/tests/system/timeouts/ns1/named.conf.in +++ b/bin/tests/system/timeouts/ns1/named.conf.in @@ -27,6 +27,7 @@ options { notify no; tcp-initial-timeout 20; tcp-idle-timeout 50; + tcp-keepalive-timeout 70; }; zone "." { diff --git a/bin/tests/system/timeouts/tests-tcp.py b/bin/tests/system/timeouts/tests-tcp.py index 03f69da434..78cba3a41e 100644 --- a/bin/tests/system/timeouts/tests-tcp.py +++ b/bin/tests/system/timeouts/tests-tcp.py @@ -24,7 +24,6 @@ def create_msg(qname, qtype): import dns.message msg = dns.message.make_query(qname, qtype, want_dnssec=True, use_edns=0, payload=4096) - return msg @@ -59,7 +58,7 @@ def test_initial_timeout(port): @pytest.mark.dnspython2 def test_idle_timeout(port): # - # The idle timeout is 5 second, so sending the second message must fail + # The idle timeout is 5 seconds, so the third message should fail # import dns.rcode @@ -72,7 +71,7 @@ def test_idle_timeout(port): (sbytes, stime) = dns.query.send_tcp(sock, msg, timeout()) (response, rtime) = dns.query.receive_tcp(sock, timeout()) - time.sleep(3) + time.sleep(2) (sbytes, stime) = dns.query.send_tcp(sock, msg, timeout()) (response, rtime) = dns.query.receive_tcp(sock, timeout()) @@ -87,6 +86,37 @@ def test_idle_timeout(port): raise EOFError from e +@pytest.mark.dnspython +@pytest.mark.dnspython2 +def test_keepalive_timeout(port): + # + # Keepalive is 7 seconds, so the third message should succeed. + # + import dns.rcode + + msg = create_msg("example.", "A") + kopt = dns.edns.GenericOption(11, b'\x00') + msg.use_edns(edns=True, payload=4096, options=[kopt]) + + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: + sock.connect(("10.53.0.1", port)) + + time.sleep(1) + + (sbytes, stime) = dns.query.send_tcp(sock, msg, timeout()) + (response, rtime) = dns.query.receive_tcp(sock, timeout()) + + time.sleep(2) + + (sbytes, stime) = dns.query.send_tcp(sock, msg, timeout()) + (response, rtime) = dns.query.receive_tcp(sock, timeout()) + + time.sleep(6) + + (sbytes, stime) = dns.query.send_tcp(sock, msg, timeout()) + (response, rtime) = dns.query.receive_tcp(sock, timeout()) + + @pytest.mark.dnspython @pytest.mark.dnspython2 def test_pipelining_timeout(port):