mirror of
https://github.com/isc-projects/bind9.git
synced 2026-04-27 09:06:51 -04:00
added incremental zone transfer test
This commit is contained in:
parent
a9ef485446
commit
89485c1d71
6 changed files with 391 additions and 2 deletions
|
|
@ -15,7 +15,7 @@
|
|||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: conf.sh.in,v 1.21 2001/03/08 16:19:35 tale Exp $
|
||||
# $Id: conf.sh.in,v 1.22 2001/05/10 18:29:07 gson Exp $
|
||||
|
||||
#
|
||||
# Common configuration data for system tests, to be sourced into
|
||||
|
|
@ -42,7 +42,7 @@ KEYSETTOOL=$TOP/bin/dnssec/dnssec-makekeyset
|
|||
|
||||
# The "stress" test is not run by default since it creates enough
|
||||
# load on the machine to make it unusable to other users.
|
||||
SUBDIRS="cacheclean dnssec forward glue limits lwresd notify nsupdate \
|
||||
SUBDIRS="cacheclean dnssec forward glue ixfr limits lwresd notify nsupdate \
|
||||
resolver sortlist stub tkey unknown upforwd v6synth views xfer xferquota"
|
||||
|
||||
# PERL will be an empty string if no perl interpreter was found.
|
||||
|
|
|
|||
157
bin/tests/system/ixfr/ans2/ans.pl
Normal file
157
bin/tests/system/ixfr/ans2/ans.pl
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM
|
||||
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
# INTERNET SOFTWARE CONSORTIUM 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.
|
||||
|
||||
# $Id: ans.pl,v 1.1 2001/05/10 18:29:09 gson Exp $
|
||||
|
||||
#
|
||||
# This is the name server from hell. It provides canned
|
||||
# responses based on pattern matching the queries, and
|
||||
# can be reprogrammed on-the-fly over a TCP connection.
|
||||
#
|
||||
# The server listens for control connections on port 5301.
|
||||
# A control connection is a TCP stream of lines like
|
||||
#
|
||||
# /pattern/
|
||||
# name ttl type rdata
|
||||
# name ttl type rdata
|
||||
# ...
|
||||
# /pattern/
|
||||
# name ttl type rdata
|
||||
# name ttl type rdata
|
||||
# ...
|
||||
#
|
||||
# There can be any number of patterns, each associated
|
||||
# with any number of response RRs. Each pattern is a
|
||||
# Perl regular expression.
|
||||
#
|
||||
# Each incoming query is converted into a string of the form
|
||||
# "qname qtype" (the printable query domain name, space,
|
||||
# printable query type) and matched against each pattern.
|
||||
#
|
||||
# The first pattern matching the query is selected, and
|
||||
# the RR following the pattern line are sent in the
|
||||
# answer section of the response.
|
||||
#
|
||||
# Each new control connection causes the current set of
|
||||
# patterns and responses to be cleared before adding new
|
||||
# ones.
|
||||
#
|
||||
# The server handles UDP and TCP queries. Zone transfer
|
||||
# responses work, but must fit in a single 64 k message.
|
||||
#
|
||||
|
||||
use IO::File;
|
||||
use IO::Socket;
|
||||
use Net::DNS;
|
||||
use Net::DNS::Packet;
|
||||
|
||||
my $ctlsock = IO::Socket::INET->new(LocalAddr => "10.53.0.2",
|
||||
LocalPort => 5301, Proto => "tcp", Listen => 5, Reuse => 1) or die "$!";
|
||||
|
||||
my $udpsock = IO::Socket::INET->new(LocalAddr => "10.53.0.2",
|
||||
LocalPort => 5300, Proto => "udp", Reuse => 1) or die "$!";
|
||||
|
||||
my $tcpsock = IO::Socket::INET->new(LocalAddr => "10.53.0.2",
|
||||
LocalPort => 5300, Proto => "tcp", Listen => 5, Reuse => 1) or die "$!";
|
||||
|
||||
my $pidf = new IO::File "ans.pid", "w" or die "cannot write pid file: $!";
|
||||
print $pidf "$$\n";
|
||||
$pidf->close;
|
||||
sub rmpid { unlink "ans.pid"; exit 1; };
|
||||
|
||||
$SIG{INT} = \&rmpid;
|
||||
$SIG{TERM} = \&rmpid;
|
||||
|
||||
my @answers = ();
|
||||
|
||||
sub handle {
|
||||
my ($buf) = @_;
|
||||
|
||||
my ($packet, $err) = new Net::DNS::Packet(\$buf, 0);
|
||||
$err and die $err;
|
||||
|
||||
$packet->header->qr(1);
|
||||
$packet->header->aa(1);
|
||||
|
||||
my @questions = $packet->question;
|
||||
my $qname = $questions[0]->qname;
|
||||
my $qtype = $questions[0]->qtype;
|
||||
|
||||
my $r;
|
||||
foreach $r (@rules) {
|
||||
my $pattern = $r->{pattern};
|
||||
warn "match $qname $qtype == $pattern";
|
||||
if ("$qname $qtype" =~ /$pattern/) {
|
||||
my $a;
|
||||
foreach $a (@{$r->{answer}}) {
|
||||
$packet->push("answer", $a);
|
||||
}
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
# $packet->print;
|
||||
|
||||
return $packet->data;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
$rin = '';
|
||||
vec($rin, fileno($ctlsock), 1) = 1;
|
||||
vec($rin, fileno($tcpsock), 1) = 1;
|
||||
vec($rin, fileno($udpsock), 1) = 1;
|
||||
|
||||
select($rout = $rin, undef, undef, undef);
|
||||
|
||||
if (vec($rout, fileno($ctlsock), 1)) {
|
||||
warn "ctl conn";
|
||||
my $conn = $ctlsock->accept;
|
||||
@rules = ();
|
||||
while (my $line = $conn->getline) {
|
||||
chomp $line;
|
||||
if ($line =~ m!^/(.*)/$!) {
|
||||
$rule = { pattern => $1, answer => [] };
|
||||
push(@rules, $rule);
|
||||
} else {
|
||||
push(@{$rule->{answer}},
|
||||
new Net::DNS::RR($line));
|
||||
}
|
||||
|
||||
}
|
||||
$conn->close;
|
||||
} elsif (vec($rout, fileno($udpsock), 1)) {
|
||||
printf "UDP request\n";
|
||||
$udpsock->recv($buf, 512);
|
||||
$response = handle($buf);
|
||||
$udpsock->send($response);
|
||||
} elsif (vec($rout, fileno($tcpsock), 1)) {
|
||||
my $conn = $tcpsock->accept;
|
||||
for (;;) {
|
||||
printf "TCP request\n";
|
||||
my $n = $conn->sysread($lenbuf, 2);
|
||||
last unless $n == 2;
|
||||
my $len = unpack("n", $lenbuf);
|
||||
$n = $conn->sysread($buf, $len);
|
||||
last unless $n == $len;
|
||||
$response = handle($buf);
|
||||
$len = length($response);
|
||||
$n = $conn->syswrite(pack("n", $len), 2);
|
||||
$n = $conn->syswrite($response, $len);
|
||||
}
|
||||
$conn->close;
|
||||
}
|
||||
}
|
||||
20
bin/tests/system/ixfr/clean.sh
Normal file
20
bin/tests/system/ixfr/clean.sh
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2001 Internet Software Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM
|
||||
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
# INTERNET SOFTWARE CONSORTIUM 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.
|
||||
|
||||
# $Id: clean.sh,v 1.1 2001/05/10 18:29:09 gson Exp $
|
||||
|
||||
rm -f ns1/named.conf
|
||||
43
bin/tests/system/ixfr/setup.sh
Normal file
43
bin/tests/system/ixfr/setup.sh
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2001 Internet Software Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM
|
||||
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
# INTERNET SOFTWARE CONSORTIUM 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.
|
||||
|
||||
# $Id: setup.sh,v 1.1 2001/05/10 18:29:09 gson Exp $
|
||||
|
||||
rm -f ns1/*.db ns1/*.jnl
|
||||
|
||||
cat <<EOF >ns1/named.conf
|
||||
options {
|
||||
query-source address 10.53.0.1;
|
||||
notify-source 10.53.0.1;
|
||||
transfer-source 10.53.0.1;
|
||||
port 5300;
|
||||
pid-file "named.pid";
|
||||
listen-on { 10.53.0.1; };
|
||||
listen-on-v6 { none; };
|
||||
recursion no;
|
||||
notify yes;
|
||||
};
|
||||
|
||||
key rndc_key {
|
||||
secret "1234abcd8765";
|
||||
algorithm hmac-md5;
|
||||
};
|
||||
|
||||
controls {
|
||||
inet 10.53.0.1 port 9953 allow { any; } keys { rndc_key; };
|
||||
};
|
||||
EOF
|
||||
130
bin/tests/system/ixfr/tests.sh
Normal file
130
bin/tests/system/ixfr/tests.sh
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2001 Internet Software Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM
|
||||
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
# INTERNET SOFTWARE CONSORTIUM 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.
|
||||
|
||||
# $Id: tests.sh,v 1.1 2001/05/10 18:29:09 gson Exp $
|
||||
|
||||
SYSTEMTESTTOP=..
|
||||
. $SYSTEMTESTTOP/conf.sh
|
||||
|
||||
DIGOPTS="+tcp +noadd +nosea +nostat +noquest +nocomm +nocmd"
|
||||
DIGCMD="$DIG $DIGOPTS @10.53.0.1 -p 5300"
|
||||
SENDCMD="$PERL ../send.pl 10.53.0.2 5301"
|
||||
RNDCCMD="$RNDC -s 10.53.0.1 -p 9953 -c ../common/rndc.conf"
|
||||
|
||||
echo "I:testing initial AXFR"
|
||||
|
||||
$SENDCMD <<EOF
|
||||
/SOA/
|
||||
nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300
|
||||
/AXFR/
|
||||
nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300
|
||||
nil. 300 NS ns.nil.
|
||||
nil. 300 TXT "initial AXFR"
|
||||
a.nil. 60 A 10.0.0.61
|
||||
b.nil. 60 A 10.0.0.62
|
||||
nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300
|
||||
EOF
|
||||
|
||||
sleep 1
|
||||
|
||||
# Initially, ns1 is not authoritative for anything (see setup.sh).
|
||||
# Now that ans is up and running with the right data, we make it
|
||||
# a slave for nil.
|
||||
|
||||
cat <<EOF >>ns1/named.conf
|
||||
zone "nil" {
|
||||
type slave;
|
||||
file "myftp.db";
|
||||
masters { 10.53.0.2; };
|
||||
};
|
||||
EOF
|
||||
|
||||
$RNDCCMD reload
|
||||
|
||||
sleep 2
|
||||
|
||||
$DIGCMD nil. TXT | grep 'initial AXFR' >/dev/null || {
|
||||
echo "I:failed"
|
||||
status=1
|
||||
}
|
||||
|
||||
echo "I:testing successful IXFR"
|
||||
|
||||
# We change the IP address of a.nil., and the TXT record at the apex.
|
||||
# Then we do a SOA-only update.
|
||||
|
||||
$SENDCMD <<EOF
|
||||
/SOA/
|
||||
nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
|
||||
/IXFR/
|
||||
nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
|
||||
nil. 300 SOA ns.nil. root.nil. 1 300 300 604800 300
|
||||
a.nil. 60 A 10.0.0.61
|
||||
nil. 300 TXT "initial AXFR"
|
||||
nil. 300 SOA ns.nil. root.nil. 2 300 300 604800 300
|
||||
nil. 300 TXT "successful IXFR"
|
||||
a.nil. 60 A 10.0.1.61
|
||||
nil. 300 SOA ns.nil. root.nil. 2 300 300 604800 300
|
||||
nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
|
||||
nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
|
||||
EOF
|
||||
|
||||
sleep 1
|
||||
|
||||
$RNDCCMD refresh nil
|
||||
|
||||
sleep 2
|
||||
|
||||
$DIGCMD nil. TXT | grep 'successful IXFR' >/dev/null || {
|
||||
echo "I:failed"
|
||||
status=1
|
||||
}
|
||||
|
||||
echo "I:testing AXFR fallback after IXFR failure"
|
||||
|
||||
# Provide a broken IXFR response and a working fallback AXFR response
|
||||
|
||||
$SENDCMD <<EOF
|
||||
/SOA/
|
||||
nil. 300 SOA ns.nil. root.nil. 4 300 300 604800 300
|
||||
/IXFR/
|
||||
nil. 300 SOA ns.nil. root.nil. 4 300 300 604800 300
|
||||
nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
|
||||
nil. 300 TXT "delete-nonexistent-txt-record"
|
||||
nil. 300 SOA ns.nil. root.nil. 4 300 300 604800 300
|
||||
nil. 300 TXT "this-txt-record-would-be-added"
|
||||
nil. 300 SOA ns.nil. root.nil. 4 300 300 604800 300
|
||||
/AXFR/
|
||||
nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
|
||||
nil. 300 NS ns.nil.
|
||||
nil. 300 TXT "fallback AXFR"
|
||||
nil. 300 SOA ns.nil. root.nil. 3 300 300 604800 300
|
||||
EOF
|
||||
|
||||
sleep 1
|
||||
|
||||
$RNDCCMD refresh nil
|
||||
|
||||
sleep 2
|
||||
|
||||
$DIGCMD nil. TXT | grep 'fallback AXFR' >/dev/null || {
|
||||
echo "I:failed"
|
||||
status=1
|
||||
}
|
||||
|
||||
echo "I:exit status: $status"
|
||||
exit $status
|
||||
39
bin/tests/system/send.pl
Normal file
39
bin/tests/system/send.pl
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (C) 2000, 2001 Internet Software Consortium.
|
||||
#
|
||||
# Permission to use, copy, modify, and 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 INTERNET SOFTWARE CONSORTIUM
|
||||
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
# INTERNET SOFTWARE CONSORTIUM 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.
|
||||
|
||||
# $Id: send.pl,v 1.1 2001/05/10 18:29:08 gson Exp $
|
||||
|
||||
#
|
||||
# Send a file to a given address and port using TCP. Used for
|
||||
# configuring the test server in ixfr/ans2/ans.pl.
|
||||
#
|
||||
|
||||
use IO::File;
|
||||
use IO::Socket;
|
||||
|
||||
@ARGV == 2 or die "usage: send.pl host port [file ...]\n";
|
||||
|
||||
my $host = shift @ARGV;
|
||||
my $port = shift @ARGV;
|
||||
|
||||
my $sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port,
|
||||
Proto => "tcp",) or die "$!";
|
||||
while (<>) {
|
||||
$sock->syswrite($_, length $_);
|
||||
}
|
||||
|
||||
$sock->close;
|
||||
Loading…
Reference in a new issue