diffto="step.$3"
[ -z "$3" ] && diffto="start"
-if [ "${context: -9}" = "-nodnssec" ]
+if type gsort >/dev/null 2>/dev/null
then
+ SORT=gsort
+else
+ SORT=sort
+fi
+
+case $backend in
+gmysql)
+ if [ "${context: -9}" = "-nodnssec" ]
+ then
mysql --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" \
"$GMYSQLDB" \
-e "SELECT r.name, r.type, r.prio, r.content, r.ttl FROM domains d JOIN records r ON d.id=r.domain_id WHERE d.name='test.dyndns' AND(r.type != 'SOA' OR r.type IS NULL) ORDER BY r.name, r.type, r.content, r.ttl, r.prio" > ${testsdir}/${testname}/$step
-else
+ else
mysql --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" \
"$GMYSQLDB" \
-e "SELECT r.name, r.type, r.prio, r.content, r.ttl, CONCAT('''', CONCAT(r.ordername, '''')), r.auth FROM domains d JOIN records r ON d.id=r.domain_id WHERE d.name='test.dyndns' AND(r.type != 'SOA' OR r.type IS NULL) ORDER BY r.name, r.type, r.content, r.ttl, r.prio" > ${testsdir}/${testname}/$step
-fi
-
-if type gsort >/dev/null 2>/dev/null
-then
- SORT=gsort
-else
- SORT=sort
-fi
+ fi
+ ;;
+*)
+ # Not as selective as the queries above, not as precise with DNSSEC details,
+ # but hopefully good enough for the sake of most tests.
+ # Maybe we should add a pdnsutil backend-cmd to retrieve these results in
+ # same format as the mysql query...
+ $PDNSUTIL --config-dir=. --config-name=$backend \
+ list-zone test.dyndns | grep -vwF SOA | \
+ $SORT > ${testsdir}/${testname}/$step
+ ;;
+esac
if [ ! "$step" == "start" ]
then
#!/usr/bin/env bash
-[ -z "$GMYSQLDB" ] && GMYSQLDB=pdnstest
-[ -z "$GMYSQLUSER" ] && GMYSQLUSER=root
-[ -z "$GMYSQLHOST" ] && GMYSQLHOST=localhost
-[ -z "$GMYSQLPASSWD" ] && GMYSQLPASSWD=''
-
-mysql --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" \
- "$GMYSQLDB" \
- -e "UPDATE records SET content = 'ns1.test.dyndns. ahu.example.dyndns. 2012060701 28800 7200 604800 86400' WHERE name in ('test.dyndns', 'sub.test.dyndns') AND type = 'SOA'"
+for zone in test.dyndns sub.test.dyndns
+do
+ $PDNSUTIL --config-dir=. --config-name=$backend \
+ replace-rrset ${zone} @ SOA "ns1.test.dyndns ahu.example.dyndns 2012060701 28800 7200 604800 86400" \
+ > /dev/null
+done
NOW=$(date +%s)
-[ -z "$GMYSQLDB" ] && GMYSQLDB=pdnstest
-[ -z "$GMYSQLUSER" ] && GMYSQLUSER=root
-[ -z "$GMYSQLHOST" ] && GMYSQLHOST=localhost
-[ -z "$GMYSQLPASSWD" ] && GMYSQLPASSWD=''
-
# lower SOA so that the test makes sense
-mysql --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" \
- "$GMYSQLDB" \
- -e "UPDATE records SET content='ns1.test.dyndns ahu.example.dyndns 10 28800 7200 604800 86400' WHERE name='test.dyndns' AND type='SOA'"
+$PDNSUTIL --config-dir=. --config-name=$backend \
+ replace-rrset test.dyndns @ SOA "ns1.test.dyndns ahu.example.dyndns 10 28800 7200 604800 86400" \
+ > /dev/null
-$PDNSUTIL --config-dir=. --config-name=gmysql list-zone test.dyndns | grep SOA
+$PDNSUTIL --config-dir=. --config-name=$backend list-zone test.dyndns | grep SOA
-$PDNSUTIL --config-dir=. --config-name=gmysql set-meta test.dyndns SOA-EDIT INCEPTION-EPOCH
+$PDNSUTIL --config-dir=. --config-name=$backend set-meta test.dyndns SOA-EDIT INCEPTION-EPOCH
-$PDNSUTIL --config-dir=. --config-name=gmysql increase-serial test.dyndns > /dev/null
+$PDNSUTIL --config-dir=. --config-name=$backend increase-serial test.dyndns > /dev/null
-NEWSERIAL=$($PDNSUTIL --config-dir=. --config-name=gmysql list-zone test.dyndns | grep SOA | awk '{print $7}')
+NEWSERIAL=$($PDNSUTIL --config-dir=. --config-name=$backend list-zone test.dyndns | grep SOA | awk '{print $7}')
NOWPLUSTEN=$((NOW + 10))
fi
# remove meta
-$PDNSUTIL --config-dir=. --config-name=gmysql set-meta test.dyndns SOA-EDIT
+$PDNSUTIL --config-dir=. --config-name=$backend set-meta test.dyndns SOA-EDIT
# restore old SOA
-mysql --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" \
- "$GMYSQLDB" \
- -e "UPDATE records SET content='ns1.test.dyndns ahu.example.dyndns 2012060701 28800 7200 604800 86400' WHERE name='test.dyndns' AND type='SOA'"
+$PDNSUTIL --config-dir=. --config-name=$backend \
+ replace-rrset test.dyndns @ SOA "ns1.test.dyndns ahu.example.dyndns 2012060701 28800 7200 604800 86400" \
+ > /dev/null
mysqldiff
-$PDNSUTIL --config-dir=. --config-name=gmysql increase-serial test.dyndns
+$PDNSUTIL --config-dir=. --config-name=$backend increase-serial test.dyndns
mysqldiff 1 "Check that test.dyndns. still has a valid ordername"
# restore old SOA
-[ -z "$GMYSQLDB" ] && GMYSQLDB=pdnstest
-[ -z "$GMYSQLUSER" ] && GMYSQLUSER=root
-[ -z "$GMYSQLHOST" ] && GMYSQLHOST=localhost
-[ -z "$GMYSQLPASSWD" ] && GMYSQLPASSWD=''
-
-mysql --user="$GMYSQLUSER" --password="$GMYSQLPASSWD" --host="$GMYSQLHOST" \
- "$GMYSQLDB" \
- -e "UPDATE records SET content='ns1.test.dyndns ahu.example.dyndns 2012060701 28800 7200 604800 86400' WHERE name='test.dyndns' AND type='SOA'"
+$PDNSUTIL --config-dir=. --config-name=$backend \
+ replace-rrset test.dyndns @ SOA "ns1.test.dyndns ahu.example.dyndns 2012060701 28800 7200 604800 86400" \
+ > /dev/null