From: Ondřej Surý Date: Thu, 14 May 2026 11:59:07 +0000 (+0200) Subject: Allow either UDP or TCP queries in flight in statistics test X-Git-Tag: v9.21.23~52^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=308c370796a6d65ad7e536b9e63de775ec8576ab;p=thirdparty%2Fbind9.git Allow either UDP or TCP queries in flight in statistics test The "active sockets" and "queries in progress" assertions previously required exactly one extra UDP/IPv4 socket and exactly one UDP query in progress, with no TCP counterpart. That shape held only because the broken TCP-fallback path left the resolver retrying UDP indefinitely. With the fix in place, after two UDP timeouts to the same authority the resolver legitimately escalates to TCP, and a stats snapshot taken during recursion may catch the in-flight query on either transport. Count the UDP and TCP counters together so the test reflects the new correct behaviour. Assisted-by: Claude:claude-opus-4-7 --- diff --git a/bin/tests/system/statistics/tests.sh b/bin/tests/system/statistics/tests.sh index dab0f28a490..71187a5fe3c 100644 --- a/bin/tests/system/statistics/tests.sh +++ b/bin/tests/system/statistics/tests.sh @@ -122,18 +122,24 @@ n=$((n + 1)) ret=0 echo_i "verifying active sockets output in named.stats ($n)" -nsock1nstat=$(grep "UDP/IPv4 sockets active" $last_stats | awk '{print $1}') -[ $((nsock1nstat - nsock0nstat)) -eq 1 ] || ret=1 +# After repeated UDP timeouts to the same authoritative server, the +# resolver switches to TCP, so the in-flight socket may be either UDP +# or TCP. Require at least one extra active socket of either kind. +nsock1udp=$(grep "UDP/IPv4 sockets active" $last_stats | awk '{print $1}') +nsock1tcp=$(grep "TCP/IPv4 sockets active" $last_stats | awk '{print $1}') +[ $((${nsock1udp:-0} + ${nsock1tcp:-0} - nsock0nstat)) -ge 1 ] || ret=1 if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status + ret)) n=$((n + 1)) -# there should be 1 UDP and no TCP queries. As the TCP counter is zero -# no status line is emitted. +# There should be 1 query in progress. After repeated UDP timeouts the +# resolver switches to TCP, so depending on which retry attempt the +# snapshot captures the query may be counted as either UDP or TCP. ret=0 echo_i "verifying queries in progress in named.stats ($n)" -grep "1 UDP queries in progress" $last_stats >/dev/null || ret=1 -grep "TCP queries in progress" $last_stats >/dev/null && ret=1 +udp_in_progress=$(awk '/UDP queries in progress/ {print $1}' $last_stats) +tcp_in_progress=$(awk '/TCP queries in progress/ {print $1}' $last_stats) +[ $((${udp_in_progress:-0} + ${tcp_in_progress:-0})) -eq 1 ] || ret=1 if [ $ret != 0 ]; then echo_i "failed"; fi status=$((status + ret)) n=$((n + 1))