]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
add recursor test suite
authorPeter van Dijk <peter.van.dijk@netherlabs.nl>
Wed, 20 Jun 2012 15:37:39 +0000 (15:37 +0000)
committerPeter van Dijk <peter.van.dijk@netherlabs.nl>
Wed, 20 Jun 2012 15:37:39 +0000 (15:37 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2634 d19b8d6e-7fed-0310-83ef-9ca221ded41b

30 files changed:
pdns/sdig.cc
regression-tests.recursor/clean.sh [new file with mode: 0644]
regression-tests.recursor/cleandig [new file with mode: 0644]
regression-tests.recursor/cname-to-a-nxdomain/command [new file with mode: 0644]
regression-tests.recursor/cname-to-a-nxdomain/description [new file with mode: 0644]
regression-tests.recursor/cname-to-a-nxdomain/expected_result [new file with mode: 0644]
regression-tests.recursor/config.sh [new file with mode: 0644]
regression-tests.recursor/cross-zone-cname-bogus-nxdomain/command [new file with mode: 0644]
regression-tests.recursor/cross-zone-cname-bogus-nxdomain/description [new file with mode: 0644]
regression-tests.recursor/cross-zone-cname-bogus-nxdomain/expected_result [new file with mode: 0644]
regression-tests.recursor/direct-cname-to-nxdomain/command [new file with mode: 0644]
regression-tests.recursor/direct-cname-to-nxdomain/description [new file with mode: 0644]
regression-tests.recursor/direct-cname-to-nxdomain/expected_result [new file with mode: 0644]
regression-tests.recursor/direct-cname/command [new file with mode: 0644]
regression-tests.recursor/direct-cname/description [new file with mode: 0644]
regression-tests.recursor/direct-cname/expected_result [new file with mode: 0644]
regression-tests.recursor/in-zone-cname-bogus-nxdomain/command [new file with mode: 0644]
regression-tests.recursor/in-zone-cname-bogus-nxdomain/description [new file with mode: 0644]
regression-tests.recursor/in-zone-cname-bogus-nxdomain/expected_result [new file with mode: 0644]
regression-tests.recursor/runtests [new file with mode: 0644]
regression-tests.recursor/simple-a/command [new file with mode: 0644]
regression-tests.recursor/simple-a/description [new file with mode: 0644]
regression-tests.recursor/simple-a/expected_result [new file with mode: 0644]
regression-tests.recursor/simple-cname-to-a/command [new file with mode: 0644]
regression-tests.recursor/simple-cname-to-a/description [new file with mode: 0644]
regression-tests.recursor/simple-cname-to-a/expected_result [new file with mode: 0644]
regression-tests.recursor/start.sh [new file with mode: 0644]
regression-tests.recursor/stop.sh [new file with mode: 0644]
regression-tests.recursor/vars.sample [new file with mode: 0644]
regression-tests/runtests

index b2c53f462133a41da7cffe768bac2a3108e87a7f..f758656f68a2b4320fa7cdcfd3bb404ea8095050 100644 (file)
@@ -10,19 +10,26 @@ int main(int argc, char** argv)
 try
 {
   bool dnssec=false;
+  bool recurse=false;
 
   reportAllTypes();
 
   if(argc < 5) {
-    cerr<<"Syntax: sdig IP-address port question question-type [dnssec]\n";
+    cerr<<"Syntax: sdig IP-address port question question-type [dnssec|recurse]\n";
     exit(EXIT_FAILURE);
   }
 
+  // FIXME: turn recurse and dnssec into proper flags or something
   if(argc > 5 && strcmp(argv[5], "dnssec")==0)
   {
     dnssec=true;
   }
 
+  if(argc > 5 && strcmp(argv[5], "recurse")==0)
+  {
+    recurse=true;
+  }
+
   vector<uint8_t> packet;
   
   DNSPacketWriter pw(packet, argv[3], DNSRecordContent::TypeToNumber(argv[4]));
@@ -32,6 +39,11 @@ try
     pw.addOpt(2800, 0, EDNSOpts::DNSSECOK);
     pw.commit();
   }
+
+  if(recurse)
+  {
+    pw.getHeader()->rd=true;
+  }
   //  pw.setRD(true);
  
   /*
diff --git a/regression-tests.recursor/clean.sh b/regression-tests.recursor/clean.sh
new file mode 100644 (file)
index 0000000..1cf5075
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+rm -rf configs run-auth run-recursor
\ No newline at end of file
diff --git a/regression-tests.recursor/cleandig b/regression-tests.recursor/cleandig
new file mode 100644 (file)
index 0000000..c173e7b
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+../pdns/sdig $nameserver $port $1 $2 recurse | sort
diff --git a/regression-tests.recursor/cname-to-a-nxdomain/command b/regression-tests.recursor/cname-to-a-nxdomain/command
new file mode 100644 (file)
index 0000000..9c31250
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+cleandig www-a.prefect.example.net a | sed 's/\(.*\tIN\t[A-Z0-9]\+\t\)\([0-9]\+\)/\13600/'
diff --git a/regression-tests.recursor/cname-to-a-nxdomain/description b/regression-tests.recursor/cname-to-a-nxdomain/description
new file mode 100644 (file)
index 0000000..82cf65c
--- /dev/null
@@ -0,0 +1 @@
+Ask for A on a CNAME that points to an NXDOMAINed name.
diff --git a/regression-tests.recursor/cname-to-a-nxdomain/expected_result b/regression-tests.recursor/cname-to-a-nxdomain/expected_result
new file mode 100644 (file)
index 0000000..40aa6d6
--- /dev/null
@@ -0,0 +1,4 @@
+0      www-a.prefect.example.net.      IN      CNAME   3600    www-a-2.prefect.example.net.
+1      prefect.example.net.    IN      SOA     3600    ns.example.net. hostmaster.example.net. 1 3600 1800 1209600 300
+Rcode: 3, RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+Reply to question for qname='www-a.prefect.example.net.', qtype=A
diff --git a/regression-tests.recursor/config.sh b/regression-tests.recursor/config.sh
new file mode 100644 (file)
index 0000000..ae4ed1f
--- /dev/null
@@ -0,0 +1,181 @@
+#!/bin/sh
+set -e
+set -x
+
+. ./vars
+
+if [ -z "$PREFIX" ] 
+then
+    echo "config not found or PREFIX not set"
+    exit 1
+fi
+
+if [ -z "$AUTHRUN" ] 
+then
+    echo "config not found or AUTHRUN not set"
+    exit 1
+fi
+
+
+rm -rf configs/
+mkdir configs
+cd configs
+
+cat > run-auth <<EOF
+#!/bin/sh
+$AUTHRUN
+EOF
+chmod +x run-auth
+
+mkdir recursor-service
+cat > recursor-service/run <<EOF
+#!/bin/sh
+$RECRUN
+EOF
+chmod +x recursor-service/run
+
+SOA="ns.example.net. hostmaster.example.net. 1 3600 1800 1209600 300"
+
+
+### plain example.net zone
+mkdir $PREFIX.10
+cat > $PREFIX.10/example.net.zone <<EOF
+example.net.             3600 IN SOA $SOA
+example.net.             3600 IN NS  ns.example.net.
+example.net.             3600 IN NS  ns2.example.net.
+ns.example.net.          3600 IN A   $PREFIX.10
+ns2.example.net.         3600 IN A   $PREFIX.11
+www.example.net.         3600 IN A   192.0.2.1
+arthur.example.net.      3600 IN NS  ns.arthur.example.net.
+arthur.example.net.      3600 IN NS  ns2.arthur.example.net.
+ns.arthur.example.net.   3600 IN A   $PREFIX.12
+ns2.arthur.example.net.  3600 IN A   $PREFIX.13
+prefect.example.net.     3600 IN NS  ns.prefect.example.net.
+ns.prefect.example.net.  3600 IN A   $PREFIX.14
+marvin.example.net.      3600 IN NS  ns.marvin.example.net.
+ns.marvin.example.net.   3600 IN A   $PREFIX.15
+trillian.example.net.    3600 IN NS  ns.trillian.example.net.
+ns.trillian.example.net. 3600 IN A   $PREFIX.16
+EOF
+
+mkdir $PREFIX.11
+cp $PREFIX.10/example.net.zone $PREFIX.11/
+
+### plain delegated zone, no surprises
+mkdir $PREFIX.12
+cat > $PREFIX.12/arthur.example.net.zone <<EOF
+arthur.example.net.      3600 IN SOA $SOA
+arthur.example.net.      3600 IN NS  ns.arthur.example.net.
+arthur.example.net.      3600 IN NS  ns2.arthur.example.net.
+arthur.example.net.      3600 IN MX  mail.arthur.example.net.
+ns.arthur.example.net.   3600 IN A   $PREFIX.12
+ns2.arthur.example.net.  3600 IN A   $PREFIX.13
+www.arthur.example.net.  3600 IN A   192.0.2.2
+www2.arthur.example.net. 3600 IN A   192.0.2.6
+mail.arthur.example.net. 3600 IN A   192.0.2.3
+EOF
+
+mkdir $PREFIX.13
+cp $PREFIX.12/arthur.example.net.zone $PREFIX.13
+
+### zone with various CNAMEs, valid packets
+mkdir $PREFIX.14
+cat > $PREFIX.14/prefect.example.net.zone <<EOF
+prefect.example.net.           3600 IN SOA   $SOA
+prefect.example.net.           3600 IN NS    ns.prefect.example.net.
+ns.prefect.example.net.        3600 IN A     $PREFIX.14
+www-a.prefect.example.net.     3600 IN CNAME www-a-2.prefect.example.net.
+;www-a-2.prefect.example.net.  NXDOMAIN
+www-b.prefect.example.net.     3600 IN CNAME www-b-2.prefect.example.net.
+www-b-2.prefect.example.net.   3600 IN A     192.0.2.4
+www-c.prefect.example.net.     3600 IN CNAME www-b-2.prefect.example.net.
+;www-c-2.prefect.example.net.  NOERROR on A
+www-c-2.prefect.example.net.   3600 IN AAAA  2001:db8::1
+www-d.prefect.example.net.     3600 IN CNAME www.arthur.example.net.
+EOF
+
+### zone with valid in-zone CNAME, invalid NXDOMAIN in response
+mkdir $PREFIX.15
+cat > $PREFIX.15/marvin.example.net.zone <<EOF
+marvin.example.net.          3600    IN  SOA $SOA
+marvin.example.net.          3600    IN  NS  ns.marvin.example.net.
+ns.marvin.example.net.   3600 IN A   $PREFIX.15
+www.marvin.example.net.      3600    IN  CNAME   android.marvin.example.net.
+android.marvin.example.net.  3600    IN  A   192.0.2.5
+EOF
+
+cat > $PREFIX.15/prequery.lua <<EOF
+function prequery ( dnspacket )
+    qname, qtype = dnspacket:getQuestion()
+    if qtype == pdns.A and qname == "www.marvin.example.net"
+    then
+        dnspacket:setRcode(pdns.NXDOMAIN)
+        ret = {}
+        ret[1] = {qname=qname, qtype=pdns.CNAME, content="android.marvin.example.net", place=1}
+        ret[2] = {qname="marvin.example.net", qtype=pdns.SOA, content="$SOA", place=2}
+        dnspacket:addRecords(ret)
+        return true
+    end
+    return false
+end
+EOF
+
+### zone with working cross-zone CNAME, invalid NXDOMAIN in response
+mkdir $PREFIX.16
+cat > $PREFIX.16/trillian.example.net.zone <<EOF
+trillian.example.net.         3600 IN SOA $SOA
+trillian.example.net.         3600 IN NS  ns.trillian.example.net.
+ns.trillian.example.net.      3600 IN A     $PREFIX.16
+www.trillian.example.net.     3600 IN CNAME www2.arthur.example.net.
+EOF
+
+cat > $PREFIX.16/prequery.lua <<EOF
+function prequery ( dnspacket )
+    qname, qtype = dnspacket:getQuestion()
+    if qtype == pdns.A and qname == "www.trillian.example.net"
+    then
+        dnspacket:setRcode(pdns.NXDOMAIN)
+        ret = {}
+        ret[1] = {qname=qname, qtype=pdns.CNAME, content="www2.arthur.example.net", place=1}
+        ret[2] = {qname="trillian.example.net", qtype=pdns.SOA, content="$SOA", place=2}
+        dnspacket:addRecords(ret)
+        return true
+    end
+    return false
+end
+EOF
+
+
+for dir in $PREFIX.*
+do
+    cat > $dir/pdns.conf <<EOF
+launch=bind
+daemon=no
+local-address=$dir
+bind-config=named.conf
+no-shuffle
+socket-dir=.
+EOF
+
+    if [ -e $dir/prequery.lua ]
+    then
+        echo 'lua-prequery-script=prequery.lua' >> $dir/pdns.conf
+    fi
+    
+    cat > $dir/named.conf <<EOF
+options {
+    directory "./";
+};
+EOF
+    for zone in $(ls $dir | grep '\.zone$' | sed 's/\.zone$//') 
+    do
+        cat >> $dir/named.conf <<EOF
+zone "$zone"{
+    type master;
+    file "./$zone.zone";
+};
+EOF
+    done
+    ln -s ../run-auth $dir/run
+done
+
diff --git a/regression-tests.recursor/cross-zone-cname-bogus-nxdomain/command b/regression-tests.recursor/cross-zone-cname-bogus-nxdomain/command
new file mode 100644 (file)
index 0000000..b1e93dd
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+cleandig www.trillian.example.net a | sed 's/\(.*\tIN\t[A-Z0-9]\+\t\)\([0-9]\+\)/\13600/'
diff --git a/regression-tests.recursor/cross-zone-cname-bogus-nxdomain/description b/regression-tests.recursor/cross-zone-cname-bogus-nxdomain/description
new file mode 100644 (file)
index 0000000..3f9b1cc
--- /dev/null
@@ -0,0 +1,2 @@
+Query A for a valid CNAME to A in another zone, except the A query terminates
+after the CNAME and sets NXDOMAIN.
diff --git a/regression-tests.recursor/cross-zone-cname-bogus-nxdomain/expected_result b/regression-tests.recursor/cross-zone-cname-bogus-nxdomain/expected_result
new file mode 100644 (file)
index 0000000..b5f0577
--- /dev/null
@@ -0,0 +1,4 @@
+0      www2.arthur.example.net.        IN      A       3600    192.0.2.6
+0      www.trillian.example.net.       IN      CNAME   3600    www2.arthur.example.net.
+Rcode: 0, RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+Reply to question for qname='www.trillian.example.net.', qtype=A
diff --git a/regression-tests.recursor/direct-cname-to-nxdomain/command b/regression-tests.recursor/direct-cname-to-nxdomain/command
new file mode 100644 (file)
index 0000000..2fd457d
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+cleandig www-a.prefect.example.net cname | sed 's/\(.*\tIN\t[A-Z0-9]\+\t\)\([0-9]\+\)/\13600/'
diff --git a/regression-tests.recursor/direct-cname-to-nxdomain/description b/regression-tests.recursor/direct-cname-to-nxdomain/description
new file mode 100644 (file)
index 0000000..c69761c
--- /dev/null
@@ -0,0 +1 @@
+Ask for CNAME on an existing CNAME that points to an NXDOMAINed name.
diff --git a/regression-tests.recursor/direct-cname-to-nxdomain/expected_result b/regression-tests.recursor/direct-cname-to-nxdomain/expected_result
new file mode 100644 (file)
index 0000000..a287893
--- /dev/null
@@ -0,0 +1,3 @@
+0      www-a.prefect.example.net.      IN      CNAME   3600    www-a-2.prefect.example.net.
+Rcode: 0, RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+Reply to question for qname='www-a.prefect.example.net.', qtype=CNAME
diff --git a/regression-tests.recursor/direct-cname/command b/regression-tests.recursor/direct-cname/command
new file mode 100644 (file)
index 0000000..50f42e7
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+cleandig www-d.prefect.example.net cname | sed 's/\(.*\tIN\t[A-Z0-9]\+\t\)\([0-9]\+\)/\13600/'
diff --git a/regression-tests.recursor/direct-cname/description b/regression-tests.recursor/direct-cname/description
new file mode 100644 (file)
index 0000000..775ee6e
--- /dev/null
@@ -0,0 +1 @@
+Ask for CNAME on a CNAME that points to an A in another zone.
diff --git a/regression-tests.recursor/direct-cname/expected_result b/regression-tests.recursor/direct-cname/expected_result
new file mode 100644 (file)
index 0000000..3de74cb
--- /dev/null
@@ -0,0 +1,3 @@
+0      www-d.prefect.example.net.      IN      CNAME   3600    www.arthur.example.net.
+Rcode: 0, RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+Reply to question for qname='www-d.prefect.example.net.', qtype=CNAME
diff --git a/regression-tests.recursor/in-zone-cname-bogus-nxdomain/command b/regression-tests.recursor/in-zone-cname-bogus-nxdomain/command
new file mode 100644 (file)
index 0000000..cb22973
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+cleandig www.marvin.example.net a | sed 's/\(.*\tIN\t[A-Z0-9]\+\t\)\([0-9]\+\)/\13600/'
diff --git a/regression-tests.recursor/in-zone-cname-bogus-nxdomain/description b/regression-tests.recursor/in-zone-cname-bogus-nxdomain/description
new file mode 100644 (file)
index 0000000..37ecb13
--- /dev/null
@@ -0,0 +1,2 @@
+Query A for a valid CNAME to A within a zone, except the A query terminates
+after the CNAME and sets NXDOMAIN.
diff --git a/regression-tests.recursor/in-zone-cname-bogus-nxdomain/expected_result b/regression-tests.recursor/in-zone-cname-bogus-nxdomain/expected_result
new file mode 100644 (file)
index 0000000..f0190c6
--- /dev/null
@@ -0,0 +1,4 @@
+0      android.marvin.example.net.     IN      A       3600    192.0.2.5
+0      www.marvin.example.net. IN      CNAME   3600    android.marvin.example.net.
+Rcode: 0, RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+Reply to question for qname='www.marvin.example.net.', qtype=A
diff --git a/regression-tests.recursor/runtests b/regression-tests.recursor/runtests
new file mode 100644 (file)
index 0000000..06de8aa
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+set -e
+set -x
+
+. ./vars
+
+if [ -z "$PREFIX" ] 
+then
+    echo "config not found or PREFIX not set"
+    exit 1
+fi
+
+nameserver=$PREFIX.9 port=53 ../regression-tests/runtests
+context=recursor ../regression-tests/toxml
\ No newline at end of file
diff --git a/regression-tests.recursor/simple-a/command b/regression-tests.recursor/simple-a/command
new file mode 100644 (file)
index 0000000..8450c90
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+cleandig www.example.net a | sed 's/\(.*\tIN\t[A-Z0-9]\+\t\)\([0-9]\+\)/\13600/'
diff --git a/regression-tests.recursor/simple-a/description b/regression-tests.recursor/simple-a/description
new file mode 100644 (file)
index 0000000..d870262
--- /dev/null
@@ -0,0 +1 @@
+Simple resolving of an A record.
diff --git a/regression-tests.recursor/simple-a/expected_result b/regression-tests.recursor/simple-a/expected_result
new file mode 100644 (file)
index 0000000..0c78f05
--- /dev/null
@@ -0,0 +1,3 @@
+0      www.example.net.        IN      A       3600    192.0.2.1
+Rcode: 0, RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+Reply to question for qname='www.example.net.', qtype=A
diff --git a/regression-tests.recursor/simple-cname-to-a/command b/regression-tests.recursor/simple-cname-to-a/command
new file mode 100644 (file)
index 0000000..b62eeaf
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+cleandig www-d.prefect.example.net a | sed 's/\(.*\tIN\t[A-Z0-9]\+\t\)\([0-9]\+\)/\13600/'
diff --git a/regression-tests.recursor/simple-cname-to-a/description b/regression-tests.recursor/simple-cname-to-a/description
new file mode 100644 (file)
index 0000000..a8b888a
--- /dev/null
@@ -0,0 +1 @@
+Ask for A on a CNAME that points to an existing A in another domain.
diff --git a/regression-tests.recursor/simple-cname-to-a/expected_result b/regression-tests.recursor/simple-cname-to-a/expected_result
new file mode 100644 (file)
index 0000000..cfb8698
--- /dev/null
@@ -0,0 +1,4 @@
+0      www.arthur.example.net. IN      A       3600    192.0.2.2
+0      www-d.prefect.example.net.      IN      CNAME   3600    www.arthur.example.net.
+Rcode: 0, RD: 1, QR: 1, TC: 0, AA: 0, opcode: 0
+Reply to question for qname='www-d.prefect.example.net.', qtype=A
diff --git a/regression-tests.recursor/start.sh b/regression-tests.recursor/start.sh
new file mode 100644 (file)
index 0000000..0a30351
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+set -e
+set -x
+
+. ./vars
+
+if [ -z "$PREFIX" ] 
+then
+    echo "config not found or PREFIX not set"
+    exit 1
+fi
+
+cd configs
+
+for dir in $PREFIX.* recursor-service
+do
+       supervise $dir &
+done
diff --git a/regression-tests.recursor/stop.sh b/regression-tests.recursor/stop.sh
new file mode 100644 (file)
index 0000000..f5d3c79
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+set -e
+set -x
+
+. ./vars
+
+if [ -z "$PREFIX" ] 
+then
+    echo "config not found or PREFIX not set"
+    exit 1
+fi
+
+cd configs
+
+for dir in $PREFIX.* recursor-service
+do
+       svc -d $dir
+       svc -k $dir
+       svc -x $dir
+done
diff --git a/regression-tests.recursor/vars.sample b/regression-tests.recursor/vars.sample
new file mode 100644 (file)
index 0000000..c30ec9e
--- /dev/null
@@ -0,0 +1,3 @@
+PREFIX=10.0.3
+AUTHRUN="exec authbind ../../../pdns/pdns_server --config-dir=. > logfile 2>&1"
+RECRUN="exec authbind ~/pdns/pdns/pdns-recursor-3.4-pre/pdns_recursor --config-dir=. --socket-dir=. --daemon=no --trace=yes --dont-query= --local-address=$PREFIX.9 --forward-zones=example.net=$PREFIX.10 > logfile 2>&1"
index 3437c6b84a98b0f7ec3b6e32688e33703dd0e9af..73e127089c7fe9328033e932294dde055f6197ae 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash
 PATH=.:$PATH
 
-make -C ../pdns sdig || false
+make -C ../pdns sdig || exit 1
 
 rm -f test-results failed_tests passed_tests skipped_tests */real_result */diff */*.out