diff --git a/.zuul.d/rally-tox-functional.yaml b/.zuul.d/rally-tox-functional.yaml index 082928e8..b42b2792 100644 --- a/.zuul.d/rally-tox-functional.yaml +++ b/.zuul.d/rally-tox-functional.yaml @@ -19,5 +19,6 @@ rally-openstack: https://opendev.org/openstack/rally-openstack devstack_localrc: USE_PYTHON3: true - rally_tox_env: "functional" - run: tests/ci/playbooks/run-rally-tox.yaml + tox_env: "functional" + pre-run: tests/ci/playbooks/tox-install.yaml + run: tests/ci/playbooks/tox-functional-env-run.yaml diff --git a/tests/ci/playbooks/roles/run-rally-tox/tasks/main.yaml b/tests/ci/playbooks/roles/tox-run/tasks/main.yaml similarity index 86% rename from tests/ci/playbooks/roles/run-rally-tox/tasks/main.yaml rename to tests/ci/playbooks/roles/tox-run/tasks/main.yaml index 7d203e17..6315fe29 100644 --- a/tests/ci/playbooks/roles/run-rally-tox/tasks/main.yaml +++ b/tests/ci/playbooks/roles/tox-run/tasks/main.yaml @@ -7,4 +7,4 @@ set -e cd /opt/stack/rally-openstack export REQUESTS_CA_BUNDLE=/opt/stack/data/ca-bundle.pem - tox -e {{ rally_tox_env }} + tox -e {{ tox_env }} diff --git a/tests/ci/playbooks/run-rally-tox.yaml b/tests/ci/playbooks/tox-functional-env-run.yaml similarity index 95% rename from tests/ci/playbooks/run-rally-tox.yaml rename to tests/ci/playbooks/tox-functional-env-run.yaml index 20b83295..f13c2d84 100644 --- a/tests/ci/playbooks/run-rally-tox.yaml +++ b/tests/ci/playbooks/tox-functional-env-run.yaml @@ -12,4 +12,4 @@ rally_task: "rally-jobs/simple-job.yaml" roles: - prepare-for-rally-task - - run-rally-tox \ No newline at end of file + - tox-run \ No newline at end of file diff --git a/tests/ci/playbooks/tox-install.yaml b/tests/ci/playbooks/tox-install.yaml new file mode 100644 index 00000000..abd9a235 --- /dev/null +++ b/tests/ci/playbooks/tox-install.yaml @@ -0,0 +1,64 @@ + +- hosts: all + name: Installs all required packages + tasks: + - name: Check required version of Python + args: + chdir: "{{ zuul.project.src_dir }}" + shell: + executable: /bin/sh + cmd: | + set -e + + iniget(){ + local xtrace + xtrace=$(set +o | grep xtrace) + set +o xtrace + local section=$1 + local file="tox.ini" + local option="basepython" + local line + + line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file") + echo ${line#*= python} + $xtrace + } + + tox_testenv_python=$(iniget 'testenv:{{ tox_env }}') + if [ "$tox_testenv_python" != "" ]; then + echo $tox_testenv_python + else + echo $(iniget 'testenv') + fi + register: python_version + + - name: Install the proper python version + become: True + become_user: root + shell: + executable: /bin/sh + cmd: | + set -e + + apt-get update + apt-get install python{{ python_version.stdout }}-dev --yes + + - name: Install the proper python pip version + become: True + become_user: root + shell: + executable: /bin/bash + cmd: | + set -e + curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py + python{{ python_version.stdout }} get-pip.py + + - name: Install python tox + become: True + become_user: root + shell: + executable: /bin/bash + cmd: | + pip{{ python_version.stdout }} install tox + roles: + - bindep