diff options
author | Matt Clay <mclay@redhat.com> | 2021-04-23 09:26:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-23 09:26:19 +0200 |
commit | 6cfe36fa1fce56a04fd4d4953f35243099d83ae6 (patch) | |
tree | dbe0ab0eda7bbb6bbe1cddcb6e8fc36becff501e /test | |
parent | Update ansible-test default test container. (#74393) (diff) | |
download | ansible-6cfe36fa1fce56a04fd4d4953f35243099d83ae6.tar.xz ansible-6cfe36fa1fce56a04fd4d4953f35243099d83ae6.zip |
Set ansible-test min controller Python to 3.8. (#74395)
- Version neutral sanity tests now require Python 3.8 or later.
- Unit tests for controller-only code now require Python 3.8 or later.
Diffstat (limited to 'test')
6 files changed, 26 insertions, 24 deletions
diff --git a/test/integration/targets/ansible-test/collection-tests/coverage.sh b/test/integration/targets/ansible-test/collection-tests/coverage.sh index 033a9836ea..221ae66ab6 100755 --- a/test/integration/targets/ansible-test/collection-tests/coverage.sh +++ b/test/integration/targets/ansible-test/collection-tests/coverage.sh @@ -7,8 +7,8 @@ cd "${WORK_DIR}/ansible_collections/ns/col" # rename the sanity ignore file to match the current ansible version and update import ignores with the python version ansible_version="$(python -c 'import ansible.release; print(".".join(ansible.release.__version__.split(".")[:2]))')" -if [ "${ANSIBLE_TEST_PYTHON_VERSION}" == "2.6" ]; then - # Non-module/module_utils plugins are not checked on this remote-only Python versions +if [[ "${ANSIBLE_TEST_PYTHON_VERSION}" =~ ^2\. ]] || [[ "${ANSIBLE_TEST_PYTHON_VERSION}" =~ ^3\.[567] ]]; then + # Non-module/module_utils plugins are not checked on these remote-only Python versions sed "s/ import$/ import-${ANSIBLE_TEST_PYTHON_VERSION}/;" < "tests/sanity/ignore.txt" | grep -v 'plugins/[^m].* import' > "tests/sanity/ignore-${ansible_version}.txt" else sed "s/ import$/ import-${ANSIBLE_TEST_PYTHON_VERSION}/;" < "tests/sanity/ignore.txt" > "tests/sanity/ignore-${ansible_version}.txt" diff --git a/test/integration/targets/ansible-test/collection-tests/venv.sh b/test/integration/targets/ansible-test/collection-tests/venv.sh index ba0d2628d6..42dbfde41b 100755 --- a/test/integration/targets/ansible-test/collection-tests/venv.sh +++ b/test/integration/targets/ansible-test/collection-tests/venv.sh @@ -7,8 +7,8 @@ cd "${WORK_DIR}/ansible_collections/ns/col" # rename the sanity ignore file to match the current ansible version and update import ignores with the python version ansible_version="$(python -c 'import ansible.release; print(".".join(ansible.release.__version__.split(".")[:2]))')" -if [ "${ANSIBLE_TEST_PYTHON_VERSION}" == "2.6" ]; then - # Non-module/module_utils plugins are not checked on this remote-only Python versions +if [[ "${ANSIBLE_TEST_PYTHON_VERSION}" =~ ^2\. ]] || [[ "${ANSIBLE_TEST_PYTHON_VERSION}" =~ ^3\.[567] ]]; then + # Non-module/module_utils plugins are not checked on these remote-only Python versions sed "s/ import$/ import-${ANSIBLE_TEST_PYTHON_VERSION}/;" < "tests/sanity/ignore.txt" | grep -v 'plugins/[^m].* import' > "tests/sanity/ignore-${ansible_version}.txt" else sed "s/ import$/ import-${ANSIBLE_TEST_PYTHON_VERSION}/;" < "tests/sanity/ignore.txt" > "tests/sanity/ignore-${ansible_version}.txt" diff --git a/test/lib/ansible_test/_internal/sanity/__init__.py b/test/lib/ansible_test/_internal/sanity/__init__.py index 44cdd9e627..6613abb99b 100644 --- a/test/lib/ansible_test/_internal/sanity/__init__.py +++ b/test/lib/ansible_test/_internal/sanity/__init__.py @@ -31,6 +31,8 @@ from ..util import ( paths_to_dirs, get_ansible_version, str_to_version, + SUPPORTED_PYTHON_VERSIONS, + CONTROLLER_PYTHON_VERSIONS, ) from ..util_common import ( @@ -54,7 +56,6 @@ from ..executor import ( AllTargetsSkipped, Delegate, install_command_requirements, - SUPPORTED_PYTHON_VERSIONS, ) from ..config import ( @@ -659,7 +660,7 @@ class SanityTest(ABC): @property def supported_python_versions(self): # type: () -> t.Optional[t.Tuple[str, ...]] """A tuple of supported Python versions or None if the test does not depend on specific Python versions.""" - return tuple(python_version for python_version in SUPPORTED_PYTHON_VERSIONS if str_to_version(python_version) >= (3, 6)) + return CONTROLLER_PYTHON_VERSIONS def filter_targets(self, targets): # type: (t.List[TestTarget]) -> t.List[TestTarget] # pylint: disable=unused-argument """Return the given list of test targets, filtered to include only those relevant for the test.""" diff --git a/test/lib/ansible_test/_internal/sanity/import.py b/test/lib/ansible_test/_internal/sanity/import.py index 3473063526..0f56851615 100644 --- a/test/lib/ansible_test/_internal/sanity/import.py +++ b/test/lib/ansible_test/_internal/sanity/import.py @@ -87,6 +87,10 @@ class ImportTest(SanityMultipleVersion): :type python_version: str :rtype: TestResult """ + settings = self.load_processor(args, python_version) + + paths = [target.path for target in targets.include] + capture_pip = args.verbosity < 2 python = find_python(python_version) @@ -97,10 +101,6 @@ class ImportTest(SanityMultipleVersion): pip = generate_pip_command(python) run_command(args, generate_pip_install(pip, '', packages=['virtualenv']), capture=capture_pip) - settings = self.load_processor(args, python_version) - - paths = [target.path for target in targets.include] - env = ansible_environment(args, color=False) temp_root = os.path.join(ResultType.TMP.path, 'sanity', 'import') diff --git a/test/lib/ansible_test/_internal/units/__init__.py b/test/lib/ansible_test/_internal/units/__init__.py index 58a119452d..d27ed7d53f 100644 --- a/test/lib/ansible_test/_internal/units/__init__.py +++ b/test/lib/ansible_test/_internal/units/__init__.py @@ -17,9 +17,10 @@ from ..util import ( is_subdir, SubprocessError, SUPPORTED_PYTHON_VERSIONS, + CONTROLLER_MIN_PYTHON_VERSION, + CONTROLLER_PYTHON_VERSIONS, + REMOTE_ONLY_PYTHON_VERSIONS, ANSIBLE_LIB_ROOT, - str_to_version, - version_to_str, ) from ..util_common import ( @@ -91,15 +92,13 @@ def command_units(args): TestContext.controller: controller_paths, } - # temporary definition of "remote" python versions until the full split controller/remote implementation is in place - controller_min_python_version = (3, 8) - remote_only_python_versions = tuple(version for version in SUPPORTED_PYTHON_VERSIONS if str_to_version(version) < controller_min_python_version) - if not paths: raise AllTargetsSkipped() - if args.python and args.python in remote_only_python_versions and not remote_paths: - raise AllTargetsSkipped() + if args.python and args.python in REMOTE_ONLY_PYTHON_VERSIONS: + if not remote_paths: + display.warning('Python %s is only supported by module and module_utils unit tests, but none were selected.' % args.python) + raise AllTargetsSkipped() if args.delegate: raise Delegate(require=changes, exclude=args.exclude) @@ -116,8 +115,9 @@ def command_units(args): test_candidates = [] for test_context, paths in test_context_paths.items(): - if test_context == TestContext.controller and version in remote_only_python_versions: - continue + if test_context == TestContext.controller: + if version not in CONTROLLER_PYTHON_VERSIONS: + continue if not paths: continue @@ -126,7 +126,7 @@ def command_units(args): env.update( PYTHONPATH=get_units_ansible_python_path(args, test_context), - ANSIBLE_CONTROLLER_MIN_PYTHON_VERSION=version_to_str(controller_min_python_version), + ANSIBLE_CONTROLLER_MIN_PYTHON_VERSION=CONTROLLER_MIN_PYTHON_VERSION, ) test_candidates.append((test_context, version, paths, env)) diff --git a/test/lib/ansible_test/_internal/util.py b/test/lib/ansible_test/_internal/util.py index 08208a97aa..3c4549a522 100644 --- a/test/lib/ansible_test/_internal/util.py +++ b/test/lib/ansible_test/_internal/util.py @@ -113,9 +113,7 @@ MODE_FILE_WRITE = MODE_FILE | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH MODE_DIRECTORY = MODE_READ | stat.S_IWUSR | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH MODE_DIRECTORY_WRITE = MODE_DIRECTORY | stat.S_IWGRP | stat.S_IWOTH -REMOTE_ONLY_PYTHON_VERSIONS = ( - '2.6', -) +CONTROLLER_MIN_PYTHON_VERSION = '3.8' SUPPORTED_PYTHON_VERSIONS = ( '2.6', @@ -904,3 +902,6 @@ def get_host_ip(): display = Display() # pylint: disable=locally-disabled, invalid-name + +CONTROLLER_PYTHON_VERSIONS = tuple(version for version in SUPPORTED_PYTHON_VERSIONS if str_to_version(version) >= str_to_version(CONTROLLER_MIN_PYTHON_VERSION)) +REMOTE_ONLY_PYTHON_VERSIONS = tuple(version for version in SUPPORTED_PYTHON_VERSIONS if str_to_version(version) < str_to_version(CONTROLLER_MIN_PYTHON_VERSION)) |