From 6a5d6896fd78b94894fc731a7f703cf893457d7c Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Fri, 24 Sep 2021 11:15:11 -0700 Subject: [PATCH] ansible-test - Warn about stale sanity venvs. --- .../_internal/commands/sanity/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/lib/ansible_test/_internal/commands/sanity/__init__.py b/test/lib/ansible_test/_internal/commands/sanity/__init__.py index edd65636464..f30d9ff0399 100644 --- a/test/lib/ansible_test/_internal/commands/sanity/__init__.py +++ b/test/lib/ansible_test/_internal/commands/sanity/__init__.py @@ -96,6 +96,7 @@ from ...content_config import ( ) from ...host_configs import ( + DockerConfig, PosixConfig, PythonConfig, VirtualPythonConfig, @@ -121,6 +122,8 @@ COMMAND = 'sanity' SANITY_ROOT = os.path.join(ANSIBLE_TEST_CONTROLLER_ROOT, 'sanity') TARGET_SANITY_ROOT = os.path.join(ANSIBLE_TEST_TARGET_ROOT, 'sanity') +created_venvs = [] # type: t.List[str] + def command_sanity(args): """ @@ -279,6 +282,12 @@ def command_sanity(args): if isinstance(result, SanityFailure): failed.append(result.test + options) + controller = args.controller + + if created_venvs and isinstance(controller, DockerConfig) and controller.name == 'default' and not args.prime_venvs: + names = ', '.join(created_venvs) + display.warning(f'There following sanity test virtual environments are out-of-date in the "default" container: {names}') + if failed: message = 'The %d sanity test(s) listed below (out of %d) failed. See error output above for details.\n%s' % ( len(failed), total, '\n'.join(failed)) @@ -1155,6 +1164,8 @@ def create_sanity_virtualenv( write_json_file(meta_yaml, virtualenv_yaml) + created_venvs.append(f'{label}-{python.version}') + # touch the marker to keep track of when the virtualenv was last used pathlib.Path(virtualenv_marker).touch()