]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add a test of the keepalive timeout
authorEvan Hunt <each@isc.org>
Thu, 15 Jul 2021 06:15:15 +0000 (23:15 -0700)
committerEvan Hunt <each@isc.org>
Fri, 27 Aug 2021 17:02:46 +0000 (10:02 -0700)
test server now has tcp-idle-timeout set to 5 seconds and
tcp-keepalive-timeout set to 7, so queries that follow a 6-second sleep
should either succeed or fail depending on whether the keepalive option
was sent.

bin/tests/system/timeouts/ns1/named.conf.in
bin/tests/system/timeouts/tests-tcp.py

index 79235249850573bb4f0469b6206053a7e792bbd4..ddd82535a06608a3746de3c08f0b6d43ba066786 100644 (file)
@@ -27,6 +27,7 @@ options {
        notify no;
        tcp-initial-timeout 20;
        tcp-idle-timeout 50;
+       tcp-keepalive-timeout 70;
 };
 
 zone "." {
index 03f69da4344adfaf5b2740f1c88004f5a0dd5bbc..78cba3a41e840fd29c55e8ec4e991bcdda127845 100644 (file)
@@ -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):