]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Mark each test's boundaries in the named instance logs 12415/head
authorNicki Křížek <nicki@isc.org>
Fri, 10 Jul 2026 11:50:51 +0000 (11:50 +0000)
committerNicki Křížek <nicki@isc.org>
Thu, 23 Jul 2026 10:03:36 +0000 (12:03 +0200)
Send an `rndc null` command with a test ID marker at the start and end
of each test function to all named instances.

This makes it easy to identify the precise point where each test was
executed when reading the named logs. This becomes especially useful for
modules which run multiple test functions, since those are executed on
the same named instances.

Assisted-by: Claude:claude-fable-5
bin/tests/system/conftest.py

index 3339eacd972a90f969bce2964a263cd91aa4323c..07b7928e6bb944f0881fcdebdb4943134cd6bc46 100644 (file)
@@ -295,6 +295,31 @@ def wait_for_zones_loaded(request, servers):
             watcher.wait_for_line("all zones loaded")
 
 
+@pytest.fixture(autouse=True)
+def named_log_test_markers(request, servers):
+    """Send `rndc null` message with a test ID to each named instance."""
+
+    def mark(event):
+        for server in servers.values():
+            if not isinstance(server, isctest.instance.NamedInstance):
+                continue
+            try:
+                with server.rndc_client(timeout=2) as c:
+                    c.call(f"null ------ {event} {request.node.nodeid} ------")
+            except (
+                OSError,
+                isctest.rndc.RNDCException,
+                isctest.rndc.RNDCProtocolError,
+            ):
+                # best-effort: the instance may be stopped or use a
+                # non-standard control channel
+                pass
+
+    mark("BEGIN")
+    yield
+    mark("END")
+
+
 @pytest.fixture(scope="module", autouse=True)
 def configure_algorithm_set(request):
     """Configure the algorithm set to use in tests."""