]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Do not overwrite cache dumps
authorMichał Kępień <michal@isc.org>
Tue, 20 Feb 2018 12:59:27 +0000 (13:59 +0100)
committerMichał Kępień <michal@isc.org>
Tue, 20 Feb 2018 12:59:27 +0000 (13:59 +0100)
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.

bin/tests/system/cacheclean/clean.sh
bin/tests/system/cacheclean/tests.sh

index 2a1734639381c23a135c473c207e4da9f1f40ce8..39396277ed3ee818f1197a0146dcc23b3ac013cc 100644 (file)
@@ -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
index 28414ade3bc593388a26c99009b4cccfce125e00..9f69e00510bb39fb11b8c86ddc4a3ee2968fbaca 100644 (file)
@@ -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`