tests.sh revision 5a75f61dd413720c16d229b24ebba6bd6ecdb738
8b7304a34c751e519ede7d00b77f1f962c0a37e4David Lawrence#!/bin/sh
754cb8a2b33fa6cfaa15d6470f66e5fb0eab4764Automatic Updater#
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# Copyright (C) 2004, 2007, 2011 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# Copyright (C) 2001 Internet Software Consortium.
ec5347e2c775f027573ce5648b910361aa926c01Automatic Updater#
8b7304a34c751e519ede7d00b77f1f962c0a37e4David Lawrence# Permission to use, copy, modify, and/or distribute this software for any
8b7304a34c751e519ede7d00b77f1f962c0a37e4David Lawrence# purpose with or without fee is hereby granted, provided that the above
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# copyright notice and this permission notice appear in all copies.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews#
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
8b7304a34c751e519ede7d00b77f1f962c0a37e4David Lawrence# PERFORMANCE OF THIS SOFTWARE.
8b7304a34c751e519ede7d00b77f1f962c0a37e4David Lawrence
754cb8a2b33fa6cfaa15d6470f66e5fb0eab4764Automatic Updater# $Id: tests.sh,v 1.8 2011/08/23 00:59:23 each Exp $
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny MayerSYSTEMTESTTOP=..
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer. $SYSTEMTESTTOP/conf.sh
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerstatus=0
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny MayerRNDCOPTS="-c ../common/rndc.conf -s 10.53.0.2 -p 9953"
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny MayerDIGOPTS="+nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm \
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer +nostat @10.53.0.2 -p 5300"
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer# fill the cache with nodes from flushtest.example zone
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerload_cache () {
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer # empty all existing cache data
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $RNDC $RNDCOPTS flush
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer # load the positive cache entries
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt top1.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt second1.top1.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt third1.second1.top1.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt third2.second1.top1.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt second2.top1.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt second3.top1.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt second1.top2.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt second2.top2.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt second3.top2.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt top3.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt second1.top3.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt third1.second1.top3.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt third2.second1.top3.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt third1.second2.top3.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt third2.second2.top3.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt second3.top3.flushtest.example > /dev/null 2>1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer # load the negative cache entries
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer # nxrrset:
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS a third1.second1.top1.flushtest.example > /dev/null
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer # nxdomain:
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt top4.flushtest.example > /dev/null
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer # empty nonterminal:
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $DIG $DIGOPTS txt second2.top3.flushtest.example > /dev/null
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer # sleep one second ensure the TTLs will be lower on cached data
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer sleep 1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer}
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerdump_cache () {
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer rm -f ns2/named_dump.db
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $RNDC $RNDCOPTS dumpdb -cache
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer sleep 1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer}
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerclear_cache () {
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer $RNDC $RNDCOPTS flush
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayer}
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache () {
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer ttl=`$DIG $DIGOPTS "$@" | awk '{print $2}'`
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer [ -z "$ttl" ] && {
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer ttl=`$DIG $DIGOPTS +noanswer +auth "$@" | awk '{print $2}'`
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer [ "$ttl" -eq 3600 ] && return 1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer return 0
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer }
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer [ "$ttl" -eq 3600 ] && return 1
e76d4c91bfadf823f04dcca1c1c5bcc14c67671dAndreas Gustafsson return 0
e76d4c91bfadf823f04dcca1c1c5bcc14c67671dAndreas Gustafsson}
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerecho "I:check correctness of routine cache cleaning"
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayer$DIG $DIGOPTS -f dig.batch > dig.out.ns2 || status=1
e76d4c91bfadf823f04dcca1c1c5bcc14c67671dAndreas Gustafssongrep ";" dig.out.ns2
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer$PERL ../digcomp.pl dig.out.ns2 knowngood.dig.out || status=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerecho "I:reset and check that records are correctly cached initially"
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerret=0
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayerload_cache
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerdump_cache
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayernrecords=`grep flushtest.example ns2/named_dump.db | grep -v '^;' | wc -l`
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer[ $nrecords -eq 20 ] || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerif [ $ret != 0 ]; then echo "I:failed"; fi
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerstatus=`expr $status + $ret`
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerecho "I:check flushing of the full cache"
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerret=0
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerclear_cache
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerdump_cache
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayernrecords=`grep flushtest.example ns2/named_dump.db | grep -v '^;' | wc -l`
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer[ $nrecords -eq 0 ] || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerif [ $ret != 0 ]; then echo "I:failed"; fi
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerstatus=`expr $status + $ret`
39125379e5c9331f3dafd8d4bcb23fd52e30bfa8Andreas Gustafsson
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerecho "I:check flushing of individual nodes"
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerret=0
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerclear_cache
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerload_cache
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer# interior node
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt top1.flushtest.example || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer$RNDC $RNDCOPTS flushname top1.flushtest.example
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt top1.flushtest.example && ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer# leaf node, under the interior node (should still exist)
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt third2.second1.top1.flushtest.example || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer$RNDC $RNDCOPTS flushname third2.second1.top1.flushtest.example
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt third2.second1.top1.flushtest.example && ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer# another leaf node, with both positive and negative cache entries
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache a third1.second1.top1.flushtest.example || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt third1.second1.top1.flushtest.example || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer$RNDC $RNDCOPTS flushname third1.second1.top1.flushtest.example
bb48ac4f813537a060579615a52f9c7963f5e3c4Danny Mayerin_cache a third1.second1.top1.flushtest.example && ret=1
bb48ac4f813537a060579615a52f9c7963f5e3c4Danny Mayerin_cache txt third1.second1.top1.flushtest.example && ret=1
bb48ac4f813537a060579615a52f9c7963f5e3c4Danny Mayerif [ $ret != 0 ]; then echo "I:failed"; fi
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerstatus=`expr $status + $ret`
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerecho "I:check flushing a nonexistent name"
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerret=0
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer$RNDC $RNDCOPTS flushname fake.flushtest.example || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerif [ $ret != 0 ]; then echo "I:failed"; fi
e76d4c91bfadf823f04dcca1c1c5bcc14c67671dAndreas Gustafssonstatus=`expr $status + $ret`
e76d4c91bfadf823f04dcca1c1c5bcc14c67671dAndreas Gustafsson
e76d4c91bfadf823f04dcca1c1c5bcc14c67671dAndreas Gustafssonecho "I:check flushing of namespaces"
e76d4c91bfadf823f04dcca1c1c5bcc14c67671dAndreas Gustafssonret=0
e76d4c91bfadf823f04dcca1c1c5bcc14c67671dAndreas Gustafssonclear_cache
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerload_cache
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer# flushing leaf node should leave the interior node:
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt third1.second1.top1.flushtest.example || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt top1.flushtest.example || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer$RNDC $RNDCOPTS flushtree third1.second1.top1.flushtest.example
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt third1.second1.top1.flushtest.example && ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt top1.flushtest.example || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt second1.top1.flushtest.example || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt third2.second1.top1.flushtest.example || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer$RNDC $RNDCOPTS flushtree second1.top1.flushtest.example
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt top1.flushtest.example || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt second1.top1.flushtest.example && ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt third2.second1.top1.flushtest.example && ret=1
1e71bc82b8e1a95d423d8db1c136080dc034433dAndreas Gustafsson
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer# flushing from an empty node should still remove all its children
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayerin_cache txt second1.top2.flushtest.example || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer$RNDC $RNDCOPTS flushtree top2.flushtest.example
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt second1.top2.flushtest.example && ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt second2.top2.flushtest.example && ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerin_cache txt second3.top2.flushtest.example && ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerif [ $ret != 0 ]; then echo "I:failed"; fi
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayerstatus=`expr $status + $ret`
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayerecho "I:check flushing a nonexistent namespace"
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayerret=0
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayer$RNDC $RNDCOPTS flushtree fake.flushtest.example || ret=1
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayerif [ $ret != 0 ]; then echo "I:failed"; fi
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayerstatus=`expr $status + $ret`
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerecho "I:check the number of cached records remaining"
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerret=0
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayerdump_cache
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayernrecords=`grep flushtest.example ns2/named_dump.db | grep -v '^;' | wc -l`
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayer[ $nrecords -eq 19 ] || ret=1
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerif [ $ret != 0 ]; then echo "I:failed"; fi
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerstatus=`expr $status + $ret`
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayer
e35c1bb3ecd9a6597360b9160b397c8053af69bfDanny Mayerecho "I:exit status: $status"
68c2ccc953059f389cefc0f8a5ce0f83be7458c9Danny Mayerexit $status
e76d4c91bfadf823f04dcca1c1c5bcc14c67671dAndreas Gustafsson