]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Minor changes to serve-stale tests
authorMatthijs Mekking <matthijs@isc.org>
Thu, 13 Aug 2020 05:58:42 +0000 (07:58 +0200)
committerMatthijs Mekking <matthijs@isc.org>
Wed, 23 Sep 2020 14:08:29 +0000 (16:08 +0200)
Minor changes are:
- Replace the "$RNDCCMD dumpdb" logic with "rndc_dumpdb" from
  conf.sh.common (it does the same thing).
- Update a comment to match the grep calls below it (comment said the
  rest should be expired, while the grep calls indicate that they
  are still in the cache, the comment now explains why).

bin/tests/system/serve-stale/ns4/named.conf.in
bin/tests/system/serve-stale/ns5/named.conf.in
bin/tests/system/serve-stale/tests.sh

index 392ec1d6f513ecbeb0081d8129dc6be7825f9e50..a6d0cc1e51cd99d76d087b93f7e42c01c6ca0040 100644 (file)
@@ -27,7 +27,7 @@ options {
        listen-on { 10.53.0.4; };
        listen-on-v6 { none; };
        recursion yes;
-       dump-file "named_dump4.db";
+       dump-file "named_dump.db";
        stale-answer-enable no;
        stale-cache-enable yes;
 };
index 7fdba0432f0de576d19ecbe82efaf1d1e2fc3b85..af725f6d48fd89d29e49fe7f8ef49a2d40e02680 100644 (file)
@@ -27,7 +27,7 @@ options {
        listen-on { 10.53.0.5; };
        listen-on-v6 { none; };
        recursion yes;
-       dump-file "named_dump5.db";
+       dump-file "named_dump.db";
        stale-answer-enable yes;
        stale-cache-enable no;
        max-cache-ttl 24h;
index a67588b1ea8b32ea3c46bf74994efa4f5bf14a8a..e2836c11ecbda1e90fc236719ebf5d06b03708fa 100755 (executable)
@@ -130,9 +130,13 @@ ret=0
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
 grep "data\.example\..*2.*IN.*TXT.*A text record with a 2 second ttl" dig.out.test$n > /dev/null || ret=1
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=$((status+ret))
+
 # Run rndc dumpdb, test whether the stale data has correct comment printed.
 # The max-stale-ttl is 3600 seconds, so the comment should say the data is
 # stale for somewhere between 3500-3599 seconds.
+echo_i "check rndc dump stale data.example ($n)"
 rndc_dumpdb ns1 || ret=1
 awk '/; stale/ { x=$0; getline; print x, $0}' ns1/named_dump.db.test$n |
     grep "; stale (will be retained for 35.. more seconds) data\.example.*A text record with a 2 second ttl" > /dev/null 2>&1 || ret=1
@@ -1026,15 +1030,9 @@ if [ $ret != 0 ]; then echo_i "failed"; fi
 n=$((n+1))
 echo_i "dump the cache (serve-stale answers disabled) ($n)"
 ret=0
-$RNDCCMD 10.53.0.4 dumpdb -cache > rndc.out.test$n 2>&1 || ret=1
-done=0
-for i in 0 1 2 3 4 5 6 7 8 9; do
-       grep '^; Dump complete$' ns4/named_dump4.db > /dev/null 2>&1 && done=1
-       if [ $done != 1 ]; then sleep 1; fi
-done
-if [ $done != 1 ]; then ret=1; fi
-status=$((status+ret))
+rndc_dumpdb ns4 -cache || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
+status=$((status+ret))
 
 echo_i "stop ns4"
 $PERL ../stop.pl --use-rndc --port ${CONTROLPORT} serve-stale ns4
@@ -1048,11 +1046,10 @@ LASTWEEK=`TZ=UTC perl -e 'my $now = time();
         my ($s, $m, $h, $d, $mo, $y) = (localtime($fiveMinutesAgo))[0, 1, 2, 3, 4, 5];
         printf("%04d%02d%02d%02d%02d%02d", $y+1900, $mo+1, $d, $h, $m, $s);'`
 
-n=$((n+1))
 echo_i "mock the cache date to $LASTWEEK (serve-stale answers disabled) ($n)"
 ret=0
-sed -E "s/DATE [0-9]{14}/DATE $LASTWEEK/g" ns4/named_dump4.db > ns4/named_dumpdb4.db.out || ret=1
-cp ns4/named_dumpdb4.db.out ns4/named_dumpdb4.db
+sed -E "s/DATE [0-9]{14}/DATE $LASTWEEK/g" ns4/named_dump.db.test$n > ns4/named_dump.db.out || ret=1
+cp ns4/named_dump.db.out ns4/named_dump.db
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status+ret))
 
@@ -1228,7 +1225,9 @@ $RNDCCMD 10.53.0.5 stats > /dev/null 2>&1
 [ -f ns5/named.stats ] || ret=1
 cp ns5/named.stats ns5/named.stats.$n
 # Check first 10 lines of Cache DB statistics.  After serve-stale queries,
-# we expect one active TXT (longttl) and the rest to be expired from cache.
+# we expect one active TXT (longttl) and the rest to be expired from cache,
+# but since we keep everything for 5 minutes (RBTDB_VIRTUAL) in the cache
+# after expiry, they still show up in the stats.
 grep -A 10 "++ Cache DB RRsets ++" ns5/named.stats.$n > ns5/named.stats.$n.cachedb || ret=1
 grep -F "1 Others" ns5/named.stats.$n.cachedb > /dev/null || ret=1
 grep -F "2 TXT" ns5/named.stats.$n.cachedb > /dev/null || ret=1
@@ -1263,8 +1262,8 @@ FIVEMINUTESAGO=`TZ=UTC perl -e 'my $now = time();
 n=$((n+1))
 echo_i "mock the cache date to $FIVEMINUTESAGO (serve-stale cache disabled) ($n)"
 ret=0
-sed -E "s/DATE [0-9]{14}/DATE $FIVEMINUTESAGO/g" ns5/named_dump5.db > ns5/named_dumpdb5.db.out || ret=1
-cp ns5/named_dumpdb5.db.out ns5/named_dumpdb5.db
+sed -E "s/DATE [0-9]{14}/DATE $FIVEMINUTESAGO/g" ns5/named_dump.db > ns5/named_dump.db.out || ret=1
+cp ns5/named_dump.db.out ns5/named_dump.db
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status+ret))