[ci] Include pytest html reports for functional job
Change-Id: I35c68ab5ad3ff9ac2f12f383489a18d55d2d0bf1
This commit is contained in:
parent
615961558d
commit
e73a897642
@ -17,5 +17,7 @@
|
|||||||
KEYSTONE_ADMIN_ENDPOINT: true
|
KEYSTONE_ADMIN_ENDPOINT: true
|
||||||
devstack_plugins:
|
devstack_plugins:
|
||||||
rally-openstack: https://opendev.org/openstack/rally-openstack
|
rally-openstack: https://opendev.org/openstack/rally-openstack
|
||||||
|
rally_home_dir: '/opt/stack/.rally'
|
||||||
|
rally_results_dir: '/opt/stack/.rally/results'
|
||||||
run: tests/ci/playbooks/run-rally-task.yaml
|
run: tests/ci/playbooks/run-rally-task.yaml
|
||||||
post-run: tests/ci/playbooks/post-rally-task.yaml
|
post-run: tests/ci/playbooks/post-rally-task.yaml
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
docker_repository: "xrally/xrally-openstack"
|
docker_repository: "xrally/xrally-openstack"
|
||||||
rally_plugin_name: "Dummy.openstack"
|
rally_plugin_name: "Dummy.openstack"
|
||||||
rally_package_name: "rally-openstack"
|
rally_package_name: "rally-openstack"
|
||||||
|
rally_results_dir: "{{ zuul.project.src_dir }}/.test_results/"
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: rally-openstack-docker-build-and-push
|
name: rally-openstack-docker-build-and-push
|
||||||
@ -59,3 +60,4 @@
|
|||||||
docker_repository: "xrally/xrally-openstack"
|
docker_repository: "xrally/xrally-openstack"
|
||||||
rally_plugin_name: "Dummy.openstack"
|
rally_plugin_name: "Dummy.openstack"
|
||||||
rally_package_name: "rally-openstack"
|
rally_package_name: "rally-openstack"
|
||||||
|
rally_results_dir: "{{ zuul.project.src_dir }}/.test_results/"
|
||||||
|
@ -20,4 +20,9 @@
|
|||||||
devstack_plugins:
|
devstack_plugins:
|
||||||
rally-openstack: https://opendev.org/openstack/rally-openstack
|
rally-openstack: https://opendev.org/openstack/rally-openstack
|
||||||
tox_env: "functional"
|
tox_env: "functional"
|
||||||
|
rally_home_dir: '/opt/stack/.rally'
|
||||||
|
rally_results_dir: '/opt/stack/.rally/results/'
|
||||||
|
html_report: 'tox_func_report.html'
|
||||||
|
non_default_html_report: 'tox_func_report.html'
|
||||||
run: tests/ci/playbooks/tox-functional-env-run.yaml
|
run: tests/ci/playbooks/tox-functional-env-run.yaml
|
||||||
|
post-run: tests/ci/playbooks/fetch-html-and-json-reports.yaml
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
- hosts: all
|
- hosts: all
|
||||||
vars:
|
vars:
|
||||||
results_dir: "{{ zuul.project.src_dir }}/.test_results/"
|
html_report: "{% if non_default_html_report is defined %}{{ non_default_html_report }}{% else %}{{ tox_env | default('self') }}_report.html{% endif %}"
|
||||||
html_report: "{{ tox_env | default('self') }}_report.html"
|
|
||||||
json_report: "{{ tox_env | default('self') }}_report.json"
|
json_report: "{{ tox_env | default('self') }}_report.json"
|
||||||
tasks:
|
tasks:
|
||||||
- shell: "ls {{ results_dir }}"
|
- shell: "ls {{ rally_results_dir }}"
|
||||||
register: results_dir_stat
|
register: results_dir_stat
|
||||||
ignore_errors: True
|
ignore_errors: True
|
||||||
|
|
||||||
@ -12,7 +11,7 @@
|
|||||||
become: yes
|
become: yes
|
||||||
when: results_dir_stat.rc == 0
|
when: results_dir_stat.rc == 0
|
||||||
synchronize:
|
synchronize:
|
||||||
src: "{{ results_dir }}"
|
src: "{{ rally_results_dir }}{% if not rally_results_dir.endswith('/')%}/{% endif %}"
|
||||||
dest: '{{ zuul.executor.log_root }}/'
|
dest: '{{ zuul.executor.log_root }}/'
|
||||||
mode: pull
|
mode: pull
|
||||||
copy_links: true
|
copy_links: true
|
||||||
@ -23,20 +22,20 @@
|
|||||||
- --exclude=*
|
- --exclude=*
|
||||||
- --prune-empty-dirs
|
- --prune-empty-dirs
|
||||||
|
|
||||||
- name: Return artifact to Zuul
|
- name: "Return artifact to Zuul - {{ html_report }}"
|
||||||
when: html_report in results_dir_stat.stdout
|
|
||||||
zuul_return:
|
zuul_return:
|
||||||
data:
|
data:
|
||||||
zuul:
|
zuul:
|
||||||
artifacts:
|
artifacts:
|
||||||
- name: "HTML report"
|
- name: "HTML report"
|
||||||
url: "{{ html_report }}"
|
url: "{{ html_report }}"
|
||||||
|
when: html_report in results_dir_stat.stdout
|
||||||
|
|
||||||
- name: Return artifact to Zuul
|
- name: "Return artifact to Zuul - {{ json_report}}"
|
||||||
when: json_report in results_dir_stat.stdout
|
|
||||||
zuul_return:
|
zuul_return:
|
||||||
data:
|
data:
|
||||||
zuul:
|
zuul:
|
||||||
artifacts:
|
artifacts:
|
||||||
- name: "JSON report"
|
- name: "JSON report"
|
||||||
url: "{{ json_report }}"
|
url: "{{ json_report }}"
|
||||||
|
when: json_report in results_dir_stat.stdout
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
become: True
|
become: True
|
||||||
become_user: stack
|
become_user: stack
|
||||||
file:
|
file:
|
||||||
path: '{{ rally_home_dir }}/results'
|
path: '{{ rally_results_dir }}'
|
||||||
state: directory
|
state: directory
|
||||||
owner: stack
|
owner: stack
|
||||||
group: stack
|
group: stack
|
||||||
@ -20,7 +20,7 @@
|
|||||||
become: True
|
become: True
|
||||||
become_user: stack
|
become_user: stack
|
||||||
file:
|
file:
|
||||||
path: '{{ rally_home_dir }}/results/{{ RALLY_OSPROFILER_CHART }}'
|
path: '{{ rally_results_dir }}/{{ RALLY_OSPROFILER_CHART }}'
|
||||||
state: directory
|
state: directory
|
||||||
owner: stack
|
owner: stack
|
||||||
group: stack
|
group: stack
|
||||||
|
@ -4,24 +4,23 @@
|
|||||||
|
|
||||||
- hosts: controller
|
- hosts: controller
|
||||||
vars:
|
vars:
|
||||||
rally_home_dir: '/opt/stack/.rally'
|
|
||||||
rally_fake_image_path: '{{ rally_home_dir }}/extra/fake-image.img'
|
rally_fake_image_path: '{{ rally_home_dir }}/extra/fake-image.img'
|
||||||
rally_task_args_file: "100-percent-not-exist-file"
|
rally_task_args_file: "100-percent-not-exist-file"
|
||||||
# this task will not be launched, but we need to specify something real to
|
# this task will not be launched, but we need to specify something real to
|
||||||
# pass a check at 'prepare-for-rally-task' role.
|
# pass a check at 'prepare-for-rally-task' role.
|
||||||
rally_task: "rally-jobs/simple-job.yaml"
|
rally_task: "rally-jobs/simple-job.yaml"
|
||||||
pip_install: "/opt/stack/rally-openstack/.tox/{{ tox_env }}/bin/pip install"
|
pip_install: "/opt/stack/rally-openstack/.tox/{{ tox_env }}/bin/pip install"
|
||||||
|
become: true
|
||||||
|
become_user: stack
|
||||||
tasks:
|
tasks:
|
||||||
- name: "Trigger prepare tasks of rally-task-at-devstack zuul job"
|
- name: "Trigger prepare tasks of rally-task-at-devstack zuul job"
|
||||||
import_role:
|
import_role:
|
||||||
name: prepare-for-rally-task
|
name: prepare-for-rally-task
|
||||||
|
|
||||||
- block:
|
|
||||||
|
|
||||||
- name: "Precreate a virtualenv for tox {{ tox_env }}"
|
- name: "Precreate a virtualenv for tox {{ tox_env }}"
|
||||||
command: tox -e {{ tox_env }} --notest
|
command: tox -e {{ tox_env }} --notest
|
||||||
args:
|
args:
|
||||||
chdir: /opt/stack/rally-openstack
|
chdir: "/opt/stack/rally-openstack"
|
||||||
|
|
||||||
- name: Check rally db connection
|
- name: Check rally db connection
|
||||||
command: rally db show
|
command: rally db show
|
||||||
@ -40,13 +39,10 @@
|
|||||||
when: "'pymysql' in rally_db_connection.stdout"
|
when: "'pymysql' in rally_db_connection.stdout"
|
||||||
|
|
||||||
- name: Run tox command
|
- name: Run tox command
|
||||||
shell: |
|
shell: tox -e {{ tox_env }}
|
||||||
set -e
|
environment:
|
||||||
|
REQUESTS_CA_BUNDLE: /opt/stack/data/ca-bundle.pem
|
||||||
export REQUESTS_CA_BUNDLE=/opt/stack/data/ca-bundle.pem
|
REPORTS_ROOT: "{{ rally_results_dir }}/reports"
|
||||||
|
PYTEST_REPORT: "{{ rally_results_dir }}/{{ html_report }}"
|
||||||
tox -e {{ tox_env }}
|
|
||||||
args:
|
args:
|
||||||
chdir: /opt/stack/rally-openstack
|
chdir: "/opt/stack/rally-openstack"
|
||||||
become: True
|
|
||||||
become_user: stack
|
|
||||||
|
@ -17,9 +17,10 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
PYTEST_REPORT = os.environ.get("PYTEST_REPORT",
|
TOX_ENV_NAME = os.environ["TOX_ENV_NAME"]
|
||||||
".test_results/pytest_results.html")
|
DEFAULT_REPORT_ROOT = os.environ.get("REPORTS_ROOT", ".test_results")
|
||||||
TESTR_REPORT = "testr_results.html"
|
DEFAULT_REPORT = f"{DEFAULT_REPORT_ROOT}/{TOX_ENV_NAME}_report.html"
|
||||||
|
PYTEST_REPORT = os.environ.get("PYTEST_REPORT", DEFAULT_REPORT)
|
||||||
PYTEST_ARGUMENTS = ("py.test" # base command
|
PYTEST_ARGUMENTS = ("py.test" # base command
|
||||||
" -vv" # show test names in logs
|
" -vv" # show test names in logs
|
||||||
" --html=%(html_report)s" # html report
|
" --html=%(html_report)s" # html report
|
||||||
@ -86,17 +87,7 @@ def main(args):
|
|||||||
|
|
||||||
print("Test(s) to launch (pytest format): %s" % path)
|
print("Test(s) to launch (pytest format): %s" % path)
|
||||||
|
|
||||||
# NOTE(andreykurilin): we cannot publish pytest reports at gates, but we
|
args = PYTEST_ARGUMENTS % {"html_report": PYTEST_REPORT,
|
||||||
# can mask them as testr reports. It looks like a dirty hack and I
|
|
||||||
# prefer to avoid it, but I see no other solutions at this point.
|
|
||||||
|
|
||||||
# apply dirty hack only in gates.
|
|
||||||
if os.environ.get("ZUUL_PROJECT"):
|
|
||||||
pytest_report = TESTR_REPORT
|
|
||||||
else:
|
|
||||||
pytest_report = PYTEST_REPORT
|
|
||||||
|
|
||||||
args = PYTEST_ARGUMENTS % {"html_report": pytest_report,
|
|
||||||
"path": path,
|
"path": path,
|
||||||
"concurrency": args.concurrency or "auto"}
|
"concurrency": args.concurrency or "auto"}
|
||||||
try:
|
try:
|
||||||
@ -104,15 +95,6 @@ def main(args):
|
|||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
# NOTE(andreykurilin): it is ok, since tests can fail.
|
# NOTE(andreykurilin): it is ok, since tests can fail.
|
||||||
exit_code = 1
|
|
||||||
else:
|
|
||||||
exit_code = 0
|
|
||||||
|
|
||||||
if os.path.exists(pytest_report) and os.environ.get("ZUUL_PROJECT"):
|
|
||||||
subprocess.check_call(["gzip", "-9", "-f", pytest_report],
|
|
||||||
stderr=subprocess.STDOUT)
|
|
||||||
|
|
||||||
if exit_code == 1:
|
|
||||||
error("")
|
error("")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user