From: Nicki Křížek Date: Tue, 14 Jul 2026 11:42:25 +0000 (+0000) Subject: Integrate the Python RNDC client into isctest X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=b07f17fbdb67b91610e7de6a2653738fc0196a98;p=thirdparty%2Fbind9.git Integrate the Python RNDC client into isctest Register the rndc module in the isctest package and provide a NamedInstance.rndc_client() factory next to rndc(), so tests can grab a client for an instance's control channel without repeating the address and port details. Assisted-by: Claude:claude-fable-5 --- diff --git a/bin/tests/system/isctest/__init__.py b/bin/tests/system/isctest/__init__.py index 326b77f0d4e..9459d93b815 100644 --- a/bin/tests/system/isctest/__init__.py +++ b/bin/tests/system/isctest/__init__.py @@ -17,6 +17,7 @@ from . import ( # pylint: disable=redefined-builtin kasp, log, query, + rndc, run, template, transfer, @@ -37,6 +38,7 @@ __all__ = [ "kasp", "log", "query", + "rndc", "run", "template", "transfer", diff --git a/bin/tests/system/isctest/instance.py b/bin/tests/system/isctest/instance.py index c6e83018143..d6b7fe0501f 100644 --- a/bin/tests/system/isctest/instance.py +++ b/bin/tests/system/isctest/instance.py @@ -11,10 +11,12 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. +from collections.abc import Iterator from pathlib import Path from typing import NamedTuple import abc +import contextlib import os import re @@ -24,6 +26,7 @@ import dns.update from .log import WatchLogFromHere, WatchLogFromStart, debug from .query import udp +from .rndc import RNDCClient from .run import CmdResult, EnvCmd, perl from .text import TextFile @@ -191,6 +194,21 @@ class NamedInstance(ServerInstance): """ return self._rndc(command, timeout=timeout, **kwargs) + @contextlib.contextmanager + def rndc_client(self, timeout: float = 10) -> Iterator[RNDCClient]: + """ + Connect a Python RNDC client to this instance's control channel; + a fast alternative to `rndc()` which does not spawn the rndc + binary. Only usable as a context manager: + + ```python + with ns1.rndc_client() as client: + client.call("status") + ``` + """ + with RNDCClient(self.ip, self.ports.rndc, timeout=timeout) as client: + yield client + def nsupdate( self, update_msg: dns.update.UpdateMessage, expected_rcode=dns.rcode.NOERROR ):