From: Štěpán Balážik Date: Fri, 31 Oct 2025 11:04:39 +0000 (+0100) Subject: Require dnspython>2.0.0 in system tests using asyncserver X-Git-Tag: v9.21.15~6^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=072a82a6c58075c248fc35503bfd31c43c112d69;p=thirdparty%2Fbind9.git Require dnspython>2.0.0 in system tests using asyncserver Maintaining compatibility with pre-2.0.0 dnspython became cumbersome leading to failure in nightly CI jobs which are the only ones that run with dnspython this old. Abort all AsyncServer instances when running with old dnspython. Add an importor skip for all system tests using isctest.asyncserver. --- diff --git a/bin/tests/system/chain/tests_sh_chain.py b/bin/tests/system/chain/tests_sh_chain.py index f7d7ac3b015..5aa86d9082f 100644 --- a/bin/tests/system/chain/tests_sh_chain.py +++ b/bin/tests/system/chain/tests_sh_chain.py @@ -11,6 +11,9 @@ import pytest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ "dig.out.*", diff --git a/bin/tests/system/cookie/tests_sh_cookie.py b/bin/tests/system/cookie/tests_sh_cookie.py index 1c9e8280f5d..d5f88dedebd 100644 --- a/bin/tests/system/cookie/tests_sh_cookie.py +++ b/bin/tests/system/cookie/tests_sh_cookie.py @@ -11,6 +11,9 @@ import pytest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ "dig.out.*", diff --git a/bin/tests/system/dispatch/tests_connreset.py b/bin/tests/system/dispatch/tests_connreset.py index 0b78fb8e0a6..6c7f7140a60 100644 --- a/bin/tests/system/dispatch/tests_connreset.py +++ b/bin/tests/system/dispatch/tests_connreset.py @@ -14,7 +14,9 @@ import pytest import isctest -pytest.importorskip("dns") +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + import dns.message pytestmark = pytest.mark.extra_artifacts( diff --git a/bin/tests/system/dnssec/tests_badkey.py b/bin/tests/system/dnssec/tests_badkey.py index ca80734d4d7..6c318c9936c 100644 --- a/bin/tests/system/dnssec/tests_badkey.py +++ b/bin/tests/system/dnssec/tests_badkey.py @@ -16,6 +16,9 @@ import pytest import isctest from isctest.util import param +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/dnssec/tests_badkey_broken.py b/bin/tests/system/dnssec/tests_badkey_broken.py index 1471ad0ca29..ae7050e02e6 100644 --- a/bin/tests/system/dnssec/tests_badkey_broken.py +++ b/bin/tests/system/dnssec/tests_badkey_broken.py @@ -9,10 +9,14 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. +import pytest from dns import flags import isctest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + def bootstrap(): return { diff --git a/bin/tests/system/dnssec/tests_badkey_revoked.py b/bin/tests/system/dnssec/tests_badkey_revoked.py index cb137b26ab1..473c4479722 100644 --- a/bin/tests/system/dnssec/tests_badkey_revoked.py +++ b/bin/tests/system/dnssec/tests_badkey_revoked.py @@ -10,6 +10,10 @@ # information regarding copyright ownership. import isctest +import pytest + +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") def bootstrap(): diff --git a/bin/tests/system/dnssec/tests_delv.py b/bin/tests/system/dnssec/tests_delv.py index 61ab35a7ac6..aa374584bac 100644 --- a/bin/tests/system/dnssec/tests_delv.py +++ b/bin/tests/system/dnssec/tests_delv.py @@ -17,6 +17,9 @@ import pytest import isctest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/dnssec/tests_policy.py b/bin/tests/system/dnssec/tests_policy.py index f32406def42..672dc8a4a45 100644 --- a/bin/tests/system/dnssec/tests_policy.py +++ b/bin/tests/system/dnssec/tests_policy.py @@ -18,6 +18,9 @@ import pytest import isctest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/dnssec/tests_tat.py b/bin/tests/system/dnssec/tests_tat.py index 48e7891ca34..609f110c598 100644 --- a/bin/tests/system/dnssec/tests_tat.py +++ b/bin/tests/system/dnssec/tests_tat.py @@ -18,6 +18,9 @@ import pytest import isctest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/dnssec/tests_validation.py b/bin/tests/system/dnssec/tests_validation.py index 338f7f4e71c..e6d8ccc7343 100644 --- a/bin/tests/system/dnssec/tests_validation.py +++ b/bin/tests/system/dnssec/tests_validation.py @@ -22,8 +22,9 @@ import isctest import isctest.mark from isctest.util import param - +# isctest.asyncserver requires dnspython >= 2.0.0 pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ "*/K*", diff --git a/bin/tests/system/dnssec/tests_validation_accept_expired.py b/bin/tests/system/dnssec/tests_validation_accept_expired.py index 72999a8623c..51283aedf9d 100644 --- a/bin/tests/system/dnssec/tests_validation_accept_expired.py +++ b/bin/tests/system/dnssec/tests_validation_accept_expired.py @@ -13,6 +13,11 @@ from dns import flags import isctest +import pytest + +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + def bootstrap(): return { diff --git a/bin/tests/system/dnssec/tests_validation_managed_keys.py b/bin/tests/system/dnssec/tests_validation_managed_keys.py index 7cf6e8edbbb..e6079e4b5a3 100644 --- a/bin/tests/system/dnssec/tests_validation_managed_keys.py +++ b/bin/tests/system/dnssec/tests_validation_managed_keys.py @@ -14,6 +14,11 @@ import shutil import isctest +import pytest + +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + def bootstrap(): assert not os.path.exists("ns4/managed-keys.bind.jnl") diff --git a/bin/tests/system/dnssec/tests_validation_many_anchors.py b/bin/tests/system/dnssec/tests_validation_many_anchors.py index 29b771dcbd6..90b071ec584 100644 --- a/bin/tests/system/dnssec/tests_validation_many_anchors.py +++ b/bin/tests/system/dnssec/tests_validation_many_anchors.py @@ -16,6 +16,9 @@ import pytest import isctest from isctest.util import param +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + def bootstrap(): return { diff --git a/bin/tests/system/dnssec/tests_validation_multiview.py b/bin/tests/system/dnssec/tests_validation_multiview.py index 7c243e90ef5..085f388b2c9 100644 --- a/bin/tests/system/dnssec/tests_validation_multiview.py +++ b/bin/tests/system/dnssec/tests_validation_multiview.py @@ -14,6 +14,11 @@ import re import isctest +import pytest + +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + def bootstrap(): return { diff --git a/bin/tests/system/fetchlimit/tests_sh_fetchlimit.py b/bin/tests/system/fetchlimit/tests_sh_fetchlimit.py index 23076980b5d..26bdff7fc24 100644 --- a/bin/tests/system/fetchlimit/tests_sh_fetchlimit.py +++ b/bin/tests/system/fetchlimit/tests_sh_fetchlimit.py @@ -11,6 +11,9 @@ import pytest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ "dig.out.*", diff --git a/bin/tests/system/forward/tests_sh_forward.py b/bin/tests/system/forward/tests_sh_forward.py index 0decea61e59..4ffec3fbd7d 100644 --- a/bin/tests/system/forward/tests_sh_forward.py +++ b/bin/tests/system/forward/tests_sh_forward.py @@ -11,6 +11,9 @@ import pytest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ "dig.out.*", diff --git a/bin/tests/system/isctest/asyncserver.py b/bin/tests/system/isctest/asyncserver.py index e5277696cc3..c91f63a1230 100644 --- a/bin/tests/system/isctest/asyncserver.py +++ b/bin/tests/system/isctest/asyncserver.py @@ -116,6 +116,7 @@ class AsyncServer: tcp_handler: Optional[_TcpHandler], pidfile: Optional[str] = None, ) -> None: + self._abort_if_on_dnspython_version_less_than_2_0_0() logging.basicConfig( format="%(asctime)s %(levelname)8s %(message)s", level=os.environ.get("ANS_LOG_LEVEL", "INFO").upper(), @@ -143,6 +144,14 @@ class AsyncServer: self._pidfile: Optional[str] = pidfile self._work_done: Optional[asyncio.Future] = None + @classmethod + def _abort_if_on_dnspython_version_less_than_2_0_0(cls) -> None: + if dns.version.MAJOR < 2: + error = f"Using {cls.__name__} requires dnspython >= 2.0.0; " + error += 'add `pytest.importorskip("dns", minversion="2.0.0")` ' + error += "to the test module to skip this test." + raise RuntimeError(error) + def _get_ipv4_address_from_directory_name(self) -> str: containing_directory = pathlib.Path().absolute().stem match_result = re.match(r"ans(?P\d+)", containing_directory) @@ -1053,7 +1062,6 @@ class AsyncDnsServer(AsyncServer): try: query = dns.message.from_wire(wire) except dns.message.UnknownTSIGKey: - self._abort_if_on_dnspython_version_less_than_2_0_0() self._abort_if_tsig_signed_query_received_unless_acknowledged() query = _DnsMessageWithTsigDisabled.from_wire(wire) except dns.exception.DNSException as exc: @@ -1074,13 +1082,6 @@ class AsyncDnsServer(AsyncServer): response_length = struct.pack("!H", len(response)) yield response_length + response - def _abort_if_on_dnspython_version_less_than_2_0_0(self) -> None: - if dns.version.MAJOR < 2: - error = "Receiving TSIG signed queries requires dnspython >= 2.0.0; " - error += 'add `pytest.importorskip("dns", minversion="2.0.0")` ' - error += "to the test module to skip this test." - raise RuntimeError(error) - def _abort_if_tsig_signed_query_received_unless_acknowledged(self) -> None: if self._acknowledge_tsig_dnspython_hacks: return diff --git a/bin/tests/system/nsupdate/tests_sh_nsupdate.py b/bin/tests/system/nsupdate/tests_sh_nsupdate.py index 2159a6a7dc9..e91d9e5206f 100644 --- a/bin/tests/system/nsupdate/tests_sh_nsupdate.py +++ b/bin/tests/system/nsupdate/tests_sh_nsupdate.py @@ -13,6 +13,9 @@ import platform import pytest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ "Kxxx*", diff --git a/bin/tests/system/qmin/tests_sh_qmin.py b/bin/tests/system/qmin/tests_sh_qmin.py index 1116f7ec6ce..4f5af7f56c1 100644 --- a/bin/tests/system/qmin/tests_sh_qmin.py +++ b/bin/tests/system/qmin/tests_sh_qmin.py @@ -11,6 +11,9 @@ import pytest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ "dig.out.*", diff --git a/bin/tests/system/rpzrecurse/tests_sh_rpzrecurse.py b/bin/tests/system/rpzrecurse/tests_sh_rpzrecurse.py index 983c6c3c331..3798ed6ee67 100644 --- a/bin/tests/system/rpzrecurse/tests_sh_rpzrecurse.py +++ b/bin/tests/system/rpzrecurse/tests_sh_rpzrecurse.py @@ -11,6 +11,9 @@ import pytest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ "dig.out.*", diff --git a/bin/tests/system/statistics/tests_sh_statistics.py b/bin/tests/system/statistics/tests_sh_statistics.py index 48d40307400..e34dd437a85 100644 --- a/bin/tests/system/statistics/tests_sh_statistics.py +++ b/bin/tests/system/statistics/tests_sh_statistics.py @@ -11,6 +11,9 @@ import pytest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ "curl.out.*", diff --git a/bin/tests/system/tsig/tests_badtime.py b/bin/tests/system/tsig/tests_badtime.py index 1a45e51ec03..4f5a1b9f974 100644 --- a/bin/tests/system/tsig/tests_badtime.py +++ b/bin/tests/system/tsig/tests_badtime.py @@ -18,7 +18,9 @@ import time import pytest +# isctest.asyncserver requires dnspython >= 2.0.0 pytest.importorskip("dns", minversion="2.0.0") + import dns.message import dns.query import dns.tsigkeyring diff --git a/bin/tests/system/upforwd/tests_sh_upforwd.py b/bin/tests/system/upforwd/tests_sh_upforwd.py index 3dfa290a316..28be6c4c2d7 100644 --- a/bin/tests/system/upforwd/tests_sh_upforwd.py +++ b/bin/tests/system/upforwd/tests_sh_upforwd.py @@ -11,6 +11,8 @@ import pytest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") pytestmark = pytest.mark.extra_artifacts( [ diff --git a/bin/tests/system/xfer/tests_sh_xfer.py b/bin/tests/system/xfer/tests_sh_xfer.py index d94f90b9811..5226cfc50b2 100644 --- a/bin/tests/system/xfer/tests_sh_xfer.py +++ b/bin/tests/system/xfer/tests_sh_xfer.py @@ -11,6 +11,9 @@ import pytest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ "axfr.out", diff --git a/bin/tests/system/zero/tests_sh_zero.py b/bin/tests/system/zero/tests_sh_zero.py index 3191f1c62a8..50abfe0f2d6 100644 --- a/bin/tests/system/zero/tests_sh_zero.py +++ b/bin/tests/system/zero/tests_sh_zero.py @@ -11,6 +11,9 @@ import pytest +# isctest.asyncserver requires dnspython >= 2.0.0 +pytest.importorskip("dns", minversion="2.0.0") + pytestmark = pytest.mark.extra_artifacts( [ "dig.out*",