From: Michał Kępień Date: Tue, 20 Feb 2018 12:59:27 +0000 (+0100) Subject: Do not overwrite cache dumps X-Git-Tag: v9.13.0~156^2~2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=aeea1faf0191f8f693393ee088272f893fc4faa1;p=thirdparty%2Fbind9.git Do not overwrite cache dumps Unless configured otherwise in named.conf, "rndc dumpdb" causes a cache dump to be written to a file called "named_dump.db" in the working directory of the given named instance. Repeatedly using this command throughout different checks in the cacheclean system test causes cache dumps for older checks to be overwritten, which hinders failure diagnosis. Prevent this by moving each cache dump to a check-specific location after running "rndc dumpdb". Furthermore, during the "check flushtree clears adb correctly" check, dump_cache() is called twice without renaming the resulting files. Prevent the first cache dump from being overwritten by moving it to a different file before calling "rndc dumpdb" for the second time. --- diff --git a/bin/tests/system/cacheclean/clean.sh b/bin/tests/system/cacheclean/clean.sh index 2a173463938..39396277ed3 100644 --- a/bin/tests/system/cacheclean/clean.sh +++ b/bin/tests/system/cacheclean/clean.sh @@ -16,5 +16,5 @@ rm -f dig.out.ns2 rm -f dig.out.expire rm -f */named.memstats rm -f */named.run -rm -f ns2/named_dump.db +rm -f ns2/named_dump.db.* rm -f ns*/named.lock diff --git a/bin/tests/system/cacheclean/tests.sh b/bin/tests/system/cacheclean/tests.sh index 28414ade3bc..9f69e00510b 100644 --- a/bin/tests/system/cacheclean/tests.sh +++ b/bin/tests/system/cacheclean/tests.sh @@ -56,9 +56,9 @@ EOF } dump_cache () { - rm -f ns2/named_dump.db $RNDC $RNDCOPTS dumpdb -cache _default sleep 1 + mv ns2/named_dump.db ns2/named_dump.db.$n } clear_cache () { @@ -94,7 +94,7 @@ echo "I:reset and check that records are correctly cached initially ($n)" ret=0 load_cache dump_cache -nrecords=`grep flushtest.example ns2/named_dump.db | grep -v '^;' | egrep '(TXT|ANY)'| wc -l` +nrecords=`grep flushtest.example ns2/named_dump.db.$n | grep -v '^;' | egrep '(TXT|ANY)'| wc -l` [ $nrecords -eq 17 ] || { ret=1; echo "I: found $nrecords records expected 17"; } if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` @@ -104,7 +104,7 @@ echo "I:check flushing of the full cache ($n)" ret=0 clear_cache dump_cache -nrecords=`grep flushtest.example ns2/named_dump.db | grep -v '^;' | wc -l` +nrecords=`grep flushtest.example ns2/named_dump.db.$n | grep -v '^;' | wc -l` [ $nrecords -eq 0 ] || ret=1 if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` @@ -188,7 +188,7 @@ n=`expr $n + 1` echo "I:check the number of cached records remaining ($n)" ret=0 dump_cache -nrecords=`grep flushtest.example ns2/named_dump.db | grep -v '^;' | egrep '(TXT|ANY)' | wc -l` +nrecords=`grep flushtest.example ns2/named_dump.db.$n | grep -v '^;' | egrep '(TXT|ANY)' | wc -l` [ $nrecords -eq 17 ] || { ret=1; echo "I: found $nrecords records expected 17"; } if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` @@ -206,7 +206,7 @@ n=`expr $n + 1` echo "I:check the number of cached records remaining ($n)" ret=0 dump_cache -nrecords=`grep flushtest.example ns2/named_dump.db | grep -v '^;' | egrep '(TXT|ANY)' | wc -l` +nrecords=`grep flushtest.example ns2/named_dump.db.$n | grep -v '^;' | egrep '(TXT|ANY)' | wc -l` [ $nrecords -eq 1 ] || { ret=1; echo "I: found $nrecords records expected 1"; } if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret` @@ -216,10 +216,12 @@ echo "I:check flushtree clears adb correctly ($n)" ret=0 load_cache dump_cache -awk '/plain success\/timeout/ {getline; getline; if ($2 == "ns.flushtest.example") exit(0); exit(1); }' ns2/named_dump.db || ret=1 +mv ns2/named_dump.db.$n ns2/named_dump.db.$n.a +awk '/plain success\/timeout/ {getline; getline; if ($2 == "ns.flushtest.example") exit(0); exit(1); }' ns2/named_dump.db.$n.a || ret=1 $RNDC $RNDCOPTS flushtree flushtest.example || ret=1 dump_cache -awk '/plain success\/timeout/ {getline; getline; if ($2 == "ns.flushtest.example") exit(1); exit(0); }' ns2/named_dump.db || ret=1 +mv ns2/named_dump.db.$n ns2/named_dump.db.$n.b +awk '/plain success\/timeout/ {getline; getline; if ($2 == "ns.flushtest.example") exit(1); exit(0); }' ns2/named_dump.db.$n.b || ret=1 if [ $ret != 0 ]; then echo "I:failed"; fi status=`expr $status + $ret`