From: Miod Vallat Date: Wed, 2 Jul 2025 19:05:05 +0000 (+0200) Subject: Make some tests mysql-agnostic... X-Git-Tag: rec-5.4.0-alpha0~34^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe70b94dd129385a7e9947870ac10a53d4b3187e;p=thirdparty%2Fpdns.git Make some tests mysql-agnostic... ... 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 --- diff --git a/regression-tests/mysqldiff b/regression-tests/mysqldiff index 17bfdd6452..a51de96d0b 100755 --- a/regression-tests/mysqldiff +++ b/regression-tests/mysqldiff @@ -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 diff --git a/regression-tests/tests/5dyndns-restore-zone/command b/regression-tests/tests/5dyndns-restore-zone/command index 9f3949a39c..087cd6d032 100755 --- a/regression-tests/tests/5dyndns-restore-zone/command +++ b/regression-tests/tests/5dyndns-restore-zone/command @@ -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 diff --git a/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/command b/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/command index 86e86e9100..b45d5c0390 100755 --- a/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/command +++ b/regression-tests/tests/pdnsutil-increase-serial-inception-epoch/command @@ -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 diff --git a/regression-tests/tests/pdnsutil-increase-serial/command b/regression-tests/tests/pdnsutil-increase-serial/command index a8f6accaf3..7814457e33 100755 --- a/regression-tests/tests/pdnsutil-increase-serial/command +++ b/regression-tests/tests/pdnsutil-increase-serial/command @@ -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