From 8bb758633d3d7473312af0f30d28963664bfe6ee Mon Sep 17 00:00:00 2001 From: Brian Conry Date: Tue, 27 Nov 2018 17:47:08 -0600 Subject: [PATCH 1/9] start.pl - wait for server to say 'running' (cherry picked from commit 597049461d9e7b3d43291ee4869aa2f6d47857b6) (cherry picked from commit ee737c8328db58210aa1d57ecc208030247cf29d) --- bin/tests/system/start.pl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/bin/tests/system/start.pl b/bin/tests/system/start.pl index 3ef49a946c..8a7a18c576 100755 --- a/bin/tests/system/start.pl +++ b/bin/tests/system/start.pl @@ -330,6 +330,36 @@ sub verify_server { $tcp = "" if (-e "$testdir/$server/named.notcp"); my $tries = 0; + + my $runfile = "$testdir/$server/named.run"; + + while (1) { + # 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:server $server seems to have not started\n"; + print "I:failed\n"; + + system("$PERL $topdir/stop.pl $testdir"); + + exit 1; + } + + sleep 2; + } + + $tries = 0; + 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); From 7f2a3a7c5f90f8ac9c67545c655e9f7cdfb583d7 Mon Sep 17 00:00:00 2001 From: Brian Conry Date: Tue, 27 Nov 2018 17:47:08 -0600 Subject: [PATCH 2/9] start.pl - refactor (cherry picked from commit 0fc8bfef139407dbe33ce936a55e279910ff82a5) (cherry picked from commit 1ae7ca660611dc8070dd248e93a5dfdab22f14c4) --- bin/tests/system/start.pl | 488 +++++++++++++++++++++----------------- 1 file changed, 271 insertions(+), 217 deletions(-) diff --git a/bin/tests/system/start.pl b/bin/tests/system/start.pl index 8a7a18c576..49a6665d2f 100755 --- a/bin/tests/system/start.pl +++ b/bin/tests/system/start.pl @@ -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,239 +58,142 @@ use Getopt::Long; # "named.args" is ignored. my $usage = "usage: $0 [--noclean] [--restart] [--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'}; my $PERL = $ENV{'PERL'}; 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 @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; +} - # 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); } # 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=) { - 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=) - { - #$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,39 +201,167 @@ 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 (-e "$testdir/$server/named.port") { - open(FH, "<", "$testdir/$server/named.port"); - while(my $line=) { - chomp $line; - $port = $line; - last; + 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 "; } - close FH; + + $command .= "$NAMED -m none -M external "; + } else { + $command = "$NAMED "; } - $tcp = "" if (-e "$testdir/$server/named.notcp"); + 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 + + chomp $line; + + $line =~ s/#.*$//; + + $command .= $line; + + last; + } + } 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"; + } + + 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; @@ -347,10 +381,10 @@ sub verify_server { $tries++; if ($tries >= 30) { - print "I:server $server seems to have not started\n"; - print "I:failed\n"; + print "I:$test:server $server seems to have not started\n"; + print "I:$test:failed\n"; - system("$PERL $topdir/stop.pl $testdir"); + system("$PERL $topdir/stop.pl $test"); exit 1; } @@ -360,16 +394,36 @@ sub verify_server { $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 > dig.out"); + 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); - if (++$tries >= 30) { - print "I:no response from $server\n"; - print "I:failed\n"; - system("$PERL $topdir/stop.pl $testdir"); + + $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"; } From 0c384a76cd91e760ba4eebed198dede8e5f96190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 3 Dec 2018 12:29:39 +0100 Subject: [PATCH 3/9] Make calls to the start.pl always use the test name instead of '.' (cherry picked from commit 16b95157e8f1e0cb1989d0a1ede14bc30b757eb0) (cherry picked from commit e8f38da2dff91a3031aa5dc89ff4dd425140419f) --- bin/tests/system/addzone/tests.sh | 4 +- bin/tests/system/dnssec/tests.sh | 8 +- bin/tests/system/forward/tests.sh | 2 +- bin/tests/system/inline/tests.sh | 10 +-- bin/tests/system/legacy/tests.sh | 4 +- bin/tests/system/lwresd/tests.sh | 10 +-- bin/tests/system/masterformat/tests.sh | 6 +- bin/tests/system/mkeys/tests.sh | 112 ++++++++++++------------- bin/tests/system/notify/tests.sh | 2 +- bin/tests/system/nsupdate/tests.sh | 4 +- bin/tests/system/nzd2nzf/tests.sh | 2 +- bin/tests/system/rpz/tests.sh | 2 +- bin/tests/system/rpzrecurse/tests.sh | 4 +- bin/tests/system/rrsetorder/tests.sh | 2 +- bin/tests/system/start.sh | 8 +- bin/tests/system/stub/tests.sh | 2 +- bin/tests/system/unknown/tests.sh | 4 +- bin/tests/system/xfer/tests.sh | 2 +- 18 files changed, 96 insertions(+), 92 deletions(-) mode change 100644 => 100755 bin/tests/system/start.sh diff --git a/bin/tests/system/addzone/tests.sh b/bin/tests/system/addzone/tests.sh index 1b0cd41ee2..be7c9a2806 100755 --- a/bin/tests/system/addzone/tests.sh +++ b/bin/tests/system/addzone/tests.sh @@ -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 @@ -528,7 +528,7 @@ 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/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` diff --git a/bin/tests/system/dnssec/tests.sh b/bin/tests/system/dnssec/tests.sh index df4aca856b..64a7a854a4 100644 --- a/bin/tests/system/dnssec/tests.sh +++ b/bin/tests/system/dnssec/tests.sh @@ -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 diff --git a/bin/tests/system/forward/tests.sh b/bin/tests/system/forward/tests.sh index f23cde1751..abb3fd5628 100644 --- a/bin/tests/system/forward/tests.sh +++ b/bin/tests/system/forward/tests.sh @@ -91,7 +91,7 @@ grep "status: NXDOMAIN" dig.out.f2 > /dev/null || ret=1 $PERL ../stop.pl . 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` diff --git a/bin/tests/system/inline/tests.sh b/bin/tests/system/inline/tests.sh index 997d81a8a2..50900f4724 100755 --- a/bin/tests/system/inline/tests.sh +++ b/bin/tests/system/inline/tests.sh @@ -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 @@ -462,7 +462,7 @@ 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` @@ -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` @@ -1330,7 +1330,7 @@ if [ $ans != 0 ]; then ret=1; fi # flushed upon shutdown since we specifically want to avoid it. $PERL $SYSTEMTESTTOP/stop.pl --use-rndc --halt --port ${CONTROLPORT} . 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 @@ -1339,7 +1339,7 @@ $PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} . ns3 # receive_secure_serial() should refrain from introducing any zone changes. $PERL $SYSTEMTESTTOP/stop.pl --use-rndc --halt --port ${CONTROLPORT} . 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 diff --git a/bin/tests/system/legacy/tests.sh b/bin/tests/system/legacy/tests.sh index c4356f2456..bc25bfe8ca 100755 --- a/bin/tests/system/legacy/tests.sh +++ b/bin/tests/system/legacy/tests.sh @@ -148,7 +148,7 @@ then 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 diff --git a/bin/tests/system/lwresd/tests.sh b/bin/tests/system/lwresd/tests.sh index e753ce175e..f36fc611c2 100644 --- a/bin/tests/system/lwresd/tests.sh +++ b/bin/tests/system/lwresd/tests.sh @@ -34,7 +34,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 @@ -49,11 +49,11 @@ $PERL $SYSTEMTESTTOP/stop.pl . 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 lwresd lwresd1 -- "-X lwresd.lock -m record,size,mctx -c lwresd.conf -d 99 -g" 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 @@ -68,11 +68,11 @@ $PERL $SYSTEMTESTTOP/stop.pl . 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 lwresd lwresd1 -- "-X lwresd.lock -m record,size,mctx -c nosearch.conf -d 99 -g" 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 diff --git a/bin/tests/system/masterformat/tests.sh b/bin/tests/system/masterformat/tests.sh index 14d90d5517..6443a89aa9 100755 --- a/bin/tests/system/masterformat/tests.sh +++ b/bin/tests/system/masterformat/tests.sh @@ -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}" diff --git a/bin/tests/system/mkeys/tests.sh b/bin/tests/system/mkeys/tests.sh index f65f49e98d..3d9d7ac682 100644 --- a/bin/tests/system/mkeys/tests.sh +++ b/bin/tests/system/mkeys/tests.sh @@ -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` @@ -457,7 +457,7 @@ echo_i "reinitialize trust anchors" $PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . 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` @@ -557,23 +557,23 @@ $PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . 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 @@ -591,7 +591,7 @@ $PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . 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 @@ -669,7 +669,7 @@ ret=0 # between the next scheduled key refresh time and startup time of restarted ns5. $PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . 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. @@ -688,7 +688,7 @@ rm -f ns5/managed-keys.bind* # 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 diff --git a/bin/tests/system/notify/tests.sh b/bin/tests/system/notify/tests.sh index ad20e3eaca..9c104bdde1 100644 --- a/bin/tests/system/notify/tests.sh +++ b/bin/tests/system/notify/tests.sh @@ -120,7 +120,7 @@ $PERL $SYSTEMTESTTOP/stop.pl . 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 diff --git a/bin/tests/system/nsupdate/tests.sh b/bin/tests/system/nsupdate/tests.sh index 9f26572cea..a5bee33eea 100755 --- a/bin/tests/system/nsupdate/tests.sh +++ b/bin/tests/system/nsupdate/tests.sh @@ -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 @@ -511,7 +511,7 @@ $PERL $SYSTEMTESTTOP/stop.pl --use-rndc --port ${CONTROLPORT} . ns1 # 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 diff --git a/bin/tests/system/nzd2nzf/tests.sh b/bin/tests/system/nzd2nzf/tests.sh index 85f1721817..879233a82c 100644 --- a/bin/tests/system/nzd2nzf/tests.sh +++ b/bin/tests/system/nzd2nzf/tests.sh @@ -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)" diff --git a/bin/tests/system/rpz/tests.sh b/bin/tests/system/rpz/tests.sh index 32eb0c6ea4..9a0fe6213f 100644 --- a/bin/tests/system/rpz/tests.sh +++ b/bin/tests/system/rpz/tests.sh @@ -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 } diff --git a/bin/tests/system/rpzrecurse/tests.sh b/bin/tests/system/rpzrecurse/tests.sh index 172a806eef..eadfc0e7ad 100644 --- a/bin/tests/system/rpzrecurse/tests.sh +++ b/bin/tests/system/rpzrecurse/tests.sh @@ -26,7 +26,7 @@ run_server() { 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 \ diff --git a/bin/tests/system/rrsetorder/tests.sh b/bin/tests/system/rrsetorder/tests.sh index 4cc21cdf2a..1b4245a4e3 100644 --- a/bin/tests/system/rrsetorder/tests.sh +++ b/bin/tests/system/rrsetorder/tests.sh @@ -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 # # diff --git a/bin/tests/system/start.sh b/bin/tests/system/start.sh old mode 100644 new mode 100755 index 78fb0443d7..c5661c52eb --- a/bin/tests/system/start.sh +++ b/bin/tests/system/start.sh @@ -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" "$@" diff --git a/bin/tests/system/stub/tests.sh b/bin/tests/system/stub/tests.sh index 3c51aec173..ed3d62e492 100644 --- a/bin/tests/system/stub/tests.sh +++ b/bin/tests/system/stub/tests.sh @@ -56,7 +56,7 @@ digcomp knowngood.dig.out.rec dig.out.ns3 || ret=1 $PERL $SYSTEMTESTTOP/stop.pl . 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 diff --git a/bin/tests/system/unknown/tests.sh b/bin/tests/system/unknown/tests.sh index 7fbec3f71e..7c3a244da2 100644 --- a/bin/tests/system/unknown/tests.sh +++ b/bin/tests/system/unknown/tests.sh @@ -137,7 +137,7 @@ 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/start.pl --noclean --restart --port ${PORT} unknown ns2 echo_i "checking large unknown record loading on slave" ret=0 @@ -155,7 +155,7 @@ 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/start.pl --noclean --restart --port ${PORT} unknown ns3 echo_i "checking large unknown record loading on inline slave" ret=0 diff --git a/bin/tests/system/xfer/tests.sh b/bin/tests/system/xfer/tests.sh index 91b23b3edb..cb1cd3ea00 100755 --- a/bin/tests/system/xfer/tests.sh +++ b/bin/tests/system/xfer/tests.sh @@ -430,7 +430,7 @@ 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/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 From 1fa08d78d3d9d51cf7c2d74bebf4615286fe5bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 3 Dec 2018 13:14:05 +0100 Subject: [PATCH 4/9] stop.pl - refactor (cherry picked from commit 27ee629e6b583f60fea0ab78fb3ebd0d1d71d9d2) (cherry picked from commit 70cbdf3528e115f396d2d1a83579891389188085) --- bin/tests/system/stop.pl | 175 +++++++++++++++++++++------------------ 1 file changed, 96 insertions(+), 79 deletions(-) diff --git a/bin/tests/system/stop.pl b/bin/tests/system/stop.pl index 2593d4d148..a0ebc95d7d 100644 --- a/bin/tests/system/stop.pl +++ b/bin/tests/system/stop.pl @@ -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,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 @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; } - # 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 @@ -98,28 +126,24 @@ 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/); + + 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 +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:$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 +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; } From 62a1054fd065bd954569f4284333d922d87659dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 3 Dec 2018 13:14:32 +0100 Subject: [PATCH 5/9] Make calls to the stop.pl always use the test name instead of '.' (cherry picked from commit e227815af51c0656e22e5aebfe99e2399106b31c) (cherry picked from commit 73e26ec1d66fc1bbc0b0aae9002a81ff6c05f971) --- bin/tests/system/addzone/tests.sh | 2 +- bin/tests/system/forward/tests.sh | 2 +- bin/tests/system/inline/tests.sh | 8 ++++---- bin/tests/system/legacy/tests.sh | 2 +- bin/tests/system/logfileconfig/tests.sh | 16 ++++++++-------- bin/tests/system/lwresd/tests.sh | 4 ++-- bin/tests/system/mkeys/tests.sh | 10 +++++----- bin/tests/system/notify/tests.sh | 2 +- bin/tests/system/nsupdate/tests.sh | 2 +- bin/tests/system/nzd2nzf/tests.sh | 2 +- bin/tests/system/rpz/tests.sh | 2 +- bin/tests/system/rpzrecurse/tests.sh | 2 +- bin/tests/system/sfcache/tests.sh | 3 +-- bin/tests/system/stop.sh | 7 +++++-- bin/tests/system/stub/tests.sh | 2 +- bin/tests/system/unknown/tests.sh | 4 ++-- bin/tests/system/xfer/tests.sh | 2 +- 17 files changed, 37 insertions(+), 35 deletions(-) mode change 100644 => 100755 bin/tests/system/stop.sh diff --git a/bin/tests/system/addzone/tests.sh b/bin/tests/system/addzone/tests.sh index be7c9a2806..1592dd0137 100755 --- a/bin/tests/system/addzone/tests.sh +++ b/bin/tests/system/addzone/tests.sh @@ -527,7 +527,7 @@ 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/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 diff --git a/bin/tests/system/forward/tests.sh b/bin/tests/system/forward/tests.sh index abb3fd5628..aa80f189e6 100644 --- a/bin/tests/system/forward/tests.sh +++ b/bin/tests/system/forward/tests.sh @@ -88,7 +88,7 @@ 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} forward ns4 || ret=1 diff --git a/bin/tests/system/inline/tests.sh b/bin/tests/system/inline/tests.sh index 50900f4724..1c51996c23 100755 --- a/bin/tests/system/inline/tests.sh +++ b/bin/tests/system/inline/tests.sh @@ -455,7 +455,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` @@ -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` @@ -1328,7 +1328,7 @@ 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} inline ns3 # At this point, the raw zone journal will not have a source serial set. Upon @@ -1337,7 +1337,7 @@ $PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} inline ns3 # 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} inline ns3 # We can now test whether the secure zone journal was correctly processed: diff --git a/bin/tests/system/legacy/tests.sh b/bin/tests/system/legacy/tests.sh index bc25bfe8ca..9e39c4f525 100755 --- a/bin/tests/system/legacy/tests.sh +++ b/bin/tests/system/legacy/tests.sh @@ -144,7 +144,7 @@ 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 diff --git a/bin/tests/system/logfileconfig/tests.sh b/bin/tests/system/logfileconfig/tests.sh index ad63bdd4f9..69914215d7 100644 --- a/bin/tests/system/logfileconfig/tests.sh +++ b/bin/tests/system/logfileconfig/tests.sh @@ -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" diff --git a/bin/tests/system/lwresd/tests.sh b/bin/tests/system/lwresd/tests.sh index f36fc611c2..df20ee9d3f 100644 --- a/bin/tests/system/lwresd/tests.sh +++ b/bin/tests/system/lwresd/tests.sh @@ -45,7 +45,7 @@ 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 @@ -64,7 +64,7 @@ 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 diff --git a/bin/tests/system/mkeys/tests.sh b/bin/tests/system/mkeys/tests.sh index 3d9d7ac682..1e9097a5de 100644 --- a/bin/tests/system/mkeys/tests.sh +++ b/bin/tests/system/mkeys/tests.sh @@ -454,7 +454,7 @@ 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} mkeys ns2 @@ -553,7 +553,7 @@ 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 @@ -587,7 +587,7 @@ 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 @@ -667,7 +667,7 @@ 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} mkeys ns5 wait_for_log "Returned from key fetch in keyfetch_done()" ns5/named.run @@ -681,7 +681,7 @@ 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 diff --git a/bin/tests/system/notify/tests.sh b/bin/tests/system/notify/tests.sh index 9c104bdde1..c3032d033a 100644 --- a/bin/tests/system/notify/tests.sh +++ b/bin/tests/system/notify/tests.sh @@ -115,7 +115,7 @@ 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 diff --git a/bin/tests/system/nsupdate/tests.sh b/bin/tests/system/nsupdate/tests.sh index a5bee33eea..901cd22f57 100755 --- a/bin/tests/system/nsupdate/tests.sh +++ b/bin/tests/system/nsupdate/tests.sh @@ -506,7 +506,7 @@ 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". diff --git a/bin/tests/system/nzd2nzf/tests.sh b/bin/tests/system/nzd2nzf/tests.sh index 879233a82c..2a43b8e535 100644 --- a/bin/tests/system/nzd2nzf/tests.sh +++ b/bin/tests/system/nzd2nzf/tests.sh @@ -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)" diff --git a/bin/tests/system/rpz/tests.sh b/bin/tests/system/rpz/tests.sh index 9a0fe6213f..4ed7841ae6 100644 --- a/bin/tests/system/rpz/tests.sh +++ b/bin/tests/system/rpz/tests.sh @@ -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?" diff --git a/bin/tests/system/rpzrecurse/tests.sh b/bin/tests/system/rpzrecurse/tests.sh index eadfc0e7ad..6a69356d5a 100644 --- a/bin/tests/system/rpzrecurse/tests.sh +++ b/bin/tests/system/rpzrecurse/tests.sh @@ -20,7 +20,7 @@ run_server() { TESTNAME=$1 echo_i "stopping resolver" - $PERL $SYSTEMTESTTOP/stop.pl . ns2 + $PERL $SYSTEMTESTTOP/stop.pl rpzrecurse ns2 sleep 1 diff --git a/bin/tests/system/sfcache/tests.sh b/bin/tests/system/sfcache/tests.sh index 6e45830922..45669fb6a1 100644 --- a/bin/tests/system/sfcache/tests.sh +++ b/bin/tests/system/sfcache/tests.sh @@ -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 diff --git a/bin/tests/system/stop.sh b/bin/tests/system/stop.sh old mode 100644 new mode 100755 index a2ae614d89..878f6aba23 --- a/bin/tests/system/stop.sh +++ b/bin/tests/system/stop.sh @@ -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" "$@" diff --git a/bin/tests/system/stub/tests.sh b/bin/tests/system/stub/tests.sh index ed3d62e492..730cd40603 100644 --- a/bin/tests/system/stub/tests.sh +++ b/bin/tests/system/stub/tests.sh @@ -53,7 +53,7 @@ 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} stub ns3 diff --git a/bin/tests/system/unknown/tests.sh b/bin/tests/system/unknown/tests.sh index 7c3a244da2..190b84020d 100644 --- a/bin/tests/system/unknown/tests.sh +++ b/bin/tests/system/unknown/tests.sh @@ -136,7 +136,7 @@ $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/stop.pl unknown ns2 $PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} unknown ns2 echo_i "checking large unknown record loading on slave" @@ -154,7 +154,7 @@ $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/stop.pl unknown ns3 $PERL $SYSTEMTESTTOP/start.pl --noclean --restart --port ${PORT} unknown ns3 echo_i "checking large unknown record loading on inline slave" diff --git a/bin/tests/system/xfer/tests.sh b/bin/tests/system/xfer/tests.sh index cb1cd3ea00..12e761f6a5 100755 --- a/bin/tests/system/xfer/tests.sh +++ b/bin/tests/system/xfer/tests.sh @@ -429,7 +429,7 @@ 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/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 From 08fa20bf54107392161d5d9a8d4e01d1c80fe791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 3 Dec 2018 19:50:47 +0100 Subject: [PATCH 6/9] Re-add functionality to handle lwresd from {start,stop}.pl --- bin/tests/system/lwresd/tests.sh | 6 ++- bin/tests/system/start.pl | 86 ++++++++++++++++++++++++++++++++ bin/tests/system/stop.pl | 13 ++++- 3 files changed, 102 insertions(+), 3 deletions(-) diff --git a/bin/tests/system/lwresd/tests.sh b/bin/tests/system/lwresd/tests.sh index df20ee9d3f..9185085489 100644 --- a/bin/tests/system/lwresd/tests.sh +++ b/bin/tests/system/lwresd/tests.sh @@ -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 @@ -49,7 +51,7 @@ $PERL $SYSTEMTESTTOP/stop.pl lwresd lwresd1 mv lwresd1/lwresd.run lwresd1/lwresd.run.resolv -$PERL $SYSTEMTESTTOP/start.pl lwresd 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 @@ -68,7 +70,7 @@ $PERL $SYSTEMTESTTOP/stop.pl lwresd lwresd1 mv lwresd1/lwresd.run lwresd1/lwresd.run.lwresd -$PERL $SYSTEMTESTTOP/start.pl lwresd 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 diff --git a/bin/tests/system/start.pl b/bin/tests/system/start.pl index 49a6665d2f..38e3045fe5 100755 --- a/bin/tests/system/start.pl +++ b/bin/tests/system/start.pl @@ -87,6 +87,7 @@ if ($server_arg && ! -d "$testdir/$server_arg") { } my $NAMED = $ENV{'NAMED'}; +my $LWRESD = $ENV{'LWRESD'}; my $DIG = $ENV{'DIG'}; my $PERL = $ENV{'PERL'}; my $PYTHON = $ENV{'PYTHON'}; @@ -95,12 +96,15 @@ my $PYTHON = $ENV{'PYTHON'}; 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"; @@ -113,6 +117,7 @@ if ($server_arg) { @ns = grep /^ns[0-9]*$/, @files; @ans = grep /^ans[0-9]*$/, @files; + @lwresd = grep /^lwresd[0-9]*$/, @files; } # Start the servers we found. @@ -127,6 +132,10 @@ foreach my $name(@ans) { &start_ans_server($name); } +foreach my $name(@lwresd) { + &start_lwresd_server($name, $options_arg); +} + # Subroutines sub read_ns_port { @@ -360,6 +369,83 @@ sub start_ans_server { 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 ) = @_; diff --git a/bin/tests/system/stop.pl b/bin/tests/system/stop.pl index a0ebc95d7d..a96f33b8a8 100644 --- a/bin/tests/system/stop.pl +++ b/bin/tests/system/stop.pl @@ -69,12 +69,15 @@ 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"; @@ -87,6 +90,7 @@ if ($server_arg) { @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. @@ -111,8 +115,14 @@ foreach my $name(@ans) { @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 $name (@ns, @ans) { +foreach my $name (@ns, @ans, @lwresd) { print "I:$test:$name didn't die when sent a SIGTERM\n"; stop_signal($name, "ABRT"); $errors = 1; @@ -128,6 +138,7 @@ sub 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"; } From 4344a7e5991c61f52e67149b31d8e16288a497f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 3 Dec 2018 20:12:19 +0100 Subject: [PATCH 7/9] Make run.sh and runall.sh executable --- bin/tests/system/run.sh | 0 bin/tests/system/runall.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 bin/tests/system/run.sh mode change 100644 => 100755 bin/tests/system/runall.sh diff --git a/bin/tests/system/run.sh b/bin/tests/system/run.sh old mode 100644 new mode 100755 diff --git a/bin/tests/system/runall.sh b/bin/tests/system/runall.sh old mode 100644 new mode 100755 From 337c87faad6364d76b35ab342120b6d38a424bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 3 Dec 2018 20:25:20 +0100 Subject: [PATCH 8/9] Add extra .gitignore to lwresd test --- bin/tests/system/lwresd/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 bin/tests/system/lwresd/.gitignore diff --git a/bin/tests/system/lwresd/.gitignore b/bin/tests/system/lwresd/.gitignore new file mode 100644 index 0000000000..14861e3d66 --- /dev/null +++ b/bin/tests/system/lwresd/.gitignore @@ -0,0 +1,2 @@ +/lwresd1/lwresd.run.lwresd +/lwresd1/lwresd.run.resolv From 948104ee5a0875119f61f6fbf16636cfa149e754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Mon, 3 Dec 2018 20:35:03 +0100 Subject: [PATCH 9/9] Replace realpath with cd&pwd shell magic --- bin/tests/system/run.sh | 2 +- bin/tests/system/start.sh | 2 +- bin/tests/system/stop.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/tests/system/run.sh b/bin/tests/system/run.sh index c2f0d63bfe..6754a4252d 100755 --- a/bin/tests/system/run.sh +++ b/bin/tests/system/run.sh @@ -13,7 +13,7 @@ # Run a system test. # -SYSTEMTESTTOP=$(realpath .) +SYSTEMTESTTOP="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" . $SYSTEMTESTTOP/conf.sh export SYSTEMTESTTOP diff --git a/bin/tests/system/start.sh b/bin/tests/system/start.sh index c5661c52eb..e71c7d6449 100755 --- a/bin/tests/system/start.sh +++ b/bin/tests/system/start.sh @@ -9,7 +9,7 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. -SYSTEMTESTTOP="$(realpath "$(dirname "$0")")" +SYSTEMTESTTOP="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" # shellcheck source=conf.sh . "$SYSTEMTESTTOP/conf.sh" export SYSTEMTESTTOP diff --git a/bin/tests/system/stop.sh b/bin/tests/system/stop.sh index 878f6aba23..ba1256bc43 100755 --- a/bin/tests/system/stop.sh +++ b/bin/tests/system/stop.sh @@ -9,7 +9,7 @@ # See the COPYRIGHT file distributed with this work for additional # information regarding copyright ownership. -SYSTEMTESTTOP="$(realpath "$(dirname "$0")")" +SYSTEMTESTTOP="$(cd -P -- "$(dirname -- "$0")" && pwd -P)" # shellcheck source=conf.sh . "$SYSTEMTESTTOP/conf.sh" export SYSTEMTESTTOP