Merge branch '745-start.pl-refactoring-v9_12-v9_11' into 'v9_11'

(v9_11) start.pl - wait for server to say 'running', refactor

See merge request isc-projects/bind9!1171
This commit is contained in:
Ondřej Surý 2018-12-03 15:01:29 -05:00
commit 47ade1ec01
26 changed files with 627 additions and 419 deletions

View file

@ -380,7 +380,7 @@ if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "reconfiguring server with multiple views"
rm -f ns2/named.conf
rm -f ns2/named.conf
copy_setports ns2/named2.conf.in ns2/named.conf
$RNDCCMD 10.53.0.2 reconfig 2>&1 | sed 's/^/ns2 /' | cat_i
sleep 5
@ -527,8 +527,8 @@ echo_i "check that named restarts with multiple added zones ($n)"
ret=0
$RNDCCMD 10.53.0.3 addzone "test4.baz" '{ type master; file "e.db"; };' > /dev/null 2>&1 || ret=1
$RNDCCMD 10.53.0.3 addzone "test5.baz" '{ type master; file "e.db"; };' > /dev/null 2>&1 || ret=1
$PERL $SYSTEMTESTTOP/stop.pl . ns3
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns3 || ret=1
$PERL $SYSTEMTESTTOP/stop.pl addzone ns3
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} addzone ns3 || ret=1
$DIG $DIGOPTS @10.53.0.3 version.bind txt ch > dig.out.test$n || ret=1
grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
n=`expr $n + 1`

View file

@ -1993,7 +1993,7 @@ echo_i "waiting till 14s have passed since NTAs were added before restarting ns4
$PERL -e 'my $delay = '$start' + 14 - time(); select(undef, undef, undef, $delay) if ($delay > 0);'
if
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns4
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} dnssec ns4
then
echo_i "restarted server ns4"
else
@ -2061,7 +2061,7 @@ echo "secure.example. regular $future" > ns4/_default.nta
start=`$PERL -e 'print time()."\n";'`
if
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns4
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} dnssec ns4
then
echo_i "restarted server ns4"
else
@ -2118,7 +2118,7 @@ echo "secure.example. forced $future" > ns4/_default.nta
start=`$PERL -e 'print time()."\n";'`
if
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns4
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} dnssec ns4
then
echo_i "restarted server ns4"
else
@ -2167,7 +2167,7 @@ echo "secure.example. forced $future" > ns4/_default.nta
added=`$PERL -e 'print time()."\n";'`
if
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns4
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} dnssec ns4
then
echo_i "restarted server ns4"
else

View file

