Commit 309d02a5 authored by JINMEI Tatuya's avatar JINMEI Tatuya

[trac606-pre] adjusted original scripts so that it can work with BIND 10.

parent e55ec73b
......@@ -15,8 +15,6 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# $Id: cleanall.sh,v 1.11 2007/06/19 23:47:00 tbox Exp $
#
# Clean up after system tests.
#
......@@ -28,7 +26,8 @@ SYSTEMTESTTOP=.
find . -type f \( \
-name 'K*' -o -name '*~' -o -name '*.core' -o -name '*.log' \
-o -name '*.pid' -o -name '*.keyset' -o -name named.run \
-o -name lwresd.run -o -name ans.run \) -print | xargs rm -f
-o name bind10.run -o -name lwresd.run -o -name ans.run \) -print | \
xargs rm -f
status=0
......
......@@ -15,63 +15,23 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# $Id: conf.sh.in,v 1.59 2011-01-13 04:59:24 tbox Exp $
#
# Common configuration data for system tests, to be sourced into
# other shell scripts.
#
# Find the top of the BIND9 tree.
TOP=${SYSTEMTESTTOP:=.}/../../..
# Make it absolute so that it continues to work after we cd.
TOP=`cd $TOP && pwd`
# Find the top of the source tree.
TOP=@abs_top_srcdir@
NAMED=$TOP/bin/named/named
# We must use "named -l" instead of "lwresd" because argv[0] is lost
# if the program is libtoolized.
LWRESD="$TOP/bin/named/named -l"
DIG=$TOP/bin/dig/dig
RNDC=$TOP/bin/rndc/rndc
NSUPDATE=$TOP/bin/nsupdate/nsupdate
DDNSCONFGEN=$TOP/bin/confgen/ddns-confgen
KEYGEN=$TOP/bin/dnssec/dnssec-keygen
KEYFRLAB=$TOP/bin/dnssec/dnssec-keyfromlabel
SIGNER=$TOP/bin/dnssec/dnssec-signzone
REVOKE=$TOP/bin/dnssec/dnssec-revoke
SETTIME=$TOP/bin/dnssec/dnssec-settime
DSFROMKEY=$TOP/bin/dnssec/dnssec-dsfromkey
CHECKZONE=$TOP/bin/check/named-checkzone
CHECKCONF=$TOP/bin/check/named-checkconf
PK11GEN="$TOP/bin/pkcs11/pkcs11-keygen -s 0 -p 1234"
PK11LIST="$TOP/bin/pkcs11/pkcs11-list -s 0 -p 1234"
PK11DEL="$TOP/bin/pkcs11/pkcs11-destroy -s 0 -p 1234"
JOURNALPRINT=$TOP/bin/tools/named-journalprint
RUN_BIND10=$TOP/src/bin/bind10/run_bind10.sh
B10_LOADZONE=$TOP/src/bin/loadzone/run_loadzone.sh
BIND9_NAMED=$BIND9_TOP/bin/named/named
DIG=$BIND9_TOP/bin/dig/dig
# The "stress" test is not run by default since it creates enough
# load on the machine to make it unusable to other users.
# v6synth
SUBDIRS="acl allow_query addzone autosign cacheclean checkconf checknames
dlv @DLZ_SYSTEM_TEST@ dlzexternal dns64 dnssec forward glue gost ixfr limits
lwresd masterfile masterformat metadata notify nsupdate pending pkcs11
resolver rpz rrsetorder sortlist smartsign staticstub stub tkey
tsig tsiggss unknown upforwd views xfer xferquota zonechecks"
SUBDIRS="glue"
#SUBDIRS="dnssec glue masterfile xfer"
# PERL will be an empty string if no perl interpreter was found.
PERL=@PERL@
if test -n "$PERL"
then
if $PERL -e "use IO::Socket::INET6;" 2> /dev/null
then
TESTSOCK6="$PERL $TOP/bin/tests/system/testsock6.pl"
else
TESTSOCK6=false
fi
else
TESTSOCK6=false
fi
export NAMED LWRESD DIG NSUPDATE KEYGEN KEYFRLAB SIGNER KEYSIGNER KEYSETTOOL \
PERL SUBDIRS RNDC CHECKZONE PK11GEN PK11LIST PK11DEL TESTSOCK6 \
JOURNALPRINT
export RUN_BIND10 BIND9_NAMED DIG SUBDIRS PERL
#!/usr/bin/perl
#
# Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2000, 2001 Internet Software Consortium.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# Compare two files, each with the output from dig, for differences.
# Ignore "unimportant" differences, like ordering of NS lines, TTL's,
# etc...
$file1 = $ARGV[0];
$file2 = $ARGV[1];
$count = 0;
$firstname = "";
$status = 0;
$rcode1 = "none";
$rcode2 = "none";
open(FILE1, $file1) || die("open: $file1: $!\n");
while (<FILE1>) {
chomp;
if (/^;.+status:\s+(\S+).+$/) {
$rcode1 = $1;
}
next if (/^;/);
if (/^(\S+)\s+\S+\s+(\S+)\s+(\S+)\s+(.+)$/) {
$name = $1;
$class = $2;
$type = $3;
$value = $4;
if ($type eq "SOA") {
$firstname = $name if ($firstname eq "");
if ($name eq $firstname) {
$name = "$name$count";
$count++;
}
}
if ($entry{"$name ; $class.$type ; $value"} ne "") {
$line = $entry{"$name ; $class.$type ; $value"};
print("Duplicate entry in $file1:\n> $_\n< $line\n");
} else {
$entry{"$name ; $class.$type ; $value"} = $_;
}
}
}
close(FILE1);
$printed = 0;
open(FILE2, $file2) || die("open: $file2: $!\n");
while (<FILE2>) {
chomp;
if (/^;.+status:\s+(\S+).+$/) {
$rcode2 = $1;
}
next if (/^;/);
if (/^(\S+)\s+\S+\s+(\S+)\s+(\S+)\s+(.+)$/) {
$name = $1;
$class = $2;
$type = $3;
$value = $4;
if (($name eq $firstname) && ($type eq "SOA")) {
$count--;
$name = "$name$count";
}
if ($entry{"$name ; $class.$type ; $value"} ne "") {
$entry{"$name ; $class.$type ; $value"} = "";
} else {
print("Only in $file2 (missing from $file1):\n")
if ($printed == 0);
print("> $_\n");
$printed++;
$status = 1;
}
}
}
close(FILE2);
$printed = 0;
foreach $key (keys(%entry)) {
if ($entry{$key} ne "") {
print("Only in $file1 (missing from $file2):\n")
if ($printed == 0);
print("< $entry{$key}\n");
$status = 1;
$printed++;
}
}
if ($rcode1 ne $rcode2) {
print("< status: $rcode1\n");
print("> status: $rcode2\n");
$status = 1;
}
exit($status);
......@@ -15,8 +15,6 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# $Id: ifconfig.sh,v 1.59 2010/06/11 23:46:49 tbox Exp $
#
# Set up interface aliases for bind9 system tests.
#
......@@ -25,7 +23,7 @@
#
config_guess=""
for f in ./config.guess ../../../config.guess
for f in ./config.guess ../../config.guess
do
if test -f $f
then
......@@ -87,7 +85,7 @@ case "$1" in
ifconfig lo0:$int 10.53.0.$ns netmask 0xffffffff up
;;
*-*-solaris2.[8-9]|*-*-solaris2.1[0-9])
/sbin/ifconfig lo0:$int plumb
/sbin/ifconfig lo0:$int plumb
/sbin/ifconfig lo0:$int 10.53.0.$ns up
if test -n "$int6"
then
......@@ -153,7 +151,7 @@ case "$1" in
then
int=`expr $ns + $base - 1`
else
int=$ns
int=$ns
fi
case "$sys" in
*-pc-solaris2.5.1)
......
......@@ -15,8 +15,6 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# $Id: run.sh,v 1.45 2010-12-20 21:35:45 each Exp $
#
# Run a system test.
#
......
......@@ -15,8 +15,6 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# $Id: runall.sh,v 1.10 2010/03/04 23:50:34 tbox Exp $
#
# Run all the system tests.
#
......@@ -35,7 +33,7 @@ $PERL testsock.pl || {
cat <<EOF >&2
I:
I:NOTE: Many of the tests were skipped because they require that
I: the IP addresses 10.53.0.1 through 10.53.0.7 are configured
I: the IP addresses 10.53.0.1 through 10.53.0.7 are configured
I: as alias addresses on the loopback interface. Please run
I: "bin/tests/system/ifconfig.sh up" as root to configure them
I: and rerun the tests.
......
#!/usr/bin/perl -w
#
# Copyright (C) 2004-2008, 2010 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2001 Internet Software Consortium.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# Framework for starting test servers.
# Based on the type of server specified, check for port availability, remove
# temporary files, start the server, and verify that the server is running.
# If a server is specified, start it. Otherwise, start all servers for test.
use strict;
use Cwd 'abs_path';
use Getopt::Long;
# Option handling
# --noclean test [server [options]]
#
# --noclean - Do not cleanup files in server directory
# test - name of the test directory
# server - name of the server directory
# options - alternate options for the server
my $usage = "usage: $0 [--noclean] test-directory [server-directory [server-options]]";
my $noclean;
GetOptions('noclean' => \$noclean);
my $test = $ARGV[0];
my $server = $ARGV[1];
my $options = $ARGV[2];
if (!$test) {
print "$usage\n";
}
if (!-d $test) {
print "No test directory: \"$test\"\n";
}
if ($server && !-d "$test/$server") {
print "No server directory: \"$test/$server\"\n";
}
# Global variables
my $topdir = abs_path("$test/..");
my $testdir = abs_path("$test");
my $RUN_BIND10 = $ENV{'RUN_BIND10'};
my $NAMED = $ENV{'NAMED'};
my $LWRESD = $ENV{'LWRESD'};
my $DIG = $ENV{'DIG'};
my $PERL = $ENV{'PERL'};
# Start the server(s)
if ($server) {
if ($server =~ /^ns/) {
&check_ports($server);
}
&start_server($server, $options);
if ($server =~ /^ns/) {
&verify_server($server);
}
} else {
# Determine which servers need to be started for this test.
opendir DIR, $testdir;
my @files = sort readdir DIR;
closedir DIR;
my @ns = grep /^nsx?[0-9]*$/, @files;
my @lwresd = grep /^lwresd[0-9]*$/, @files;
my @ans = grep /^ans[0-9]*$/, @files;
# Start the servers we found.
&check_ports();
foreach my $s (@ns, @lwresd, @ans) {
&start_server($s);
}
foreach my $s (@ns) {
&verify_server($s);
}
}
# Subroutines
sub check_ports {
my $server = shift;
my $options = "";
if ($server && $server =~ /(\d+)$/) {
$options = "-i $1";
}
my $tries = 0;
while (1) {
my $return = system("$PERL $topdir/testsock.pl -p 5300 $options");
last if ($return == 0);
if (++$tries > 4) {
print "$0: could not bind to server addresses, still running?\n";
print "I:server sockets not available\n";
print "R:FAIL\n";
system("$PERL $topdir/stop.pl $testdir"); # Is this the correct behavior?
exit 1;
}
print "I:Couldn't bind to socket (yet)\n";
sleep 2;
}
}
sub start_server {
my $server = shift;
my $options = shift;
my $cleanup_files;
my $command;
my $pid_file;
if ($server =~ /^nsx/) {
$cleanup_files = "{bind10.run}";
$command = "B10_FROM_SOURCE_CONFIG_DATA_PATH=$testdir/$server/ ";
$command .= "$RUN_BIND10 ";
if ($options) {
$command .= "$options";
} else {
$command .= "--msgq-socket-file=$testdir/$server/msgq_socket ";
$command .= "--pid-file=$testdir/$server/bind10.pid ";
$command .= "-v";
}
$command .= " >bind10.run 2>&1 &";
$pid_file = "bind10.pid";
} elsif ($server =~ /^ns/) {
$cleanup_files = "{*.jnl,*.bk,*.st,named.run}";
$command = "$NAMED ";
if ($options) {
$command .= "$options";
} else {
$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 .= "-c named.conf -d 99 -g";
}
$command .= " >named.run 2>&1 &";
$pid_file = "named.pid";
} elsif ($server =~ /^lwresd/) {
$cleanup_files = "{lwresd.run}";
$command = "$LWRESD ";
if ($options) {
$command .= "$options";
} else {
$command .= "-m record,size,mctx ";
$command .= "-T clienttest ";
$command .= "-C resolv.conf -d 99 -g ";
$command .= "-i lwresd.pid -P 9210 -p 5300";
}
$command .= " >lwresd.run 2>&1 &";
$pid_file = "lwresd.pid";
} elsif ($server =~ /^ans/) {
$cleanup_files = "{ans.run}";
$command = "$PERL ./ans.pl ";
if ($options) {
$command .= "$options";
} else {
$command .= "";
}
$command .= " >ans.run 2>&1 &";
$pid_file = "ans.pid";
} else {
print "I:Unknown server type $server\n";
print "R:FAIL\n";
system "$PERL $topdir/stop.pl $testdir";
exit 1;
}
# print "I:starting server $server\n";
chdir "$testdir/$server";
unless ($noclean) {
unlink glob $cleanup_files;
}
system "$command";
my $tries = 0;
while (!-f $pid_file) {
if (++$tries > 14) {
print "I:Couldn't start server $server\n";
print "R:FAIL\n";
system "$PERL $topdir/stop.pl $testdir";
exit 1;
}
sleep 1;
}
}
sub verify_server {
my $server = shift;
my $n = $server;
$n =~ s/^nsx?//;
my $tries = 0;
while (1) {
my $return = system("$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd -p 5300 version.bind. chaos txt \@10.53.0.$n > dig.out");
last if ($return == 0);
print `grep ";" dig.out`;
if (++$tries >= 30) {
print "I:no response from $server\n";
print "R:FAIL\n";
system("$PERL $topdir/stop.pl $testdir");
exit 1;
}
sleep 2;
}
unlink "dig.out";
}
sub get_bind10_pid {
my $runfile = shift;
my $pidfile = shift;
my $pid;
return if (!-f $runfile);
open(RUNFILE, $runfile) || return;
while (<RUNFILE>) {
if (/BIND 10 started \(PID ([\d]+)\)/) {
$pid = $1;
last;
}
}
close(RUNFILE);
if ($pid) {
open(PIDFILE, ">$pidfile") || return;
print PIDFILE "$pid\n";
close(PIDFILE);
}
}
#!/usr/bin/perl -w
#
# Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2001 Internet Software Consortium.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# Framework for stopping test servers
# Based on the type of server specified, signal the server to stop, wait
# briefly for it to die, and then kill it if it is still alive.
# If a server is specified, stop it. Otherwise, stop all servers for test.
use strict;
use Cwd 'abs_path';
# Option handling
# [--use-rndc] test [server]
#
# test - name of the test directory
# server - name of the server directory
my $usage = "usage: $0 [--use-rndc] test-directory [server-directory]";
my $use_rndc;
while (@ARGV && $ARGV[0] =~ /^-/) {
my $opt = shift @ARGV;
if ($opt eq '--use-rndc') {
$use_rndc = 1;
} else {
die "$usage\n";
}
}
my $test = $ARGV[0];
my $server = $ARGV[1];
my $errors = 0;
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");
# Global variables
my $testdir = abs_path($test);
my @servers;
# Determine which servers need to be stopped.
if (defined $server) {
@servers = ($server);
} else {
local *DIR;
opendir DIR, $testdir or die "$testdir: $!\n";
my @files = sort readdir DIR;
closedir DIR;
my @ns = grep /^nsx?[0-9]*$/, @files;
my @lwresd = grep /^lwresd[0-9]*$/, @files;
my @ans = grep /^ans[0-9]*$/, @files;
push @servers, @ns, @lwresd, @ans;
}
# Stop the server(s), pass 1: rndc.
if ($use_rndc) {
foreach my $server (grep /^ns/, @servers) {
stop_rndc($server);
}
wait_for_servers(30, grep /^ns/, @servers);
}
# Pass 2: SIGTERM
foreach my $server (@servers) {
stop_signal($server, "TERM");
}
wait_for_servers(60, @servers);
# Pass 3: SIGABRT
foreach my $server (@servers) {
stop_signal($server, "ABRT");
}
exit($errors ? 1 : 0);
# Subroutines
# Return the full path to a given server's PID file.
sub server_pid_file {
my($server) = @_;
my $pid_file;
if ($server =~ /^nsx/) {
$pid_file = "bind10.pid";
} elsif ($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 $pid_file;
}
# Read a PID.
sub read_pid {
my($pid_file) = @_;
local *FH;
my $result = open FH, "< $pid_file";
if (!$result) {
print "I:$pid_file: $!\n";
unlink $pid_file;
return;
}
my $pid = <FH>;
chomp($pid);
return $pid;
}
# Stop a named process with rndc.
sub stop_rndc {
my($server) = @_;
return unless ($server =~ /^ns(\d+)$/);
my $ip = "10.53.0.$1";
# Ugly, but should work.
system("$ENV{RNDC} -c $testdir/../common/rndc.conf -s $ip -p 9953 stop | sed 's/^/I:$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 $pid = read_pid($pid_file);
return unless defined($pid);
if ($sig eq 'ABRT') {
print "I:$server didn't die when sent a SIGTERM\n";
$errors++;
}
my $result = kill $sig, $pid;
if (!$result) {
print "I:$server died before a SIG$sig was sent\n";
unlink $pid_file;
$errors++;
}
return;
}
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);
$timeout--;
}
return;
}
#!/usr/bin/perl
#
# Copyright (C) 2004, 2007, 2010 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2000, 2001 Internet Software Consortium.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
# Test whether the interfaces on 10.53.0.* are up.
require 5.001;
use Socket;
use Getopt::Long;
my $port = 0;
my $id = 0;
GetOptions("p=i" => \$port,
"i=i" => \$id);
my @ids;
if ($id != 0) {