tests: Do not always fetch the get-pip.py script during tests

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
This commit is contained in:
Markos Chandras 2018-04-18 11:59:41 +01:00
parent 5a99262155
commit 40373daf7e
3 changed files with 17 additions and 3 deletions

View File

@ -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 }}

View File

@ -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:

View File

@ -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"
@ -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')"