@ -88,10 +88,10 @@ echo_i "checking for negative caching of forwarder response"
ret=0
$DIG $DIGOPTS nonexist. txt @10.53.0.5 > dig.out.f2 || ret=1
grep "status: NXDOMAIN" dig.out.f2 > /dev/null || ret=1
$PERL ../stop.pl . ns4 || ret=1
$PERL ../stop.pl forward ns4 || ret=1
$DIG $DIGOPTS nonexist. txt @10.53.0.5 > dig.out.f2 || ret=1
grep "status: NXDOMAIN" dig.out.f2 > /dev/null || ret=1
$PERL ../start.pl --restart --noclean --port ${PORT} . ns4 || ret=1
$PERL ../start.pl --restart --noclean --port ${PORT} forward ns4 || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`

View file

@ -438,7 +438,7 @@ EOF
[ -f ns3/dynamic.db.jnl ] || { ret=1 ; echo_i "journal does not exist (posttest)" ; }
for i in 1 2 3 4 5 6 7 8 9 10
do
do
ans=0
$DIG $DIGOPTS @10.53.0.3 e.dynamic > dig.out.ns3.test$n
grep "status: NOERROR" dig.out.ns3.test$n > /dev/null || ans=1
@ -455,14 +455,14 @@ status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "stop bump in the wire signer server ($n)"
ret=0
$PERL ../stop.pl . ns3 || ret=1
$PERL ../stop.pl inline ns3 || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "restart bump in the wire signer server ($n)"
ret=0
$PERL ../start.pl --noclean --restart --port ${PORT} . ns3 || ret=1
$PERL ../start.pl --noclean --restart --port ${PORT} inline ns3 || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@ -870,7 +870,7 @@ status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "stop bump in the wire signer server ($n)"
ret=0
$PERL ../stop.pl . ns3 || ret=1
$PERL ../stop.pl inline ns3 || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@ -881,7 +881,7 @@ rm ns3/master.db.jnl
n=`expr $n + 1`
echo_i "restart bump in the wire signer server ($n)"
ret=0
$PERL ../start.pl --noclean --restart --port ${PORT} . ns3 || ret=1
$PERL ../start.pl --noclean --restart --port ${PORT} inline ns3 || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@ -1328,18 +1328,18 @@ done
if [ $ans != 0 ]; then ret=1; fi
# Halt rather than stopping the server to prevent the master file from being
# flushed upon shutdown since we specifically want to avoid it.
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --halt --port ${CONTROLPORT} . ns3
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --halt --port ${CONTROLPORT} inline ns3
ensure_sigs_only_in_journal delayedkeys ns3/delayedkeys.db.signed
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns3
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} inline ns3
# At this point, the raw zone journal will not have a source serial set. Upon
# server startup, receive_secure_serial() will rectify that, update SOA, resign
# it, and schedule its future resign. This will cause "rndc zonestatus" to
# return delayedkeys/SOA as the next node to resign, so we restart the server
# once again; with the raw zone journal now having a source serial set,
# receive_secure_serial() should refrain from introducing any zone changes.
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --halt --port ${CONTROLPORT} . ns3
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --halt --port ${CONTROLPORT} inline ns3
ensure_sigs_only_in_journal delayedkeys ns3/delayedkeys.db.signed
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns3
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} inline ns3
# We can now test whether the secure zone journal was correctly processed:
# unless the records contained in it were scheduled for resigning, no resigning
# event will be scheduled at all since the secure zone master file contains no

View file

@ -144,11 +144,11 @@ status=`expr $status + $ret`
if $SHELL ../testcrypto.sh > /dev/null 2>&1
then
$PERL $SYSTEMTESTTOP/stop.pl . ns1
$PERL $SYSTEMTESTTOP/stop.pl legacy ns1
copy_setports ns1/named2.conf.in ns1/named.conf
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns1
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} legacy ns1
n=`expr $n + 1`
echo_i "checking recursive lookup to edns 512 + no tcp + trust anchor fails ($n)"
@ -160,7 +160,7 @@ then
status=`expr $status + $ret`
else
echo_i "skipping checking recursive lookup to edns 512 + no tcp + trust anchor fails as crypto not enabled"
fi
fi
echo_i "exit status: $status"
[ $status -eq 0 ] || exit 1

View file

@ -73,7 +73,7 @@ then
else
echo_i "testing plain file failed (unexpected)"
echo_i "exit status: 1"
exit 1
exit 1
fi
# Now try directory, expect failure
@ -124,7 +124,7 @@ else
echo_i "skipping pipe test (unable to create pipe)"
fi
# Now try symlink file to plain file, expect success
# Now try symlink file to plain file, expect success
n=`expr $n + 1`
echo_i "testing symlink to plain file as log file (named -g) ($n)"
# Assume success
@ -153,7 +153,7 @@ fi
# files while controlling the stop/start of the server.
# Have to stop the stock server because it uses "-g"
#
$PERL ../../stop.pl .. ns1
$PERL ../../stop.pl logfileconfig ns1
$myNAMED > /dev/null 2>&1
@ -181,7 +181,7 @@ then
else
echo_i "testing plain file failed (unexpected)"
echo_i "exit status: 1"
exit 1
exit 1
fi
# Now try directory, expect failure
@ -232,7 +232,7 @@ else
echo_i "skipping pipe test (unable to create pipe)"
fi
# Now try symlink file to plain file, expect success
# Now try symlink file to plain file, expect success
n=`expr $n + 1`
echo_i "testing symlink to plain file as log file ($n)"
# Assume success
@ -265,7 +265,7 @@ n=`expr $n + 1`
echo_i "testing default logfile using named -L file ($n)"
# Now stop the server again and test the -L option
rm -f $DLFILE
$PERL ../../stop.pl .. ns1
$PERL ../../stop.pl logfileconfig ns1
if ! test -f $PIDFILE; then
copy_setports $PLAINCONF named.conf
$myNAMED -L $DLFILE > /dev/null 2>&1
@ -307,7 +307,7 @@ if test ${t:-1000} -gt 5
then
echo_i "testing explicit versions failed: cleanup of old entries took too long ($t secs)"
status=`expr $status + 1`
fi
fi
if ! grep "status: NOERROR" dig.out.test$n > /dev/null
then
echo_i "testing explicit versions failed: DiG lookup failed"
@ -343,7 +343,7 @@ if test ${t:-1000} -gt 5
then
echo_i "testing unlimited versions failed: took too long ($t secs)"
status=`expr $status + 1`
fi
fi
if ! grep "status: NOERROR" dig.out.test$n > /dev/null
then
echo_i "testing unlimited versions failed: DiG lookup failed"

2
bin/tests/system/lwresd/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/lwresd1/lwresd.run.lwresd
/lwresd1/lwresd.run.resolv

View file

@ -14,6 +14,8 @@
SYSTEMTESTTOP=..
. $SYSTEMTESTTOP/conf.sh
common_options="-D lwresd-lwresd1 -X lwresd.lock -m record,size,mctx -T clienttest -d 99 -g -U 4 -i lwresd.pid -P 9210 -p 5300"
status=0
echo "I:waiting for nameserver to load"
for i in 0 1 2 3 4 5 6 7 8 9
@ -34,7 +36,7 @@ status=`expr $status + $ret`
echo "I:using resolv.conf"
ret=0
for i in 0 1 2 3 4 5 6 7 8 9
for i in 0 1 2 3 4 5 6 7 8 9
do
grep ' running$' lwresd1/lwresd.run > /dev/null && break
sleep 1
@ -45,15 +47,15 @@ if [ $ret != 0 ]; then
fi
status=`expr $status + $ret`
$PERL $SYSTEMTESTTOP/stop.pl . lwresd1
$PERL $SYSTEMTESTTOP/stop.pl lwresd lwresd1
mv lwresd1/lwresd.run lwresd1/lwresd.run.resolv
$PERL $SYSTEMTESTTOP/start.pl . lwresd1 -- "-X lwresd.lock -m record,size,mctx -c lwresd.conf -d 99 -g"
$PERL $SYSTEMTESTTOP/start.pl --restart lwresd lwresd1 -- "-c lwresd.conf $common_options"
echo "I:using lwresd.conf"
ret=0
for i in 0 1 2 3 4 5 6 7 8 9
for i in 0 1 2 3 4 5 6 7 8 9
do
grep ' running$' lwresd1/lwresd.run > /dev/null && break
sleep 1
@ -64,15 +66,15 @@ if [ $ret != 0 ]; then
fi
status=`expr $status + $ret`
$PERL $SYSTEMTESTTOP/stop.pl . lwresd1
$PERL $SYSTEMTESTTOP/stop.pl lwresd lwresd1
mv lwresd1/lwresd.run lwresd1/lwresd.run.lwresd
$PERL $SYSTEMTESTTOP/start.pl . lwresd1 -- "-X lwresd.lock -m record,size,mctx -c nosearch.conf -d 99 -g"
$PERL $SYSTEMTESTTOP/start.pl --restart lwresd lwresd1 -- "-c nosearch.conf $common_options"
echo "I:using nosearch.conf"
ret=0
for i in 0 1 2 3 4 5 6 7 8 9
for i in 0 1 2 3 4 5 6 7 8 9
do
grep ' running$' lwresd1/lwresd.run > /dev/null && break
sleep 1

View file

@ -42,7 +42,7 @@ rawversion () {
read(STDIN, $input, 8);
if (length($input) < 8) { print "not raw\n"; exit 0; };
($style, $version) = unpack("NN", $input);
print ($style == 2 || $style == 3 ? "$version\n" :
print ($style == 2 || $style == 3 ? "$version\n" :
"not raw or map\n");' < $1
}
@ -50,7 +50,7 @@ sourceserial () {
$PERL -e 'binmode STDIN;
read(STDIN, $input, 20);
if (length($input) < 20) { print "UNSET\n"; exit; };
($format, $version, $dumptime, $flags, $sourceserial) =
($format, $version, $dumptime, $flags, $sourceserial) =
unpack("NNNNN", $input);
if ($format != 2 || $version < 1) { print "UNSET\n"; exit; };
if ($flags & 02) {
@ -72,7 +72,7 @@ stomp () {
restart () {
sleep 1
(cd ..; $PERL start.pl --noclean --restart --port ${PORT} masterformat ns3)
$PERL "$SYSTEMTESTTOP/start.pl" --noclean --restart --port ${PORT} masterformat ns3
}
DIGOPTS="+tcp +noauth +noadd +nosea +nostat +noquest +nocomm +nocmd -p ${PORT}"

View file

@ -135,13 +135,13 @@ mkeys_loadkeys_on 1
mkeys_refresh_on 2
mkeys_status_on 2 > rndc.out.$n 2>&1
# there should be two keys listed now
count=`grep -c "keyid: " rndc.out.$n`
count=`grep -c "keyid: " rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# two lines indicating trust status
count=`grep -c "trust" rndc.out.$n`
count=`grep -c "trust" rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# one indicates current trust
count=`grep -c "trusted since" rndc.out.$n`
count=`grep -c "trusted since" rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
# one indicates pending trust
count=`grep -c "trust pending" rndc.out.$n`
@ -155,10 +155,10 @@ ret=0
mkeys_refresh_on 3
mkeys_status_on 3 > rndc.out.$n 2>&1
# there should be one key listed now
count=`grep -c "keyid: " rndc.out.$n`
count=`grep -c "keyid: " rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
# one line indicating trust status
count=`grep -c "trust" rndc.out.$n`
count=`grep -c "trust" rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
# ... and the key is not trusted
count=`grep -c "no trust" rndc.out.$n`
@ -203,10 +203,10 @@ mkeys_refresh_on 2
mkeys_sync_on 2
mkeys_status_on 2 > rndc.out.$n 2>&1
# two keys listed
count=`grep -c "keyid: " rndc.out.$n`
count=`grep -c "keyid: " rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# two lines indicating trust status
count=`grep -c "trust" rndc.out.$n`
count=`grep -c "trust" rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# trust is revoked
count=`grep -c "trust revoked" rndc.out.$n`
@ -237,10 +237,10 @@ mkeys_refresh_on 2
mkeys_sync_on 2
mkeys_status_on 2 > rndc.out.$n 2>&1
# two keys listed
count=`grep -c "keyid: " rndc.out.$n`
count=`grep -c "keyid: " rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# two lines indicating trust status
count=`grep -c "trust" rndc.out.$n`
count=`grep -c "trust" rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# trust is revoked
count=`grep -c "trust revoked" rndc.out.$n`
@ -275,10 +275,10 @@ mkeys_refresh_on 2
mkeys_sync_on 2
mkeys_status_on 2 > rndc.out.$n 2>&1
# two keys listed
count=`grep -c "keyid: " rndc.out.$n`
count=`grep -c "keyid: " rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# two lines indicating trust status
count=`grep -c "trust" rndc.out.$n`
count=`grep -c "trust" rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# trust is revoked
count=`grep -c "trust revoked" rndc.out.$n`
@ -297,10 +297,10 @@ if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "reinitialize trust anchors"
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc . ns2
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc mkeys ns2
rm -f ns2/managed-keys.bind*
nextpart ns2/named.run > /dev/null
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns2
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} mkeys ns2
n=`expr $n + 1`
echo_i "check that standby key is now trusted ($n)"
@ -308,13 +308,13 @@ ret=0
wait_for_log "Returned from key fetch in keyfetch_done()" ns2/named.run
mkeys_status_on 2 > rndc.out.$n 2>&1
# two keys listed
count=`grep -c "keyid: " rndc.out.$n`
count=`grep -c "keyid: " rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# two lines indicating trust status
count=`grep -c "trust" rndc.out.$n`
count=`grep -c "trust" rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# both indicate current trust
count=`grep -c "trusted since" rndc.out.$n`
count=`grep -c "trusted since" rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@ -328,22 +328,22 @@ mkeys_loadkeys_on 1
mkeys_refresh_on 2
mkeys_status_on 2 > rndc.out.$n 2>&1
# three keys listed
count=`grep -c "keyid: " rndc.out.$n`
count=`grep -c "keyid: " rndc.out.$n`
[ "$count" -eq 3 ] || ret=1
# one is revoked
count=`grep -c "REVOKE" rndc.out.$n`
count=`grep -c "REVOKE" rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
# three lines indicating trust status
count=`grep -c "trust" rndc.out.$n`
count=`grep -c "trust" rndc.out.$n`
[ "$count" -eq 3 ] || ret=1
# one indicates current trust
count=`grep -c "trusted since" rndc.out.$n`
count=`grep -c "trusted since" rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
# one indicates revoked trust
count=`grep -c "trust revoked" rndc.out.$n`
count=`grep -c "trust revoked" rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
# one indicates trust pending
count=`grep -c "trust pending" rndc.out.$n`
count=`grep -c "trust pending" rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
# removal scheduled
count=`grep -c "remove at" rndc.out.$n`
@ -359,26 +359,26 @@ mkeys_loadkeys_on 1
mkeys_refresh_on 2
mkeys_status_on 2 > rndc.out.a.$n 2>&1
# four keys listed
count=`grep -c "keyid: " rndc.out.a.$n`
count=`grep -c "keyid: " rndc.out.a.$n`
[ "$count" -eq 4 ] || { echo "keyid: count ($count) != 4"; ret=1; }
# one revoked
count=`grep -c "trust revoked" rndc.out.a.$n`
count=`grep -c "trust revoked" rndc.out.a.$n`
[ "$count" -eq 1 ] || { echo "trust revoked count ($count) != 1"; ret=1; }
# two pending
count=`grep -c "trust pending" rndc.out.a.$n`
count=`grep -c "trust pending" rndc.out.a.$n`
[ "$count" -eq 2 ] || { echo "trust pending count ($count) != 2"; ret=1; }
$SETTIME -R now -K ns1 $standby3 > /dev/null
mkeys_loadkeys_on 1
mkeys_refresh_on 2
mkeys_status_on 2 > rndc.out.b.$n 2>&1
# now three keys listed
count=`grep -c "keyid: " rndc.out.b.$n`
count=`grep -c "keyid: " rndc.out.b.$n`
[ "$count" -eq 3 ] || { echo "keyid: count ($count) != 3"; ret=1; }
# one revoked
count=`grep -c "trust revoked" rndc.out.b.$n`
count=`grep -c "trust revoked" rndc.out.b.$n`
[ "$count" -eq 1 ] || { echo "trust revoked count ($count) != 1"; ret=1; }
# one pending
count=`grep -c "trust pending" rndc.out.b.$n`
count=`grep -c "trust pending" rndc.out.b.$n`
[ "$count" -eq 1 ] || { echo "trust pending count ($count) != 1"; ret=1; }
$SETTIME -D now -K ns1 $standby3 > /dev/null
mkeys_loadkeys_on 1
@ -392,16 +392,16 @@ sleep 20
mkeys_refresh_on 2
mkeys_status_on 2 > rndc.out.$n 2>&1
# two keys listed
count=`grep -c "keyid: " rndc.out.$n`
count=`grep -c "keyid: " rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# none revoked
count=`grep -c "REVOKE" rndc.out.$n`
count=`grep -c "REVOKE" rndc.out.$n`
[ "$count" -eq 0 ] || ret=1
# two lines indicating trust status
count=`grep -c "trust" rndc.out.$n`
count=`grep -c "trust" rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# both indicate current trust
count=`grep -c "trusted since" rndc.out.$n`
count=`grep -c "trusted since" rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@ -416,16 +416,16 @@ mkeys_loadkeys_on 1
mkeys_refresh_on 2
mkeys_status_on 2 > rndc.out.$n 2>&1
# two keys listed
count=`grep -c "keyid: " rndc.out.$n`
count=`grep -c "keyid: " rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# both revoked
count=`grep -c "REVOKE" rndc.out.$n`
count=`grep -c "REVOKE" rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# two lines indicating trust status
count=`grep -c "trust" rndc.out.$n`
count=`grep -c "trust" rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# both indicate trust revoked
count=`grep -c "trust revoked" rndc.out.$n`
count=`grep -c "trust revoked" rndc.out.$n`
[ "$count" -eq 2 ] || ret=1
# both have removal scheduled
count=`grep -c "remove at" rndc.out.$n`
@ -454,10 +454,10 @@ rm -f ns1/root.db.signed.jnl
mkeys_reconfig_on 1
echo_i "reinitialize trust anchors"
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . ns2
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} mkeys ns2
rm -f ns2/managed-keys.bind*
nextpart ns2/named.run > /dev/null
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns2
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} mkeys ns2
n=`expr $n + 1`
echo_i "check positive validation ($n)"
@ -494,18 +494,18 @@ mkeys_reload_on 1
mkeys_refresh_on 2
mkeys_status_on 2 > rndc.out.$n 2>&1
# one key listed
count=`grep -c "keyid: " rndc.out.$n`
count=`grep -c "keyid: " rndc.out.$n`
[ "$count" -eq 1 ] || { echo "'keyid:' count ($count) != 1"; ret=1; }
# it's the original key id
count=`grep -c "keyid: $originalid" rndc.out.$n`
count=`grep -c "keyid: $originalid" rndc.out.$n`
[ "$count" -eq 1 ] || { echo "'keyid: $originalid' count ($count) != 1"; ret=1; }
# not revoked
count=`grep -c "REVOKE" rndc.out.$n`
count=`grep -c "REVOKE" rndc.out.$n`
[ "$count" -eq 0 ] || { echo "'REVOKE' count ($count) != 0"; ret=1; }
# trust is still current
count=`grep -c "trust" rndc.out.$n`
count=`grep -c "trust" rndc.out.$n`
[ "$count" -eq 1 ] || { echo "'trust' count != 1"; ret=1; }
count=`grep -c "trusted since" rndc.out.$n`
count=`grep -c "trusted since" rndc.out.$n`
[ "$count" -eq 1 ] || { echo "'trusted since' count != 1"; ret=1; }
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
@ -553,27 +553,27 @@ ret=0
mkeys_refresh_on 2
mkeys_status_on 2 > rndc.out.$n 2>&1
t1=`grep 'next refresh:' rndc.out.$n`
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . ns1
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} mkeys ns1
rm -f ns1/root.db.signed.jnl
cp ns1/root.db ns1/root.db.signed
nextpart ns1/named.run > /dev/null
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns1
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} mkeys ns1
wait_for_log "loaded serial" ns1/named.run
mkeys_refresh_on 2
mkeys_status_on 2 > rndc.out.$n 2>&1
# one key listed
count=`grep -c "keyid: " rndc.out.$n`
count=`grep -c "keyid: " rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
# it's the original key id
count=`grep -c "keyid: $originalid" rndc.out.$n`
count=`grep -c "keyid: $originalid" rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
# not revoked
count=`grep -c "REVOKE" rndc.out.$n`
count=`grep -c "REVOKE" rndc.out.$n`
[ "$count" -eq 0 ] || ret=1
# trust is still current
count=`grep -c "trust" rndc.out.$n`
count=`grep -c "trust" rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
count=`grep -c "trusted since" rndc.out.$n`
count=`grep -c "trusted since" rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
t2=`grep 'next refresh:' rndc.out.$n`
[ "$t1" = "$t2" ] && ret=1
@ -587,11 +587,11 @@ ret=0
mkeys_refresh_on 2
mkeys_status_on 2 > rndc.out.$n 2>&1
t1=`grep 'next refresh:' rndc.out.$n`
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . ns1
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} mkeys ns1
rm -f ns1/root.db.signed.jnl
cat ns1/K*.key >> ns1/root.db.signed
nextpart ns1/named.run > /dev/null
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns1
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} mkeys ns1
wait_for_log "loaded serial" ns1/named.run
# Less than a second may have passed since the last time ns2 received a
# ./DNSKEY response from ns1. Ensure keys are refreshed at a different
@ -600,18 +600,18 @@ sleep 1
mkeys_refresh_on 2
mkeys_status_on 2 > rndc.out.$n 2>&1
# one key listed
count=`grep -c "keyid: " rndc.out.$n`
count=`grep -c "keyid: " rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
# it's the original key id
count=`grep -c "keyid: $originalid" rndc.out.$n`
count=`grep -c "keyid: $originalid" rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
# not revoked
count=`grep -c "REVOKE" rndc.out.$n`
count=`grep -c "REVOKE" rndc.out.$n`
[ "$count" -eq 0 ] || ret=1
# trust is still current
count=`grep -c "trust" rndc.out.$n`
count=`grep -c "trust" rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
count=`grep -c "trusted since" rndc.out.$n`
count=`grep -c "trusted since" rndc.out.$n`
[ "$count" -eq 1 ] || ret=1
t2=`grep 'next refresh:' rndc.out.$n`
[ "$t1" = "$t2" ] && ret=1
@ -667,9 +667,9 @@ ret=0
# ensure key refresh retry will be scheduled to one actual hour after the first
# key refresh failure instead of just a few seconds, in order to prevent races
# between the next scheduled key refresh time and startup time of restarted ns5.
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . ns5
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} mkeys ns5
nextpart ns5/named.run > /dev/null
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns5
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} mkeys ns5
wait_for_log "Returned from key fetch in keyfetch_done()" ns5/named.run
# ns5/named.run will contain logs from both the old instance and the new
# instance. In order for the test to pass, both must attempt a fetch.
@ -681,14 +681,14 @@ status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "check key refreshes are resumed after root servers become available ($n)"
ret=0
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . ns5
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} mkeys ns5
# Prevent previous check from affecting this one
rm -f ns5/managed-keys.bind*
# named2.args adds "-T mkeytimers=2/20/40" to named1.args as we need to wait for
# an "hour" until keys are refreshed again after initial failure
cp ns5/named2.args ns5/named.args
nextpart ns5/named.run > /dev/null
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns5
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} mkeys ns5
wait_for_log "Returned from key fetch in keyfetch_done() for '.': failure" ns5/named.run
# ns1 should still REFUSE queries from ns5, so resolving should be impossible
$DIG $DIGOPTS +noauth example. @10.53.0.5 txt > dig.out.ns5.a.test$n || ret=1

