From 7118cbed984108ba22bd2de4b86ccf4abc9a558d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicki=20K=C5=99=C3=AD=C5=BEek?= Date: Mon, 27 May 2024 16:10:04 +0200 Subject: [PATCH 1/2] Make system tests compatible with pytest 8.0.0+ The pytest collection mechanism has been overhauled in pytest 8.0.0, resulting in a different node tree when collecting the tests. Ensure the paths / names we're using that are derived from the node tree are consistent across different pytest versions. Particularly, this has affected the convenience symlink name (which is supposed to be in the form of e.g. dns64_sh_dns64 for the dns64 module and tests_sh_dns64.py module) and the test name that's logged at the start of the test, which is supposed to include the system test directory relative to the root system test directory as well as the module name (e.g. dns64/tests_sh_dns64.py). Related https://github.com/pytest-dev/pytest/issues/7777 --- bin/tests/system/conftest.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/tests/system/conftest.py b/bin/tests/system/conftest.py index b2c27c0a6d..d799f96d29 100644 --- a/bin/tests/system/conftest.py +++ b/bin/tests/system/conftest.py @@ -355,7 +355,7 @@ def system_test_dir(request, system_test_name): isctest.vars.dirs.set_system_test_name(testdir.name) # Create a convenience symlink with a stable and predictable name - module_name = SYMLINK_REPLACEMENT_RE.sub(r"\1", request.node.name) + module_name = SYMLINK_REPLACEMENT_RE.sub(r"\1", str(_get_node_path(request.node))) symlink_dst = system_test_root / module_name unlink(symlink_dst) symlink_dst.symlink_to(os.path.relpath(testdir, start=system_test_root)) @@ -446,6 +446,15 @@ def _run_script( isctest.log.debug(" exited with %d", returncode) +def _get_node_path(node) -> Path: + if isinstance(node.parent, pytest.Session): + if _pytest_major_ver >= 8: + return Path() + return Path(node.name) + assert node.parent is not None + return _get_node_path(node.parent) / node.name + + @pytest.fixture(scope="module") def shell(system_test_dir): """Function to call a shell script with arguments.""" @@ -543,7 +552,7 @@ def system_test( isctest.log.error("Found core dumps or sanitizer reports") pytest.fail(f"get_core_dumps.sh exited with {exc.returncode}") - isctest.log.info(f"test started: {request.node.name}") + isctest.log.info(f"test started: {_get_node_path(request.node)}") port = int(os.environ["PORT"]) isctest.log.info( "using port range: <%d, %d>", port, port + isctest.vars.ports.PORTS_PER_TEST - 1 From 6262d002bf7d27d2b84681e76fed2bac9344451b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicki=20K=C5=99=C3=AD=C5=BEek?= Date: Mon, 27 May 2024 16:24:35 +0200 Subject: [PATCH 2/2] Add legacy.run.sh to .gitignore While this file is no longer created / used in the main branch, it may linger around when switching from maintenance branches. --- bin/tests/system/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/tests/system/.gitignore b/bin/tests/system/.gitignore index 663f744cf9..0866236c20 100644 --- a/bin/tests/system/.gitignore +++ b/bin/tests/system/.gitignore @@ -16,6 +16,7 @@ named.run /*.trs /*.xml /resolve +/legacy.run.sh /run.log /start.sh /stop.sh