tests.sh revision cc51cd2d2076e33117c60c9effcb8caccde4983b
#
# Copyright (C) 2000, 2001, 2004, 2007, 2009-2016 Internet Systems Consortium, Inc. ("ISC")
#
# 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/.
# $Id: tests.sh,v 1.42 2011/12/16 23:01:17 each Exp $
status=0
n=0
# wait for zone transfer to complete
tries=0
while true; do
then
exit 1
fi
then
break
else
echo "I:zones are not fully loaded, waiting..."
sleep 1
fi
done
ret=0
echo "I:fetching first copy of zone before update"
ret=0
echo "I:fetching second copy of zone before update"
ret=0
echo "I:comparing pre-update copies to known good data"
ret=0
echo "I:updating zone"
# nsupdate will print a ">" prompt to stdout as it gets each input line.
server 10.53.0.1 5300
update add updated.example.nil. 600 A 10.10.10.1
add updated.example.nil. 600 TXT Foo
delete t.example.nil.
END
echo "I:sleeping 5 seconds for server to incorporate changes"
sleep 5
ret=0
echo "I:fetching first copy of zone after update"
ret=0
echo "I:fetching second copy of zone after update"
ret=0
echo "I:comparing post-update copies to known good data"
ret=0
echo "I:testing local update policy"
ret=0
echo "I:updating zone"
# nsupdate will print a ">" prompt to stdout as it gets each input line.
zone other.nil.
update add new.other.nil. 600 IN A 10.10.10.1
send
END
echo "I:sleeping 5 seconds for server to incorporate changes"
sleep 5
ret=0
echo "I:checking result of update"
ret=0
echo "I:comparing post-update copy to known good data"
ret=0
echo "I:testing zone consistency checks"
# inserting an NS record without a corresponding A or AAAA record should fail
update add other.nil. 600 in ns ns3.other.nil.
send
END
# ...but should work if an A record is inserted first:
update add ns4.other.nil 600 in a 10.53.0.1
send
update add other.nil. 600 in ns ns4.other.nil.
send
END
# ...or if an AAAA record does:
update add ns5.other.nil 600 in aaaa 2001:db8::1
send
update add other.nil. 600 in ns ns5.other.nil.
send
END
update add other.nil. 600 in ns ns6.other.nil.
update add ns6.other.nil 600 in a 10.53.0.1
send
END
echo "I:sleeping 5 seconds for server to incorporate changes"
sleep 5
ret=0
echo "I:checking result of update"
ret=0
echo "I:check SIG(0) key is accepted"
n=`expr $n + 1`
ret=0
echo "I:check TYPE=0 update is rejected by nsupdate ($n)"
$NSUPDATE <<END > nsupdate.out 2>&1 && ret=1
server 10.53.0.1 5300
ttl 300
update add example.nil. in type0 ""
send
END
n=`expr $n + 1`
ret=0
echo "I:check TYPE=0 prerequisite is handled ($n)"
server 10.53.0.1 5300
prereq nxrrset example.nil. type0
send
END
n=`expr $n + 1`
ret=0
echo "I:check that TYPE=0 update is handled ($n)"
echo "a0e4280000010000000100000000060001c00c000000fe000000000000" |
n=`expr $n + 1`
echo "I:check that TYPE=0 additional data is handled ($n)"
echo "a0e4280000010000000000010000060001c00c000000fe000000000000" |
n=`expr $n + 1`
echo "I:check that update to undefined class is handled ($n)"
echo "a0e4280000010001000000000000060101c00c000000fe000000000000" |
n=`expr $n + 1`
echo "I:check that address family mismatch is handled ($n)"
$NSUPDATE <<END > /dev/null 2>&1 && ret=1
server ::1
local 127.0.0.1
update add 600 txt.example.nil in txt "test"
send
END
n=`expr $n + 1`
echo "I:check that unixtime serial number is correctly generated ($n)"
$NSUPDATE <<END > /dev/null 2>&1 || ret=1
server 10.53.0.1 5300
ttl 600
update add new.unixtime.nil in a 1.2.3.4
send
END
sleep 1
# allow up to 2 seconds difference between the serial
# number and the unix epoch date but no more
then
echo "I:running update.pl test"
else
echo "I:The second part of this test requires the Net::DNS library." >&2
fi
ret=0
echo "I:fetching first copy of test zone"
echo "I:fetching second copy of test zone"
ret=0
echo "I:comparing zones"
echo "I:SIGKILL and restart server ns1"
cd ns1
cd ..
sleep 10
if
then
echo "I:restarted server ns1"
else
echo "I:could not restart server ns1"
exit 1
fi
sleep 10
ret=0
echo "I:fetching ns1 after hard restart"
ret=0
echo "I:comparing zones"
echo "I:begin RT #482 regression test"
ret=0
echo "I:update master"
server 10.53.0.1 5300
update add updated2.example.nil. 600 A 10.10.10.2
update add updated2.example.nil. 600 TXT Bar
update delete c.example.nil.
send
END
sleep 5
if [ ! "$CYGWIN" ]; then
echo "I:SIGHUP slave"
else
echo "I:reload slave"
fi
sleep 5
ret=0
echo "I:update master again"
server 10.53.0.1 5300
update add updated3.example.nil. 600 A 10.10.10.3
update add updated3.example.nil. 600 TXT Zap
del d.example.nil.
send
END
sleep 5
if [ ! "$CYGWIN" ]; then
echo "I:SIGHUP slave again"
else
echo "I:reload slave again"
fi
sleep 5
echo "I:check to 'out of sync' message"
then
echo "I: failed (found 'out of sync')"
status=1
fi
echo "I:end RT #482 regression test"
n=`expr $n + 1`
ret=0
echo "I:start NSEC3PARAM changes via UPDATE on a unsigned zone test ($n)"
$NSUPDATE << EOF
server 10.53.0.3 5300
update add example 3600 nsec3param 1 0 0 -
send
EOF
sleep 1
# the zone is not signed. The nsec3param records should be removed.
# this also proves that the server is still running.
n=`expr $n + 1`
ret=0
echo "I:change the NSEC3PARAM ttl via update ($n)"
$NSUPDATE << EOF
server 10.53.0.3 5300
update add nsec3param.test 3600 NSEC3PARAM 1 0 1 -
send
EOF
sleep 1
n=`expr $n + 1`
ret=0
echo "I:add a new the NSEC3PARAM via update ($n)"
$NSUPDATE << EOF
server 10.53.0.3 5300
update add nsec3param.test 3600 NSEC3PARAM 1 0 4 -
send
EOF
sleep 1
n=`expr $n + 1`
ret=0
echo "I:add, delete and change the ttl of the NSEC3PARAM rrset via update ($n)"
$NSUPDATE << EOF
server 10.53.0.3 5300
update delete nsec3param.test NSEC3PARAM
update add nsec3param.test 7200 NSEC3PARAM 1 0 5 -
send
EOF
sleep 1
# intermediate TTL changes.
# delayed adds and deletes.
echo "I:testing that rndc stop updates the master file"
server 10.53.0.1 5300
update add updated4.example.nil. 600 A 10.10.10.3
send
END
# Removing the journal file and restarting the server means
# that the data served by the new server process are exactly
# those dumped to the master file by "rndc stop".
ret=0
echo "I:check that 'nsupdate -l' with a missing keyfile reports the missing file"
then
fi
n=`expr $n + 1`
ret=0
echo "I:check that changes to the DNSKEY RRset TTL do not have side effects ($n)"
then
fi
n=`expr $n + 1`
ret=0
echo "I:check notify with TSIG worked ($n)"
# if the alternate view received a notify--meaning, the notify was
# validly signed by "altkey"--then the zonefile update.alt.bk will
# will have been created.
echo "I:failed"
status=1
fi
n=`expr $n + 1`
ret=0
echo "I:check type list options ($n)"
echo "I:failed"
status=1
fi
n=`expr $n + 1`
ret=0
echo "I:check command list ($n)"
(
while read cmd
do
if test $? -gt 1 ; then
echo "I: failed ($cmd)"
ret=1
fi
if test $? -gt 1 ; then
echo "I: failed ($cmd)"
ret=1
fi
done
exit $ret
status=1
fi
n=`expr $n + 1`
ret=0
echo "I:check TSIG key algorithms ($n)"
server 10.53.0.1 5300
update add ${alg}.keytests.nil. 600 A 10.10.10.3
send
END
done
sleep 2
done
echo "I:failed"
status=1
fi
n=`expr $n + 1`
ret=0
echo "I:check that ttl is capped by max-ttl ($n)"
$NSUPDATE <<END > /dev/null || ret=1
server 10.53.0.1 5300
update add cap.max-ttl.nil. 600 A 10.10.10.3
update add nocap.max-ttl.nil. 150 A 10.10.10.3
send
END
sleep 2
$DIG @10.53.0.1 -p 5300 nocap.max-ttl.nil | grep "^nocap.max-ttl.nil. 150" > /dev/null 2>&1 || ret=1
echo "I:failed"
status=1
fi
n=`expr $n + 1`
ret=0
echo "I:add a record which is truncated when logged. ($n)"
echo "I:failed"
status=1
fi
n=`expr $n + 1`
echo "I:check that yyyymmddvv serial number is correctly generated ($n)"
$NSUPDATE <<END > /dev/null 2>&1 || ret=1
server 10.53.0.1 5300
ttl 600
update add new.yyyymmddvv.nil in a 1.2.3.4
send
END
sleep 1
#
# Refactor to use perl to launch the parallel updates.
#
if false
then
n=`expr $n + 1`
echo "I:send many simultaneous updates via a update forwarder ($n)"
ret=0
do
(
for j in 0 1 2 3 4 5 6 7
do
(
$NSUPDATE << EOF
server 10.53.0.3 5300
zone many.test
update add $i-$j.many.test 0 IN A 1.2.3.4
send
EOF
) &
done
wait
) &
done
wait
fi
n=`expr $n + 1`
echo "I:check check-names processing ($n)"
ret=0
$NSUPDATE << EOF > nsupdate.out1-$n 2>&1
update add # 0 in a 1.2.3.4
EOF
$NSUPDATE << EOF > nsupdate.out2-$n 2>&1
check-names off
update add # 0 in a 1.2.3.4
EOF
$NSUPDATE << EOF > nsupdate.out3-$n 2>&1
update add . 0 in mx 0 #
EOF
$NSUPDATE << EOF > nsupdate.out4-$n 2>&1
check-names off
update add . 0 in mx 0 #
EOF
n=`expr $n + 1`
echo "I:check adding of delegating NS records processing ($n)"
ret=0
$NSUPDATE -v << EOF > nsupdate.out-$n 2>&1 || ret=1
server 10.53.0.3 5300
zone delegation.test.
update add child.delegation.test. 3600 NS foo.example.net.
update add child.delegation.test. 3600 NS bar.example.net.
send
EOF
n=`expr $n + 1`
echo "I:check deleting of delegating NS records processing ($n)"
ret=0
$NSUPDATE -v << EOF > nsupdate.out-$n 2>&1 || ret=1
server 10.53.0.3 5300
zone delegation.test.
update del child.delegation.test. 3600 NS foo.example.net.
update del child.delegation.test. 3600 NS bar.example.net.
send
EOF
echo "I:exit status: $status"