From b86a41780a32ebc93cb6c8304431d611938e889e Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Thu, 31 Aug 2023 13:15:24 +0200 Subject: [PATCH 01/20] Use pytest runner for make check Make python & pytest required dependencies to run system tests and invoke the pytest runner from the makefile. (cherry picked from commit 56c108730405a42464f3c17b22ccb7b816ec8be0) --- bin/tests/system/Makefile.am | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/bin/tests/system/Makefile.am b/bin/tests/system/Makefile.am index 04c24924c7..44c186937c 100644 --- a/bin/tests/system/Makefile.am +++ b/bin/tests/system/Makefile.am @@ -18,6 +18,8 @@ LDADD += \ $(LIBISC_LIBS) if HAVE_PERL +if HAVE_PYTHON +if HAVE_PYTEST noinst_PROGRAMS = \ feature-test \ @@ -110,10 +112,12 @@ TESTS += \ catz \ cds \ checkconf \ + checkds \ checknames \ checkzone \ database \ dialup \ + dispatch \ dlzexternal \ dns64 \ dsdigest \ @@ -135,8 +139,10 @@ TESTS += \ hooks \ host \ journal \ + kasp \ keepalive \ keyfromlabel \ + keymgr2kasp \ legacy \ limits \ logfileconfig \ @@ -151,22 +157,27 @@ TESTS += \ nslookup \ padding \ pending \ + pipelined \ redirect \ rndc \ rootkeysentinel \ rpz \ + rpzextra \ rrchecker \ rrl \ rrsetorder \ rsabigexponent \ runtime \ sfcache \ + shutdown \ smartsign \ sortlist \ spf \ staticstub \ stub \ synthfromdnssec \ + tcp \ + timeouts \ tkey \ tools \ transport-acl \ @@ -214,13 +225,6 @@ endif HAVE_PERLMOD_NET_DNS_NAMESERVER endif HAVE_PERLMOD_NET_DNS -if HAVE_PYTHON -TESTS += kasp keymgr2kasp tcp pipelined - -if HAVE_PYTEST -TESTS += checkds dispatch rpzextra shutdown timeouts -endif - if HAVE_PYMOD_DNS TESTS += qmin cookie if HAVE_PERLMOD_NET_DNS @@ -231,8 +235,16 @@ endif HAVE_PERLMOD_NET_DNS_NAMESERVER endif HAVE_PERLMOD_NET_DNS endif HAVE_PYMOD_DNS -endif HAVE_PYTHON - +else !HAVE_PYTEST +check: + echo pytest is not available, no tests were ran + exit 1 +endif !HAVE_PYTEST +else !HAVE_PYTHON +check: + echo Python is not available, no tests were ran + exit 1 +endif !HAVE_PYTHON else !HAVE_PERL check: echo Perl is not available, no tests were ran @@ -247,10 +259,7 @@ LOG_DRIVER_V_1 = --verbose yes LOG_DRIVER = $(srcdir)/custom-test-driver AM_LOG_DRIVER_FLAGS = $(LOG_DRIVER_V) -LOG_COMPILER = $(builddir)/legacy.run.sh -AM_LOG_FLAGS = -r - -$(TESTS): legacy.run.sh +LOG_COMPILER = $(srcdir)/run.sh test-local: check From 9d9f2dcda5433ffd6f721aaef546ca0170d456de Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Thu, 31 Aug 2023 13:18:17 +0200 Subject: [PATCH 02/20] Fix pytest module detection for run.sh To allow concurrent invocations of pytest, it is necessary to assign ports properly to avoid conflicts. In order to do that, pytest needs to know a complete list of all test modules. When pytest is invoked from run.sh, the current working directory is the system test directory. To properly detect other tests, the conftest.py has to look in the bin/tests/system directory, rather than the current working directory. (cherry picked from commit d4502206a146b00ce1f8c1fad50a024d654b25f5) --- bin/tests/system/conftest.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/bin/tests/system/conftest.py b/bin/tests/system/conftest.py index 50510a000c..8f40ff0657 100644 --- a/bin/tests/system/conftest.py +++ b/bin/tests/system/conftest.py @@ -268,13 +268,21 @@ else: @pytest.fixture(scope="session") def modules(): - """Sorted list of all modules. Used to determine port distribution.""" + """ + Sorted list of ALL modules. + + The list includes even test modules that are not tested in the current + session. It is used to determine port distribution. Using a complete + list of all possible test modules allows independent concurrent pytest + invocations. + """ mods = [] - for dirpath, _dirs, files in os.walk(os.getcwd()): + for dirpath, _dirs, files in os.walk(FILE_DIR): for file in files: if file.startswith("tests_") and file.endswith(".py"): mod = f"{dirpath}/{file}" - mods.append(mod) + if not pytest_ignore_collect(mod): + mods.append(mod) return sorted(mods) @pytest.fixture(scope="session") @@ -282,11 +290,11 @@ else: """ Dictionary containing assigned base port for every module. - Note that this is a session-wide fixture. The port numbers are - deterministically assigned before any testing starts. This fixture MUST - return the same value when called again during the same test session. - When running tests in parallel, this is exactly what happens - every - worker thread will call this fixture to determine test ports. + The port numbers are deterministically assigned before any testing + starts. This fixture MUST return the same value when called again + during the same test session. When running tests in parallel, this is + exactly what happens - every worker thread will call this fixture to + determine test ports. """ port_min = PORT_MIN port_max = PORT_MAX - len(modules) * PORTS_PER_TEST From 76b5c07b8df08c6daacf90b0071dd00211becf11 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 4 Sep 2023 13:41:09 +0200 Subject: [PATCH 03/20] Remove redundant dependency checks for system tests Dependencies for these tests are already checked in prereq.sh - if the dependencies are missing, these tests will be skipped. The extra dependency check in Makefile.am is extraneous and only applied for the legacy test runner. (cherry picked from commit 807f67b1cd938c3877759c3998cebf21aaddf062) --- bin/tests/system/Makefile.am | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/bin/tests/system/Makefile.am b/bin/tests/system/Makefile.am index 44c186937c..8f185728c3 100644 --- a/bin/tests/system/Makefile.am +++ b/bin/tests/system/Makefile.am @@ -94,11 +94,6 @@ TESTS += \ rpzrecurse endif HAVE_PERLMOD_NET_DNS -if HAVE_LIBNGHTTP2 -TESTS += \ - doth -endif - TESTS += \ acl \ additional \ @@ -120,6 +115,8 @@ TESTS += \ dispatch \ dlzexternal \ dns64 \ + dnstap \ + doth \ dsdigest \ dupsigs \ dyndb \ @@ -155,6 +152,7 @@ TESTS += \ notify \ nsec3 \ nslookup \ + nzd2nzf \ padding \ pending \ pipelined \ @@ -191,10 +189,6 @@ TESTS += \ xferquota \ zonechecks -if HAVE_LMDB -TESTS += nzd2nzf -endif # HAVE_LMDB - if HAVE_PERLMOD_NET_DNS TESTS += \ @@ -207,10 +201,6 @@ TESTS += \ upforwd \ zero -if HAVE_DNSTAP -TESTS += dnstap -endif - if HAVE_PERLMOD_FILE_FETCH TESTS += statschannel endif HAVE_PERLMOD_FILE_FETCH From ee849d2a0c81795e68ac772879bc58b6f74d60cf Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 4 Sep 2023 13:49:18 +0200 Subject: [PATCH 04/20] Use proper perl interpreter in xfer system test (cherry picked from commit f0493890cc0fc18b807ec87eec06a298cafdbe06) --- bin/tests/system/xfer/prereq.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/tests/system/xfer/prereq.sh b/bin/tests/system/xfer/prereq.sh index c7b78281e2..16d04a26bd 100644 --- a/bin/tests/system/xfer/prereq.sh +++ b/bin/tests/system/xfer/prereq.sh @@ -16,9 +16,9 @@ # macOS ships with Net::DNS 0.74 which does not work with # HMAC-SHA256, despite the workarounds in ans.pl -if perl -MNet::DNS -e 'exit $Net::DNS::VERSION >= 1.0' +if ${PERL} -MNet::DNS -e 'exit ($Net::DNS::VERSION >= 1.0)' then - version=$(perl -MNet::DNS -e 'print $Net::DNS::VERSION') + version=$(${PERL} -MNet::DNS -e 'print $Net::DNS::VERSION') echo_i "perl Net::DNS $version is too old - skipping xfer test" exit 1 fi From c0e44119619057123690413fd31cdc156a5392a3 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 4 Sep 2023 13:56:28 +0200 Subject: [PATCH 05/20] Add prereq.sh scripts for system tests requiring perl mod DNS prereq.sh mechanism for dependency detection is preferred since it works for both legacy and pytest runner. (cherry picked from commit 9cc821d42f7dc1faf0f9777eaf1aee1cd9e9878b) --- bin/tests/system/Makefile.am | 18 ++++++++---------- bin/tests/system/fetchlimit/prereq.sh | 22 ++++++++++++++++++++++ bin/tests/system/ixfr/prereq.sh | 22 ++++++++++++++++++++++ bin/tests/system/nsupdate/prereq.sh | 22 ++++++++++++++++++++++ bin/tests/system/resolver/prereq.sh | 22 ++++++++++++++++++++++ bin/tests/system/statistics/prereq.sh | 22 ++++++++++++++++++++++ bin/tests/system/stress/prereq.sh | 22 ++++++++++++++++++++++ bin/tests/system/upforwd/prereq.sh | 22 ++++++++++++++++++++++ bin/tests/system/zero/prereq.sh | 22 ++++++++++++++++++++++ 9 files changed, 184 insertions(+), 10 deletions(-) create mode 100644 bin/tests/system/fetchlimit/prereq.sh create mode 100644 bin/tests/system/ixfr/prereq.sh create mode 100644 bin/tests/system/nsupdate/prereq.sh create mode 100644 bin/tests/system/resolver/prereq.sh create mode 100644 bin/tests/system/statistics/prereq.sh create mode 100644 bin/tests/system/stress/prereq.sh create mode 100644 bin/tests/system/upforwd/prereq.sh create mode 100644 bin/tests/system/zero/prereq.sh diff --git a/bin/tests/system/Makefile.am b/bin/tests/system/Makefile.am index 8f185728c3..af5795f5fc 100644 --- a/bin/tests/system/Makefile.am +++ b/bin/tests/system/Makefile.am @@ -126,6 +126,7 @@ TESTS += \ emptyzones \ enginepkcs11 \ filter-aaaa \ + fetchlimit \ formerr \ geoip2 \ glue \ @@ -133,6 +134,7 @@ TESTS += \ include-multiplecfg \ inline \ integrity \ + ixfr \ hooks \ host \ journal \ @@ -152,11 +154,13 @@ TESTS += \ notify \ nsec3 \ nslookup \ + nsupdate \ nzd2nzf \ padding \ pending \ pipelined \ redirect \ + resolver \ rndc \ rootkeysentinel \ rpz \ @@ -172,6 +176,8 @@ TESTS += \ sortlist \ spf \ staticstub \ + statistics \ + stress \ stub \ synthfromdnssec \ tcp \ @@ -183,24 +189,16 @@ TESTS += \ tsiggss \ ttl \ unknown \ + upforwd \ verify \ views \ wildcard \ xferquota \ + zero \ zonechecks if HAVE_PERLMOD_NET_DNS -TESTS += \ - fetchlimit \ - ixfr \ - nsupdate \ - resolver \ - statistics \ - stress \ - upforwd \ - zero - if HAVE_PERLMOD_FILE_FETCH TESTS += statschannel endif HAVE_PERLMOD_FILE_FETCH diff --git a/bin/tests/system/fetchlimit/prereq.sh b/bin/tests/system/fetchlimit/prereq.sh new file mode 100644 index 0000000000..0c29427e97 --- /dev/null +++ b/bin/tests/system/fetchlimit/prereq.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +exit 0 diff --git a/bin/tests/system/ixfr/prereq.sh b/bin/tests/system/ixfr/prereq.sh new file mode 100644 index 0000000000..0c29427e97 --- /dev/null +++ b/bin/tests/system/ixfr/prereq.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +exit 0 diff --git a/bin/tests/system/nsupdate/prereq.sh b/bin/tests/system/nsupdate/prereq.sh new file mode 100644 index 0000000000..0c29427e97 --- /dev/null +++ b/bin/tests/system/nsupdate/prereq.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +exit 0 diff --git a/bin/tests/system/resolver/prereq.sh b/bin/tests/system/resolver/prereq.sh new file mode 100644 index 0000000000..0c29427e97 --- /dev/null +++ b/bin/tests/system/resolver/prereq.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +exit 0 diff --git a/bin/tests/system/statistics/prereq.sh b/bin/tests/system/statistics/prereq.sh new file mode 100644 index 0000000000..0c29427e97 --- /dev/null +++ b/bin/tests/system/statistics/prereq.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +exit 0 diff --git a/bin/tests/system/stress/prereq.sh b/bin/tests/system/stress/prereq.sh new file mode 100644 index 0000000000..0c29427e97 --- /dev/null +++ b/bin/tests/system/stress/prereq.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +exit 0 diff --git a/bin/tests/system/upforwd/prereq.sh b/bin/tests/system/upforwd/prereq.sh new file mode 100644 index 0000000000..0c29427e97 --- /dev/null +++ b/bin/tests/system/upforwd/prereq.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +exit 0 diff --git a/bin/tests/system/zero/prereq.sh b/bin/tests/system/zero/prereq.sh new file mode 100644 index 0000000000..0c29427e97 --- /dev/null +++ b/bin/tests/system/zero/prereq.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +exit 0 From cefa09ada55ada45d05d6c9da52153b117500b30 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 4 Sep 2023 14:32:06 +0200 Subject: [PATCH 06/20] Use prereq.sh for statschannel system test (cherry picked from commit 27281955afe901d2705829edc8c327043cd689fd) --- bin/tests/system/Makefile.am | 5 +---- bin/tests/system/statschannel/prereq.sh | 28 +++++++++++++++++++++++++ configure.ac | 4 ---- 3 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 bin/tests/system/statschannel/prereq.sh diff --git a/bin/tests/system/Makefile.am b/bin/tests/system/Makefile.am index af5795f5fc..4907c1e37d 100644 --- a/bin/tests/system/Makefile.am +++ b/bin/tests/system/Makefile.am @@ -177,6 +177,7 @@ TESTS += \ spf \ staticstub \ statistics \ + statschannel \ stress \ stub \ synthfromdnssec \ @@ -199,10 +200,6 @@ TESTS += \ if HAVE_PERLMOD_NET_DNS -if HAVE_PERLMOD_FILE_FETCH -TESTS += statschannel -endif HAVE_PERLMOD_FILE_FETCH - if HAVE_PERLMOD_DIGEST_HMAC TESTS += xfer endif HAVE_PERLMOD_DIGEST_HMAC diff --git a/bin/tests/system/statschannel/prereq.sh b/bin/tests/system/statschannel/prereq.sh new file mode 100644 index 0000000000..77d0c38334 --- /dev/null +++ b/bin/tests/system/statschannel/prereq.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +if ! ${PERL} -MFile::Fetch -e '' +then + echo_i "perl File::Fetch module is required" + exit 1 +fi + +exit 0 diff --git a/configure.ac b/configure.ac index 263014e51b..c26265a7df 100644 --- a/configure.ac +++ b/configure.ac @@ -241,10 +241,6 @@ AX_PERL_MODULE([Digest::HMAC]) AM_CONDITIONAL([HAVE_PERLMOD_DIGEST_HMAC], [test "$HAVE_PERLMOD_DIGEST__HMAC" = "yes"]) -AX_PERL_MODULE([File::Fetch]) -AM_CONDITIONAL([HAVE_PERLMOD_FILE_FETCH], - [test "$HAVE_PERLMOD_FILE__FETCH" = "yes"]) - AX_PERL_MODULE([Net::DNS]) AM_CONDITIONAL([HAVE_PERLMOD_NET_DNS], [test "$HAVE_PERLMOD_NET__DNS" = "yes"]) From 697041ae934d009c9a8da7a040b0bbc534973f70 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 4 Sep 2023 15:00:12 +0200 Subject: [PATCH 07/20] Use prereq.sh for xfer system test (cherry picked from commit 587129b4c0537ea9159bad5b887b945d9811006c) --- bin/tests/system/Makefile.am | 5 +---- bin/tests/system/xfer/prereq.sh | 6 ++++++ configure.ac | 4 ---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/bin/tests/system/Makefile.am b/bin/tests/system/Makefile.am index 4907c1e37d..0574f69f45 100644 --- a/bin/tests/system/Makefile.am +++ b/bin/tests/system/Makefile.am @@ -194,16 +194,13 @@ TESTS += \ verify \ views \ wildcard \ + xfer \ xferquota \ zero \ zonechecks if HAVE_PERLMOD_NET_DNS -if HAVE_PERLMOD_DIGEST_HMAC -TESTS += xfer -endif HAVE_PERLMOD_DIGEST_HMAC - if HAVE_PERLMOD_NET_DNS_NAMESERVER TESTS += reclimit endif HAVE_PERLMOD_NET_DNS_NAMESERVER diff --git a/bin/tests/system/xfer/prereq.sh b/bin/tests/system/xfer/prereq.sh index 16d04a26bd..76252a3cd8 100644 --- a/bin/tests/system/xfer/prereq.sh +++ b/bin/tests/system/xfer/prereq.sh @@ -23,4 +23,10 @@ then exit 1 fi +if ! ${PERL} -MDigest::HMAC -e '' +then + echo_i "perl Digest::HMAC module is required" + exit 1 +fi + exit 0 diff --git a/configure.ac b/configure.ac index c26265a7df..9be625d50c 100644 --- a/configure.ac +++ b/configure.ac @@ -237,10 +237,6 @@ AC_PATH_PROGS([PERL], [perl5 perl]) AC_SUBST([PERL]) AM_CONDITIONAL([HAVE_PERL], [test -n "$PERL"]) -AX_PERL_MODULE([Digest::HMAC]) -AM_CONDITIONAL([HAVE_PERLMOD_DIGEST_HMAC], - [test "$HAVE_PERLMOD_DIGEST__HMAC" = "yes"]) - AX_PERL_MODULE([Net::DNS]) AM_CONDITIONAL([HAVE_PERLMOD_NET_DNS], [test "$HAVE_PERLMOD_NET__DNS" = "yes"]) From 39770409a9ab0aa40051ba3e3c4187af39396fff Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 4 Sep 2023 15:15:34 +0200 Subject: [PATCH 08/20] Use prereq.sh for reclimit system test (cherry picked from commit 2f962f7041066c05d8de1991295bc574fa147913) --- bin/tests/system/Makefile.am | 9 +-------- bin/tests/system/reclimit/prereq.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 bin/tests/system/reclimit/prereq.sh diff --git a/bin/tests/system/Makefile.am b/bin/tests/system/Makefile.am index 0574f69f45..64f3851499 100644 --- a/bin/tests/system/Makefile.am +++ b/bin/tests/system/Makefile.am @@ -159,6 +159,7 @@ TESTS += \ padding \ pending \ pipelined \ + reclimit \ redirect \ resolver \ rndc \ @@ -199,14 +200,6 @@ TESTS += \ zero \ zonechecks -if HAVE_PERLMOD_NET_DNS - -if HAVE_PERLMOD_NET_DNS_NAMESERVER -TESTS += reclimit -endif HAVE_PERLMOD_NET_DNS_NAMESERVER - -endif HAVE_PERLMOD_NET_DNS - if HAVE_PYMOD_DNS TESTS += qmin cookie if HAVE_PERLMOD_NET_DNS diff --git a/bin/tests/system/reclimit/prereq.sh b/bin/tests/system/reclimit/prereq.sh new file mode 100644 index 0000000000..ab548bc4f1 --- /dev/null +++ b/bin/tests/system/reclimit/prereq.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +if ! ${PERL} -MNet::DNS::Nameserver -e '' +then + echo_i "perl Net::DNS::Nameserver module is required" + exit 1 +fi + +exit 0 From 53a09edc4fa885c335c835cc4b7bf5e0d8cd1fce Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 4 Sep 2023 15:34:05 +0200 Subject: [PATCH 09/20] Use prereq.sh for qmin, cookie system tests (cherry picked from commit 78981cee775f38c23cef7ce49ba680e09527ecee) --- bin/tests/system/Makefile.am | 3 ++- bin/tests/system/cookie/.gitignore | 1 - bin/tests/system/cookie/prereq.sh | 22 ++++++++++++++++++++++ bin/tests/system/qmin/prereq.sh | 22 ++++++++++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) delete mode 100644 bin/tests/system/cookie/.gitignore create mode 100644 bin/tests/system/cookie/prereq.sh create mode 100644 bin/tests/system/qmin/prereq.sh diff --git a/bin/tests/system/Makefile.am b/bin/tests/system/Makefile.am index 64f3851499..dca4dd205a 100644 --- a/bin/tests/system/Makefile.am +++ b/bin/tests/system/Makefile.am @@ -110,6 +110,7 @@ TESTS += \ checkds \ checknames \ checkzone \ + cookie \ database \ dialup \ dispatch \ @@ -159,6 +160,7 @@ TESTS += \ padding \ pending \ pipelined \ + qmin \ reclimit \ redirect \ resolver \ @@ -201,7 +203,6 @@ TESTS += \ zonechecks if HAVE_PYMOD_DNS -TESTS += qmin cookie if HAVE_PERLMOD_NET_DNS TESTS += digdelv dnssec forward if HAVE_PERLMOD_NET_DNS_NAMESERVER diff --git a/bin/tests/system/cookie/.gitignore b/bin/tests/system/cookie/.gitignore deleted file mode 100644 index eee491d3c6..0000000000 --- a/bin/tests/system/cookie/.gitignore +++ /dev/null @@ -1 +0,0 @@ -prereq.sh diff --git a/bin/tests/system/cookie/prereq.sh b/bin/tests/system/cookie/prereq.sh new file mode 100644 index 0000000000..a48d383456 --- /dev/null +++ b/bin/tests/system/cookie/prereq.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PYTHON} -c 'import dns' +then + echo_i "python dns module is required" + exit 1 +fi + +exit 0 diff --git a/bin/tests/system/qmin/prereq.sh b/bin/tests/system/qmin/prereq.sh new file mode 100644 index 0000000000..a48d383456 --- /dev/null +++ b/bin/tests/system/qmin/prereq.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PYTHON} -c 'import dns' +then + echo_i "python dns module is required" + exit 1 +fi + +exit 0 From 74def754f9d507ca45f86b673fe347642a4a79ec Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 4 Sep 2023 15:38:25 +0200 Subject: [PATCH 10/20] Use prereq.sh for digdelv, dnssec, forward system tests (cherry picked from commit 00b92bd06465134b8108c2c947cc8226f5a15205) --- bin/tests/system/Makefile.am | 4 +++- bin/tests/system/digdelv/prereq.sh | 28 ++++++++++++++++++++++++++++ bin/tests/system/dnssec/prereq.sh | 28 ++++++++++++++++++++++++++++ bin/tests/system/forward/prereq.sh | 28 ++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 bin/tests/system/digdelv/prereq.sh create mode 100644 bin/tests/system/dnssec/prereq.sh create mode 100644 bin/tests/system/forward/prereq.sh diff --git a/bin/tests/system/Makefile.am b/bin/tests/system/Makefile.am index dca4dd205a..03dc17b32e 100644 --- a/bin/tests/system/Makefile.am +++ b/bin/tests/system/Makefile.am @@ -113,9 +113,11 @@ TESTS += \ cookie \ database \ dialup \ + digdelv \ dispatch \ dlzexternal \ dns64 \ + dnssec \ dnstap \ doth \ dsdigest \ @@ -129,6 +131,7 @@ TESTS += \ filter-aaaa \ fetchlimit \ formerr \ + forward \ geoip2 \ glue \ idna \ @@ -204,7 +207,6 @@ TESTS += \ if HAVE_PYMOD_DNS if HAVE_PERLMOD_NET_DNS -TESTS += digdelv dnssec forward if HAVE_PERLMOD_NET_DNS_NAMESERVER TESTS += chain endif HAVE_PERLMOD_NET_DNS_NAMESERVER diff --git a/bin/tests/system/digdelv/prereq.sh b/bin/tests/system/digdelv/prereq.sh new file mode 100644 index 0000000000..213178ada2 --- /dev/null +++ b/bin/tests/system/digdelv/prereq.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PYTHON} -c 'import dns' +then + echo_i "python dns module is required" + exit 1 +fi + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +exit 0 diff --git a/bin/tests/system/dnssec/prereq.sh b/bin/tests/system/dnssec/prereq.sh new file mode 100644 index 0000000000..213178ada2 --- /dev/null +++ b/bin/tests/system/dnssec/prereq.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PYTHON} -c 'import dns' +then + echo_i "python dns module is required" + exit 1 +fi + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +exit 0 diff --git a/bin/tests/system/forward/prereq.sh b/bin/tests/system/forward/prereq.sh new file mode 100644 index 0000000000..213178ada2 --- /dev/null +++ b/bin/tests/system/forward/prereq.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PYTHON} -c 'import dns' +then + echo_i "python dns module is required" + exit 1 +fi + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +exit 0 From 27c3e576fdcfae311bbfe1062c5c7a881f1643a0 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 4 Sep 2023 16:05:10 +0200 Subject: [PATCH 11/20] Use prereq.sh for chain system test (cherry picked from commit 5d9a09c08698fe450fa521ce78c40f298beb2e9a) --- bin/tests/system/Makefile.am | 9 +-------- bin/tests/system/chain/prereq.sh | 34 ++++++++++++++++++++++++++++++++ configure.ac | 7 ------- 3 files changed, 35 insertions(+), 15 deletions(-) create mode 100644 bin/tests/system/chain/prereq.sh diff --git a/bin/tests/system/Makefile.am b/bin/tests/system/Makefile.am index 03dc17b32e..f550411215 100644 --- a/bin/tests/system/Makefile.am +++ b/bin/tests/system/Makefile.am @@ -106,6 +106,7 @@ TESTS += \ case \ catz \ cds \ + chain \ checkconf \ checkds \ checknames \ @@ -205,14 +206,6 @@ TESTS += \ zero \ zonechecks -if HAVE_PYMOD_DNS -if HAVE_PERLMOD_NET_DNS -if HAVE_PERLMOD_NET_DNS_NAMESERVER -TESTS += chain -endif HAVE_PERLMOD_NET_DNS_NAMESERVER -endif HAVE_PERLMOD_NET_DNS -endif HAVE_PYMOD_DNS - else !HAVE_PYTEST check: echo pytest is not available, no tests were ran diff --git a/bin/tests/system/chain/prereq.sh b/bin/tests/system/chain/prereq.sh new file mode 100644 index 0000000000..ae09abfe3f --- /dev/null +++ b/bin/tests/system/chain/prereq.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PYTHON} -c 'import dns' +then + echo_i "python dns module is required" + exit 1 +fi + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +if ! ${PERL} -MNet::DNS::Nameserver -e '' +then + echo_i "perl Net::DNS::Nameserver module is required" + exit 1 +fi + +exit 0 diff --git a/configure.ac b/configure.ac index 9be625d50c..9c6186417d 100644 --- a/configure.ac +++ b/configure.ac @@ -241,10 +241,6 @@ AX_PERL_MODULE([Net::DNS]) AM_CONDITIONAL([HAVE_PERLMOD_NET_DNS], [test "$HAVE_PERLMOD_NET__DNS" = "yes"]) -AX_PERL_MODULE([Net::DNS::Nameserver]) -AM_CONDITIONAL([HAVE_PERLMOD_NET_DNS_NAMESERVER], - [test "$HAVE_PERLMOD_NET__DNS__NAMESERVER" = "yes"]) - AX_PERL_MODULE([Time::HiRes]) AM_CONDITIONAL([HAVE_PERLMOD_TIME_HIRES], [test "$HAVE_PERLMOD_TIME__HIRES" = "yes"]) @@ -261,9 +257,6 @@ AS_IF([test -z "$PYTEST"], AC_SUBST([PYTEST]) AM_CONDITIONAL([HAVE_PYTEST], [test -n "$PYTEST"]) -AX_PYTHON_MODULE([dns]) -AM_CONDITIONAL([HAVE_PYMOD_DNS], [test "$HAVE_PYMOD_DNS" = "yes"]) - # # xsltproc is optional, it is used only by system test scripts. # From 3fb1f2e8517e98bc5e4b819cd48ab07115a07931 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 4 Sep 2023 15:56:14 +0200 Subject: [PATCH 12/20] Use prereq.sh for serve-stale system test (cherry picked from commit c3abedc0a2819c5be733df32981cfd2c6ae898a0) --- bin/tests/system/Makefile.am | 5 +---- bin/tests/system/serve-stale/prereq.sh | 22 ++++++++++++++++++++++ configure.ac | 4 ---- 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 bin/tests/system/serve-stale/prereq.sh diff --git a/bin/tests/system/Makefile.am b/bin/tests/system/Makefile.am index f550411215..b107d59348 100644 --- a/bin/tests/system/Makefile.am +++ b/bin/tests/system/Makefile.am @@ -85,10 +85,6 @@ tkey_keydelete_LDADD = \ TESTS = -if HAVE_PERLMOD_TIME_HIRES -TESTS += serve-stale -endif HAVE_PERLMOD_TIME_HIRES - if HAVE_PERLMOD_NET_DNS TESTS += \ rpzrecurse @@ -177,6 +173,7 @@ TESTS += \ rrsetorder \ rsabigexponent \ runtime \ + serve-stale \ sfcache \ shutdown \ smartsign \ diff --git a/bin/tests/system/serve-stale/prereq.sh b/bin/tests/system/serve-stale/prereq.sh new file mode 100644 index 0000000000..01ac7e3944 --- /dev/null +++ b/bin/tests/system/serve-stale/prereq.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PERL} -MTime::HiRes -e '' +then + echo_i "perl Time::HiRes module is required" + exit 1 +fi + +exit 0 diff --git a/configure.ac b/configure.ac index 9c6186417d..84b5da232f 100644 --- a/configure.ac +++ b/configure.ac @@ -241,10 +241,6 @@ AX_PERL_MODULE([Net::DNS]) AM_CONDITIONAL([HAVE_PERLMOD_NET_DNS], [test "$HAVE_PERLMOD_NET__DNS" = "yes"]) -AX_PERL_MODULE([Time::HiRes]) -AM_CONDITIONAL([HAVE_PERLMOD_TIME_HIRES], - [test "$HAVE_PERLMOD_TIME__HIRES" = "yes"]) - # # Python is optional, it is used only by some of the system test scripts. # From a28529c11dfcfac04494ea75f4ffc151fd553cf1 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 4 Sep 2023 16:03:05 +0200 Subject: [PATCH 13/20] Use prereq.sh for rpzrecurse system test (cherry picked from commit 0538b7e0da4acdafc9a1fa2f6e6872481ffdd2d1) --- bin/tests/system/Makefile.am | 10 ++-------- bin/tests/system/rpzrecurse/prereq.sh | 22 ++++++++++++++++++++++ configure.ac | 4 ---- 3 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 bin/tests/system/rpzrecurse/prereq.sh diff --git a/bin/tests/system/Makefile.am b/bin/tests/system/Makefile.am index b107d59348..3abfad1dc2 100644 --- a/bin/tests/system/Makefile.am +++ b/bin/tests/system/Makefile.am @@ -83,14 +83,7 @@ tkey_keydelete_LDADD = \ $(LDADD) \ $(LIBDNS_LIBS) -TESTS = - -if HAVE_PERLMOD_NET_DNS -TESTS += \ - rpzrecurse -endif HAVE_PERLMOD_NET_DNS - -TESTS += \ +TESTS = \ acl \ additional \ addzone \ @@ -168,6 +161,7 @@ TESTS += \ rootkeysentinel \ rpz \ rpzextra \ + rpzrecurse \ rrchecker \ rrl \ rrsetorder \ diff --git a/bin/tests/system/rpzrecurse/prereq.sh b/bin/tests/system/rpzrecurse/prereq.sh new file mode 100644 index 0000000000..0c29427e97 --- /dev/null +++ b/bin/tests/system/rpzrecurse/prereq.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +. ../conf.sh + +if ! ${PERL} -MNet::DNS -e '' +then + echo_i "perl Net::DNS module is required" + exit 1 +fi + +exit 0 diff --git a/configure.ac b/configure.ac index 84b5da232f..c31b8068a9 100644 --- a/configure.ac +++ b/configure.ac @@ -237,10 +237,6 @@ AC_PATH_PROGS([PERL], [perl5 perl]) AC_SUBST([PERL]) AM_CONDITIONAL([HAVE_PERL], [test -n "$PERL"]) -AX_PERL_MODULE([Net::DNS]) -AM_CONDITIONAL([HAVE_PERLMOD_NET_DNS], - [test "$HAVE_PERLMOD_NET__DNS" = "yes"]) - # # Python is optional, it is used only by some of the system test scripts. # From 68f186dd82f12e966e2dbb2f47dc1de2a1ac80b5 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Mon, 4 Sep 2023 16:08:06 +0200 Subject: [PATCH 14/20] Prioritize long-running system tests for legacy runner Synchronize the test priority with the pytest runner (which handles the prioritization in conftest.py). (cherry picked from commit 15fa8f1506f28fdc304f863155cf71f50ed917c1) --- bin/tests/system/Makefile.am | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/tests/system/Makefile.am b/bin/tests/system/Makefile.am index 3abfad1dc2..befd51270f 100644 --- a/bin/tests/system/Makefile.am +++ b/bin/tests/system/Makefile.am @@ -83,7 +83,14 @@ tkey_keydelete_LDADD = \ $(LDADD) \ $(LIBDNS_LIBS) +# Longer running tests are listed (and executed) first to take the most +# advantage of parallel execution. TESTS = \ + rpz \ + rpzrecurse \ + serve-stale \ + timeouts \ + upforwd \ acl \ additional \ addzone \ @@ -159,15 +166,12 @@ TESTS = \ resolver \ rndc \ rootkeysentinel \ - rpz \ rpzextra \ - rpzrecurse \ rrchecker \ rrl \ rrsetorder \ rsabigexponent \ runtime \ - serve-stale \ sfcache \ shutdown \ smartsign \ @@ -180,7 +184,6 @@ TESTS = \ stub \ synthfromdnssec \ tcp \ - timeouts \ tkey \ tools \ transport-acl \ @@ -188,7 +191,6 @@ TESTS = \ tsiggss \ ttl \ unknown \ - upforwd \ verify \ views \ wildcard \ From fce6fa0fc4beb15929102546151bac9599941cd7 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Tue, 5 Sep 2023 16:16:20 +0200 Subject: [PATCH 15/20] Convert JUnit XML from pytest into Automake .trs files It's important to parse the JUnit result file rather than relying on the exit code from pytest, which has a different meaning. Include a .trs test result for each test case and set an exit code which is most appropriate as the aggregate result (e.g. it will be set to 77 (SKIP) if there's at least one test case that was skipped). (cherry picked from commit b96c8e806265ba8dbe81ea50fc0d84c33c27289c) --- bin/tests/system/convert-junit-to-trs.py | 70 ++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 bin/tests/system/convert-junit-to-trs.py diff --git a/bin/tests/system/convert-junit-to-trs.py b/bin/tests/system/convert-junit-to-trs.py new file mode 100755 index 0000000000..7d490fa550 --- /dev/null +++ b/bin/tests/system/convert-junit-to-trs.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 +# +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# Convert JUnit pytest output to automake .trs files + +import argparse +import sys +from xml.etree import ElementTree + + +def junit_to_trs(junit_xml): + root = ElementTree.fromstring(junit_xml) + testcases = root.findall("./testsuite/testcase") + + if len(testcases) < 1: + print(":test-result: ERROR convert-junit-to-trs.py") + return 99 + + has_fail = False + has_error = False + has_skipped = False + for testcase in testcases: + filename = f"{testcase.attrib['classname'].replace('.', '/')}.py" + name = f"{filename}::{testcase.attrib['name']}" + res = "PASS" + for node in testcase: + if node.tag == "failure": + res = "FAIL" + has_fail = True + elif node.tag == "error": + res = "ERROR" + has_error = True + elif node.tag == "skipped": + if node.attrib["type"] == "pytest.xfail": + res = "XFAIL" + else: + res = "SKIP" + has_skipped = True + print(f":test-result: {res} {name}") + + if has_error: + return 99 + if has_fail: + return 1 + if has_skipped: + return 77 + return 0 + + +def main(): + parser = argparse.ArgumentParser( + description="Convert JUnit XML to Automake TRS and exit with " + "the appropriate Automake-compatible exit code." + ) + parser.add_argument( + "junit_file", + type=argparse.FileType("r", encoding="utf-8"), + help="junit xml result file", + ) + args = parser.parse_args() + + junit_xml = args.junit_file.read() + sys.exit(junit_to_trs(junit_xml)) + + +if __name__ == "__main__": + main() From ca392c6f64312cf79b08434e2e0ec4e8e0db4071 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Tue, 5 Sep 2023 10:29:13 +0200 Subject: [PATCH 16/20] Modify custom-test-driver to interpret JUnit results Pytest provides JUnit output and uses different exit codes from Automake. Use the conversion script to interpret the JUnit test results from python rather than relying on the status code. (cherry picked from commit 295890a16b24f740b8bc8b7c75a4ded9802cb3ff) --- bin/tests/system/.gitignore | 1 + bin/tests/system/custom-test-driver | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/bin/tests/system/.gitignore b/bin/tests/system/.gitignore index a54b7c9565..f946793ae7 100644 --- a/bin/tests/system/.gitignore +++ b/bin/tests/system/.gitignore @@ -16,6 +16,7 @@ named.run parallel.mk /*.log /*.trs +/*.xml /resolve /legacy.run.sh /run.log diff --git a/bin/tests/system/custom-test-driver b/bin/tests/system/custom-test-driver index 7499aa0bc0..fed98cccc6 100755 --- a/bin/tests/system/custom-test-driver +++ b/bin/tests/system/custom-test-driver @@ -56,7 +56,7 @@ END test_name= # Used for reporting. log_file= # Where to save the output of the test script. trs_file= # Where to save the metadata of the test run. -status_file= # Where to save the status of the test run. +junit_file= # Where to save pytest junit output. expect_failure=no color_tests=no enable_hard_errors=yes @@ -67,8 +67,7 @@ while test $# -gt 0; do --version) echo "test-driver $scriptversion"; exit $?;; --test-name) test_name=$2; shift;; --log-file) log_file=$2; shift;; - --trs-file) trs_file=$2; shift;; - --status-file) status_file=$2; shift;; + --trs-file) trs_file=$2; junit_file=$(echo $trs_file | sed 's/\.trs$/\.xml/'); shift;; --color-tests) color_tests=$2; shift;; --expect-failure) expect_failure=$2; shift;; --enable-hard-errors) enable_hard_errors=$2; shift;; @@ -104,22 +103,22 @@ else red= grn= lgn= blu= mgn= std= fi -do_exit='rm -f $log_file $trs_file $status_file; (exit $st); exit $st' +do_exit='rm -f $log_file $trs_file $junit_file; (exit $st); exit $st' trap "st=129; $do_exit" 1 trap "st=130; $do_exit" 2 trap "st=141; $do_exit" 13 trap "st=143; $do_exit" 15 -# Set default -test x"$status_file" = x && status_file=$(mktemp ./custom-test-runner.XXXXXX) # Test script is run here. if test $verbose = yes; then - ("$@" 2>&1; echo $? > "$status_file") | tee $log_file + "$@" --junit-xml $PWD/$junit_file 2>&1 | tee $log_file else - "$@" >$log_file 2>&1; echo $? > "$status_file" + "$@" --junit-xml $PWD/$junit_file >$log_file 2>&1 fi -read -r estatus < "$status_file" -rm "$status_file" + +# Run junit to trs converter script. +./convert-junit-to-trs.py $junit_file > $trs_file +estatus=$? if test $enable_hard_errors = no && test $estatus -eq 99; then tweaked_estatus=1 @@ -145,8 +144,7 @@ echo "$res $test_name (exit status: $estatus)" >>$log_file # Report outcome to console. echo "${col}${res}${std}: $test_name" -# Register the test result, and other relevant metadata. -echo ":test-result: $res" > $trs_file +# Register other relevant test metadata. echo ":global-test-result: $res" >> $trs_file echo ":recheck: $recheck" >> $trs_file echo ":copy-in-global-log: $gcopy" >> $trs_file From a4edb7db2936f7fd0e0e4157293d0d3a30a31d92 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Wed, 6 Sep 2023 13:43:18 +0200 Subject: [PATCH 17/20] ci: switch OpenBSD job to use make check Invoking pytest directly provides a better formatted output and more flexibility. However, it's prudent to verify that `make check` keeps working as expected. Use it in the OpenBSD job which isn't executed as frequently and its output is of least concern. (cherry picked from commit f1c631f44899b728300240ad93f13bc72e78c12c) --- .gitlab-ci.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cff89be374..df6cec6800 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -435,6 +435,14 @@ cross-version-config-tests: reports: junit: junit.xml +.system_test_make_check: &system_test_make_check_job + <<: *system_test_common + script: + - cd bin/tests/system + - make -j${TEST_PARALLEL_JOBS:-1} check + after_script: + - cat bin/tests/system/test-suite.log || true + .system_test_gcov: &system_test_gcov_job <<: *system_test_common artifacts: @@ -1341,6 +1349,7 @@ clang:openbsd:amd64: system:clang:openbsd:amd64: <<: *openbsd_amd64_image <<: *system_test_job + <<: *system_test_make_check_job <<: *api_schedules_triggers_web_triggering_rules variables: USER: gitlab-runner From 01aada479c9f919527f69df72ec112c22193e424 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Fri, 8 Sep 2023 12:44:08 +0200 Subject: [PATCH 18/20] Remove make check invocation from legacy.run.sh The legacy runner no longer uses make check. Ensure the legacy runner script doesn't interact with that automake target in any way. The legacy runner script remains available to execute the legacy runner, but there is no out-of-the box support for running tests in parallel. Other tools such as xargs can be utilized for that. (cherry picked from commit 0a9ee342e9d6703137d0eda2d24b30deccfc5e8f) --- bin/tests/system/legacy.run.sh.in | 32 +------------------------------ 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/bin/tests/system/legacy.run.sh.in b/bin/tests/system/legacy.run.sh.in index 026e5850c9..50af41c41d 100644 --- a/bin/tests/system/legacy.run.sh.in +++ b/bin/tests/system/legacy.run.sh.in @@ -44,11 +44,8 @@ else clean=true fi -do_run=false restart=false -log_flags="-r" -while getopts "sknp:r-:t" OPT; do - log_flags="$log_flags -$OPT$OPTARG" +while getopts "sknp:-:t" OPT; do if [ "$OPT" = "-" ] && [ -n "$OPTARG" ]; then OPT="${OPTARG%%=*}" OPTARG="${OPTARG#$OPT}" @@ -60,7 +57,6 @@ while getopts "sknp:r-:t" OPT; do k | keep) stopservers=false ;; n | noclean) clean=false ;; p | port) baseport=$OPTARG ;; - r | run) do_run=true ;; s | skip) exit 77 ;; t | restart) restart=true ;; -) break ;; @@ -70,32 +66,6 @@ done shift $((OPTIND-1)) -if ! $do_run; then - if [ "$baseport" -eq 0 ]; then - log_flags="$log_flags -p 5300" - fi - env - \ - CYGWIN="$CYGWIN" \ - SYSTEMTEST_FORCE_COLOR="$SYSTEMTEST_FORCE_COLOR" \ - SYSTEMTEST_NO_CLEAN="$SYSTEMTEST_NO_CLEAN" \ - SLOT="$SLOT" \ - OPENSSL_CONF="$OPENSSL_CONF" \ - SOFTHSM2_CONF="$SOFTHSM2_CONF" \ - SOFTHSM2_MODULE="$SOFTHSM2_MODULE" \ - PATH="$PATH" \ - ${LD_LIBRARY_PATH:+"LD_LIBRARY_PATH=${LD_LIBRARY_PATH}"} \ - TESTS="$*" \ - TEST_SUITE_LOG=run.log \ - LOG_DRIVER_FLAGS="--verbose yes --color-tests yes" \ - LOG_FLAGS="$log_flags" \ - TEST_LARGE_MAP="${TEST_LARGE_MAP}" \ - CI_ENABLE_ALL_TESTS="${CI_ENABLE_ALL_TESTS}" \ - ${VIRTUAL_ENV:+"VIRTUAL_ENV=${VIRTUAL_ENV}"} \ - ${PERL5LIB:+"PERL5LIB=${PERL5LIB}"} \ - make -e check - exit $? -fi - if [ $# -eq 0 ]; then echofail "Usage: $0 [-k] [-n] [-p ] test-directory [test-options]" >&2; exit 1 From 20c8fab299e1669aa24c3921c9c24742b71107ed Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Wed, 20 Sep 2023 10:49:44 +0200 Subject: [PATCH 19/20] ci: make sure to use legacy test runner on EL7 EL7 doesn't have the required dependencies for the newer pytest runner. Since make check now invokes the pytest runner, ensure that the legacy runner will be used instead. --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index df6cec6800..8816984493 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -412,14 +412,13 @@ cross-version-config-tests: .system_test_legacy: &system_test_legacy script: - cd bin/tests/system - - make -j${TEST_PARALLEL_JOBS:-1} -k check V=1 + - find . -maxdepth 2 -mindepth 2 -type f -name "tests.sh" | cut -d/ -f2 | xargs -n 1 -P ${TEST_PARALLEL_JOBS:-1} sh legacy.run.sh - if git rev-parse > /dev/null 2>&1; then ( ! grep "^I:.*:file.*not removed$" *.log ); fi - '( ! grep -F "grep: warning:" *.log )' after_script: - test -d bind-* && cd bind-* - REALSOURCEDIR="$PWD" - test -n "${OUT_OF_TREE_WORKSPACE}" && cd "${OUT_OF_TREE_WORKSPACE}" - - cat bin/tests/system/test-suite.log - find bin/tests/system -name "*dig.*" | xargs grep "error" || true - *find_python - > From 8c1a1b304cf4faa676e1166ae436d63a67840650 Mon Sep 17 00:00:00 2001 From: Tom Krizek Date: Wed, 20 Sep 2023 13:45:41 +0200 Subject: [PATCH 20/20] Use 0 exit code for skipped tests in legacy runner Since the legacy runner is no longer used in the automake test suite, don't use the special GNU exit code indicating a skipped tests. Instead, use 0 to avoid considering skipped tests as failed when using simpler mechanism (such as xargs -P) to run the tests with the legacy runner. --- bin/tests/system/legacy.run.sh.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/tests/system/legacy.run.sh.in b/bin/tests/system/legacy.run.sh.in index 50af41c41d..501e554e3d 100644 --- a/bin/tests/system/legacy.run.sh.in +++ b/bin/tests/system/legacy.run.sh.in @@ -57,7 +57,7 @@ while getopts "sknp:-:t" OPT; do k | keep) stopservers=false ;; n | noclean) clean=false ;; p | port) baseport=$OPTARG ;; - s | skip) exit 77 ;; + s | skip) exit 0 ;; t | restart) restart=true ;; -) break ;; *) echo "invalid option" >&2; exit 1 ;; @@ -152,7 +152,7 @@ else echowarn "I:$systest:Prerequisites missing, skipping test." echowarn "R:$systest:SKIPPED"; echoend "E:$systest:$(date_with_args)" - exit 77 + exit 0 fi # Clean up files left from any potential previous runs except when