3140. [func] New command "rndc flushtree <name>" clears the

specified name from the server cache along with
			all names under it. [RT #19970]
This commit is contained in:
Evan Hunt
2011-08-02 20:36:13 +00:00
parent ea2c704ca2
commit 0127993480
13 changed files with 362 additions and 65 deletions

View File

@@ -15,18 +15,153 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# $Id: tests.sh,v 1.5 2007/06/19 23:47:00 tbox Exp $
# $Id: tests.sh,v 1.6 2011/08/02 20:36:12 each Exp $
SYSTEMTESTTOP=..
. $SYSTEMTESTTOP/conf.sh
status=0
$DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat \
-f dig.batch -p 5300 @10.53.0.2 > dig.out.ns2 || status=1
RNDCOPTS="-c ../common/rndc.conf -s 10.53.0.2 -p 9953"
DIGOPTS="+nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm \
+nostat @10.53.0.2 -p 5300"
# fill the cache with nodes from flushtest.example zone
load_cache () {
# empty all existing cache data
$RNDC $RNDCOPTS flush
# load the positive cache entries
$DIG $DIGOPTS txt top1.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt second1.top1.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt third1.second1.top1.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt third2.second1.top1.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt second2.top1.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt second3.top1.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt second1.top2.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt second2.top2.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt second3.top2.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt top3.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt second1.top3.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt third1.second1.top3.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt third2.second1.top3.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt third1.second2.top3.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt third2.second2.top3.flushtest.example > /dev/null 2>1
$DIG $DIGOPTS txt second3.top3.flushtest.example > /dev/null 2>1
# 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
# sleep one second ensure the TTLs will be lower on cached data
sleep 1
}
dump_cache () {
rm -f ns2/named_dump.db
$RNDC $RNDCOPTS dumpdb -cache
sleep 1
}
clear_cache () {
$RNDC $RNDCOPTS flush
}
in_cache () {
ttl=`$DIG $DIGOPTS "$@" | awk '{print $2}'`
[ -z "$ttl" ] && {
ttl=`$DIG $DIGOPTS +noanswer +auth "$@" | awk '{print $2}'`
[ "$ttl" -eq 3600 ] && return 1
return 0
}
[ "$ttl" -eq 3600 ] && return 1
return 0
}
echo "I:check correctness of routine cache cleaning"
$DIG $DIGOPTS -f dig.batch > dig.out.ns2 || status=1
grep ";" dig.out.ns2
$PERL ../digcomp.pl dig.out.ns2 knowngood.dig.out || status=1
echo "I:reset and check that records are correctly cached initially"
ret=0
load_cache
dump_cache
nrecords=`grep flushtest.example ns2/named_dump.db | grep -v '^;' | wc -l`
[ $nrecords -eq 20 ] || ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:check flushing of the full cache"
ret=0
clear_cache
dump_cache
nrecords=`grep flushtest.example ns2/named_dump.db | grep -v '^;' | wc -l`
[ $nrecords -eq 0 ] || ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:check flushing of individual nodes"
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
# 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
# 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
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:check flushing of namespaces"
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
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:check the number of cached records remaining"
ret=0
dump_cache
nrecords=`grep flushtest.example ns2/named_dump.db | grep -v '^;' | wc -l`
[ $nrecords -eq 19 ] || ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:exit status: $status"
exit $status