Add a generic process-test-results role
Takes an stestr or testr repo as input and generates a subunit file and an html report out of it. The files are stored in the staging area on the test node. This in combination with a generic role to pull the staging folder to the zuul executor is meant to eventually replace to existing roles: - fetch-testr-output - fetch-stestr-output Change-Id: Id6149d4e265ab9f0ab6d8faeffdec651c63dc056
This commit is contained in:
parent
2ea8661801
commit
7bd86fcd99
35
roles/process-test-results/README.rst
Normal file
35
roles/process-test-results/README.rst
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
Process test results
|
||||||
|
|
||||||
|
Take a testr / stestr repo as input. Produce subunit from the latest
|
||||||
|
run and the html report using subunit2html.
|
||||||
|
|
||||||
|
**Role Variables**
|
||||||
|
|
||||||
|
.. zuul:rolevar:: test_results_dir
|
||||||
|
:default: None
|
||||||
|
|
||||||
|
The folder where the [s]testr repo lives.
|
||||||
|
|
||||||
|
.. zuul:rolevar:: tox_envdir
|
||||||
|
:default: venv
|
||||||
|
|
||||||
|
The name of the virtual environemnt created by tox to run tests.
|
||||||
|
This may be different from the name of the tox environment.
|
||||||
|
|
||||||
|
.. zuul:rolevar:: stage_dir
|
||||||
|
:default: {{ ansible_user_dir }}
|
||||||
|
|
||||||
|
Folder into which the output files will be written. Assumption is that
|
||||||
|
the user that runs this role has read access to test results and write
|
||||||
|
access to tempest_work_dir.
|
||||||
|
|
||||||
|
.. zuul:rolevar:: subunit2html
|
||||||
|
:default: /usr/os-testr-env/bin/subunit2html
|
||||||
|
|
||||||
|
The full path to subunit2html. This utility is part of os-testr,
|
||||||
|
and it's usually baked into test images, hence the default value.
|
||||||
|
|
||||||
|
.. zuul:rolevar:: test_results_stage_name
|
||||||
|
:default: test_results
|
||||||
|
|
||||||
|
The name of the subunit and html files generated.
|
4
roles/process-test-results/defaults/main.yaml
Normal file
4
roles/process-test-results/defaults/main.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
tox_envdir: venv
|
||||||
|
stage_dir: "{{ ansible_user_dir }}"
|
||||||
|
subunit2html: /usr/os-testr-env/bin/subunit2html
|
||||||
|
test_results_stage_name: test_results
|
49
roles/process-test-results/tasks/main.yaml
Normal file
49
roles/process-test-results/tasks/main.yaml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# NOTE(andreaf) There could be more than one repo in the test folder.
|
||||||
|
# Since that's unlikely we don't provide a variable to select the
|
||||||
|
# test runner and we pick the first hit.
|
||||||
|
- name: Discover stestr repo
|
||||||
|
stat:
|
||||||
|
path: "{{ test_results_dir }}/.stestr"
|
||||||
|
register: stestr_repo
|
||||||
|
|
||||||
|
- name: Discover testr repo
|
||||||
|
stat:
|
||||||
|
path: "{{ test_results_dir }}/.testrepository"
|
||||||
|
register: testr_repo
|
||||||
|
when: not stestr_repo.stat.exists
|
||||||
|
|
||||||
|
- name: Use stestr test runner
|
||||||
|
set_fact:
|
||||||
|
test_runner: ".tox/{{ tox_envdir }}/bin/stestr"
|
||||||
|
when: stestr_repo.stat.exists
|
||||||
|
|
||||||
|
- name: Use legacy testr test runner
|
||||||
|
set_fact:
|
||||||
|
test_runner: ".tox/{{ tox_envdir }}/bin/testr"
|
||||||
|
when: not stestr_repo.stat.exists and testr_repo.stat.exists
|
||||||
|
|
||||||
|
- name: Check if the venv has been created
|
||||||
|
stat:
|
||||||
|
path: "{{ test_results_dir }}/.tox/{{ tox_envdir }}"
|
||||||
|
register: run_venv
|
||||||
|
|
||||||
|
- name: Make sure test results are world readable
|
||||||
|
file:
|
||||||
|
path: "{{ test_results_dir }}"
|
||||||
|
mode: "a+rX"
|
||||||
|
recurse: true
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Create a subunit file from the last run
|
||||||
|
shell: "{{ test_runner }} last --subunit > {{ stage_dir }}/{{ test_results_stage_name }}.subunit"
|
||||||
|
args:
|
||||||
|
chdir: "{{ test_results_dir }}"
|
||||||
|
when: run_venv.stat.exists and test_runner is defined
|
||||||
|
register: subunit_report
|
||||||
|
|
||||||
|
- name: Generate the html report for the last run
|
||||||
|
command: "{{ subunit2html }} ./{{ test_results_stage_name}}.subunit {{ test_results_stage_name }}.html"
|
||||||
|
args:
|
||||||
|
chdir: "{{ stage_dir }}"
|
||||||
|
when: run_venv.stat.exists and test_runner is defined
|
||||||
|
register: html_report
|
Loading…
Reference in New Issue
Block a user