2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 18:19:42 +00:00

chg: test: DNSTAP test cleanup

Merge branch 'pspacek/dnstap-test-cleanup' into 'main'

See merge request isc-projects/bind9!10478
This commit is contained in:
Petr Špaček 2025-05-28 11:16:17 +00:00
commit 83e4fda8c1
4 changed files with 41 additions and 51 deletions

View File

@ -1,20 +0,0 @@
#!/bin/sh
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
#
# SPDX-License-Identifier: MPL-2.0
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
. ../conf.sh
$FEATURETEST --enable-dnstap || {
echo_i "This test requires dnstap support." >&2
exit 255
}
exit 0

View File

@ -13,35 +13,38 @@
import os
import re
import subprocess
import isctest
import isctest.mark
import pytest
import dns.message
pytest.importorskip("dns", minversion="2.0.0")
pytestmark = pytest.mark.extra_artifacts(
[
"dnstap.out.*",
"ns*/dnstap.out*",
"ns2/example.db",
]
)
pytestmark = [
isctest.mark.with_dnstap,
pytest.mark.extra_artifacts(
[
"dnstap.out.*",
"ns*/dnstap.out*",
"ns2/example.db",
]
),
]
def run_rndc(server, rndc_command):
"""
Send the specified 'rndc_command' to 'server' with a timeout of 10 seconds
"""
rndc = os.getenv("RNDC")
port = os.getenv("CONTROLPORT")
rndc = isctest.vars.ALL["RNDC"]
port = isctest.vars.ALL["CONTROLPORT"]
cmdline = [rndc, "-c", "../_common/rndc.conf", "-p", port, "-s", server]
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():
@ -59,8 +62,9 @@ def test_dnstap_dispatch_socket_addresses():
os.rename(os.path.join("ns3", "dnstap.out.0"), "dnstap.out.resolver_addresses")
# Read the contents of the dnstap file using dnstap-read.
output = subprocess.check_output(
[os.getenv("DNSTAPREAD"), "dnstap.out.resolver_addresses"], encoding="utf-8"
run = isctest.run.cmd(
[isctest.vars.ALL["DNSTAPREAD"], "dnstap.out.resolver_addresses"],
log_stdout=True,
)
# Check whether all frames contain the expected addresses.
@ -75,7 +79,7 @@ def test_dnstap_dispatch_socket_addresses():
bad_frames = []
inspected_frames = 0
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)
# Only inspect RESOLVER_QUERY and RESOLVER_RESPONSE frames.
if frame_type not in ("RQ", "RR"):

View File

@ -11,19 +11,24 @@
import pytest
pytestmark = pytest.mark.extra_artifacts(
[
"dig.out*",
"dnstap.hex*",
"dnstap.out*",
"fstrm_capture.out.*",
"nsupdate.out*",
"ydump.out*",
"ns*/dnstap.out*",
"ns2/example.db",
"ns2/example.db.jnl",
]
)
import isctest.mark
pytestmark = [
isctest.mark.with_dnstap,
pytest.mark.extra_artifacts(
[
"dig.out*",
"dnstap.hex*",
"dnstap.out*",
"fstrm_capture.out.*",
"nsupdate.out*",
"ydump.out*",
"ns*/dnstap.out*",
"ns2/example.db",
"ns2/example.db.jnl",
]
),
]
def test_dnstap(run_tests_sh):

View File

@ -34,10 +34,6 @@ def feature_test(feature):
return True
def with_dnstap(*args): # pylint: disable=unused-argument
return feature_test("--enable-dnstap")
def with_tsan(*args): # pylint: disable=unused-argument
return feature_test("--tsan")
@ -48,6 +44,11 @@ def with_algorithm(name: str):
return pytest.mark.skipif(os.getenv(key) != "1", reason=f"{name} is not supported")
with_dnstap = pytest.mark.skipif(
not feature_test("--enable-dnstap"), reason="DNSTAP support disabled in the build"
)
without_fips = pytest.mark.skipif(
feature_test("--have-fips-mode"), reason="FIPS support enabled in the build"
)