2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 21:47:59 +00:00

Port dnstap test to use isctest utilities

(cherry picked from commit f176acdfcc813cfc870ca9d4cbec525d23ece314)
This commit is contained in:
Petr Špaček 2025-05-23 17:27:02 +02:00
parent 7f0f7168d0
commit ddbcf9192c

View File

@ -13,7 +13,6 @@
import os import os
import re import re
import subprocess
import isctest import isctest
import pytest import pytest
@ -35,13 +34,13 @@ def run_rndc(server, rndc_command):
""" """
Send the specified 'rndc_command' to 'server' with a timeout of 10 seconds Send the specified 'rndc_command' to 'server' with a timeout of 10 seconds
""" """
rndc = os.getenv("RNDC") rndc = isctest.vars.ALL["RNDC"]
port = os.getenv("CONTROLPORT") port = isctest.vars.ALL["CONTROLPORT"]
cmdline = [rndc, "-c", "../_common/rndc.conf", "-p", port, "-s", server] cmdline = [rndc, "-c", "../_common/rndc.conf", "-p", port, "-s", server]
cmdline.extend(rndc_command) cmdline.extend(rndc_command)
subprocess.check_output(cmdline, stderr=subprocess.STDOUT, timeout=10) isctest.run.cmd(cmdline, log_stdout=True)
def test_dnstap_dispatch_socket_addresses(): def test_dnstap_dispatch_socket_addresses():
@ -59,8 +58,9 @@ def test_dnstap_dispatch_socket_addresses():
os.rename(os.path.join("ns3", "dnstap.out.0"), "dnstap.out.resolver_addresses") os.rename(os.path.join("ns3", "dnstap.out.0"), "dnstap.out.resolver_addresses")
# Read the contents of the dnstap file using dnstap-read. # Read the contents of the dnstap file using dnstap-read.
output = subprocess.check_output( run = isctest.run.cmd(
[os.getenv("DNSTAPREAD"), "dnstap.out.resolver_addresses"], encoding="utf-8" [isctest.vars.ALL["DNSTAPREAD"], "dnstap.out.resolver_addresses"],
log_stdout=True,
) )
# Check whether all frames contain the expected addresses. # Check whether all frames contain the expected addresses.
@ -75,7 +75,7 @@ def test_dnstap_dispatch_socket_addresses():
bad_frames = [] bad_frames = []
inspected_frames = 0 inspected_frames = 0
addr_regex = r"^10\.53\.0\.[0-9]+:[0-9]{1,5}$" addr_regex = r"^10\.53\.0\.[0-9]+:[0-9]{1,5}$"
for line in output.splitlines(): for line in run.stdout.decode("utf-8").splitlines():
_, _, frame_type, addr1, _, addr2, _ = line.split(" ", 6) _, _, frame_type, addr1, _, addr2, _ = line.split(" ", 6)
# Only inspect RESOLVER_QUERY and RESOLVER_RESPONSE frames. # Only inspect RESOLVER_QUERY and RESOLVER_RESPONSE frames.
if frame_type not in ("RQ", "RR"): if frame_type not in ("RQ", "RR"):