From: Nicki Křížek Date: Thu, 11 Jun 2026 09:16:22 +0000 (+0000) Subject: fixup! Port TCP request statistics checks to Python X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b14d53a2ab04e998914f8a8b77b5773152a308df;p=thirdparty%2Fbind9.git fixup! Port TCP request statistics checks 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 2045ba9940a..0e6b96e6a73 100644 --- a/bin/tests/system/tcp/tests_tcp.py +++ b/bin/tests/system/tcp/tests_tcp.py @@ -139,16 +139,11 @@ def create_socket(host: str, port: int) -> socket.socket: def tcp_requests_received(ns: NamedInstance) -> int: ns.rndc("stats") - stats_file = ns.directory / "named.stats" - last_count: int | None = None - - with open(stats_file, "r", encoding="utf-8") as stats: - for line in stats: - if "TCP requests received" in line: - last_count = int(line.split()[0]) - - assert last_count is not None, f"'TCP requests received' not found in {stats_file}" - return last_count + stats = isctest.text.TextFile(str(ns.directory / "named.stats")) + matches = stats.grep("TCP requests received") + assert matches, f"'TCP requests received' not found in {stats}" + # `rndc stats` appends to the file; only the last occurrence is current + return int(matches[-1].string.split()[0]) def tcp_status(ns: NamedInstance) -> TcpStatus: