From 3ed8ac0e93367a02ad53d9fa93467057724b6621 Mon Sep 17 00:00:00 2001 From: Andrey Kurilin Date: Mon, 22 Oct 2018 16:39:43 +0300 Subject: [PATCH] [ci] Manage tox job manually Patch Ia56cba58c87aa48de3e8e3f3d28f6252f7dcd7c3 introduced a new role 'ensure-python' which checks for installed python version before our pre-run playbook can install not-default versions. Such change broke our py34 job. To continue checking Python 3.4 and ensure that everything is done as we wish let's do not use global 'tox' job and implement the custom one. The new rally-tox-base job checks tox.ini for required python version and installs it via 'apt'. Also, there is new post playbook which publishes the results of execution. Change-Id: Ia69d36670ff07079c82c9b1fef54d8ade62c7c7b --- .zuul.d/python-jobs.yaml | 80 ++++++++++++++----- .zuul.d/zuul.yaml | 35 ++++---- doc/requirements.txt | 1 - tests/ci/playbooks/pre-run-tox.yaml | 15 ---- .../ci/playbooks/rally-tox-base/post-run.yaml | 23 ++++++ .../ci/playbooks/rally-tox-base/pre-run.yaml | 62 ++++++++++++++ tests/ci/playbooks/rally-tox-base/run.yaml | 6 ++ tests/ci/rally_self_job.sh | 14 ++-- tox.ini | 2 +- 9 files changed, 179 insertions(+), 59 deletions(-) delete mode 100644 tests/ci/playbooks/pre-run-tox.yaml create mode 100644 tests/ci/playbooks/rally-tox-base/post-run.yaml create mode 100644 tests/ci/playbooks/rally-tox-base/pre-run.yaml create mode 100644 tests/ci/playbooks/rally-tox-base/run.yaml diff --git a/.zuul.d/python-jobs.yaml b/.zuul.d/python-jobs.yaml index 359c66f7e4..1a5c88a177 100644 --- a/.zuul.d/python-jobs.yaml +++ b/.zuul.d/python-jobs.yaml @@ -1,56 +1,98 @@ - job: - name: rally-tox-functional - parent: tox + name: rally-tox-base + parent: unittests + pre-run: tests/ci/playbooks/rally-tox-base/pre-run.yaml + run: tests/ci/playbooks/rally-tox-base/run.yaml + post-run: tests/ci/playbooks/rally-tox-base/post-run.yaml + description: | + Run test for rally project. + +- job: + name: rally-tox-docs + parent: rally-tox-base description: | Run test for rally project. Uses tox with the ``self`` environment. vars: - tox_envlist: functional + tox_env: docs + +- job: + name: rally0-tox-pep8 + parent: rally-tox-base + description: | + Run test for rally project. + + Uses tox with the ``self`` environment. + vars: + tox_env: pep8 + +- job: + name: rally-tox-functional + parent: rally-tox-base + description: | + Run test for rally project. + + Uses tox with the ``functional`` environment. + vars: + tox_env: functional - job: name: rally-tox-self - parent: tox + parent: rally-tox-base description: | Run test for rally project. Uses tox with the ``self`` environment. vars: - tox_envlist: self + tox_env: self - job: - name: rally-tox-py34 - parent: tox - nodeset: ubuntu-bionic - pre-run: tests/ci/playbooks/pre-run-tox.yaml + name: rally0-tox-py27 + parent: rally-tox-base description: | Run unit test for rally project. Uses tox with the ``py34`` environment. vars: - tox_envlist: py34 - python_version: 3.4 + tox_env: py27 + +- job: + name: rally-tox-py34 + parent: rally-tox-base + description: | + Run unit test for rally project. + + Uses tox with the ``py34`` environment. + vars: + tox_env: py34 + +- job: + name: rally0-tox-py35 + parent: rally-tox-base + description: | + Run unit test for rally project. + + Uses tox with the ``py35`` environment. + vars: + tox_env: py35 - job: name: rally-tox-py36 - parent: tox - nodeset: ubuntu-bionic + parent: rally-tox-base description: | Run unit test for rally project. Uses tox with the ``py36`` environment. vars: - tox_envlist: py36 + tox_env: py36 - job: name: rally-tox-py37 - parent: tox - nodeset: ubuntu-bionic - pre-run: tests/ci/playbooks/pre-run-tox.yaml + parent: rally-tox-base description: | Run unit test for rally project. Uses tox with the ``py37`` environment. vars: - tox_envlist: py37 - python_version: 3.7 + tox_env: py37 diff --git a/.zuul.d/zuul.yaml b/.zuul.d/zuul.yaml index 49e6319ac8..af93c2f37e 100644 --- a/.zuul.d/zuul.yaml +++ b/.zuul.d/zuul.yaml @@ -27,32 +27,37 @@ timeout: 1800 - project: - templates: - - openstack-python-jobs - - openstack-python35-jobs - - publish-openstack-docs-pti + #templates: + # - publish-openstack-docs-pti check: jobs: + - rally-tox-docs + - rally0-tox-pep8 + - rally0-tox-py27 + - rally-tox-py34 + - rally0-tox-py35 + - rally-tox-py36 + - rally-tox-py37 + - rally-tox-cover + - rally-tox-functional - rally-database-migration - rally-install-ubuntu-xenial - rally-install-ubuntu-bionic - rally-install-centos-7 - - rally-tox-cover - - rally-tox-functional - - rally-tox-py34 - - rally-tox-py36 - - rally-tox-py37 - rally-tox-self gate: jobs: + - rally-tox-docs + - rally0-tox-pep8 + - rally0-tox-py27 + - rally-tox-py34 + - rally0-tox-py35 + - rally-tox-py36 + - rally-tox-py37 + - rally-tox-cover + - rally-tox-functional - rally-database-migration - rally-install-ubuntu-xenial - rally-install-ubuntu-bionic - rally-install-centos-7 - - rally-tox-cover - - rally-tox-functional - - rally-tox-py34 - - rally-tox-py36 - - rally-tox-py37 - rally-tox-self - diff --git a/doc/requirements.txt b/doc/requirements.txt index 02d59d8dc1..841d0278e1 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -1,3 +1,2 @@ -rally-openstack # we are using theme from it oslosphinx \ No newline at end of file diff --git a/tests/ci/playbooks/pre-run-tox.yaml b/tests/ci/playbooks/pre-run-tox.yaml deleted file mode 100644 index 1d61afaa29..0000000000 --- a/tests/ci/playbooks/pre-run-tox.yaml +++ /dev/null @@ -1,15 +0,0 @@ - -- hosts: all - name: Installs all required packages - tasks: - - name: Install the proper python version - become: True - become_user: root - shell: - executable: /bin/sh - cmd: | - set -e - - add-apt-repository ppa:deadsnakes/ppa --yes - apt-get update - apt-get install python{{python_version}}-dev --yes diff --git a/tests/ci/playbooks/rally-tox-base/post-run.yaml b/tests/ci/playbooks/rally-tox-base/post-run.yaml new file mode 100644 index 0000000000..27ef5cbf2b --- /dev/null +++ b/tests/ci/playbooks/rally-tox-base/post-run.yaml @@ -0,0 +1,23 @@ +- hosts: all + vars: + results_dir: "{{ zuul.project.src_dir }}/.test_results/" + tasks: + - name: Check the existence of results dir + stat: + path: '{{ results_dir }}' + register: results_dir_stat + + - name: Save results + become: yes + when: results_dir_stat.stat.exists == True + synchronize: + src: "{{ results_dir }}" + dest: '{{ zuul.executor.log_root }}/' + mode: pull + copy_links: true + verify_host: true + rsync_opts: + - --include=/** + - --include=*/ + - --exclude=* + - --prune-empty-dirs diff --git a/tests/ci/playbooks/rally-tox-base/pre-run.yaml b/tests/ci/playbooks/rally-tox-base/pre-run.yaml new file mode 100644 index 0000000000..1038fecdab --- /dev/null +++ b/tests/ci/playbooks/rally-tox-base/pre-run.yaml @@ -0,0 +1,62 @@ + +- 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 + + add-apt-repository ppa:deadsnakes/ppa --yes + 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/sh + 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 + command: pip{{ python_version.stdout }} install tox + roles: + - bindep diff --git a/tests/ci/playbooks/rally-tox-base/run.yaml b/tests/ci/playbooks/rally-tox-base/run.yaml new file mode 100644 index 0000000000..a5c9a2b062 --- /dev/null +++ b/tests/ci/playbooks/rally-tox-base/run.yaml @@ -0,0 +1,6 @@ +- hosts: all + tasks: + - name: Run tox + args: + chdir: "{{ zuul.project.src_dir }}" + command: "tox -e{{ tox_env }}" diff --git a/tests/ci/rally_self_job.sh b/tests/ci/rally_self_job.sh index f8beff7ee3..128ffe6439 100755 --- a/tests/ci/rally_self_job.sh +++ b/tests/ci/rally_self_job.sh @@ -14,13 +14,11 @@ TASK_FILE=$1 PLUGIN_PATHS=rally-jobs/plugins -if [ -n "$ZUUL_PROJECT" ]; then - HTML_REPORT=testr_results.html - JSON_REPORT=testr_results.json -else - HTML_REPORT=rally_self_results.html - JSON_REPORT=rally_self_results.json -fi + +mkdir -p .test_results +HTML_REPORT=.test_results/rally_self_report.html +JSON_REPORT=.test_results/rally_self_results.json + RND=$(head /dev/urandom | tr -dc a-z0-9 | head -c 5) TMP_RALLY_CONF="/tmp/self-rally-$RND.conf" TMP_RALLY_DB="/tmp/self-rally-$RND.sqlite" @@ -33,7 +31,7 @@ sed -i.bak "s|#connection =.*|connection = \"$DBCONNSTRING\"|" $TMP_RALLY_CONF rally --config-file $TMP_RALLY_CONF db create # Create self deployment -$RALLY -d deployment create --name=self +$RALLY -d env create --name=self # Run task $RALLY -d --plugin-paths=$PLUGIN_PATHS task start $TASK_FILE diff --git a/tox.ini b/tox.ini index d762f40c06..c748b47e35 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,7 @@ commands = python {toxinidir}/tests/ci/pytest_launcher.py tests/unit --posargs={posargs} distribute = false basepython = python2.7 -passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY +passenv = PYTEST_REPORT http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY [testenv:pep8] commands = flake8