From 3d2ff642647aa48b100aed4f024226334a907608 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Thu, 6 Jul 2023 22:57:10 -0700 Subject: [PATCH] ansible-test - Fix import sanity test for targets (#81184) --- .../fragments/ansible-test-import-sanity-fix.yml | 2 ++ .../ansible_test/_internal/commands/sanity/import.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/ansible-test-import-sanity-fix.yml diff --git a/changelogs/fragments/ansible-test-import-sanity-fix.yml b/changelogs/fragments/ansible-test-import-sanity-fix.yml new file mode 100644 index 00000000000..bb8c2823d8b --- /dev/null +++ b/changelogs/fragments/ansible-test-import-sanity-fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - ansible-test - The ``import`` sanity test now checks the collection loader for remote-only Python support when testing ansible-core. diff --git a/test/lib/ansible_test/_internal/commands/sanity/import.py b/test/lib/ansible_test/_internal/commands/sanity/import.py index b808332478b..92f6abffd92 100644 --- a/test/lib/ansible_test/_internal/commands/sanity/import.py +++ b/test/lib/ansible_test/_internal/commands/sanity/import.py @@ -127,14 +127,20 @@ class ImportTest(SanityMultipleVersion): ('plugin', _get_module_test(False)), ): if import_type == 'plugin' and python.version in REMOTE_ONLY_PYTHON_VERSIONS: - continue + # Plugins are not supported on remote-only Python versions. + # However, the collection loader is used by the import sanity test and unit tests on remote-only Python versions. + # To support this, it is tested as a plugin, but using a venv which installs no requirements. + # Filtering of paths relevant to the Python version tested has already been performed by filter_remote_targets. + venv_type = 'empty' + else: + venv_type = import_type data = '\n'.join([path for path in paths if test(path)]) if not data and not args.prime_venvs: continue - virtualenv_python = create_sanity_virtualenv(args, python, f'{self.name}.{import_type}', coverage=args.coverage, minimize=True) + virtualenv_python = create_sanity_virtualenv(args, python, f'{self.name}.{venv_type}', coverage=args.coverage, minimize=True) if not virtualenv_python: display.warning(f'Skipping sanity test "{self.name}" on Python {python.version} due to missing virtual environment support.')