From: Nicki Křížek Date: Thu, 11 Jun 2026 11:36:44 +0000 (+0000) Subject: fixup! Port the long TCP stream test to Python X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=16800904a0028fc86ea5037a145f262df0a34cac;p=thirdparty%2Fbind9.git fixup! Port the long TCP stream test to Python Assisted-by: Claude:claude-fable-5 --- diff --git a/bin/tests/system/tcp/tests_tcp.py b/bin/tests/system/tcp/tests_tcp.py index b788a96d62c..8472ece8fc0 100644 --- a/bin/tests/system/tcp/tests_tcp.py +++ b/bin/tests/system/tcp/tests_tcp.py @@ -11,7 +11,7 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. -from collections.abc import Iterable +from collections.abc import Iterable, Iterator from types import TracebackType from typing import NamedTuple @@ -479,9 +479,27 @@ def test_tcp_high_water(named_port: int, ns5: NamedInstance) -> None: asyncio.run(run()) +def debug_level(ns: NamedInstance) -> int: + status = ns.rndc("status").out + matches = status.grep("debug level:") + assert matches, f"'debug level' not found in rndc status:\n{status}" + return int(matches[0].string.partition(":")[2]) + + +@contextlib.contextmanager +def temporary_trace_level(ns: NamedInstance, level: int) -> Iterator[None]: + """Lower the debug level for a noisy section, then restore the default.""" + prev_level = debug_level(ns) + ns.rndc(f"trace {level}") + try: + yield + finally: + # Don't mask an in-flight test failure if named has died. + ns.rndc(f"trace {prev_level}", raise_on_exception=False) + + def test_long_tcp_messages(named_port: int, ns1: NamedInstance) -> None: isctest.log.info("checking that BIND 9 doesn't crash on long TCP messages") - ns1.rndc("trace 1") stream_bytes = 6 * 1024 * 1024 msg = isctest.query.create( "isc.org.", @@ -492,7 +510,10 @@ def test_long_tcp_messages(named_port: int, ns1: NamedInstance) -> None: ad=False, message_id=1, ) - asyncio.run(send_long_tcp_stream(ns1.ip, named_port, msg, stream_bytes)) - msg = isctest.query.create("txt.example.", "A") - isctest.query.tcp(msg, ns1.ip) + # Avoid logging the huge query stream at the default debug level. + with temporary_trace_level(ns1, 1): + asyncio.run(send_long_tcp_stream(ns1.ip, named_port, msg, stream_bytes)) + + msg = isctest.query.create("txt.example.", "A") + isctest.query.tcp(msg, ns1.ip)