From a4c42ba687d68dee7e9397c6be4dc74c59b3b949 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Fri, 5 Apr 2019 22:34:38 -0700 Subject: [PATCH] Update the default test container to 1.7.0. (#54930) * Update the default test container to 1.7.0. * Run `pip check` after installing test requirements. * Support older versions of pip. * Remove obsolete pip error handler. --- test/runner/completion/docker.txt | 2 +- test/runner/lib/executor.py | 38 ++++++++++++------------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/test/runner/completion/docker.txt b/test/runner/completion/docker.txt index bdba569104..2643d4ead8 100644 --- a/test/runner/completion/docker.txt +++ b/test/runner/completion/docker.txt @@ -1,4 +1,4 @@ -default name=quay.io/ansible/default-test-container:1.6.0 python=3.6,2.6,2.7,3.5,3.7,3.8 python3.8=/usr/local/bin/python3.8 seccomp=unconfined +default name=quay.io/ansible/default-test-container:1.7.0 python=3.6,2.6,2.7,3.5,3.7,3.8 seccomp=unconfined centos6 name=quay.io/ansible/centos6-test-container:1.8.0 python=2.6 seccomp=unconfined centos7 name=quay.io/ansible/centos7-test-container:1.8.0 python=2.7 seccomp=unconfined fedora28 name=quay.io/ansible/fedora28-test-container:1.8.0 python=2.7 diff --git a/test/runner/lib/executor.py b/test/runner/lib/executor.py index c9429e56d1..5dfb85e77e 100644 --- a/test/runner/lib/executor.py +++ b/test/runner/lib/executor.py @@ -213,17 +213,22 @@ def install_command_requirements(args, python_version=None): # first pass to install requirements, changes expected unless environment is already set up changes = run_pip_commands(args, pip, commands, detect_pip_changes) - if not changes: - return # no changes means we can stop early + if changes: + # second pass to check for conflicts in requirements, changes are not expected here + changes = run_pip_commands(args, pip, commands, detect_pip_changes) - # second pass to check for conflicts in requirements, changes are not expected here - changes = run_pip_commands(args, pip, commands, detect_pip_changes) + if changes: + raise ApplicationError('Conflicts detected in requirements. The following commands reported changes during verification:\n%s' % + '\n'.join((' '.join(pipes.quote(c) for c in cmd) for cmd in changes))) - if not changes: - return # no changes means no conflicts - - raise ApplicationError('Conflicts detected in requirements. The following commands reported changes during verification:\n%s' % - '\n'.join((' '.join(pipes.quote(c) for c in cmd) for cmd in changes))) + # ask pip to check for conflicts between installed packages + try: + run_command(args, pip + ['check', '--disable-pip-version-check'], capture=True) + except SubprocessError as ex: + if ex.stderr.strip() == 'ERROR: unknown command "check"': + display.warning('Cannot check pip requirements for conflicts because "pip check" is not supported.') + else: + raise def run_pip_commands(args, pip, commands, detect_pip_changes=False): @@ -244,20 +249,7 @@ def run_pip_commands(args, pip, commands, detect_pip_changes=False): before_list = after_list - try: - run_command(args, cmd) - except SubprocessError as ex: - if ex.status != 2: - raise - - # If pip is too old it won't understand the arguments we passed in, so we'll need to upgrade it. - - # Installing "coverage" on ubuntu 16.04 fails with the error: - # AttributeError: 'Requirement' object has no attribute 'project_name' - # See: https://bugs.launchpad.net/ubuntu/xenial/+source/python-pip/+bug/1626258 - # Upgrading pip works around the issue. - run_command(args, pip + ['install', '--upgrade', 'pip']) - run_command(args, cmd) + run_command(args, cmd) after_list = pip_list(args, pip) if detect_pip_changes else None