]> 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)
committerMark Andrews <marka@isc.org>
Wed, 21 Feb 2018 00:26:58 +0000 (11:26 +1100)
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.

(cherry picked from commit aeea1faf0191f8f693393ee088272f893fc4faa1)
(cherry picked from commit dcd91ab32281c56917e71397d405c11a1c7ed10f)

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

index be16f9267aa5841c1f677e32f5ec25a5c5c21432..e04d826977388781ae467bae393422a1681a31be 100644 (file)
@@ -15,8 +15,6 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: clean.sh,v 1.8 2011/08/03 23:47:48 tbox Exp $
-
 #
 # Clean up after cache cleaner tests.
 #
@@ -24,4 +22,4 @@
 rm -f dig.out.ns2
 rm -f */named.memstats
 rm -f */named.run
-rm -f ns2/named_dump.db
+rm -f ns2/named_dump.db.*
index b41a138cc005c5121a16919c659a344176b4feec..7fe67e98cdedc76eb5325b251aaf9d6356ed939a 100644 (file)
@@ -63,9 +63,9 @@ EOF
 }
 
 dump_cache () {
-        rm -f ns2/named_dump.db
         $RNDC $RNDCOPTS dumpdb -cache
         sleep 1
+        mv ns2/named_dump.db ns2/named_dump.db.$n
 }
 
 clear_cache () {
@@ -101,7 +101,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 '^;' | wc -l`
+nrecords=`grep flushtest.example ns2/named_dump.db.$n | grep -v '^;' | wc -l`
 [ $nrecords -eq 20 ] || ret=1
 if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
@@ -111,7 +111,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`
@@ -195,7 +195,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 '^;' | wc -l`
+nrecords=`grep flushtest.example ns2/named_dump.db.$n | grep -v '^;' | wc -l`
 [ $nrecords -eq 19 ] || ret=1
 if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
@@ -213,7 +213,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`
@@ -223,10 +223,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`