diff --git a/changelogs/fragments/ansible-test-delegation-options.yml b/changelogs/fragments/ansible-test-delegation-options.yml new file mode 100644 index 00000000000..38b48f8b814 --- /dev/null +++ b/changelogs/fragments/ansible-test-delegation-options.yml @@ -0,0 +1,2 @@ +minor_changes: +- "ansible-test - allow delegation config to specify equivalents to the ``--no-pip-check``, ``--disable-httptester`` and `--no-temp-unicode`` options" diff --git a/test/lib/ansible_test/_internal/config.py b/test/lib/ansible_test/_internal/config.py index 5b2b6c9e9e1..53a92efd605 100644 --- a/test/lib/ansible_test/_internal/config.py +++ b/test/lib/ansible_test/_internal/config.py @@ -13,6 +13,7 @@ from .util import ( find_python, generate_pip_command, get_docker_completion, + get_remote_completion, ApplicationError, ) @@ -91,6 +92,12 @@ class EnvironmentConfig(CommonConfig): self.inject_httptester = args.inject_httptester if 'inject_httptester' in args else False # type: bool self.httptester = docker_qualify_image(args.httptester if 'httptester' in args else '') # type: str + if self.get_delegated_completion().get('httptester', 'enabled') == 'disabled': + self.httptester = False + + if self.get_delegated_completion().get('pip-check', 'enabled') == 'disabled': + self.pip_check = False + if args.check_python and args.check_python != actual_major_minor: raise ApplicationError('Running under Python %s instead of Python %s as expected.' % (actual_major_minor, args.check_python)) @@ -117,6 +124,18 @@ class EnvironmentConfig(CommonConfig): """ return generate_pip_command(self.python_executable) + def get_delegated_completion(self): + """Returns a dictionary of settings specific to the selected delegation system, if any. Otherwise returns an empty dictionary. + :rtype: dict[str, str] + """ + if self.docker: + return get_docker_completion().get(self.docker_raw, {}) + + if self.remote: + return get_remote_completion().get(self.remote, {}) + + return {} + class TestConfig(EnvironmentConfig): """Configuration common to all test commands.""" @@ -236,6 +255,9 @@ class IntegrationConfig(TestConfig): self.no_temp_workdir = args.no_temp_workdir self.no_temp_unicode = args.no_temp_unicode + if self.get_delegated_completion().get('temp-unicode', 'enabled') == 'disabled': + self.no_temp_unicode = True + if self.list_targets: self.explain = True diff --git a/test/lib/ansible_test/_internal/delegation.py b/test/lib/ansible_test/_internal/delegation.py index 24630277e8a..56ca578bdc8 100644 --- a/test/lib/ansible_test/_internal/delegation.py +++ b/test/lib/ansible_test/_internal/delegation.py @@ -575,6 +575,12 @@ def filter_options(args, argv, options, exclude, require): '--base-branch': 1, }) + if isinstance(args, IntegrationConfig): + options.update({ + '--no-temp-unicode': 0, + '--no-pip-check': 0, + }) + if isinstance(args, (NetworkIntegrationConfig, WindowsIntegrationConfig)): options.update({ '--inventory': 1, @@ -621,3 +627,10 @@ def filter_options(args, argv, options, exclude, require): yield '--redact' else: yield '--no-redact' + + if isinstance(args, IntegrationConfig): + if args.no_temp_unicode: + yield '--no-temp-unicode' + + if not args.pip_check: + yield '--no-pip-check'