From 3a8b498847dc4862ad1a60d77b24ebe6047439c3 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Wed, 12 Aug 2015 20:59:42 +0300 Subject: [PATCH] Supermaster feature test --- .../supermaster-signed/command | 237 + .../supermaster-signed/description | 1 + .../supermaster-signed/expected_result | 8 + .../supermaster-unsigned/command | 220 + .../supermaster-unsigned/description | 1 + .../supermaster-unsigned/expected_result | 3 + regression-tests.nobackend/zones/example.com | 20187 ++++++++++++++++ regression-tests.nobackend/zones/test.com | 40 + 8 files changed, 20697 insertions(+) create mode 100755 regression-tests.nobackend/supermaster-signed/command create mode 100644 regression-tests.nobackend/supermaster-signed/description create mode 100644 regression-tests.nobackend/supermaster-signed/expected_result create mode 100755 regression-tests.nobackend/supermaster-unsigned/command create mode 100644 regression-tests.nobackend/supermaster-unsigned/description create mode 100644 regression-tests.nobackend/supermaster-unsigned/expected_result create mode 100644 regression-tests.nobackend/zones/example.com create mode 100644 regression-tests.nobackend/zones/test.com diff --git a/regression-tests.nobackend/supermaster-signed/command b/regression-tests.nobackend/supermaster-signed/command new file mode 100755 index 000000000..c2270327b --- /dev/null +++ b/regression-tests.nobackend/supermaster-signed/command @@ -0,0 +1,237 @@ +#!/usr/bin/env bash +set -e +set -x + +PDNS=${PDNS:-../pdns/pdns_server} +PDNS2=${PDNS2:-../pdns/pdns_server} + +ALGORITHM=${ALGORITHM:="hmac-md5"} +KEY=${KEY:="kp4/24gyYsEzbuTVJRUMoqGFmN3LYgVDzJ/3oRSP7ys="} +if [ "$RUNWRAPPER" = "" ]; then + RUNWRAPPER="authbind" +fi +MAKE=${MAKE:-make} + +$MAKE -C ../pdns notify > /dev/null + +export ALGORITHM +export KEY + +port=$1 +[ -z "$port" ] && port=53 + +trap "kill_process 2" EXIT INT TERM + +tosql () +{ + ${MAKE} -C ../pdns zone2sql > /dev/null + ../pdns/zone2sql --transactions --$1 --named-conf=./named.conf +} + +prepare() +{ + rm -f named.conf + cat > named.conf< pdns-gsqlite3-master.conf< pdns-gsqlite3-slave.conf</dev/null) + if [ ! -z "$pids" ] + then + kill -0 $pids >/dev/null 2>&1 + if [ $? -eq 0 ] + then + set -e + return + fi + fi + let loopcount=loopcount+1 + done + echo "PowerDNS did not start" + exit +} + +kill_process () +{ + set +e + trap - EXIT INT TERM + + if [ $1 -gt 1 ] + then + echo "exitvalue$1" >> failed_tests + fi + + pids=$(cat pdns*.pid) + + if [ -n "$pids" ] + then + kill $pids + # make sure they die. + loopcount=0 + done=0 + while [ $loopcount -lt 10 ] && [ $done -eq 0 ] + do + done=1 + for pid in $pids + do + kill -0 $pid > /dev/null 2>&1 + if [ $? -eq 0 ]; + then + done=0 + fi + done + let loopcount=loopcount+1 + sleep 1 + done + + kill -9 $pids + fi + + rm pdns*.pid + exit $1 +} + +sqlite3wait() +{ + # make sure domains are transferred and created + domcount=0 + retries=15 + delay=1 + domains=2 + + while [ $retries -ge 0 ]; do + domcount=`sqlite3 slave.db "select count(*) from domains"` + # at the moment we want three domains + if [ $domcount -eq $domains ]; then + break + fi + sleep $delay + let retries=retries-1 + done + + if [ $domcount -ne $domains ]; then + echo "Supermaster provisioning failed" + exit + fi +} + +prepare +start_slave +check_process +sleep 1 +start_master +# to avoid locking issues later on +sleep 2 + +# then we check that test.com has not been transferred yet. +for domain in test.com; do + reccount=`sqlite3 slave.db "select count(*) from records join domains on records.domain_id = domains.id where domains.name='$domain'"` + if [ $reccount -ne 0 ]; then + echo "Transfer of '$domain' has unexpectedly succeeded" + fi +done + +# create supermaster +sqlite3 slave.db <&1 + +kill_process 0 diff --git a/regression-tests.nobackend/supermaster-signed/description b/regression-tests.nobackend/supermaster-signed/description new file mode 100644 index 000000000..2503e4b37 --- /dev/null +++ b/regression-tests.nobackend/supermaster-signed/description @@ -0,0 +1 @@ +Tests that supermaster backend works and assings TSIG keyname to zone on provision diff --git a/regression-tests.nobackend/supermaster-signed/expected_result b/regression-tests.nobackend/supermaster-signed/expected_result new file mode 100644 index 000000000..d0ec878db --- /dev/null +++ b/regression-tests.nobackend/supermaster-signed/expected_result @@ -0,0 +1,8 @@ +Imported TSIG key tsig.com hmac-md5 +Imported TSIG key tsig.com hmac-md5 +Set 'example.com' meta TSIG-ALLOW-AXFR = tsig.com +Set 'test.com' meta TSIG-ALLOW-AXFR = tsig.com +Set 'example.com' meta AXFR-MASTER-TSIG = tsig.com +Added to queue +Received notification response with error: Query Refused +For: 'test.com.' diff --git a/regression-tests.nobackend/supermaster-unsigned/command b/regression-tests.nobackend/supermaster-unsigned/command new file mode 100755 index 000000000..75f81841a --- /dev/null +++ b/regression-tests.nobackend/supermaster-unsigned/command @@ -0,0 +1,220 @@ +#!/usr/bin/env bash +set -e +set -x + +PDNS=${PDNS:-../pdns/pdns_server} +PDNS2=${PDNS2:-../pdns/pdns_server} +if [ "$RUNWRAPPER" = "" ]; then + RUNWRAPPER="authbind" +fi +MAKE=${MAKE:-make} + +port=$1 +[ -z "$port" ] && port=53 + +trap "kill_process 2" EXIT INT TERM + +$MAKE -C ../pdns notify > /dev/null + +tosql () +{ + ${MAKE} -C ../pdns zone2sql > /dev/null + ../pdns/zone2sql --transactions --$1 --named-conf=./named.conf +} + +prepare() +{ + rm -f named.conf + cat > named.conf< pdns-gsqlite3-master.conf< pdns-gsqlite3-slave.conf</dev/null) + if [ ! -z "$pids" ] + then + kill -0 $pids >/dev/null 2>&1 + if [ $? -eq 0 ] + then + set -e + return + fi + fi + let loopcount=loopcount+1 + done + echo "PowerDNS did not start" + exit +} + +kill_process () +{ + set +e + trap - EXIT INT TERM + + if [ $1 -gt 1 ] + then + echo "exitvalue$1" >> failed_tests + fi + + pids=$(cat pdns*.pid) + + if [ -n "$pids" ] + then + kill $pids + # make sure they die. + loopcount=0 + done=0 + while [ $loopcount -lt 10 ] && [ $done -eq 0 ] + do + done=1 + for pid in $pids + do + kill -0 $pid > /dev/null 2>&1 + if [ $? -eq 0 ]; + then + done=0 + fi + done + let loopcount=loopcount+1 + sleep 1 + done + + kill -9 $pids + fi + + rm pdns*.pid + exit $1 +} + +sqlite3wait() +{ + # make sure domains are transferred and created + domcount=0 + retries=15 + delay=1 + domains=2 + + while [ $retries -ge 0 ]; do + domcount=`sqlite3 slave.db "select count(*) from domains"` + # at the moment we want three domains + if [ $domcount -eq $domains ]; then + break + fi + sleep $delay + let retries=retries-1 + done + + if [ $domcount -ne $domains ]; then + echo "Supermaster provisioning failed" + exit + fi +} + +prepare +start_slave +check_process +sleep 1 +start_master +# to avoid locking issues later on +sleep 2 + +# then we check that test.com has not been transferred yet. +for domain in test.com; do + reccount=`sqlite3 slave.db "select count(*) from records join domains on records.domain_id = domains.id where domains.name='$domain'"` + if [ $reccount -ne 0 ]; then + echo "Transfer of '$domain' has unexpectedly succeeded" + fi +done + +# create supermaster +sqlite3 slave.db <