View file

@ -115,12 +115,12 @@ digcomp dig.out.ns2.test$n dig.out.ns3.test$n || ret=1
status=`expr $ret + $status`
echo_i "stopping master and restarting with example4 then waiting up to 45 seconds"
$PERL $SYSTEMTESTTOP/stop.pl . ns2
$PERL $SYSTEMTESTTOP/stop.pl notify ns2
rm -f ns2/example.db
cp -f ns2/example4.db ns2/example.db
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns2
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} notify ns2
try=0
while test $try -lt 45

View file

@ -338,7 +338,7 @@ rm named.pid
cd ..
sleep 10
if
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns1
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} nsupdate ns1
then
echo_i "restarted server ns1"
else
@ -506,12 +506,12 @@ server 10.53.0.1 ${PORT}
update add updated4.example.nil. 600 A 10.10.10.3
send
END
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . ns1
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} nsupdate ns1
# 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".
rm -f ns1/*jnl
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns1
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} nsupdate ns1
$DIG $DIGOPTS +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd updated4.example.nil.\
@10.53.0.1 a > dig.out.ns1 || status=1
digcomp knowngood.ns1.afterstop dig.out.ns1 || ret=1

View file

@ -39,7 +39,7 @@ if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "stopping ns1"
$PERL $SYSTEMTESTTOP/stop.pl . ns1
$PERL $SYSTEMTESTTOP/stop.pl nzd2nzf ns1
n=`expr $n + 1`
echo_i "dumping _default.nzd to _default.nzf ($n)"
@ -57,7 +57,7 @@ echo_i "deleting _default.nzd database"
rm -f ns1/_default.nzd
echo_i "starting ns1 which should migrate the .nzf to .nzd"
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns1
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} nzd2nzf ns1
n=`expr $n + 1`
echo_i "querying for zone data from migrated zone config ($n)"

View file

@ -118,7 +118,7 @@ restart () {
cp -f ns$1/base.db $NM
done
fi
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns$1
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} rpz ns$1
load_db
}
@ -590,7 +590,7 @@ fi
# restart the main test RPZ server to see if that creates a core file
if test -z "$HAVE_CORE"; then
$PERL $SYSTEMTESTTOP/stop.pl . ns3
$PERL $SYSTEMTESTTOP/stop.pl rpz ns3
restart 3
HAVE_CORE=`find ns* -name '*core*' -print`
test -z "$HAVE_CORE" || setret "found $HAVE_CORE; memory leak?"

View file

@ -20,13 +20,13 @@ run_server() {
TESTNAME=$1
echo_i "stopping resolver"
$PERL $SYSTEMTESTTOP/stop.pl . ns2
$PERL $SYSTEMTESTTOP/stop.pl rpzrecurse ns2
sleep 1
echo_i "starting resolver using named.$TESTNAME.conf"
cp -f ns2/named.$TESTNAME.conf ns2/named.conf
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns2
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} rpzrecurse ns2
}
run_query() {
@ -122,7 +122,7 @@ expect_recurse 3f 2
# Group 4
testlist="aa ap bf"
values="1 16 32"
# Uncomment the following to test every skip value instead of
# Uncomment the following to test every skip value instead of
# only a sample of values
#
#testlist="aa ab ac ad ae af ag ah ai aj ak al am an ao ap \

View file

@ -248,7 +248,7 @@ fi
echo_i "Re-starting slave"
(cd ..; $PERL start.pl --noclean --port ${PORT} rrsetorder ns2 )
$PERL $SYSTEMTESTTOP/start.pl --noclean --port ${PORT} rrsetorder ns2
#
#

2
bin/tests/system/run.sh Normal file → Executable file
View file

@ -13,7 +13,7 @@
# Run a system test.
#
SYSTEMTESTTOP=$(realpath .)
SYSTEMTESTTOP="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
. $SYSTEMTESTTOP/conf.sh
export SYSTEMTESTTOP

0
bin/tests/system/runall.sh Normal file → Executable file
View file

View file

@ -51,8 +51,7 @@ if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "disabling server to force non-dnssec SERVFAIL"
$RNDCCMD 10.53.0.2 stop 2>&1 | sed 's/^/I:ns2 /'
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} sfcache ns2
awk '/SERVFAIL/ { next; out=1 } /Zone/ { out=0 } { if (out) print }' ns5/named_dump.db
echo_i "checking SERVFAIL is cached ($n)"
ret=0

View file

@ -15,9 +15,12 @@
# If a server is specified, start it. Otherwise, start all servers for test.
use strict;
use Cwd;
use Cwd 'abs_path';
use warnings;
use Cwd ':DEFAULT', 'abs_path';
use English '-no_match_vars';
use Getopt::Long;
use Time::HiRes 'sleep'; # allows sleeping fractional seconds
# Usage:
# perl start.pl [--noclean] [--restart] [--port port] test [server [options]]
@ -55,29 +58,34 @@ use Getopt::Long;
# "named.args" is ignored.
my $usage = "usage: $0 [--noclean] [--restart] [--port <port>] test-directory [server-directory [server-options]]";
my $noclean = '';
my $restart = '';
my $clean = 1;
my $restart = 0;
my $queryport = 5300;
GetOptions('noclean' => \$noclean, 'restart' => \$restart, 'port=i' => \$queryport) or die "$usage\n";
GetOptions(
'clean!' => \$clean,
'restart!' => \$restart,
'port=i' => \$queryport,
) or die "$usage\n";
my $test = $ARGV[0];
my $server = $ARGV[1];
my $options = $ARGV[2];
my( $test, $server_arg, $options_arg ) = @ARGV;
if (!$test) {
die "$usage\n";
}
if (!-d $test) {
die "No test directory: \"$test\"\n";
}
if ($server && !-d "$test/$server") {
die "No server directory: \"$test/$server\"\n";
}
# Global variables
my $topdir = abs_path("$test/..");
my $testdir = abs_path("$test");
my $topdir = abs_path($ENV{'SYSTEMTESTTOP'});
my $testdir = abs_path($topdir . "/" . $test);
if (! -d $testdir) {
die "No test directory: \"$testdir\"\n";
}
if ($server_arg && ! -d "$testdir/$server_arg") {
die "No server directory: \"$testdir/$server_arg\"\n";
}
my $NAMED = $ENV{'NAMED'};
my $LWRESD = $ENV{'LWRESD'};
my $DIG = $ENV{'DIG'};
@ -86,208 +94,115 @@ my $PYTHON = $ENV{'PYTHON'};
# Start the server(s)
if ($server) {
if ($server =~ /^ns/) {
&check_ports($server);
}
&start_server($server, $options);
if ($server =~ /^ns/) {
&verify_server($server);
my @ns;
my @ans;
my @lwresd;
if ($server_arg) {
if ($server_arg =~ /^ns/) {
push(@ns, $server_arg);
} elsif ($server_arg =~ /^ans/) {
push(@ans, $server_arg);
} elsif ($server_arg =~ /^lwresd/) {
push(@lwresd, $server_arg);
} else {
print "$0: ns or ans directory expected";
print "I:$test:failed";
}
} else {
# Determine which servers need to be started for this test.
opendir DIR, $testdir;
opendir DIR, $testdir or die "unable to read test directory: \"$test\" ($OS_ERROR)\n";
my @files = sort readdir DIR;
closedir DIR;
my @ns = grep /^ns[0-9]*$/, @files;
my @lwresd = grep /^lwresd[0-9]*$/, @files;
my @ans = grep /^ans[0-9]*$/, @files;
my $name;
@ns = grep /^ns[0-9]*$/, @files;
@ans = grep /^ans[0-9]*$/, @files;
@lwresd = grep /^lwresd[0-9]*$/, @files;
}
# Start the servers we found.
&check_ports();
foreach $name(@ns, @lwresd, @ans) {
&start_server($name);
&verify_server($name) if ($name =~ /^ns/);
}
# Start the servers we found.
foreach my $name(@ns) {
&check_ns_port($name);
&start_ns_server($name, $options_arg);
&verify_ns_server($name);
}
foreach my $name(@ans) {
&start_ans_server($name);
}
foreach my $name(@lwresd) {
&start_lwresd_server($name, $options_arg);
}
# Subroutines
sub check_ports {
my $server = shift;
my $options = "";
sub read_ns_port {
my ( $server ) = @_;
my $port = $queryport;
my $file = "";
my $options = "";
$file = $testdir . "/" . $server . "/named.port" if ($server);
if ($server) {
my $file = $testdir . "/" . $server . "/named.port";
if ($server && $server =~ /(\d+)$/) {
if (-e $file) {
open(my $fh, "<", $file) or die "unable to read ports file \"$file\" ($OS_ERROR)";
my $line = <$fh>;
if ($line) {
chomp $line;
$port = $line;
}
}
}
return ($port);
}
sub check_ns_port {
my ( $server ) = @_;
my $options = "";
my $port = read_ns_port($server);
if ($server =~ /(\d+)$/) {
$options = "-i $1";
}
if ($file ne "" && -e $file) {
open(FH, "<", $file);
while(my $line=<FH>) {
chomp $line;
$port = $line;
last;
}
close FH;
}
my $tries = 0;
while (1) {
my $return = system("$PERL $topdir/testsock.pl -p $port $options");
last if ($return == 0);
if (++$tries > 4) {
if ($return == 0) {
last;
}
$tries++;
if ($tries > 4) {
print "$0: could not bind to server addresses, still running?\n";
print "I:server sockets not available\n";
print "I:failed\n";
system("$PERL $topdir/stop.pl $testdir"); # Is this the correct behavior?
print "I:$test:server sockets not available\n";
print "I:$test:failed\n";
system("$PERL $topdir/stop.pl $test"); # Is this the correct behavior?
exit 1;
}
print "I:Couldn't bind to socket (yet)\n";
print "I:$test:Couldn't bind to socket (yet)\n";
sleep 2;
}
}
sub start_server {
my $server = shift;
my $options = shift;
my ( $server, $command, $pid_file ) = @_;
my $cleanup_files;
my $command;
my $pid_file;
my $cwd = getcwd();
my $args_file = $cwd . "/" . $test . "/" . $server . "/" . "named.args";
if ($server =~ /^ns/) {
$cleanup_files = "{*.jnl,*.bk,*.st,named.run}";
if ($ENV{'USE_VALGRIND'}) {
$command = "valgrind -q --gen-suppressions=all --num-callers=48 --fullpath-after= --log-file=named-$server-valgrind-%p.log ";
if ($ENV{'USE_VALGRIND'} eq 'helgrind') {
$command .= "--tool=helgrind ";
} else {
$command .= "--tool=memcheck --track-origins=yes --leak-check=full ";
}
$command .= "$NAMED -m none -M external ";
} else {
$command = "$NAMED ";
}
if ($options) {
$command .= "$options";
} elsif (-e $args_file) {
open(FH, "<", $args_file);
while(my $line=<FH>)
{
#$line =~ s/\R//g;
chomp $line;
next if ($line =~ /^\s*$/); #discard blank lines
next if ($line =~ /^\s*#/); #discard comment lines
$line =~ s/#.*$//g;
$options = $line;
last;
}
close FH;
$command .= "$options";
} else {
$command .= "-D $test-$server ";
$command .= "-X named.lock ";
$command .= "-m record,size,mctx ";
$command .= "-T clienttest ";
$command .= "-T nosoa "
if (-e "$testdir/$server/named.nosoa");
$command .= "-T noaa "
if (-e "$testdir/$server/named.noaa");
$command .= "-T noedns "
if (-e "$testdir/$server/named.noedns");
$command .= "-T dropedns "
if (-e "$testdir/$server/named.dropedns");
$command .= "-T maxudp512 "
if (-e "$testdir/$server/named.maxudp512");
$command .= "-T maxudp1460 "
if (-e "$testdir/$server/named.maxudp1460");
$command .= "-c named.conf -d 99 -g -U 4";
}
$command .= " -T notcp"
if (-e "$testdir/$server/named.notcp");
if ($restart) {
$command .= " >>named.run 2>&1 &";
} else {
$command .= " >named.run 2>&1 &";
}
$pid_file = "named.pid";
} elsif ($server =~ /^lwresd/) {
$cleanup_files = "{lwresd.run}";
if ($ENV{'USE_VALGRIND'}) {
$command = "valgrind -q --gen-suppressions=all --num-callers=48 --fullpath-after= --log-file=lwresd-valgrind-%p.log ";
if ($ENV{'USE_VALGRIND'} eq 'helgrind') {
$command .= "--tool=helgrind ";
} else {
$command .= "--tool=memcheck --track-origins=yes --leak-check=full ";
}
$command .= "$LWRESD -m none -M external ";
} else {
$command = "$LWRESD ";
}
if ($options) {
$command .= "$options";
} else {
$command .= "-X lwresd.lock ";
$command .= "-m record,size,mctx ";
$command .= "-T clienttest ";
$command .= "-C resolv.conf -d 99 -g -U 4 ";
$command .= "-i lwresd.pid -P 9210 -p 5300";
}
if ($restart) {
$command .= " >>lwresd.run 2>&1 &";
} else {
$command .= " >lwresd.run 2>&1 &";
}
$pid_file = "lwresd.pid";
} elsif ($server =~ /^ans/) {
$cleanup_files = "{ans.run}";
if (-e "$testdir/$server/ans.py") {
$command = "$PYTHON -u ans.py 10.53.0.$' $queryport";
} elsif (-e "$testdir/$server/ans.pl") {
$command = "$PERL ans.pl";
} else {
$command = "$PERL $topdir/ans.pl 10.53.0.$'";
}
if ($options) {
$command .= "$options";
} else {
$command .= "";
}
if ($restart) {
$command .= " >>ans.run 2>&1 &";
} else {
$command .= " >ans.run 2>&1 &";
}
$pid_file = "ans.pid";
} else {
print "I:Unknown server type $server\n";
print "I:failed\n";
system "$PERL $topdir/stop.pl $testdir";
exit 1;
}
# print "I:starting server %s\n",$server;
chdir "$testdir/$server";
unless ($noclean) {
unlink glob $cleanup_files;
}
# get the shell to report the pid of the server ($!)
$command .= "echo \$!";
chdir "$testdir/$server" or die "unable to chdir \"$testdir/$server\" ($OS_ERROR)\n";
# start the server
my $child = `$command`;
$child =~ s/\s+$//g;
$child =~ s/\s+$//;
# wait up to 14 seconds for the server to start and to write the
# pid file otherwise kill this server and any others that have
@ -295,51 +210,306 @@ sub start_server {
my $tries = 0;
while (!-s $pid_file) {
if (++$tries > 140) {
print "I:Couldn't start server $server (pid=$child)\n";
print "I:failed\n";
print "I:$test:Couldn't start server $command (pid=$child)\n";
print "I:$test:failed\n";
system "kill -9 $child" if ("$child" ne "");
system "$PERL $topdir/stop.pl $testdir";
system "$PERL $topdir/stop.pl $test";
exit 1;
}
# sleep for 0.1 seconds
select undef,undef,undef,0.1;
sleep 0.1;
}
# go back to the top level directory
chdir $cwd;
# go back to the top level directory
chdir $topdir;
}
sub verify_server {
my $server = shift;
my $n = $server;
my $port = $queryport;
my $tcp = "+tcp";
sub construct_ns_command {
my ( $server, $options ) = @_;
$n =~ s/^ns//;
my $command;
if ($ENV{'USE_VALGRIND'}) {
$command = "valgrind -q --gen-suppressions=all --num-callers=48 --fullpath-after= --log-file=named-$server-valgrind-%p.log ";
if ($ENV{'USE_VALGRIND'} eq 'helgrind') {
$command .= "--tool=helgrind ";
} else {
$command .= "--tool=memcheck --track-origins=yes --leak-check=full ";
}
$command .= "$NAMED -m none -M external ";
} else {
$command = "$NAMED ";
}
my $args_file = $testdir . "/" . $server . "/" . "named.args";
if ($options) {
$command .= $options;
} elsif (-e $args_file) {
open(my $fh, "<", $args_file) or die "unable to read args_file \"$args_file\" ($OS_ERROR)\n";
while(my $line=<$fh>) {
next if ($line =~ /^\s*$/); #discard blank lines
next if ($line =~ /^\s*#/); #discard comment lines
if (-e "$testdir/$server/named.port") {
open(FH, "<", "$testdir/$server/named.port");
while(my $line=<FH>) {
chomp $line;
$port = $line;
$line =~ s/#.*$//;
$command .= $line;
last;
}
close FH;
} else {
$command .= "-D $test-$server ";
$command .= "-X named.lock ";
$command .= "-m record,size,mctx ";
$command .= "-T clienttest ";
foreach my $t_option(
"dropedns", "ednsformerr", "ednsnotimp", "ednsrefused",
"noaa", "noedns", "nosoa", "maxudp512", "maxudp1460",
) {
if (-e "$testdir/$server/named.$t_option") {
$command .= "-T $t_option "
}
}
$command .= "-c named.conf -d 99 -g -U 4";
}
$tcp = "" if (-e "$testdir/$server/named.notcp");
if (-e "$testdir/$server/named.notcp") {
$command .= " -T notcp"
}
if ($restart) {
$command .= " >>named.run 2>&1 &";
} else {
$command .= " >named.run 2>&1 &";
}
# get the shell to report the pid of the server ($!)
$command .= " echo \$!";
return $command;
}
sub start_ns_server {
my ( $server, $options ) = @_;
my $cleanup_files;
my $command;
my $pid_file;
$cleanup_files = "{./*.jnl,./*.bk,./*.st,./named.run}";
$command = construct_ns_command($server, $options);
$pid_file = "named.pid";
if ($clean) {
unlink glob $cleanup_files;
}
start_server($server, $command, $pid_file);
}
sub construct_ans_command {
my ( $server, $options ) = @_;
my $command;
my $n;
if ($server =~ /^ans(\d+)/) {
$n = $1;
} else {
die "unable to parse server number from name \"$server\"\n";
}
if (-e "$testdir/$server/ans.py") {
$command = "$PYTHON -u ans.py 10.53.0.$n $queryport";
} elsif (-e "$testdir/$server/ans.pl") {
$command = "$PERL ans.pl";
} else {
$command = "$PERL $topdir/ans.pl 10.53.0.$n";
}
if ($options) {
$command .= $options;
}
if ($restart) {
$command .= " >>ans.run 2>&1 &";
} else {
$command .= " >ans.run 2>&1 &";
}
# get the shell to report the pid of the server ($!)
$command .= " echo \$!";
return $command;
}
sub start_ans_server {
my ( $server, $options ) = @_;
my $cleanup_files;
my $command;
my $pid_file;
$cleanup_files = "{./ans.run}";
$command = construct_ans_command($server, $options);
$pid_file = "ans.pid";
if ($clean) {
unlink glob $cleanup_files;
}
start_server($server, $command, $pid_file);
}
sub construct_lwresd_command {
my ( $server, $options ) = @_;
my $command;
if ($ENV{'USE_VALGRIND'}) {
$command = "valgrind -q --gen-suppressions=all --num-callers=48 --fullpath-after= --log-file=lwresd-$server-valgrind-%p.log ";
if ($ENV{'USE_VALGRIND'} eq 'helgrind') {
$command .= "--tool=helgrind ";
} else {
$command .= "--tool=memcheck --track-origins=yes --leak-check=full ";
}
$command .= "$LWRESD -m none -M external ";
} else {
$command = "$LWRESD ";
}
my $args_file = $testdir . "/" . $server . "/" . "lwresd.args";
if ($options) {
$command .= $options;
} elsif (-e $args_file) {
open(my $fh, "<", $args_file) or die "unable to read args_file \"$args_file\" ($OS_ERROR)\n";
while(my $line=<$fh>) {
next if ($line =~ /^\s*$/); #discard blank lines
next if ($line =~ /^\s*#/); #discard comment lines
chomp $line;
$line =~ s/#.*$//;
$command .= $line;
last;
}
} else {
$command .= "-C resolv.conf ";
$command .= "-D $test-$server ";
$command .= "-X lwresd.lock ";
$command .= "-m record,size,mctx ";
$command .= "-T clienttest ";
$command .= "-d 99 -g -U 4 ";
$command .= "-i lwresd.pid -P 9210 -p 5300";
}
if ($restart) {
$command .= " >>lwresd.run 2>&1 &";
} else {
$command .= " >lwresd.run 2>&1 &";
}
# get the shell to report the pid of the server ($!)
$command .= " echo \$!";
return $command;
}
sub start_lwresd_server {
my ( $server, $options ) = @_;
my $cleanup_files;
my $command;
my $pid_file;
$cleanup_files = "{lwresd.run}";
$command = construct_lwresd_command($server, $options);
$pid_file = "lwresd.pid";
if ($clean) {
unlink glob $cleanup_files;
}
start_server($server, $command, $pid_file);
}
sub verify_ns_server {
my ( $server ) = @_;
my $tries = 0;
my $runfile = "$testdir/$server/named.run";
while (1) {
my $return = system("$DIG $tcp +noadd +nosea +nostat +noquest +nocomm +nocmd +noedns -p $port version.bind. chaos txt \@10.53.0.$n > dig.out");
last if ($return == 0);
if (++$tries >= 30) {
print "I:no response from $server\n";
print "I:failed\n";
system("$PERL $topdir/stop.pl $testdir");
# the shell *ought* to have created the file immediately, but this
# logic allows the creation to be delayed without issues
if (open(my $fh, "<", $runfile)) {
# the two non-whitespace blobs should be the date and time
# but we don't care about them really, only that they are there
if (grep /^\S+ \S+ running$/, <$fh>) {
last;
}
}
$tries++;
if ($tries >= 30) {
print "I:$test:server $server seems to have not started\n";
print "I:$test:failed\n";
system("$PERL $topdir/stop.pl $test");
exit 1;
}
sleep 2;
}
$tries = 0;
my $port = read_ns_port($server);
my $tcp = "+tcp";
my $n;
if ($server =~ /^ns(\d+)/) {
$n = $1;
} else {
die "unable to parse server number from name \"$server\"\n";
}
if (-e "$testdir/$server/named.notcp") {
$tcp = "";
}
while (1) {
my $return = system("$DIG $tcp +noadd +nosea +nostat +noquest +nocomm +nocmd +noedns -p $port version.bind. chaos txt \@10.53.0.$n > /dev/null");
last if ($return == 0);
$tries++;
if ($tries >= 30) {
print "I:$test:no response from $server\n";
print "I:$test:failed\n";
system("$PERL $topdir/stop.pl $test");
exit 1;
}
sleep 2;
}
unlink "dig.out";
}

8
bin/tests/system/start.sh Normal file → Executable file
View file

@ -9,5 +9,9 @@
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
. ./conf.sh
$PERL start.pl "$@"
SYSTEMTESTTOP="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
# shellcheck source=conf.sh
. "$SYSTEMTESTTOP/conf.sh"
export SYSTEMTESTTOP
$PERL "$SYSTEMTESTTOP/start.pl" "$@"

View file

@ -15,7 +15,10 @@
# If a server is specified, stop it. Otherwise, stop all servers for test.
use strict;
use Cwd 'abs_path';
use warnings;
use Cwd ':DEFAULT', 'abs_path';
use English '-no_match_vars';
use Getopt::Long;
# Usage:
@ -35,62 +38,97 @@ my $usage = "usage: $0 [--use-rndc [--halt] [--port port]] test-directory [serve
my $use_rndc = 0;
my $halt = 0;
my $port = 9953;
GetOptions('use-rndc' => \$use_rndc, 'halt' => \$halt, 'port=i' => \$port) or die "$usage\n";
my $rndc_port = 9953;
my $errors = 0;
my $test = $ARGV[0];
my $server = $ARGV[1];
die "$usage\n" unless defined($test);
die "No test directory: \"$test\"\n" unless (-d $test);
die "No server directory: \"$server\"\n" if (defined($server) && !-d "$test/$server");
GetOptions(
'use-rndc!' => \$use_rndc,
'halt!' => \$halt,
'port=i' => \$rndc_port
) or die "$usage\n";
my ( $test, $server_arg ) = @ARGV;
if (!$test) {
die "$usage\n";
}
# Global variables
my $testdir = abs_path($test);
my @servers;
my $topdir = abs_path($ENV{'SYSTEMTESTTOP'});
my $testdir = abs_path($topdir . "/" . $test);
if (! -d $testdir) {
die "No test directory: \"$testdir\"\n";
}
# Determine which servers need to be stopped.
if (defined $server) {
@servers = ($server);
if ($server_arg && ! -d "$testdir/$server_arg") {
die "No server directory: \"$testdir/$server_arg\"\n";
}
my $RNDC = $ENV{RNDC};
my @ns;
my @ans;
my @lwresd;
if ($server_arg) {
if ($server_arg =~ /^ns/) {
push(@ns, $server_arg);
} elsif ($server_arg =~ /^ans/) {
push(@ans, $server_arg);
} elsif ($server_arg =~ /^lwresd/) {
push(@lwresd, $server_arg);
} else {
print "$0: ns or ans directory expected";
print "I:$test:failed";
}
} else {
local *DIR;
opendir DIR, $testdir or die "$testdir: $!\n";
# Determine which servers need to be stopped for this test.
opendir DIR, $testdir or die "unable to read test directory: \"$test\" ($OS_ERROR)\n";
my @files = sort readdir DIR;
closedir DIR;
my @ns = grep /^ns[0-9]*$/, @files;
my @lwresd = grep /^lwresd[0-9]*$/, @files;
my @ans = grep /^ans[0-9]*$/, @files;
push @servers, @ns, @lwresd, @ans;
@ns = grep /^ns[0-9]*$/, @files;
@ans = grep /^ans[0-9]*$/, @files;
@lwresd = grep /^lwresd[0-9]*$/, @files;
}
# Stop the server(s), pass 1: rndc.
if ($use_rndc) {
foreach my $server (grep /^ns/, @servers) {
stop_rndc($server);
foreach my $name(@ns) {
stop_rndc($name, $rndc_port);
}
wait_for_servers(30, grep /^ns/, @servers);
@ns = wait_for_servers(30, @ns);
}
# Pass 2: SIGTERM
foreach my $server (@servers) {
stop_signal($server, "TERM");
foreach my $name (@ns) {
stop_signal($name, "TERM");
}
wait_for_servers(60, @servers);
@ns = wait_for_servers(60, @ns);
foreach my $name(@ans) {
stop_signal($name, "TERM");
}
@ans = wait_for_servers(60, @ans);
foreach my $name(@lwresd) {
stop_signal($name, "TERM");
}
@lwresd = wait_for_servers(60, @lwresd);
# Pass 3: SIGABRT
foreach my $server (@servers) {
stop_signal($server, "ABRT");
foreach my $name (@ns, @ans, @lwresd) {
print "I:$test:$name didn't die when sent a SIGTERM\n";
stop_signal($name, "ABRT");
$errors = 1;
}
exit($errors ? 1 : 0);
exit($errors);
# Subroutines
@ -98,28 +136,25 @@ exit($errors ? 1 : 0);
sub server_pid_file {
my($server) = @_;
my $pid_file;
if ($server =~ /^ns/) {
$pid_file = "named.pid";
} elsif ($server =~ /^lwresd/) {
$pid_file = "lwresd.pid";
} elsif ($server =~ /^ans/) {
$pid_file = "ans.pid";
} else {
print "I:Unknown server type $server\n";
exit 1;
}
$pid_file = "$testdir/$server/$pid_file";
return $testdir . "/" . $server . "/named.pid" if ($server =~ /^ns/);
return $testdir . "/" . $server . "/ans.pid" if ($server =~ /^ans/);
return $testdir . "/" . $server . "/lwresd.pid" if ($server =~ /^lwresd/);
die "Unknown server type $server\n";
}
# Read a PID.
sub read_pid {
my($pid_file) = @_;
my ( $server ) = @_;
my $pid_file = server_pid_file($server);
return unless -f $pid_file;
local *FH;
my $result = open FH, "< $pid_file";
if (!$result) {
print "I:$pid_file: $!\n";
print "I:$test:$pid_file: $!\n";
unlink $pid_file;
return;
}
@ -131,47 +166,43 @@ sub read_pid {
# Stop a named process with rndc.
sub stop_rndc {
my($server) = @_;
my ( $server, $port ) = @_;
my $n;
return unless ($server =~ /^ns(\d+)$/);
my $ip = "10.53.0.$1";
if ($server =~ /^ns(\d+)/) {
$n = $1;
} else {
die "unable to parse server number from name \"$server\"\n";
}
my $ip = "10.53.0.$n";
my $how = $halt ? "halt" : "stop";
# Ugly, but should work.
system("$ENV{RNDC} -c ../common/rndc.conf -s $ip -p $port $how | sed 's/^/I:$server /'");
system("$RNDC -c ../common/rndc.conf -s $ip -p $port $how | sed 's/^/I:$test:$server /'");
return;
}
# Stop a server by sending a signal to it.
sub stop_signal {
my($server, $sig) = @_;
my $pid_file = server_pid_file($server);
return unless -f $pid_file;
my($server, $signal) = @_;
my $pid = read_pid($pid_file);
my $pid = read_pid($server);
return unless defined($pid);
if ($sig eq 'ABRT') {
print "I:$server didn't die when sent a SIGTERM\n";
$errors++;
my $result;
my $pid_file = server_pid_file($server);
if ($^O eq 'cygwin') {
$result = !system("/bin/kill -f -$signal $pid");
} else {
$result = kill $signal, $pid;
}
my $result;
if ($^O eq 'cygwin') {
$result = system("/bin/kill -f -$sig $pid");
if (!$result) {
print "I:$test:$server died before a SIG$signal was sent\n";
$errors = 1;
unlink $pid_file;
if ($result != 0) {
print "I:$server died before a SIG$sig was sent\n";
$errors++;
}
} else {
$result = kill $sig, $pid;
if (!$result) {
print "I:$server died before a SIG$sig was sent\n";
unlink $pid_file;
$errors++;
}
}
return;
@ -180,14 +211,11 @@ sub stop_signal {
sub wait_for_servers {
my($timeout, @servers) = @_;
my @pid_files = grep { defined($_) }
map { server_pid_file($_) } @servers;
while ($timeout > 0 && @pid_files > 0) {
@pid_files = grep { -f $_ } @pid_files;
sleep 1 if (@pid_files > 0);
while ($timeout > 0 && @servers > 0) {
@servers = grep { -f server_pid_file($_) } @servers;
sleep 1 if (@servers > 0);
$timeout--;
}
return;
return @servers;
}

7
bin/tests/system/stop.sh Normal file → Executable file
View file

@ -9,6 +9,9 @@
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
. ./conf.sh
$PERL ./stop.pl "$@"
SYSTEMTESTTOP="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
# shellcheck source=conf.sh
. "$SYSTEMTESTTOP/conf.sh"
export SYSTEMTESTTOP
$PERL "$SYSTEMTESTTOP/stop.pl" "$@"

View file

@ -53,10 +53,10 @@ digcomp knowngood.dig.out.rec dig.out.ns3 || ret=1
[ $pass = 1 ] && {
echo_i "stopping stub server"
$PERL $SYSTEMTESTTOP/stop.pl . ns3
$PERL $SYSTEMTESTTOP/stop.pl stub ns3
echo_i "re-starting stub server"
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns3
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} stub ns3
}
done

View file

@ -136,8 +136,8 @@ $DIFF -s large.out dig.out > /dev/null || { ret=1 ; echo_i "$DIFF failed"; }
status=`expr $status + $ret`
echo_i "stop and restart slave"
$PERL $SYSTEMTESTTOP/stop.pl . ns2
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns2
$PERL $SYSTEMTESTTOP/stop.pl unknown ns2
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} unknown ns2
echo_i "checking large unknown record loading on slave"
ret=0
@ -154,8 +154,8 @@ $DIFF large.out dig.out > /dev/null || { ret=1 ; echo_i "$DIFF failed"; }
status=`expr $status + $ret`
echo_i "stop and restart inline slave"
$PERL $SYSTEMTESTTOP/stop.pl . ns3
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns3
$PERL $SYSTEMTESTTOP/stop.pl unknown ns3
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} unknown ns3
echo_i "checking large unknown record loading on inline slave"
ret=0

View file

@ -429,8 +429,8 @@ echo_i "test mapped zone with out of zone data ($n)"
tmp=0
$DIG -p ${PORT} txt mapped @10.53.0.3 > dig.out.1.$n
grep "status: NOERROR," dig.out.1.$n > /dev/null || tmp=1
$PERL $SYSTEMTESTTOP/stop.pl . ns3
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns3
$PERL $SYSTEMTESTTOP/stop.pl xfer ns3
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} xfer ns3
$DIG -p ${PORT} txt mapped @10.53.0.3 > dig.out.2.$n
grep "status: NOERROR," dig.out.2.$n > /dev/null || tmp=1
$DIG -p ${PORT} axfr mapped @10.53.0.3 > dig.out.3.$n