mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
Remove unused sbytes, stime, n, response, and rtime variables
This commit is contained in:
parent
a8383e5785
commit
4857da271d
3 changed files with 58 additions and 64 deletions
|
|
@ -45,8 +45,8 @@ def create_socket(host, port):
|
|||
def test_tcp_garbage(named_port):
|
||||
with create_socket("10.53.0.7", named_port) as sock:
|
||||
msg = create_msg("a.example.", "A")
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
|
||||
wire = msg.to_wire()
|
||||
assert len(wire) > 0
|
||||
|
|
@ -58,8 +58,8 @@ def test_tcp_garbage(named_port):
|
|||
|
||||
with pytest.raises(EOFError):
|
||||
try:
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
except ConnectionError as e:
|
||||
raise EOFError from e
|
||||
|
||||
|
|
@ -67,8 +67,8 @@ def test_tcp_garbage(named_port):
|
|||
def test_tcp_garbage_response(named_port):
|
||||
with create_socket("10.53.0.7", named_port) as sock:
|
||||
msg = create_msg("a.example.", "A")
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
|
||||
wire = msg.to_wire()
|
||||
assert len(wire) > 0
|
||||
|
|
@ -77,11 +77,11 @@ def test_tcp_garbage_response(named_port):
|
|||
# the connection to be terminated
|
||||
|
||||
rmsg = dns.message.make_response(msg)
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, rmsg, timeout())
|
||||
dns.query.send_tcp(sock, rmsg, timeout())
|
||||
|
||||
with pytest.raises(EOFError):
|
||||
try:
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
except ConnectionError as e:
|
||||
raise EOFError from e
|
||||
|
||||
|
|
@ -90,11 +90,11 @@ def test_tcp_garbage_response(named_port):
|
|||
def test_close_wait(named_port):
|
||||
with create_socket("10.53.0.7", named_port) as sock:
|
||||
msg = create_msg("a.example.", "A")
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
|
||||
msg = dns.message.make_query("a.example.", "A", use_edns=0, payload=1232)
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
|
||||
# Shutdown the socket, but ignore the other side closing the socket
|
||||
# first because we sent DNS message with EDNS0
|
||||
|
|
@ -112,8 +112,8 @@ def test_close_wait(named_port):
|
|||
# available for the query below and it will time out.
|
||||
with create_socket("10.53.0.7", named_port) as sock:
|
||||
msg = create_msg("a.example.", "A")
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
|
||||
|
||||
# GL #4273
|
||||
|
|
@ -125,10 +125,10 @@ def test_tcp_big(named_port):
|
|||
msg.additional.append(
|
||||
dns.rrset.from_text(dns.name.root, 0, 1, "URI", "0 0 " + "b" * 65503)
|
||||
)
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
|
||||
# Now check that the server is alive and well
|
||||
msg = create_msg("a.example.", "A")
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ def test_initial_timeout(named_port):
|
|||
|
||||
with pytest.raises(EOFError):
|
||||
try:
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
except ConnectionError as e:
|
||||
raise EOFError from e
|
||||
|
||||
|
|
@ -72,20 +72,20 @@ def test_idle_timeout(named_port):
|
|||
|
||||
time.sleep(1)
|
||||
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
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())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
|
||||
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())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
except ConnectionError as e:
|
||||
raise EOFError from e
|
||||
|
||||
|
|
@ -103,18 +103,18 @@ def test_keepalive_timeout(named_port):
|
|||
|
||||
time.sleep(1)
|
||||
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
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())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
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())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
|
||||
|
||||
def test_pipelining_timeout(named_port):
|
||||
|
|
@ -128,25 +128,25 @@ def test_pipelining_timeout(named_port):
|
|||
time.sleep(1)
|
||||
|
||||
# Send and receive 25 DNS queries
|
||||
for n in range(25):
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
for n in range(25):
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
for _ in range(25):
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
for _ in range(25):
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
# Send and receive 25 DNS queries
|
||||
for n in range(25):
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
for n in range(25):
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
for _ in range(25):
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
for _ in range(25):
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
|
||||
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())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
except ConnectionError as e:
|
||||
raise EOFError from e
|
||||
|
||||
|
|
@ -161,12 +161,10 @@ def test_long_axfr(named_port):
|
|||
|
||||
name = dns.name.from_text("example.")
|
||||
msg = create_msg("example.", "AXFR")
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
|
||||
# Receive the initial DNS message with SOA
|
||||
(response, rtime) = dns.query.receive_tcp(
|
||||
sock, timeout(), one_rr_per_rrset=True
|
||||
)
|
||||
(response, _) = dns.query.receive_tcp(sock, timeout(), one_rr_per_rrset=True)
|
||||
soa = response.get_rrset(
|
||||
dns.message.ANSWER, name, dns.rdataclass.IN, dns.rdatatype.SOA
|
||||
)
|
||||
|
|
@ -174,7 +172,7 @@ def test_long_axfr(named_port):
|
|||
|
||||
# Pull DNS message from wire until the second SOA is received
|
||||
while True:
|
||||
(response, rtime) = dns.query.receive_tcp(
|
||||
(response, _) = dns.query.receive_tcp(
|
||||
sock, timeout(), one_rr_per_rrset=True
|
||||
)
|
||||
soa = response.get_rrset(
|
||||
|
|
@ -192,13 +190,13 @@ def test_send_timeout(named_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())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
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())
|
||||
for _ in range(28):
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
|
||||
# configure idle interval is 5 seconds, sleep 6 to make sure we are
|
||||
# above the interval
|
||||
|
|
@ -206,8 +204,8 @@ def test_send_timeout(named_port):
|
|||
|
||||
with pytest.raises(EOFError):
|
||||
try:
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.receive_tcp(sock, timeout())
|
||||
except ConnectionError as e:
|
||||
raise EOFError from e
|
||||
|
||||
|
|
@ -219,12 +217,10 @@ def test_max_transfer_idle_out(named_port):
|
|||
|
||||
name = dns.name.from_text("example.")
|
||||
msg = create_msg("example.", "AXFR")
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
|
||||
# Receive the initial DNS message with SOA
|
||||
(response, rtime) = dns.query.receive_tcp(
|
||||
sock, timeout(), one_rr_per_rrset=True
|
||||
)
|
||||
(response, _) = dns.query.receive_tcp(sock, timeout(), one_rr_per_rrset=True)
|
||||
soa = response.get_rrset(
|
||||
dns.message.ANSWER, name, dns.rdataclass.IN, dns.rdatatype.SOA
|
||||
)
|
||||
|
|
@ -235,7 +231,7 @@ def test_max_transfer_idle_out(named_port):
|
|||
with pytest.raises(ConnectionResetError):
|
||||
# Process queued TCP messages
|
||||
while True:
|
||||
(response, rtime) = dns.query.receive_tcp(
|
||||
(response, _) = dns.query.receive_tcp(
|
||||
sock, timeout(), one_rr_per_rrset=True
|
||||
)
|
||||
soa = response.get_rrset(
|
||||
|
|
@ -253,12 +249,10 @@ def test_max_transfer_time_out(named_port):
|
|||
|
||||
name = dns.name.from_text("example.")
|
||||
msg = create_msg("example.", "AXFR")
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
|
||||
dns.query.send_tcp(sock, msg, timeout())
|
||||
|
||||
# Receive the initial DNS message with SOA
|
||||
(response, rtime) = dns.query.receive_tcp(
|
||||
sock, timeout(), one_rr_per_rrset=True
|
||||
)
|
||||
(response, _) = dns.query.receive_tcp(sock, timeout(), one_rr_per_rrset=True)
|
||||
soa = response.get_rrset(
|
||||
dns.message.ANSWER, name, dns.rdataclass.IN, dns.rdatatype.SOA
|
||||
)
|
||||
|
|
@ -268,7 +262,7 @@ def test_max_transfer_time_out(named_port):
|
|||
with pytest.raises(EOFError):
|
||||
while True:
|
||||
time.sleep(1)
|
||||
(response, rtime) = dns.query.receive_tcp(
|
||||
(response, _) = dns.query.receive_tcp(
|
||||
sock, timeout(), one_rr_per_rrset=True
|
||||
)
|
||||
soa = response.get_rrset(
|
||||
|
|
|
|||
|
|
@ -58,6 +58,6 @@ def test_tsig_badtime(named_port):
|
|||
|
||||
time.sleep(3)
|
||||
|
||||
(sbytes, stime) = dns.query.send_tcp(sock, wire, timeout())
|
||||
dns.query.send_tcp(sock, wire, timeout())
|
||||
with pytest.raises(dns.tsig.PeerBadTime):
|
||||
(response, rtime) = dns.query.receive_tcp(sock, timeout(), keyring=keyring)
|
||||
dns.query.receive_tcp(sock, timeout(), keyring=keyring)
|
||||
|
|
|
|||
Loading…
Reference in a new issue