mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-23 02:28:55 +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:
commit
83e4fda8c1
@ -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
|
|
@ -13,35 +13,38 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
|
||||||
|
|
||||||
import isctest
|
import isctest
|
||||||
|
import isctest.mark
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import dns.message
|
import dns.message
|
||||||
|
|
||||||
pytest.importorskip("dns", minversion="2.0.0")
|
pytest.importorskip("dns", minversion="2.0.0")
|
||||||
|
|
||||||
pytestmark = pytest.mark.extra_artifacts(
|
pytestmark = [
|
||||||
[
|
isctest.mark.with_dnstap,
|
||||||
"dnstap.out.*",
|
pytest.mark.extra_artifacts(
|
||||||
"ns*/dnstap.out*",
|
[
|
||||||
"ns2/example.db",
|
"dnstap.out.*",
|
||||||
]
|
"ns*/dnstap.out*",
|
||||||
)
|
"ns2/example.db",
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def run_rndc(server, rndc_command):
|
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 +62,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 +79,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"):
|
||||||
|
@ -11,19 +11,24 @@
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
pytestmark = pytest.mark.extra_artifacts(
|
import isctest.mark
|
||||||
[
|
|
||||||
"dig.out*",
|
pytestmark = [
|
||||||
"dnstap.hex*",
|
isctest.mark.with_dnstap,
|
||||||
"dnstap.out*",
|
pytest.mark.extra_artifacts(
|
||||||
"fstrm_capture.out.*",
|
[
|
||||||
"nsupdate.out*",
|
"dig.out*",
|
||||||
"ydump.out*",
|
"dnstap.hex*",
|
||||||
"ns*/dnstap.out*",
|
"dnstap.out*",
|
||||||
"ns2/example.db",
|
"fstrm_capture.out.*",
|
||||||
"ns2/example.db.jnl",
|
"nsupdate.out*",
|
||||||
]
|
"ydump.out*",
|
||||||
)
|
"ns*/dnstap.out*",
|
||||||
|
"ns2/example.db",
|
||||||
|
"ns2/example.db.jnl",
|
||||||
|
]
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_dnstap(run_tests_sh):
|
def test_dnstap(run_tests_sh):
|
||||||
|
@ -34,10 +34,6 @@ def feature_test(feature):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def with_dnstap(*args): # pylint: disable=unused-argument
|
|
||||||
return feature_test("--enable-dnstap")
|
|
||||||
|
|
||||||
|
|
||||||
def with_tsan(*args): # pylint: disable=unused-argument
|
def with_tsan(*args): # pylint: disable=unused-argument
|
||||||
return feature_test("--tsan")
|
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")
|
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(
|
without_fips = pytest.mark.skipif(
|
||||||
feature_test("--have-fips-mode"), reason="FIPS support enabled in the build"
|
feature_test("--have-fips-mode"), reason="FIPS support enabled in the build"
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user