]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
doth test: fix failure after reconfig
authorArtem Boldariev <artem@boldariev.com>
Fri, 14 Jan 2022 10:25:04 +0000 (12:25 +0200)
committerArtem Boldariev <artem@boldariev.com>
Tue, 18 Jan 2022 12:25:43 +0000 (14:25 +0200)
Sometimes the serving a query or two might fail in the test due to the
listeners not being reinitialised on time. This commit makes the test
suite to wait for reconfiguration message in the log file to detect
the time when the reconfiguration request completed.

bin/tests/system/conf.sh.common
bin/tests/system/doth/tests.sh

index 3d8d988a8e3965d3d0dc3bf490b715e5482a4708..3809d74aa8d0c976844fb84e6868bc2a18bf95be 100644 (file)
@@ -578,23 +578,28 @@ _repeat() (
     return 0
 )
 
+_times() {
+       awk "BEGIN{ for(i = 1; i <= $1; i++) print i}";
+}
+
 rndc_reload() {
     $RNDC -c ../common/rndc.conf -s $2 -p ${CONTROLPORT} reload $3 2>&1 | sed 's/^/'"I:$SYSTESTDIR:$1"' /'
     # reloading single zone is synchronous, if we're reloading whole server
     # we need to wait for reload to finish
     if [ -z "$3" ]; then
-       for __try in 0 1 2 3 4 5 6 7 8 9; do
-           $RNDC -c ../common/rndc.conf -s $2 -p ${CONTROLPORT} status | grep "reload/reconfig in progress" > /dev/null || break
-           sleep 1
-       done
+        for _ in $(_times 10); do
+            $RNDC -c ../common/rndc.conf -s $2 -p ${CONTROLPORT} status | grep "reload/reconfig in progress" > /dev/null || break
+            sleep 1
+        done
     fi
 }
 
 rndc_reconfig() {
-    $RNDC -c ../common/rndc.conf -s $2 -p ${CONTROLPORT} reconfig 2>&1 | sed 's/^/'"I:$SYSTESTDIR:$1"' /'
-    for __try in 0 1 2 3 4 5 6 7 8 9; do
-       $RNDC -c ../common/rndc.conf -s $2 -p ${CONTROLPORT} status | grep "reload/reconfig in progress" > /dev/null || break
-       sleep 1
+    seconds=${3:-10}
+    $RNDC -c ../common/rndc.conf -s "$2" -p "${CONTROLPORT}" reconfig 2>&1 | sed 's/^/'"I:$SYSTESTDIR:$1"' /'
+    for _ in $(_times "$seconds"); do
+        "$RNDC" -c ../common/rndc.conf -s "$2" -p "${CONTROLPORT}" status | grep "reload/reconfig in progress" > /dev/null || break
+        sleep 1
     done
 }
 
index 119085a2539edccf6d017ff048e742975675962d..a69e2e57b38429589ee32168eb2f24b8b7466cf8 100644 (file)
@@ -37,10 +37,6 @@ dig_with_opts() {
        "$DIG" $common_dig_options -p "${PORT}" "$@"
 }
 
-rndccmd() (
-       "$RNDC" -c ../common/rndc.conf -p "${CONTROLPORT}" -s "$@"
-)
-
 wait_for_tls_xfer() (
        srv_number="$1"
        shift
@@ -458,7 +454,7 @@ status=$((status + ret))
 n=$((n + 1))
 echo_i "doing rndc reconfig to see that queries keep being served after that ($n)"
 ret=0
-rndccmd 10.53.0.4 reconfig
+rndc_reconfig ns4 10.53.0.4 60
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))