ansible-test - Warn about stale sanity venvs.

pull/75783/head
Matt Clay 4 years ago
parent b70077364a
commit 6a5d6896fd

@ -96,6 +96,7 @@ from ...content_config import (
) )
from ...host_configs import ( from ...host_configs import (
DockerConfig,
PosixConfig, PosixConfig,
PythonConfig, PythonConfig,
VirtualPythonConfig, VirtualPythonConfig,
@ -121,6 +122,8 @@ COMMAND = 'sanity'
SANITY_ROOT = os.path.join(ANSIBLE_TEST_CONTROLLER_ROOT, 'sanity') SANITY_ROOT = os.path.join(ANSIBLE_TEST_CONTROLLER_ROOT, 'sanity')
TARGET_SANITY_ROOT = os.path.join(ANSIBLE_TEST_TARGET_ROOT, 'sanity') TARGET_SANITY_ROOT = os.path.join(ANSIBLE_TEST_TARGET_ROOT, 'sanity')
created_venvs = [] # type: t.List[str]
def command_sanity(args): def command_sanity(args):
""" """
@ -279,6 +282,12 @@ def command_sanity(args):
if isinstance(result, SanityFailure): if isinstance(result, SanityFailure):
failed.append(result.test + options) 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: if failed:
message = 'The %d sanity test(s) listed below (out of %d) failed. See error output above for details.\n%s' % ( 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)) len(failed), total, '\n'.join(failed))
@ -1155,6 +1164,8 @@ def create_sanity_virtualenv(
write_json_file(meta_yaml, virtualenv_yaml) 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 # touch the marker to keep track of when the virtualenv was last used
pathlib.Path(virtualenv_marker).touch() pathlib.Path(virtualenv_marker).touch()

Loading…
Cancel
Save