]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Make some tests mysql-agnostic...
authorMiod Vallat <miod.vallat@powerdns.com>
Wed, 2 Jul 2025 19:05:05 +0000 (21:05 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Fri, 11 Jul 2025 08:16:11 +0000 (10:16 +0200)
... by replacing actual SQL operations on the database with proper
pdnsutil command invocations, which can then work regardless of the
backend being used.

Signed-off-by: Miod Vallat <miod.vallat@powerdns.com>
regression-tests/mysqldiff
regression-tests/tests/5dyndns-restore-zone/command
regression-tests/tests/pdnsutil-increase-serial-inception-epoch/command
regression-tests/tests/pdnsutil-increase-serial/command

index 17bfdd64523743bc9f2c67bc4186d385bdfa117d..a51de96d0bc7b38abec5e56015f20c6a95977d9b 100755 (executable)
@@ -12,23 +12,36 @@ comment=$2
 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
index 9f3949a39c43e39c1473d3d0e213306303503ab2..087cd6d0323cc42e8f230916d94df007b2d09033 100755 (executable)
@@ -1,10 +1,8 @@
 #!/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
index 86e86e9100bec04a0054f708bc70c25ecf55e25e..b45d5c0390a831980f490cabec0547e21ca3e310 100755 (executable)
@@ -2,23 +2,18 @@
 
 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))
 
@@ -30,9 +25,9 @@ else
 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
index a8f6accaf31ae14eee84cc3f5a2e088fd418c763..7814457e33d3b5c054dfe00a25336fb2535b6dc6 100755 (executable)
@@ -2,16 +2,11 @@
 
 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