Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
tests: Do not always fetch the get-pip.py script during tests
Browse files Browse the repository at this point in the history
Since we are testing the idempotence of this role, we shouldn't
fetch the get-pip.py script on every iteration so we set the variable
to 'false'. Moreover, we bump the PIP version to 9.0.3 since this is
what is currently being deployed on the hosts. Finally, get-pip.py
uses --force-reinstall by default which means that everything is being
reinstalled all the time and this breaks idempotence. We can fix that by
simply checking if a suitable version of PIP is installed and then use
it to do a proper upgrade.

Change-Id: I998182eca9851d2cc745930fc73ca37bfefd0951
  • Loading branch information
Markos Chandras committed Apr 20, 2018
1 parent 5a99262 commit 40373da
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tasks/install_source.yml
Expand Up @@ -16,7 +16,7 @@
- block:
- name: Install PIP
command: >
python /opt/get-pip.py {{ (pip_install_upper_constraints is defined) |
{{ pip_install_script.stdout }} {{ (pip_install_upper_constraints is defined) |
ternary('--constraint ' ~ pip_install_upper_constraints | default(''), '') }}
{{ pip_source_install_options }}
{{ pip_get_pip_options }}
Expand Down
13 changes: 13 additions & 0 deletions tasks/main.yml
Expand Up @@ -34,9 +34,22 @@
tags:
- pip_install-install

- name: Determine PIP installation script
shell: >
if [[ $(set -o pipefail; pip --version 2>/dev/null | awk '{print $2}' | cut -d. -f1) -ge 7 ]]; then
echo "$(which pip) install --upgrade"
else
echo "python /opt/get-pip.py"
fi
args:
executable: /bin/bash
register: pip_install_script
changed_when: False

- include_tasks: "install_{{ pip_offline_install | ternary('offline', 'online') }}.yml"
tags:
- pip_install-install
when: pip_install_script.find('get-pip.py') != -1 # skip get-pip.py if a suitable pip is installed

- include_tasks: install_source.yml
tags:
Expand Down
5 changes: 3 additions & 2 deletions tests/test.yml
Expand Up @@ -17,8 +17,9 @@
hosts: localhost
connection: local
vars:
pip_get_pip_force: no
pip_packages:
- "pip==8.0.3"
- "pip==9.0.3"
pip_install_upper_constraints: "http://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt"
roles:
- role: "pip_install"
Expand All @@ -44,4 +45,4 @@
that:
- "pip_dir.stat.isdir"
- "pip_selfcheck_file.stat.exists"
- "pip_version.stdout | search('8.0.3')"
- "pip_version.stdout | search('9.0.3')"

0 comments on commit 40373da

Please sign in to comment.