diff --git a/build-scripts/test-recursor b/build-scripts/test-recursor index b0999567f1dc..947ede06ef7e 100755 --- a/build-scripts/test-recursor +++ b/build-scripts/test-recursor @@ -6,7 +6,7 @@ export PDNS=${PDNS:-"/usr/sbin/pdns_server"} export PDNSUTIL=${PDNSUTIL:-"/usr/bin/pdnsutil"} export SDIG=${SDIG:-"/usr/bin/sdig"} export NSEC3DIG=${NSEC3DIG:-"/usr/bin/nsec3dig"} -export NOTIFY=${NOTIFY:-"/usr/bin/notify"} +export NOTIFY=${NOTIFY:-"/usr/bin/pdns_notify"} export SAXFR=${SAXFR:-"/usr/bin/saxfr"} if [ "$0" != "./build-scripts/test-recursor" ]; then diff --git a/meson.build b/meson.build index c201c5cc0883..9afe50adb186 100644 --- a/meson.build +++ b/meson.build @@ -1093,14 +1093,23 @@ endif if get_option('unit-tests-backends') start_test_stop = files('regression-tests' / 'start-test-stop')[0] -endif -if get_option('module-geoip') != 'disabled' and get_option('unit-tests-backends') - test( - 'pdns-auth-backend-geoip', - start_test_stop, - args: ['5300', 'geoip'], - workdir: product_source_dir / 'regression-tests', - depends: [pdns_auth], - ) + test_modules = { + 'geoip': 'module-geoip', + 'lmdb': 'module-lmdb', + 'lmdb-nodnssec': 'module-lmdb', + } + + foreach module, option: test_modules + if get_option(option) != 'disabled' + test( + 'pdns-auth-backend-' + module, + start_test_stop, + args: ['5300', module], + workdir: product_source_dir / 'regression-tests', + depends: [pdns_auth, pdns_auth_util, sdig, saxfr, pdns_auth_notify, nsec3dig], + is_parallel: false, + ) + endif + endforeach endif diff --git a/regression-tests.nobackend/rectify-axfr/command b/regression-tests.nobackend/rectify-axfr/command index 5cc875fc827c..ee936fdad30e 100755 --- a/regression-tests.nobackend/rectify-axfr/command +++ b/regression-tests.nobackend/rectify-axfr/command @@ -9,8 +9,8 @@ sed '/directory/ { s@./zones@../regression-tests/zones@ }' ../regression-tests/n cat >> ./named.conf << __EOF__ zone "."{ - type primary; - file "../../regression-tests.rootzone/zones/ROOT"; + type primary; + file "../../regression-tests.rootzone/zones/ROOT"; }; __EOF__ @@ -32,8 +32,8 @@ echo ANALYZE\; | sqlite3 pdns.sqlite3 for zone in $(grep 'zone ' named.conf | cut -f2 -d\") do - $PDNSUTIL $ARGS set-nsec3 $zone "1 0 1 abcd" >&2 - $PDNSUTIL $ARGS add-zone-key $zone rsasha256 1024 zsk active >&2 + $PDNSUTIL $ARGS set-nsec3 $zone "1 0 1 abcd" >&2 + $PDNSUTIL $ARGS add-zone-key $zone rsasha256 1024 zsk active >&2 done $RUNWRAPPER $PDNS --daemon=no --local-port=$port --socket-dir=./ \ diff --git a/regression-tests/backends/lmdb-slave b/regression-tests/backends/lmdb-slave index 697ee7aa8f5f..62057691b07a 100644 --- a/regression-tests/backends/lmdb-slave +++ b/regression-tests/backends/lmdb-slave @@ -1,82 +1,82 @@ - context=${context}-presigned-lmdb - cat > pdns-lmdb2.conf << __EOF__ + context=${context}-presigned-lmdb + cat > pdns-lmdb2.conf << __EOF__ module-dir=./modules launch=lmdb lmdb-filename=./pdns2.lmdb __EOF__ - rm -f pdns2.lmdb* - zones=0 - for zone in $(grep 'zone ' named.conf | cut -f2 -d\" | grep -v '^nztest.com$' | perl -e 'print reverse ') - do - zones=$((zones+1)) - if [ "$zone" = "example.com" ]; then - $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone $zone 127.0.0.1:$port - fi - if [ "$zone" = "test.com" ]; then - $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone $zone 127.0.0.1:$port - $PDNSUTIL --config-dir=. --config-name=lmdb2 set-catalog $zone other-catalog.invalid - $PDNSUTIL --config-dir=. --config-name=lmdb2 set-options-json $zone '{"consumer":{"coo":"catalog.invalid","unique":"42"}}' - fi - if [ "$zone" = "tsig.com" ]; then - $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone $zone 127.0.0.2:$port - $PDNSUTIL --config-dir=. --config-name=lmdb2 set-catalog $zone catalog.invalid - $PDNSUTIL --config-dir=. --config-name=lmdb2 set-options-json $zone "{\"consumer\":{\"unique\":\"$($SAXFR 127.0.0.1 $port catalog.invalid | grep $zone | grep PTR | cut -d'.' -f1)\"}}" - $PDNSUTIL --config-dir=. --config-name=lmdb2 import-tsig-key test $ALGORITHM $KEY - $PDNSUTIL --config-dir=. --config-name=lmdb2 activate-tsig-key tsig.com test secondary - fi - if [ "$zone" = "stest.com" ]; then - $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone $zone 127.0.0.1:$port - $PDNSUTIL --config-dir=. --config-name=lmdb2 set-catalog $zone other-catalog.invalid - $PDNSUTIL --config-dir=. --config-name=lmdb2 set-options-json $zone "{\"consumer\":{\"coo\":\"catalog.invalid\",\"unique\":\"$($SAXFR 127.0.0.1 $port catalog.invalid | grep $zone | grep PTR | cut -d'.' -f1)\"}}" - if [[ $skipreasons != *nolua* ]]; then - $PDNSUTIL --config-dir=. --config-name=lmdb2 set-meta stest.com AXFR-SOURCE 127.0.0.2 - fi - fi - if [ "$zone" = "wtest.com" ]; then - $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone $zone 127.0.0.1:$port - $PDNSUTIL --config-dir=. --config-name=lmdb2 set-catalog $zone catalog.invalid - $PDNSUTIL --config-dir=. --config-name=lmdb2 set-options-json $zone '{"consumer":{"unique":"42"}}' - fi - if [ "$zone" = "." ]; then - $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone $zone 127.0.0.1:$port - fi - done + rm -f pdns2.lmdb* + zones=0 + for zone in $(grep 'zone ' named.conf | cut -f2 -d\" | grep -v '^nztest.com$' | perl -e 'print reverse ') + do + zones=$((zones+1)) + if [ "$zone" = "example.com" ]; then + $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone $zone 127.0.0.1:$port + fi + if [ "$zone" = "test.com" ]; then + $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone $zone 127.0.0.1:$port + $PDNSUTIL --config-dir=. --config-name=lmdb2 set-catalog $zone other-catalog.invalid + $PDNSUTIL --config-dir=. --config-name=lmdb2 set-options-json $zone '{"consumer":{"coo":"catalog.invalid","unique":"42"}}' + fi + if [ "$zone" = "tsig.com" ]; then + $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone $zone 127.0.0.2:$port + $PDNSUTIL --config-dir=. --config-name=lmdb2 set-catalog $zone catalog.invalid + $PDNSUTIL --config-dir=. --config-name=lmdb2 set-options-json $zone "{\"consumer\":{\"unique\":\"$($SAXFR 127.0.0.1 $port catalog.invalid | grep $zone | grep PTR | cut -d'.' -f1)\"}}" + $PDNSUTIL --config-dir=. --config-name=lmdb2 import-tsig-key test $ALGORITHM $KEY + $PDNSUTIL --config-dir=. --config-name=lmdb2 activate-tsig-key tsig.com test secondary + fi + if [ "$zone" = "stest.com" ]; then + $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone $zone 127.0.0.1:$port + $PDNSUTIL --config-dir=. --config-name=lmdb2 set-catalog $zone other-catalog.invalid + $PDNSUTIL --config-dir=. --config-name=lmdb2 set-options-json $zone "{\"consumer\":{\"coo\":\"catalog.invalid\",\"unique\":\"$($SAXFR 127.0.0.1 $port catalog.invalid | grep $zone | grep PTR | cut -d'.' -f1)\"}}" + if [[ $skipreasons != *nolua* ]]; then + $PDNSUTIL --config-dir=. --config-name=lmdb2 set-meta stest.com AXFR-SOURCE 127.0.0.2 + fi + fi + if [ "$zone" = "wtest.com" ]; then + $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone $zone 127.0.0.1:$port + $PDNSUTIL --config-dir=. --config-name=lmdb2 set-catalog $zone catalog.invalid + $PDNSUTIL --config-dir=. --config-name=lmdb2 set-options-json $zone '{"consumer":{"unique":"42"}}' + fi + if [ "$zone" = "." ]; then + $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone $zone 127.0.0.1:$port + fi + done - # setup catalog zone - if [ $zones -ne 1 ] # detect root tests - then - zones=$((zones+1)) - $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone catalog.invalid 127.0.0.1:$port - $PDNSUTIL --config-dir=. --config-name=lmdb2 set-kind catalog.invalid consumer + # setup catalog zone + if [ $zones -ne 1 ] # detect root tests + then + zones=$((zones+1)) + $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone catalog.invalid 127.0.0.1:$port + $PDNSUTIL --config-dir=. --config-name=lmdb2 set-kind catalog.invalid consumer - $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone remove.invalid 127.0.0.1:$port - $PDNSUTIL --config-dir=. --config-name=lmdb2 set-catalog remove.invalid catalog.invalid - fi + $PDNSUTIL --config-dir=. --config-name=lmdb2 create-secondary-zone remove.invalid 127.0.0.1:$port + $PDNSUTIL --config-dir=. --config-name=lmdb2 set-catalog remove.invalid catalog.invalid + fi - port=$((port+100)) + port=$((port+100)) - $RUNWRAPPER $PDNS2 --daemon=no --local-port=$port --config-dir=. \ - --config-name=lmdb2 --socket-dir=./ --no-shuffle \ - --secondary --xfr-cycle-interval=15 --dname-processing --api --api-key=secret & + $RUNWRAPPER $PDNS2 --daemon=no --local-port=$port --config-dir=. \ + --config-name=lmdb2 --socket-dir=./ --no-shuffle \ + --secondary --xfr-cycle-interval=15 --dname-processing --api --api-key=secret & - sleep 1 - $PDNSCONTROL --config-name=lmdb2 --socket-dir=. --no-config retrieve catalog.invalid + sleep 1 + $PDNSCONTROL --config-name=lmdb2 --socket-dir=. --no-config retrieve catalog.invalid - echo 'waiting for zones to be fetched' - loopcount=0 - while [ $loopcount -lt 30 ] - do - sleep 5 - present=$(curl -s -S -H 'X-API-Key: secret' http://127.0.0.1:8081/api/v1/servers/localhost/zones | jq -r '.[] | .serial' | grep -c -v '^0$') - if [ $zones -eq $present ] - then - break - fi - let loopcount=loopcount+1 - done - if [ $zones -ne $present ] - then - echo "AXFR FAILED" >> failed_tests - exit - fi + echo 'waiting for zones to be fetched' + loopcount=0 + while [ $loopcount -lt 30 ] + do + sleep 5 + present=$(curl -s -S -H 'X-API-Key: secret' http://127.0.0.1:8081/api/v1/servers/localhost/zones | jq -r '.[] | .serial' | grep -c -v '^0$') + if [ $zones -eq $present ] + then + break + fi + let loopcount=loopcount+1 + done + if [ $zones -ne $present ] + then + echo "AXFR FAILED" >> failed_tests + exit + fi diff --git a/regression-tests/runtests b/regression-tests/runtests index d1ced13730f8..acf50bd93d5d 100755 --- a/regression-tests/runtests +++ b/regression-tests/runtests @@ -46,8 +46,15 @@ spectest=$1 [ -z $spectest ] && spectest="" for prog in $SDIG $SAXFR $NOTIFY $NSEC3DIG; do - if `echo $prog | grep -q '\.\./pdns'`; then - ${MAKE} -C ../pdns ${prog##*../pdns/} || exit + if [ -z "$PDNS_BUILD_PATH" ]; then + if `echo $prog | grep -q '\.\./pdns'`; then + ${MAKE} -C ../pdns ${prog##*../pdns/} || exit + fi + else + if [ ! -x "$prog" ]; then + echo "Error: cannot find $prog, please build it." + exit 1 + fi fi done @@ -66,112 +73,112 @@ touch passed_tests failed_tests skipped_tests for a in $(find $testsdir -type d | grep -v ^.$ | grep -v .svn | grep -v ^confdir | LC_ALL=C sort) do - if [ ! -x $a/command ] - then - continue - fi - testname=$(basename $a) - export testname - echo "$testname: " - if [ "${PDNS_DEBUG}" = "YES" ]; then - cat $a/description - fi - - echo "$testname: " >> test-results - cat $a/description >> test-results - - SKIPIT=0 - if [ -e $a/skip ] - then - SKIPIT=1 - result=" Skipped test $a" - else - for reason in $skipreasons $context $backend - do - if [ -e $a/skip.$reason ] - then - SKIPIT=1 - result=" Skipped test $a for reason $reason" - break - fi - done - fi - - FAIL=0 - for reason in $skipreasons $context $backend - do - if [ -e $a/fail.$reason ] - then - FAIL=1 - break - fi - done - - if [ "$spectest" != "" ] && [ "$spectest" != "$testname" ] && [ "$testname" != "00dnssec-grabkeys" ] - then - SKIPIT=1 - result=" Skipped test $a because it's not the specified single test" - fi - - - if [ $SKIPIT = 1 ] - then - echo $testname >> skipped_tests - skipped=$[$skipped+1] - else - $a/command > $a/real_result - expected=$a/expected_result - - diffopts="-u" - if [ -e $a/expected_result.i ]; then - expected=$a/expected_result.i - diffopts="${diffopts} -i" - fi - - for extracontext in $extracontexts - do - [ -e "$a/expected_result.$extracontext" ] && expected=$a/expected_result.$extracontext - done - [ -n "$context" ] && [ -e "$a/expected_result.$context" ] && expected=$a/expected_result.$context - diff ${diffopts} $expected $a/real_result > $a/diff 2>&1 - if [ -s $a/diff ] - then - if [ $FAIL = 0 ] - then - result=" Failed test $a" - echo $testname >> failed_tests - failed=$[$failed+1] - if [ "$FIX_TESTS" == "YES" ] - then - mv -f $a/real_result $expected - result="$result (fixed)" - fi - else - result=" Expected failure for reason $reason, test passed $a" - echo $testname >> passed_tests - passed=$[$passed+1] - fi - else - if [ $FAIL = 0 ] - then - result=" Passed test $a" - echo $testname >> passed_tests - passed=$[$passed+1] - else - result=" Unexpected pass for reason $reason, test failed $a" - echo $testname >> failed_tests - failed=$[$failed+1] - fi - fi - fi - echo "$result" - echo - echo "$result" >> test-results - echo >> test-results + if [ ! -x $a/command ] + then + continue + fi + testname=$(basename $a) + export testname + echo "$testname: " + if [ "${PDNS_DEBUG}" = "YES" ]; then + cat $a/description + fi + + echo "$testname: " >> test-results + cat $a/description >> test-results + + SKIPIT=0 + if [ -e $a/skip ] + then + SKIPIT=1 + result=" Skipped test $a" + else + for reason in $skipreasons $context $backend + do + if [ -e $a/skip.$reason ] + then + SKIPIT=1 + result=" Skipped test $a for reason $reason" + break + fi + done + fi + + FAIL=0 + for reason in $skipreasons $context $backend + do + if [ -e $a/fail.$reason ] + then + FAIL=1 + break + fi + done + + if [ "$spectest" != "" ] && [ "$spectest" != "$testname" ] && [ "$testname" != "00dnssec-grabkeys" ] + then + SKIPIT=1 + result=" Skipped test $a because it's not the specified single test" + fi + + + if [ $SKIPIT = 1 ] + then + echo $testname >> skipped_tests + skipped=$[$skipped+1] + else + $a/command > $a/real_result + expected=$a/expected_result + + diffopts="-u" + if [ -e $a/expected_result.i ]; then + expected=$a/expected_result.i + diffopts="${diffopts} -i" + fi + + for extracontext in $extracontexts + do + [ -e "$a/expected_result.$extracontext" ] && expected=$a/expected_result.$extracontext + done + [ -n "$context" ] && [ -e "$a/expected_result.$context" ] && expected=$a/expected_result.$context + diff ${diffopts} $expected $a/real_result > $a/diff 2>&1 + if [ -s $a/diff ] + then + if [ $FAIL = 0 ] + then + result=" Failed test $a" + echo $testname >> failed_tests + failed=$[$failed+1] + if [ "$FIX_TESTS" == "YES" ] + then + mv -f $a/real_result $expected + result="$result (fixed)" + fi + else + result=" Expected failure for reason $reason, test passed $a" + echo $testname >> passed_tests + passed=$[$passed+1] + fi + else + if [ $FAIL = 0 ] + then + result=" Passed test $a" + echo $testname >> passed_tests + passed=$[$passed+1] + else + result=" Unexpected pass for reason $reason, test failed $a" + echo $testname >> failed_tests + failed=$[$failed+1] + fi + fi + fi + echo "$result" + echo + echo "$result" >> test-results + echo >> test-results done if [ $failed -gt 0 ]; then - echo -n "::error title=Regression-tests::Tests failed. " + echo -n "::error title=Regression-tests::Tests failed. " fi echo -n $passed out of $[$passed+$failed] echo -n " (" diff --git a/regression-tests/start-test-stop b/regression-tests/start-test-stop index 9c23ae869ac3..c721f36f4197 100755 --- a/regression-tests/start-test-stop +++ b/regression-tests/start-test-stop @@ -43,8 +43,6 @@ export FIX_TESTS=${FIX_TESTS:-NO} ALGORITHM=${ALGORITHM:="hmac-md5"} KEY=${KEY:="kp4/24gyYsEzbuTVJRUMoqGFmN3LYgVDzJ/3oRSP7ys="} -MAKE=${MAKE:-make} - export ALGORITHM export KEY @@ -242,8 +240,9 @@ spectest=$5 testsdir=./tests for prog in $SDIG $SAXFR $NOTIFY $NSEC3DIG; do - if `echo $prog | grep -q '\.\./pdns'`; then - ${MAKE} -C ../pdns ${prog##*../pdns/} || exit + if [ ! -x "$prog" ]; then + echo "Error: cannot find $prog, please build it." + exit 1 fi done diff --git a/tasks.py b/tasks.py index f2b00d5a0a1c..8033253ff664 100644 --- a/tasks.py +++ b/tasks.py @@ -735,6 +735,7 @@ def ci_auth_run_unit_tests(c, meson=False): if meson: suite_timeout_sec = 120 logfile = 'meson-logs/testlog.txt' + c.run(f'touch {repo_home}/regression-tests/tests/verify-dnssec-zone/allow-missing {repo_home}/regression-tests.nobackend/rectify-axfr/allow-missing') # FIXME: can this go? res = c.run(f'. {repo_home}/.venv/bin/activate && meson test --verbose -t {suite_timeout_sec}', warn=True) else: logfile = 'pdns/test-suite.log'