]> 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>
Tue, 20 Feb 2018 23:38:42 +0000 (10:38 +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)

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

index a1a950ad15967a4379ef2935d3d482751d6d8fdb..0a06f3a0bec75e66cf9f25b6ec3d8f5226803b98 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.
 #
@@ -25,4 +23,4 @@ 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.*
index eb7b64e42e2de03b3579967d06908827c7e30c7a..652814c0d82eb2f328b81170aa87c2928f93295f 100644 (file)
@@ -63,9 +63,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 () {
@@ -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 '^;' | 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`
@@ -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 '^;' | 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`
@@ -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`