2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

Merge branch '745-start.pl-refactoring' into 'master'

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

Closes #745

See merge request isc-projects/bind9!1141
This commit is contained in:
Ondřej Surý
2018-12-03 10:58:32 -05:00
23 changed files with 532 additions and 397 deletions

View File

@@ -467,7 +467,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/^/I:ns2 /'
sleep 5
@@ -695,8 +695,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

@@ -1989,7 +1989,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
@@ -2057,7 +2057,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
@@ -2114,7 +2114,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
@@ -2163,7 +2163,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`
@@ -869,7 +869,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`
@@ -880,7 +880,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`
@@ -1323,18 +1323,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

@@ -196,11 +196,11 @@ grep "status: NOERROR" dig.out.test$n > /dev/null && ret=1
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
$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)"

View File

@@ -79,7 +79,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
@@ -130,7 +130,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
@@ -159,7 +159,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
@@ -187,7 +187,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
@@ -238,7 +238,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
@@ -269,7 +269,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
@@ -333,7 +333,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"
@@ -369,7 +369,7 @@ if test ${t:-1000} -gt 5
then
echo_i "testing timestamped 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 timestamped versions failed: DiG lookup failed"
@@ -395,7 +395,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"

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

@@ -165,10 +165,10 @@ status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "checking that loading a correctly signed mirror zone from disk succeeds ($n)"
ret=0
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . ns3
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} mirror ns3
cat ns2/verify-load.db.good.signed > ns3/verify-load.db.mirror
nextpart ns3/named.run > /dev/null
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns3
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} mirror ns3
wait_for_load verify-load ${UPDATED_SERIAL_GOOD} ns3/named.run
$DIG $DIGOPTS @10.53.0.3 +norec verify-load SOA > dig.out.ns3.test$n 2>&1 || ret=1
grep "${UPDATED_SERIAL_GOOD}.*; serial" dig.out.ns3.test$n > /dev/null || ret=1
@@ -178,11 +178,11 @@ status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "checking that loading a journal for an incorrectly signed mirror zone fails ($n)"
ret=0
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . ns3
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} mirror ns3
cp ns3/verify-journal.db.mirror ns3/verify-ixfr.db.mirror
cp ns3/verify-journal.db.bad.mirror.jnl ns3/verify-ixfr.db.mirror.jnl
nextpart ns3/named.run > /dev/null
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns3
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} mirror ns3
wait_for_load verify-ixfr ${UPDATED_SERIAL_BAD} ns3/named.run
$DIG $DIGOPTS @10.53.0.3 +norec verify-ixfr SOA > dig.out.ns3.test$n 2>&1 || ret=1
grep "${UPDATED_SERIAL_BAD}.*; serial" dig.out.ns3.test$n > /dev/null && ret=1
@@ -193,11 +193,11 @@ status=`expr $status + $ret`
n=`expr $n + 1`
echo_i "checking that loading a journal for a correctly signed mirror zone succeeds ($n)"
ret=0
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . ns3
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} mirror ns3
cp ns3/verify-journal.db.mirror ns3/verify-ixfr.db.mirror
cp ns3/verify-journal.db.good.mirror.jnl ns3/verify-ixfr.db.mirror.jnl
nextpart ns3/named.run > /dev/null
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns3
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} mirror ns3
wait_for_load verify-ixfr ${UPDATED_SERIAL_GOOD} ns3/named.run
$DIG $DIGOPTS @10.53.0.3 +norec verify-ixfr SOA > dig.out.ns3.test$n 2>&1 || ret=1
grep "${UPDATED_SERIAL_GOOD}.*; serial" dig.out.ns3.test$n > /dev/null || ret=1
@@ -329,10 +329,10 @@ mv ns2/named.conf.modified ns2/named.conf
$RNDCCMD 10.53.0.2 reconfig > /dev/null 2>&1
# Stop ns3, update the timestamp of the zone file to one far in the past, then
# restart ns3.
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . ns3
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} mirror ns3
touch -t 200001010000 ns3/initially-unavailable.db.mirror
nextpart ns3/named.run > /dev/null
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns3
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} mirror ns3
# Ensure named attempts to retransfer the zone due to its expiry.
wait_for_transfer initially-unavailable
nextpart ns3/named.run | grep "initially-unavailable.*expired" > /dev/null || ret=1

View File

@@ -137,13 +137,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`
@@ -157,10 +157,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`
@@ -205,10 +205,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`
@@ -239,10 +239,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`
@@ -277,10 +277,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`
@@ -299,11 +299,11 @@ if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "reinitialize trust anchors, add second key to bind.keys"
$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*
keyfile_to_managed_keys ns1/$original ns1/$standby1 > ns2/managed.conf
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 no key from bind.keys is marked as an initializing key ($n)"
@@ -315,11 +315,11 @@ if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "reinitialize trust anchors, revert to one key in bind.keys"
$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*
mv ns2/managed1.conf ns2/managed.conf
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)"
@@ -327,13 +327,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`
@@ -347,22 +347,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`
@@ -378,26 +378,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
@@ -411,16 +411,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`
@@ -435,16 +435,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`
@@ -473,10 +473,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)"
@@ -513,18 +513,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`
@@ -572,27 +572,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
@@ -606,11 +606,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
@@ -619,18 +619,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
@@ -708,9 +708,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.
@@ -722,14 +722,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
mkeys_secroots_on 5
grep '; initializing managed' ns5/named.secroots > /dev/null 2>&1 || 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

@@ -206,7 +206,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
dnsrps_loaded
}
@@ -430,7 +430,7 @@ for mode in native dnsrps; do
continue
fi
echo_i "attempting to configure servers with DNSRPS..."
$PERL $SYSTEMTESTTOP/stop.pl .
$PERL $SYSTEMTESTTOP/stop.pl rpz
$SHELL ./setup.sh -N -D $DEBUG
for server in ns*; do
resetstats $server
@@ -445,7 +445,7 @@ for mode in native dnsrps; do
continue
else
echo_i "running DNSRPS sub-test"
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} .
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} rpz
fi
;;
esac
@@ -741,7 +741,7 @@ EOF
# 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

@@ -46,13 +46,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
sleep 3
}
@@ -122,7 +122,7 @@ for mode in native dnsrps; do
continue
fi
echo_i "attempting to configure servers with DNSRPS..."
$PERL $SYSTEMTESTTOP/stop.pl .
$PERL $SYSTEMTESTTOP/stop.pl rpzrecurse
$SHELL ./setup.sh -N -D $DEBUG
sed -n 's/^## //p' dnsrps.conf | cat_i
if grep '^#fail' dnsrps.conf >/dev/null; then
@@ -134,7 +134,7 @@ for mode in native dnsrps; do
continue
else
echo_i "running DNSRPS sub-test"
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} .
$PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} rpzrecurse
fi
;;
esac

View File

@@ -251,7 +251,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
#
#

View File

@@ -51,7 +51,7 @@ if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "disabling server to force non-dnssec SERVFAIL"
$PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . 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 $DIG = $ENV{'DIG'};
my $PERL = $ENV{'PERL'};
@@ -85,185 +93,107 @@ 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;
if ($server_arg) {
if ($server_arg =~ /^ns/) {
push(@ns, $server_arg);
} elsif ($server_arg =~ /^ans/) {
push(@ans, $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 @ans = grep /^ans[0-9]*$/, @files;
my $name;
@ns = grep /^ns[0-9]*$/, @files;
@ans = grep /^ans[0-9]*$/, @files;
}
# Start the servers we found.
&check_ports();
foreach $name(@ns, @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);
}
# 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 dropedns "
if (-e "$testdir/$server/named.dropedns");
$command .= "-T ednsformerr "
if (-e "$testdir/$server/named.ednsformerr");
$command .= "-T ednsnotimp "
if (-e "$testdir/$server/named.ednsnotimp");
$command .= "-T ednsrefused "
if (-e "$testdir/$server/named.ednsrefused");
$command .= "-T noaa "
if (-e "$testdir/$server/named.noaa");
$command .= "-T noedns "
if (-e "$testdir/$server/named.noedns");
$command .= "-T nosoa "
if (-e "$testdir/$server/named.nosoa");
$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 =~ /^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
@@ -271,51 +201,229 @@ 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 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="$(realpath "$(dirname "$0")")"
# 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,61 +38,87 @@ 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;
if ($server_arg) {
if ($server_arg =~ /^ns/) {
push(@ns, $server_arg);
} elsif ($server_arg =~ /^ans/) {
push(@ans, $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 @ans = grep /^ans[0-9]*$/, @files;
push @servers, @ns, @ans;
@ns = grep /^ns[0-9]*$/, @files;
@ans = grep /^ans[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);
# Pass 3: SIGABRT
foreach my $server (@servers) {
stop_signal($server, "ABRT");
foreach my $name (@ns, @ans) {
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
@@ -97,26 +126,24 @@ exit($errors ? 1 : 0);
sub server_pid_file {
my($server) = @_;
my $pid_file;
if ($server =~ /^ns/) {
$pid_file = "named.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/);
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;
}
@@ -128,47 +155,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:$test:$server died before a SIG$sig was sent\n";
$errors++;
}
} else {
$result = kill $sig, $pid;
if (!$result) {
print "I:$test:$server died before a SIG$sig was sent\n";
unlink $pid_file;
$errors++;
}
}
return;
@@ -177,14 +200,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="$(realpath "$(dirname "$0")")"
# 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