]> granicus.if.org Git - pdns/commitdiff
add a test for the overload limit in the distributor
authorbert hubert <bert.hubert@netherlabs.nl>
Fri, 12 Aug 2016 19:56:22 +0000 (21:56 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Fri, 12 Aug 2016 19:56:22 +0000 (21:56 +0200)
regression-tests.nobackend/distributor/command [new file with mode: 0755]
regression-tests.nobackend/distributor/description [new file with mode: 0644]
regression-tests.nobackend/distributor/expected_result [new file with mode: 0644]
regression-tests.nobackend/distributor/slow.pl [new file with mode: 0755]

diff --git a/regression-tests.nobackend/distributor/command b/regression-tests.nobackend/distributor/command
new file mode 100755 (executable)
index 0000000..dd59a3a
--- /dev/null
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+set -e
+
+if [ "${PDNS_DEBUG}" = "YES" ]; then
+  set -x
+fi
+
+port=5600
+
+rm -f pdns*.pid
+
+$PDNS --daemon=no --local-ipv6=::1 --local-address=127.0.0.1 \
+  --local-port=$port --socket-dir=./ --no-shuffle --launch=pipe --no-config \
+  --module-dir=../regression-tests/modules --pipe-command=$(pwd)/distributor/slow.pl \
+  --pipe-abi-version=5 \
+  --overload-queue-length=10 --log-dns-queries --loglevel=9 \
+  --pipe-timeout=1000 &
+
+sleep 2
+
+for a in {1..20} 
+       do $SDIG 127.0.0.1 $port $a.example.com A >&2 >/dev/null &
+done 
+
+sleep 1
+
+if [ $($PDNSCONTROL --config-name= --no-config --socket-dir=./ show overload-drops) -gt 0 ]
+then
+       echo had non-zero drops
+fi
+
+sleep 5
+
+$SDIG 127.0.0.1 $port example.com A
+
+kill $(cat pdns*.pid)
+rm pdns*.pid
diff --git a/regression-tests.nobackend/distributor/description b/regression-tests.nobackend/distributor/description
new file mode 100644 (file)
index 0000000..fe93fd9
--- /dev/null
@@ -0,0 +1 @@
+check if the distributor implements overload limit correctly
diff --git a/regression-tests.nobackend/distributor/expected_result b/regression-tests.nobackend/distributor/expected_result
new file mode 100644 (file)
index 0000000..0271c8c
--- /dev/null
@@ -0,0 +1,4 @@
+had non-zero drops
+Reply to question for qname='example.com.', qtype=A
+Rcode: 0 (No Error), RD: 0, QR: 1, TC: 0, AA: 1, opcode: 0
+1      example.com.    IN      SOA     3600    ahu.example.com. ns1.example.com. 2008080300 1800 3600 604800 3600
diff --git a/regression-tests.nobackend/distributor/slow.pl b/regression-tests.nobackend/distributor/slow.pl
new file mode 100755 (executable)
index 0000000..f6ba846
--- /dev/null
@@ -0,0 +1,75 @@
+#!/usr/bin/perl -w
+# sample PowerDNS Coprocess backend with edns-client-subnet support
+#
+
+use strict;
+
+
+$|=1;                                  # no buffering
+
+my $line=<>;
+chomp($line);
+
+unless($line eq "HELO\t5" ) {
+       print "FAIL\n";
+       print STDERR "Received unexpected '$line', wrong ABI version?\n";
+       <>;
+       exit;
+}
+print "OK      Sample backend firing up\n";    # print our banner
+
+while(<>)
+{
+       print STDERR "$$ Received: $_";
+        sleep(1);
+       chomp();
+       my @arr=split(/\t/);
+
+        if ($arr[0] eq "CMD") {
+          print $arr[1],"\n";
+          print "END\n";
+          next;
+        }
+
+       if(@arr < 8) {
+               print "LOG      PowerDNS sent unparseable line\n";
+               print "FAIL\n";
+               next;
+       }
+
+       my ($type,$qname,$qclass,$qtype,$id,$ip,$localip,$ednsip)=split(/\t/);
+       my $bits=21;
+       my $auth = 1;
+
+       if(($qtype eq "SOA" || $qtype eq "ANY") && $qname eq "example.com") {
+               print STDERR "$$ Sent SOA records\n";
+               print "DATA     $bits   $auth   $qname  $qclass SOA     3600    -1      ahu.example.com ns1.example.com 2008080300 1800 3600 604800 3600\n";
+       }
+       if(($qtype eq "NS" || $qtype eq "ANY") && $qname eq "example.com") {
+               print STDERR "$$ Sent NS records\n";
+               print "DATA     $bits   $auth   $qname  $qclass NS      3600    -1      ns1.example.com\n";
+               print "DATA     $bits   $auth   $qname  $qclass NS      3600    -1      ns2.example.com\n";
+       }
+       if(($qtype eq "TXT" || $qtype eq "ANY") && $qname eq "example.com") {
+               print STDERR "$$ Sent TXT records\n";
+               print "DATA     $bits   $auth   $qname  $qclass TXT     3600    -1      \"hallo allemaal!\"\n";
+       }
+       if(($qtype eq "A" || $qtype eq "ANY") && $qname eq "webserver.example.com") {
+               print STDERR "$$ Sent A records\n";
+               print "DATA     $bits   $auth   $qname  $qclass A       3600    -1      1.2.3.4\n";
+               print "DATA     $bits   $auth   $qname  $qclass A       3600    -1      1.2.3.5\n";
+               print "DATA     $bits   $auth   $qname  $qclass A       3600    -1      1.2.3.6\n";
+       }
+       if(($qtype eq "CNAME" || $qtype eq "ANY") && $qname eq "www.example.com") {
+               print STDERR "$$ Sent CNAME records\n";
+               print "DATA     $bits   $auth   $qname  $qclass CNAME   3600    -1      webserver.example.com\n";
+       }
+       if(($qtype eq "MX" || $qtype eq "ANY") && $qname eq "example.com") {
+               print STDERR "$$ Sent MX records\n";
+               print "DATA     $bits   $auth   $qname  $qclass MX      3600    -1      25      smtp.powerdns.com\n";
+       }
+
+       print STDERR "$$ End of data\n";
+       print "END\n";
+}
+