diff --git a/bin/tests/system/pytest_custom_markers.py b/bin/tests/system/pytest_custom_markers.py new file mode 100644 index 0000000000..256fb7db8d --- /dev/null +++ b/bin/tests/system/pytest_custom_markers.py @@ -0,0 +1,20 @@ +#!/usr/bin/python3 + +# 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. + +import os + +import pytest + + +long_test = pytest.mark.skipif(not os.environ.get('CI_ENABLE_ALL_TESTS'), + reason='CI_ENABLE_ALL_TESTS not set') diff --git a/bin/tests/system/run.sh.in b/bin/tests/system/run.sh.in index 532134cee4..87a98bc671 100644 --- a/bin/tests/system/run.sh.in +++ b/bin/tests/system/run.sh.in @@ -111,7 +111,7 @@ if [ "${srcdir}" != "${builddir}" ]; then cp -a "${srcdir}/common" "${builddir}" fi # Some tests require additional files to work for out-of-tree test runs. - for file in ckdnsrps.sh conftest.py digcomp.pl ditch.pl fromhex.pl kasp.sh packet.pl start.pl stop.pl testcrypto.sh; do + for file in ckdnsrps.sh conftest.py digcomp.pl ditch.pl fromhex.pl kasp.sh packet.pl pytest_custom_markers.py start.pl stop.pl testcrypto.sh; do if [ ! -r "${file}" ]; then cp -a "${srcdir}/${file}" "${builddir}" fi diff --git a/bin/tests/system/timeouts/conftest.py b/bin/tests/system/timeouts/conftest.py deleted file mode 100644 index 3a4375232d..0000000000 --- a/bin/tests/system/timeouts/conftest.py +++ /dev/null @@ -1,30 +0,0 @@ -# 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. - -import os -import pytest - - -def pytest_configure(config): - config.addinivalue_line( - "markers", "long: mark tests that take a long time to run" - ) - - -def pytest_collection_modifyitems(config, items): - # pylint: disable=unused-argument,unused-import,too-many-branches - # pylint: disable=import-outside-toplevel - skip_long_tests = pytest.mark.skip( - reason="need CI_ENABLE_ALL_TESTS environment variable") - if not os.environ.get("CI_ENABLE_ALL_TESTS"): - for item in items: - if "long" in item.keywords: - item.add_marker(skip_long_tests) diff --git a/bin/tests/system/timeouts/tests-tcp.py b/bin/tests/system/timeouts/tests-tcp.py index e883dddda4..74d7cb695f 100644 --- a/bin/tests/system/timeouts/tests-tcp.py +++ b/bin/tests/system/timeouts/tests-tcp.py @@ -26,6 +26,8 @@ import dns.query import dns.rdataclass import dns.rdatatype +import pytest_custom_markers # pylint: disable=import-error + TIMEOUT = 10 @@ -204,7 +206,7 @@ def test_send_timeout(named_port): raise EOFError from e -@pytest.mark.long +@pytest_custom_markers.long_test def test_max_transfer_idle_out(named_port): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: sock.connect(("10.53.0.1", named_port)) @@ -235,7 +237,7 @@ def test_max_transfer_idle_out(named_port): assert soa is None -@pytest.mark.long +@pytest_custom_markers.long_test def test_max_transfer_time_out(named_port): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: sock.connect(("10.53.0.1", named_port))