]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Adjusted ancient rrset system test
authorDiego Fronza <diego@isc.org>
Tue, 20 Oct 2020 00:24:38 +0000 (21:24 -0300)
committerDiego Fronza <diego@isc.org>
Wed, 11 Nov 2020 15:53:24 +0000 (12:53 -0300)
Before the stale-refresh-time feature, the system test for ancient rrset
was somewhat based on the average time the previous tests and queries
were taking, thus not very precise.

After the addition of stale-refresh-time the system test for ancient
rrset started to fail since the queries for stale records (low
max-stale-ttl) were not taking the time to do a full resolution
anymore, since the answers now were coming from the cache (because the
rrset were stale and within stale-refresh-time window after the
previous resolution failure).

To handle this, the correct time to wait before rrset become ancient is
calculated from max-stale-ttl configuration plus the TTL set in the
rrset used in the tests (ans2/ans.pl).

Then before sending queries for ancient rrset, we check if we need to
sleep enough to ensure those rrset will be marked as ancient.

bin/tests/system/serve-stale/tests.sh

index 518396bde4a8c133015e5bac3c680d2c4bb04172..e5bfcbb0181335194c59c21a66a928882764bdfa 100755 (executable)
@@ -471,6 +471,10 @@ grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status+ret))
 
+# keep track of time so we can access these rrset later,
+# when we expect them to become ancient.
+t1=`$PERL -e 'print time()'`
+
 n=$((n+1))
 echo_i "prime cache othertype.example (low max-stale-ttl) ($n)"
 ret=0
@@ -594,6 +598,20 @@ grep "1 #NXDOMAIN" ns1/named.stats.$n.cachedb > /dev/null || ret=1
 status=$((status+ret))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 
+# retrieve max-stale-ttl value,
+interval_to_ancient=`grep 'max-stale-ttl' ns1/named2.conf.in  | awk '{ print $2 }' | tr -d ';'`
+# we add 2 seconds to it since this is the ttl value of the records being tested.
+interval_to_ancient=$((interval_to_ancient + 2))
+t2=`$PERL -e 'print time()'`
+elapsed=$((t2 - t1))
+
+# if elapsed time so far is less than max-stale-ttl + 2 seconds,
+# then we sleep enough to ensure that we'll ask for ancient rrsets
+# in the next queries.
+if [ $elapsed -lt $interval_to_ancient ]; then
+    sleep $((interval_to_ancient - elapsed))
+fi
+
 echo_i "sending queries for tests $((n+1))-$((n+4))..."
 $DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$((n+1)) &
 $DIG -p ${PORT} @10.53.0.1 othertype.example CAA > dig.out.test$((n+2)) &