Retry the SOA serial check in the rpz test

While a response-policy zone is being (re)loaded it can briefly answer
with no SOA (SERVFAIL/REFUSED), which `dig +short` renders as empty
output.  get_sn() aborted the whole tests.sh on the first such miss.
Keep probing for up to ten seconds instead of failing on a single
transient miss.

Assisted-by: Claude:claude-opus-4-8
(cherry picked from commit bb4afd1332)
This commit is contained in:
Michal Nowak 2026-06-03 16:39:56 +00:00
parent 69f9beb2ff
commit 6efda73ed6

View file

@ -124,11 +124,21 @@ setret() {
# $1=domain
# $2=DNS server and client IP address
get_sn() {
SOA=$($DIG -p ${PORT} +short +norecurse soa "$1" "@$2" "-b$2")
SN=$(expr "$SOA" : '[^ ]* [^ ]* \([^ ]*\) .*' || true)
test "$SN" != "" && return
echo_i "no serial number from \`dig -p ${PORT} soa $1 @$2\` in \"$SOA\""
exit 1
gsn_n=0
while true; do
SOA=$($DIG -p ${PORT} +short +norecurse soa "$1" "@$2" "-b$2")
SN=$(expr "$SOA" : '[^ ]* [^ ]* \([^ ]*\) .*' || true)
test "$SN" != "" && return
# A policy zone being (re)loaded can briefly answer with no SOA
# (SERVFAIL/REFUSED), which +short renders as empty output; keep
# probing instead of failing on a single transient miss.
gsn_n=$((gsn_n + 1))
if test "$gsn_n" -gt $TEN_SECS; then
echo_i "no serial number from \`dig -p ${PORT} soa $1 @$2\` in \"$SOA\""
exit 1
fi
$WAIT_CMD
done
}
get_sn_fast() {