]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Retry quiet check keys
authorMatthijs Mekking <matthijs@isc.org>
Fri, 19 Mar 2021 11:13:28 +0000 (12:13 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Mon, 22 Mar 2021 08:50:05 +0000 (09:50 +0100)
Change the 'check_keys' function to try three times. Some intermittent
kasp test failures are because we are inspecting the key files
before the actual change has happen. The 'retry_quiet' approach allows
for a bit more time to let the write operation finish.

bin/tests/system/kasp.sh

index 4013e9f68327cb3def2e35b71a252680c3a10443..863facc648340b7e09afa2aa67713e36c7fea4fa 100644 (file)
@@ -660,28 +660,9 @@ check_numkeys() {
        return 0
 }
 
-# Check keys for a configured zone. This verifies:
-# 1. The right number of keys exist in the key pool ($1).
-# 2. The right number of keys is active. Checks KEY1, KEY2, KEY3, and KEY4.
-#
-# It is expected that KEY1, KEY2, KEY3, and KEY4 arrays are set correctly.
-# Found key identifiers are stored in the right key array.
-check_keys() {
-       n=$((n+1))
-       echo_i "check keys are created for zone ${ZONE} ($n)"
+_check_keys() {
        ret=0
 
-       echo_i "check number of keys for zone ${ZONE} in dir ${DIR} ($n)"
-       retry_quiet 10 check_numkeys || ret=1
-       if [ $ret -ne 0 ]; then
-               _numkeys=$(get_keyids "$DIR" "$ZONE" | wc -l)
-               _log_error "bad number of key files ($_numkeys) for zone $ZONE (expected $NUM_KEYS)"
-               status=$((status+ret))
-       fi
-
-       # Temporarily don't log errors because we are searching multiple files.
-       disable_logerror
-
        # Clear key ids.
        key_set KEY1 ID "no"
        key_set KEY2 ID "no"
@@ -693,6 +674,7 @@ check_keys() {
        for _id in $_ids; do
                # There are three key files with the same algorithm.
                # Check them until a match is found.
+               ret=0
                echo_i "check key id $_id"
 
                if [ "no" = "$(key_get KEY1 ID)" ] && [ "$(key_get KEY1 EXPECT)" = "yes" ]; then
@@ -721,10 +703,39 @@ check_keys() {
                test "$ret" -eq 0 && continue
 
                # If ret is still non-zero, none of the files matched.
-               test "$ret" -eq 0 || echo_i "failed"
-               status=$((status+ret))
+               echo_i "failed"
+               return 1
        done
 
+       return 0
+}
+
+# Check keys for a configured zone. This verifies:
+# 1. The right number of keys exist in the key pool ($1).
+# 2. The right number of keys is active. Checks KEY1, KEY2, KEY3, and KEY4.
+#
+# It is expected that KEY1, KEY2, KEY3, and KEY4 arrays are set correctly.
+# Found key identifiers are stored in the right key array.
+check_keys() {
+       n=$((n+1))
+       echo_i "check keys are created for zone ${ZONE} ($n)"
+       ret=0
+
+       echo_i "check number of keys for zone ${ZONE} in dir ${DIR} ($n)"
+       retry_quiet 10 check_numkeys || ret=1
+       if [ $ret -ne 0 ]; then
+               _numkeys=$(get_keyids "$DIR" "$ZONE" | wc -l)
+               _log_error "bad number of key files ($_numkeys) for zone $ZONE (expected $NUM_KEYS)"
+               status=$((status+ret))
+       fi
+
+       # Temporarily don't log errors because we are searching multiple files.
+       disable_logerror
+
+       retry_quiet 3 _check_keys || ret=1
+       test "$ret" -eq 0 || echo_i "failed"
+       status=$((status+ret))
+
        # Turn error logs on again.
        enable_logerror