tests.sh revision 247bf378605811d695e968dbe930a7fc45c0038e
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer#!/bin/sh
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer#
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer * Copyright (C) 2010, 2011 Internet Systems Consortium, Inc. ("ISC")
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer *
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer * Permission to use, copy, modify, and/or distribute this software for any
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews * purpose with or without fee is hereby granted, provided that the above
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer * copyright notice and this permission notice appear in all copies.
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews *
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews * PERFORMANCE OF THIS SOFTWARE.
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews# $Id: tests.sh,v 1.6 2011/06/17 23:47:49 tbox Exp $
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark AndrewsSYSTEMTESTTOP=..
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews. $SYSTEMTESTTOP/conf.sh
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark AndrewsDIGOPTS="+tcp +nosea +nostat +nocmd +norec +noques +noauth +noadd +nostats +dnssec -p 5300"
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsstatus=0
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsn=0
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsecho "I:checking normally loaded zone ($n)"
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsret=0
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews$DIG $DIGOPTS @10.53.0.2 a.normal.example a > dig.out.ns2.$n || ret=1
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsgrep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsgrep '^a.normal.example' dig.out.ns2.$n > /dev/null || ret=1
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsn=`expr $n + 1`
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsif [ $ret != 0 ]; then echo "I:failed"; fi
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsstatus=`expr $status + $ret`
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsecho "I:checking previously added zone ($n)"
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsret=0
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews$DIG $DIGOPTS @10.53.0.2 a.previous.example a > dig.out.ns2.$n || ret=1
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsgrep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsgrep '^a.previous.example' dig.out.ns2.$n > /dev/null || ret=1
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecickin=`expr $n + 1`
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecickiif [ $ret != 0 ]; then echo "I:failed"; fi
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayerstatus=`expr $status + $ret`
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsecho "I:adding new zone ($n)"
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayerret=0
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'added.example { type master; file "added.db"; };' 2>&1 | sed 's/^/I:ns2 /'
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews$DIG $DIGOPTS @10.53.0.2 a.added.example a > dig.out.ns2.$n || ret=1
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsgrep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsgrep '^a.added.example' dig.out.ns2.$n > /dev/null || ret=1
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsn=`expr $n + 1`
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecickiif [ $ret != 0 ]; then echo "I:failed"; fi
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsstatus=`expr $status + $ret`
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecicki
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecickiecho "I:adding new zone with missing master file ($n)"
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecickiret=0
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews$DIG $DIGOPTS +all @10.53.0.2 a.missing.example a > dig.out.ns2.pre.$n || ret=1
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecickigrep "status: REFUSED" dig.out.ns2.pre.$n > /dev/null || ret=1
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'missing.example { type master; file "missing.db"; };' 2> rndc.out.ns2.$n
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecickigrep "file not found" rndc.out.ns2.$n > /dev/null || ret=1
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer$DIG $DIGOPTS +all @10.53.0.2 a.missing.example a > dig.out.ns2.post.$n || ret=1
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsgrep "status: REFUSED" dig.out.ns2.post.$n > /dev/null || ret=1
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews$PERL ../digcomp.pl dig.out.ns2.pre.$n dig.out.ns2.post.$n || ret=1
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayern=`expr $n + 1`
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsif [ $ret != 0 ]; then echo "I:failed"; fi
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsstatus=`expr $status + $ret`
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsecho "I:deleting previously added zone ($n)"
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsret=0
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone previous.example 2>&1 | sed 's/^/I:ns2 /'
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews$DIG $DIGOPTS @10.53.0.2 a.previous.example a > dig.out.ns2.$n
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsgrep 'status: REFUSED' dig.out.ns2.$n > /dev/null || ret=1
cc51cd2d2076e33117c60c9effcb8caccde4983bWitold Krecickigrep '^a.previous.example' dig.out.ns2.$n > /dev/null && ret=1
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsn=`expr $n + 1`
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsif [ $ret != 0 ]; then echo "I:failed"; fi
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsstatus=`expr $status + $ret`
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsecho "I:deleting newly added zone ($n)"
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayerret=0
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone added.example 2>&1 | sed 's/^/I:ns2 /'
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrews$DIG $DIGOPTS @10.53.0.2 a.added.example a > dig.out.ns2.$n
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayergrep 'status: REFUSED' dig.out.ns2.$n > /dev/null || ret=1
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsgrep '^a.added.example' dig.out.ns2.$n > /dev/null && ret=1
132410d33fa565dd5a4254a1aca17ccd4e872a27Mark Andrewsn=`expr $n + 1`
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayerif [ $ret != 0 ]; then echo "I:failed"; fi
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayerstatus=`expr $status + $ret`
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayerecho "I:attempt to delete a normally-loaded zone ($n)"
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayerret=0
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayer$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone normal.example 2> rndc.out.ns2.$n
5236050c0f819b727dfc4850133f5194f346f76fDanny Mayergrep "permission denied" rndc.out.ns2.$n > /dev/null || ret=1
$DIG $DIGOPTS @10.53.0.2 a.normal.example a > dig.out.ns2.$n
grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
grep '^a.normal.example' dig.out.ns2.$n > /dev/null || ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:reconfiguring server with multiple views"
rm -f ns2/named.conf
cp -f ns2/named2.conf ns2/named.conf
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reconfig 2>&1 | sed 's/^/I:ns2 /'
sleep 5
echo "I:adding new zone to external view ($n)"
# NOTE: The internal view has "recursion yes" set, and so queries for
# nonexistent zones should return NOERROR. The external view is
# "recursion no", so queries for nonexistent zones should return
# REFUSED. This behavior should be the same regardless of whether
# the zone does not exist because a) it has not yet been loaded, b)
# it failed to load, or c) it has been deleted.
ret=0
$DIG +norec $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.intpre.$n || ret=1
grep 'status: NOERROR' dig.out.ns2.intpre.$n > /dev/null || ret=1
$DIG +norec $DIGOPTS @10.53.0.4 -b 10.53.0.4 a.added.example a > dig.out.ns2.extpre.$n || ret=1
grep 'status: REFUSED' dig.out.ns2.extpre.$n > /dev/null || ret=1
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'added.example in external { type master; file "added.db"; };' 2>&1 | sed 's/^/I:ns2 /'
$DIG +norec $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.int.$n || ret=1
grep 'status: NOERROR' dig.out.ns2.int.$n > /dev/null || ret=1
$DIG +norec $DIGOPTS @10.53.0.4 -b 10.53.0.4 a.added.example a > dig.out.ns2.ext.$n || ret=1
grep 'status: NOERROR' dig.out.ns2.ext.$n > /dev/null || ret=1
grep '^a.added.example' dig.out.ns2.ext.$n > /dev/null || ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:deleting newly added zone ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone 'added.example in external' 2>&1 | sed 's/^/I:ns2 /'
$DIG $DIGOPTS @10.53.0.4 -b 10.53.0.4 a.added.example a > dig.out.ns2.$n || ret=1
grep 'status: REFUSED' dig.out.ns2.$n > /dev/null || ret=1
grep '^a.added.example' dig.out.ns2.$n > /dev/null && ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:attempting to add zone to internal view ($n)"
ret=0
$DIG +norec $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.pre.$n || ret=1
grep 'status: NOERROR' dig.out.ns2.pre.$n > /dev/null || ret=1
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'added.example in internal { type master; file "added.db"; };' 2> rndc.out.ns2.$n
grep "permission denied" rndc.out.ns2.$n > /dev/null || ret=1
$DIG $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.int.$n || ret=1
grep 'status: NOERROR' dig.out.ns2.int.$n > /dev/null || ret=1
$DIG $DIGOPTS @10.53.0.4 -b 10.53.0.4 a.added.example a > dig.out.ns2.ext.$n || ret=1
grep 'status: REFUSED' dig.out.ns2.ext.$n > /dev/null || ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:ensure the configuration context is cleaned up correctly ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reconfig > /dev/null 2>&1 || ret=1
sleep 5
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 status > /dev/null 2>&1 || ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:exit status: $status"
exit $status