[ci] Include pytest html reports for functional job

Change-Id: I35c68ab5ad3ff9ac2f12f383489a18d55d2d0bf1
This commit is contained in:
Andrey Kurilin 2023-12-07 16:19:14 +01:00
parent 615961558d
commit e73a897642
8 changed files with 53 additions and 65 deletions

View File

@ -17,5 +17,7 @@
KEYSTONE_ADMIN_ENDPOINT: true
devstack_plugins:
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
post-run: tests/ci/playbooks/post-rally-task.yaml

View File

@ -40,6 +40,7 @@
docker_repository: "xrally/xrally-openstack"
rally_plugin_name: "Dummy.openstack"
rally_package_name: "rally-openstack"
rally_results_dir: "{{ zuul.project.src_dir }}/.test_results/"
- job:
name: rally-openstack-docker-build-and-push
@ -59,3 +60,4 @@
docker_repository: "xrally/xrally-openstack"
rally_plugin_name: "Dummy.openstack"
rally_package_name: "rally-openstack"
rally_results_dir: "{{ zuul.project.src_dir }}/.test_results/"

View File

@ -20,4 +20,9 @@
devstack_plugins:
rally-openstack: https://opendev.org/openstack/rally-openstack
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
post-run: tests/ci/playbooks/fetch-html-and-json-reports.yaml

View File

@ -1,10 +1,9 @@
- hosts: all
vars:
results_dir: "{{ zuul.project.src_dir }}/.test_results/"
html_report: "{{ tox_env | default('self') }}_report.html"
html_report: "{% if non_default_html_report is defined %}{{ non_default_html_report }}{% else %}{{ tox_env | default('self') }}_report.html{% endif %}"
json_report: "{{ tox_env | default('self') }}_report.json"
tasks:
- shell: "ls {{ results_dir }}"
- shell: "ls {{ rally_results_dir }}"
register: results_dir_stat
ignore_errors: True
@ -12,7 +11,7 @@
become: yes
when: results_dir_stat.rc == 0
synchronize:
src: "{{ results_dir }}"
src: "{{ rally_results_dir }}{% if not rally_results_dir.endswith('/')%}/{% endif %}"
dest: '{{ zuul.executor.log_root }}/'
mode: pull
copy_links: true
@ -23,20 +22,20 @@
- --exclude=*
- --prune-empty-dirs
- name: Return artifact to Zuul
when: html_report in results_dir_stat.stdout
- name: "Return artifact to Zuul - {{ html_report }}"
zuul_return:
data:
zuul:
artifacts:
- name: "HTML report"
url: "{{ html_report }}"
when: html_report in results_dir_stat.stdout
- name: Return artifact to Zuul
when: json_report in results_dir_stat.stdout
- name: "Return artifact to Zuul - {{ json_report}}"
zuul_return:
data:
zuul:
artifacts:
- name: "JSON report"
url: "{{ json_report }}"
when: json_report in results_dir_stat.stdout

View File

@ -11,7 +11,7 @@
become: True
become_user: stack
file:
path: '{{ rally_home_dir }}/results'
path: '{{ rally_results_dir }}'
state: directory
owner: stack
group: stack
@ -20,7 +20,7 @@
become: True
become_user: stack
file:
path: '{{ rally_home_dir }}/results/{{ RALLY_OSPROFILER_CHART }}'
path: '{{ rally_results_dir }}/{{ RALLY_OSPROFILER_CHART }}'
state: directory
owner: stack
group: stack

View File

@ -4,24 +4,23 @@
- hosts: controller
vars:
rally_home_dir: '/opt/stack/.rally'
rally_fake_image_path: '{{ rally_home_dir }}/extra/fake-image.img'
rally_task_args_file: "100-percent-not-exist-file"
# this task will not be launched, but we need to specify something real to
# pass a check at 'prepare-for-rally-task' role.
rally_task: "rally-jobs/simple-job.yaml"
pip_install: "/opt/stack/rally-openstack/.tox/{{ tox_env }}/bin/pip install"
become: true
become_user: stack
tasks:
- name: "Trigger prepare tasks of rally-task-at-devstack zuul job"
import_role:
name: prepare-for-rally-task
- block:
- name: "Precreate a virtualenv for tox {{ tox_env }}"
command: tox -e {{ tox_env }} --notest
args:
chdir: /opt/stack/rally-openstack
chdir: "/opt/stack/rally-openstack"
- name: Check rally db connection
command: rally db show
@ -40,13 +39,10 @@
when: "'pymysql' in rally_db_connection.stdout"
- name: Run tox command
shell: |
set -e
export REQUESTS_CA_BUNDLE=/opt/stack/data/ca-bundle.pem
tox -e {{ tox_env }}
shell: tox -e {{ tox_env }}
environment:
REQUESTS_CA_BUNDLE: /opt/stack/data/ca-bundle.pem
REPORTS_ROOT: "{{ rally_results_dir }}/reports"
PYTEST_REPORT: "{{ rally_results_dir }}/{{ html_report }}"
args:
chdir: /opt/stack/rally-openstack
become: True
become_user: stack
chdir: "/opt/stack/rally-openstack"

View File

@ -17,9 +17,10 @@ import subprocess
import sys
PYTEST_REPORT = os.environ.get("PYTEST_REPORT",
".test_results/pytest_results.html")
TESTR_REPORT = "testr_results.html"
TOX_ENV_NAME = os.environ["TOX_ENV_NAME"]
DEFAULT_REPORT_ROOT = os.environ.get("REPORTS_ROOT", ".test_results")
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
" -vv" # show test names in logs
" --html=%(html_report)s" # html report
@ -86,17 +87,7 @@ def main(args):
print("Test(s) to launch (pytest format): %s" % path)
# NOTE(andreykurilin): we cannot publish pytest reports at gates, but we
# 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,
args = PYTEST_ARGUMENTS % {"html_report": PYTEST_REPORT,
"path": path,
"concurrency": args.concurrency or "auto"}
try:
@ -104,15 +95,6 @@ def main(args):
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError:
# 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("")

View File

@ -33,6 +33,8 @@ passenv =
NO_PROXY
REQUESTS_CA_BUNDLE
HOME
REPORTS_ROOT
PYTEST_REPORT
[testenv:pep8]
deps = -r{toxinidir}/test-requirements.txt