Skip to content

Commit

Permalink
Merge "[ci] Register job reports as zuul atrifacts"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and openstack-gerrit committed Feb 25, 2020
2 parents f28216f + 89e1cb8 commit 12404b8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
27 changes: 23 additions & 4 deletions tests/ci/playbooks/rally-tox-base/post-run.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
- hosts: all
vars:
results_dir: "{{ zuul.project.src_dir }}/.test_results/"
html_report: "{{ tox_env }}_report.html"
json_report: "{{ tox_env }}_report.html"
tasks:
- name: Check the existence of results dir
stat:
path: '{{ results_dir }}'
- shell: "ls {{ results_dir }}"
register: results_dir_stat
ignore_errors: True

- name: Save results
become: yes
when: results_dir_stat.stat.exists == True
when: results_dir_stat.rc == 0
synchronize:
src: "{{ results_dir }}"
dest: '{{ zuul.executor.log_root }}/'
Expand All @@ -21,3 +22,21 @@
- --include=*/
- --exclude=*
- --prune-empty-dirs

- name: Return artifact to Zuul
when: html_report in results_dir_stat.stdout
zuul_return:
data:
zuul:
artifacts:
- name: "HTML report"
url: "{{ html_report }}"

- name: Return artifact to Zuul
when: json_report in results_dir_stat.stdout
zuul_return:
data:
zuul:
artifacts:
- name: "JSON report"
url: "{{ json_report }}"
26 changes: 3 additions & 23 deletions tests/ci/pytest_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
import sys


PYTEST_REPORT = os.environ.get("PYTEST_REPORT",
".test_results/pytest_results.html")
TESTR_REPORT = "testr_results.html"
DEFAULT_REPORT = ".test_results/%s_report.html" % os.environ["TOX_ENV_NAME"]
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
Expand Down Expand Up @@ -86,33 +85,14 @@ 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:
subprocess.check_call(args.split(" "),
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("")


Expand Down
4 changes: 2 additions & 2 deletions tests/ci/rally_self_job.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ TASK_FILE=$1
PLUGIN_PATHS=rally-jobs/plugins

mkdir -p .test_results
HTML_REPORT=.test_results/rally_self_report.html
JSON_REPORT=.test_results/rally_self_results.json
HTML_REPORT=.test_results/self_report.html
JSON_REPORT=.test_results/self_report.json

RND=$(head /dev/urandom | tr -dc a-z0-9 | head -c 5)
TMP_RALLY_CONF="/tmp/self-rally-$RND.conf"
Expand Down

0 comments on commit 12404b8

Please sign in to comment.