From: Nicki Křížek Date: Fri, 12 Jun 2026 11:44:10 +0000 (+0200) Subject: Use AnsInstance fixture in dispatch test X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=630247e845f133e1fa09e796bf1ecb715b6446f3;p=thirdparty%2Fbind9.git Use AnsInstance fixture in dispatch test Replace manual ans.run parsing with the ans4 fixture. Assisted-by: Claude:claude-fable-5 --- diff --git a/bin/tests/system/dispatch/tests_tcponly.py b/bin/tests/system/dispatch/tests_tcponly.py index 373ee56017c..a4d30c3429b 100644 --- a/bin/tests/system/dispatch/tests_tcponly.py +++ b/bin/tests/system/dispatch/tests_tcponly.py @@ -27,13 +27,12 @@ pytestmark = pytest.mark.extra_artifacts( ) -def _count_received(path, qname, protocol): +def _count_received(ans, qname, protocol): pattern = Re(rf"Received {escape(qname)}/IN/A .* \({protocol}\)$") - with open(path, encoding="utf-8") as fh: - return sum(1 for line in fh if pattern.search(line.rstrip())) + return len(ans.log.grep(pattern)) -def test_tcponly_fallback(): +def test_tcponly_fallback(ans4): """ A resolver must fall back to TCP after repeated UDP timeouts to the same authoritative server. ans4 drops every UDP query and answers @@ -51,7 +50,7 @@ def test_tcponly_fallback(): ) assert str(rdataset[0]) == "127.0.0.1" - udp = _count_received("ans4/ans.run", "foo.tcp-only", "UDP") - tcp = _count_received("ans4/ans.run", "foo.tcp-only", "TCP") + udp = _count_received(ans4, "foo.tcp-only", "UDP") + tcp = _count_received(ans4, "foo.tcp-only", "TCP") assert udp == 2, f"expected exactly 2 UDP queries, got {udp}" assert tcp == 1, f"expected exactly 1 TCP query, got {tcp}"