mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 04:30:00 -04:00
add a test of the keepalive timeout
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.
This commit is contained in:
parent
fc6f751fbe
commit
947e80066c
2 changed files with 34 additions and 3 deletions
|
|
@ -27,6 +27,7 @@ options {
|
|||
notify no;
|
||||
tcp-initial-timeout 20;
|
||||
tcp-idle-timeout 50;
|
||||
tcp-keepalive-timeout 70;
|
||||
};
|
||||
|
||||
zone "." {
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue