2001-03-05 12:50:08 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2016-06-27 14:56:38 +10:00
|
|
|
# Copyright (C) 2001, 2004, 2007, 2011-2014, 2016 Internet Systems Consortium, Inc. ("ISC")
|
2012-06-29 11:39:47 +10:00
|
|
|
#
|
2016-06-27 14:56:38 +10:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2001-03-05 12:50:08 +00:00
|
|
|
|
|
|
|
SYSTEMTESTTOP=..
|
|
|
|
. $SYSTEMTESTTOP/conf.sh
|
|
|
|
|
|
|
|
status=0
|
2018-02-20 13:59:25 +01:00
|
|
|
n=0
|
2001-03-05 12:50:08 +00:00
|
|
|
|
2018-02-20 15:43:27 -08:00
|
|
|
RNDCOPTS="-c ../common/rndc.conf -s 10.53.0.2 -p ${CONTROLPORT}"
|
2011-08-02 20:36:13 +00:00
|
|
|
DIGOPTS="+nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm \
|
2018-02-20 15:43:27 -08:00
|
|
|
+nostat @10.53.0.2 -p ${PORT}"
|
2011-08-02 20:36:13 +00:00
|
|
|
|
|
|
|
# fill the cache with nodes from flushtest.example zone
|
|
|
|
load_cache () {
|
|
|
|
# empty all existing cache data
|
|
|
|
$RNDC $RNDCOPTS flush
|
|
|
|
|
|
|
|
# load the positive cache entries
|
2012-03-14 16:02:15 +11:00
|
|
|
$DIG $DIGOPTS -f - << EOF > /dev/null 2>&1
|
2011-09-01 05:28:14 +00:00
|
|
|
txt top1.flushtest.example
|
|
|
|
txt second1.top1.flushtest.example
|
|
|
|
txt third1.second1.top1.flushtest.example
|
|
|
|
txt third2.second1.top1.flushtest.example
|
|
|
|
txt second2.top1.flushtest.example
|
|
|
|
txt second3.top1.flushtest.example
|
|
|
|
txt second1.top2.flushtest.example
|
|
|
|
txt second2.top2.flushtest.example
|
|
|
|
txt second3.top2.flushtest.example
|
|
|
|
txt top3.flushtest.example
|
|
|
|
txt second1.top3.flushtest.example
|
|
|
|
txt third1.second1.top3.flushtest.example
|
|
|
|
txt third2.second1.top3.flushtest.example
|
|
|
|
txt third1.second2.top3.flushtest.example
|
|
|
|
txt third2.second2.top3.flushtest.example
|
|
|
|
txt second3.top3.flushtest.example
|
|
|
|
EOF
|
2011-08-02 20:36:13 +00:00
|
|
|
|
|
|
|
# load the negative cache entries
|
|
|
|
# nxrrset:
|
|
|
|
$DIG $DIGOPTS a third1.second1.top1.flushtest.example > /dev/null
|
|
|
|
# nxdomain:
|
|
|
|
$DIG $DIGOPTS txt top4.flushtest.example > /dev/null
|
|
|
|
# empty nonterminal:
|
|
|
|
$DIG $DIGOPTS txt second2.top3.flushtest.example > /dev/null
|
|
|
|
|
2011-09-01 05:28:14 +00:00
|
|
|
# sleep 2 seconds ensure the TTLs will be lower on cached data
|
|
|
|
sleep 2
|
2011-08-02 20:36:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dump_cache () {
|
2013-06-26 14:59:32 -07:00
|
|
|
$RNDC $RNDCOPTS dumpdb -cache _default
|
2018-02-20 13:59:28 +01:00
|
|
|
for i in 0 1 2 3 4 5 6 7 8 9
|
|
|
|
do
|
|
|
|
grep '^; Dump complete$' ns2/named_dump.db > /dev/null && break
|
|
|
|
sleep 1
|
|
|
|
done
|
2018-02-20 13:59:27 +01:00
|
|
|
mv ns2/named_dump.db ns2/named_dump.db.$n
|
2011-08-02 20:36:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
clear_cache () {
|
|
|
|
$RNDC $RNDCOPTS flush
|
|
|
|
}
|
|
|
|
|
|
|
|
in_cache () {
|
|
|
|
ttl=`$DIG $DIGOPTS "$@" | awk '{print $2}'`
|
|
|
|
[ -z "$ttl" ] && {
|
|
|
|
ttl=`$DIG $DIGOPTS +noanswer +auth "$@" | awk '{print $2}'`
|
2011-09-01 05:28:14 +00:00
|
|
|
[ "$ttl" -ge 3599 ] && return 1
|
2011-08-02 20:36:13 +00:00
|
|
|
return 0
|
|
|
|
}
|
2011-09-01 05:28:14 +00:00
|
|
|
[ "$ttl" -ge 3599 ] && return 1
|
2011-08-02 20:36:13 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "check correctness of routine cache cleaning ($n)"
|
2013-11-07 10:50:01 +11:00
|
|
|
$DIG $DIGOPTS +tcp +keepopen -b 10.53.0.7 -f dig.batch > dig.out.ns2 || status=1
|
2001-03-05 12:50:08 +00:00
|
|
|
grep ";" dig.out.ns2
|
|
|
|
|
2013-09-05 12:22:34 +10:00
|
|
|
$PERL ../digcomp.pl --lc dig.out.ns2 knowngood.dig.out || status=1
|
2001-03-05 12:50:08 +00:00
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "only one tcp socket was used ($n)"
|
2016-08-29 11:56:36 -07:00
|
|
|
tcpclients=`awk '$3 == "client" && $5 ~ /10.53.0.7#[0-9]*:/ {print $5}' ns2/named.run | sort | uniq -c | wc -l`
|
2013-11-07 10:50:01 +11:00
|
|
|
|
2018-02-20 15:43:27 -08:00
|
|
|
test $tcpclients -eq 1 || { status=1; echo_i "failed"; }
|
2013-11-07 10:50:01 +11:00
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "reset and check that records are correctly cached initially ($n)"
|
2011-08-02 20:36:13 +00:00
|
|
|
ret=0
|
|
|
|
load_cache
|
|
|
|
dump_cache
|
2018-02-20 13:59:27 +01:00
|
|
|
nrecords=`grep flushtest.example ns2/named_dump.db.$n | grep -v '^;' | egrep '(TXT|ANY)'| wc -l`
|
2018-02-20 15:43:27 -08:00
|
|
|
[ $nrecords -eq 17 ] || { ret=1; echo_i "found $nrecords records expected 17"; }
|
|
|
|
if [ $ret != 0 ]; then echo_i "failed"; fi
|
2011-08-02 20:36:13 +00:00
|
|
|
status=`expr $status + $ret`
|
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "check flushing of the full cache ($n)"
|
2011-08-02 20:36:13 +00:00
|
|
|
ret=0
|
|
|
|
clear_cache
|
|
|
|
dump_cache
|
2018-02-20 13:59:27 +01:00
|
|
|
nrecords=`grep flushtest.example ns2/named_dump.db.$n | grep -v '^;' | wc -l`
|
2011-08-02 20:36:13 +00:00
|
|
|
[ $nrecords -eq 0 ] || ret=1
|
2018-02-20 15:43:27 -08:00
|
|
|
if [ $ret != 0 ]; then echo_i "failed"; fi
|
2011-08-02 20:36:13 +00:00
|
|
|
status=`expr $status + $ret`
|
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "check flushing of individual nodes (interior node) ($n)"
|
2011-08-02 20:36:13 +00:00
|
|
|
ret=0
|
|
|
|
clear_cache
|
|
|
|
load_cache
|
|
|
|
# interior node
|
|
|
|
in_cache txt top1.flushtest.example || ret=1
|
|
|
|
$RNDC $RNDCOPTS flushname top1.flushtest.example
|
|
|
|
in_cache txt top1.flushtest.example && ret=1
|
2018-02-20 15:43:27 -08:00
|
|
|
if [ $ret != 0 ]; then echo_i "failed"; fi
|
2011-08-29 03:31:29 +00:00
|
|
|
status=`expr $status + $ret`
|
2011-08-02 20:36:13 +00:00
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "check flushing of individual nodes (leaf node, under the interior node) ($n)"
|
2011-08-29 03:31:29 +00:00
|
|
|
ret=0
|
2011-08-02 20:36:13 +00:00
|
|
|
# leaf node, under the interior node (should still exist)
|
|
|
|
in_cache txt third2.second1.top1.flushtest.example || ret=1
|
|
|
|
$RNDC $RNDCOPTS flushname third2.second1.top1.flushtest.example
|
|
|
|
in_cache txt third2.second1.top1.flushtest.example && ret=1
|
2018-02-20 15:43:27 -08:00
|
|
|
if [ $ret != 0 ]; then echo_i "failed"; fi
|
2011-08-29 03:31:29 +00:00
|
|
|
status=`expr $status + $ret`
|
2011-08-02 20:36:13 +00:00
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "check flushing of individual nodes (another leaf node, with both positive and negative cache entries) ($n)"
|
2011-08-29 03:31:29 +00:00
|
|
|
ret=0
|
2011-08-02 20:36:13 +00:00
|
|
|
# another leaf node, with both positive and negative cache entries
|
|
|
|
in_cache a third1.second1.top1.flushtest.example || ret=1
|
|
|
|
in_cache txt third1.second1.top1.flushtest.example || ret=1
|
|
|
|
$RNDC $RNDCOPTS flushname third1.second1.top1.flushtest.example
|
|
|
|
in_cache a third1.second1.top1.flushtest.example && ret=1
|
|
|
|
in_cache txt third1.second1.top1.flushtest.example && ret=1
|
2018-02-20 15:43:27 -08:00
|
|
|
if [ $ret != 0 ]; then echo_i "failed"; fi
|
2011-08-02 20:36:13 +00:00
|
|
|
status=`expr $status + $ret`
|
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "check flushing a nonexistent name ($n)"
|
2011-08-23 00:59:23 +00:00
|
|
|
ret=0
|
|
|
|
$RNDC $RNDCOPTS flushname fake.flushtest.example || ret=1
|
2018-02-20 15:43:27 -08:00
|
|
|
if [ $ret != 0 ]; then echo_i "failed"; fi
|
2011-08-23 00:59:23 +00:00
|
|
|
status=`expr $status + $ret`
|
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "check flushing of namespaces ($n)"
|
2011-08-02 20:36:13 +00:00
|
|
|
ret=0
|
|
|
|
clear_cache
|
|
|
|
load_cache
|
|
|
|
# flushing leaf node should leave the interior node:
|
|
|
|
in_cache txt third1.second1.top1.flushtest.example || ret=1
|
|
|
|
in_cache txt top1.flushtest.example || ret=1
|
|
|
|
$RNDC $RNDCOPTS flushtree third1.second1.top1.flushtest.example
|
|
|
|
in_cache txt third1.second1.top1.flushtest.example && ret=1
|
|
|
|
in_cache txt top1.flushtest.example || ret=1
|
|
|
|
in_cache txt second1.top1.flushtest.example || ret=1
|
|
|
|
in_cache txt third2.second1.top1.flushtest.example || ret=1
|
|
|
|
$RNDC $RNDCOPTS flushtree second1.top1.flushtest.example
|
|
|
|
in_cache txt top1.flushtest.example || ret=1
|
|
|
|
in_cache txt second1.top1.flushtest.example && ret=1
|
|
|
|
in_cache txt third2.second1.top1.flushtest.example && ret=1
|
|
|
|
|
|
|
|
# flushing from an empty node should still remove all its children
|
|
|
|
in_cache txt second1.top2.flushtest.example || ret=1
|
|
|
|
$RNDC $RNDCOPTS flushtree top2.flushtest.example
|
|
|
|
in_cache txt second1.top2.flushtest.example && ret=1
|
|
|
|
in_cache txt second2.top2.flushtest.example && ret=1
|
|
|
|
in_cache txt second3.top2.flushtest.example && ret=1
|
2018-02-20 15:43:27 -08:00
|
|
|
if [ $ret != 0 ]; then echo_i "failed"; fi
|
2011-08-02 20:36:13 +00:00
|
|
|
status=`expr $status + $ret`
|
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "check flushing a nonexistent namespace ($n)"
|
2011-08-23 00:59:23 +00:00
|
|
|
ret=0
|
|
|
|
$RNDC $RNDCOPTS flushtree fake.flushtest.example || ret=1
|
2018-02-20 15:43:27 -08:00
|
|
|
if [ $ret != 0 ]; then echo_i "failed"; fi
|
2011-08-23 00:59:23 +00:00
|
|
|
status=`expr $status + $ret`
|
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "check the number of cached records remaining ($n)"
|
2011-08-02 20:36:13 +00:00
|
|
|
ret=0
|
|
|
|
dump_cache
|
2018-02-20 13:59:27 +01:00
|
|
|
nrecords=`grep flushtest.example ns2/named_dump.db.$n | grep -v '^;' | egrep '(TXT|ANY)' | wc -l`
|
2018-02-20 15:43:27 -08:00
|
|
|
[ $nrecords -eq 17 ] || { ret=1; echo_i "found $nrecords records expected 17"; }
|
|
|
|
if [ $ret != 0 ]; then echo_i "failed"; fi
|
2011-08-02 20:36:13 +00:00
|
|
|
status=`expr $status + $ret`
|
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "check the check that flushname of a partial match works ($n)"
|
2016-03-24 11:31:25 +11:00
|
|
|
ret=0
|
|
|
|
in_cache txt second2.top1.flushtest.example || ret=1
|
|
|
|
$RNDC $RNDCOPTS flushtree example
|
|
|
|
in_cache txt second2.top1.flushtest.example && ret=1
|
2018-02-20 15:43:27 -08:00
|
|
|
if [ $ret != 0 ]; then echo_i "failed"; fi
|
2016-03-24 11:31:25 +11:00
|
|
|
status=`expr $status + $ret`
|
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "check the number of cached records remaining ($n)"
|
2016-03-24 11:31:25 +11:00
|
|
|
ret=0
|
|
|
|
dump_cache
|
2018-02-20 13:59:27 +01:00
|
|
|
nrecords=`grep flushtest.example ns2/named_dump.db.$n | grep -v '^;' | egrep '(TXT|ANY)' | wc -l`
|
2018-02-20 15:43:27 -08:00
|
|
|
[ $nrecords -eq 1 ] || { ret=1; echo_i "found $nrecords records expected 1"; }
|
|
|
|
if [ $ret != 0 ]; then echo_i "failed"; fi
|
2016-03-24 11:31:25 +11:00
|
|
|
status=`expr $status + $ret`
|
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "check flushtree clears adb correctly ($n)"
|
2013-06-26 14:59:32 -07:00
|
|
|
ret=0
|
|
|
|
load_cache
|
|
|
|
dump_cache
|
2018-02-20 13:59:27 +01:00
|
|
|
mv ns2/named_dump.db.$n ns2/named_dump.db.$n.a
|
2018-02-21 12:33:02 +11:00
|
|
|
sed -n '/plain success\/timeout/,/Unassociated entries/p' \
|
|
|
|
ns2/named_dump.db.$n.a > sed.out.$n.a
|
|
|
|
grep 'plain success/timeout' sed.out.$n.a > /dev/null 2>&1 || ret=1
|
|
|
|
grep 'Unassociated entries' sed.out.$n.a > /dev/null 2>&1 || ret=1
|
|
|
|
grep 'ns.flushtest.example' sed.out.$n.a > /dev/null 2>&1 || ret=1
|
2013-06-30 18:53:48 -07:00
|
|
|
$RNDC $RNDCOPTS flushtree flushtest.example || ret=1
|
2013-06-26 14:59:32 -07:00
|
|
|
dump_cache
|
2018-02-20 13:59:27 +01:00
|
|
|
mv ns2/named_dump.db.$n ns2/named_dump.db.$n.b
|
2018-02-21 12:33:02 +11:00
|
|
|
sed -n '/plain success\/timeout/,/Unassociated entries/p' \
|
|
|
|
ns2/named_dump.db.$n.b > sed.out.$n.b
|
|
|
|
grep 'plain success/timeout' sed.out.$n.b > /dev/null 2>&1 || ret=1
|
|
|
|
grep 'Unassociated entries' sed.out.$n.b > /dev/null 2>&1 || ret=1
|
|
|
|
grep 'ns.flushtest.example' sed.out.$n.b > /dev/null 2>&1 && ret=1
|
2018-02-20 15:43:27 -08:00
|
|
|
if [ $ret != 0 ]; then echo_i "failed"; fi
|
2013-06-26 14:59:32 -07:00
|
|
|
status=`expr $status + $ret`
|
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "check expire option returned from master zone ($n)"
|
2016-08-12 09:31:41 +10:00
|
|
|
ret=0
|
2018-02-20 15:43:27 -08:00
|
|
|
$DIG @10.53.0.1 -p ${PORT} +expire soa expire-test > dig.out.expire
|
2016-08-12 09:31:41 +10:00
|
|
|
grep EXPIRE: dig.out.expire > /dev/null || ret=1
|
2018-02-20 15:43:27 -08:00
|
|
|
if [ $ret != 0 ]; then echo_i "failed"; fi
|
2016-08-12 09:31:41 +10:00
|
|
|
status=`expr $status + $ret`
|
|
|
|
|
2018-02-20 13:59:25 +01:00
|
|
|
n=`expr $n + 1`
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "check expire option returned from slave zone ($n)"
|
2014-02-20 14:56:20 +11:00
|
|
|
ret=0
|
2018-02-20 15:43:27 -08:00
|
|
|
$DIG @10.53.0.2 -p ${PORT} +expire soa expire-test > dig.out.expire
|
2014-02-20 14:56:20 +11:00
|
|
|
grep EXPIRE: dig.out.expire > /dev/null || ret=1
|
2018-02-20 15:43:27 -08:00
|
|
|
if [ $ret != 0 ]; then echo_i "failed"; fi
|
2014-02-20 14:56:20 +11:00
|
|
|
status=`expr $status + $ret`
|
|
|
|
|
2018-02-20 15:43:27 -08:00
|
|
|
echo_i "exit status: $status"
|
2016-06-14 13:48:39 +10:00
|
|
|
[ $status -eq 0 ] || exit 1
|