Skip to content

Commit 9dbc277

Browse files
authored
[ci] Update report_results to use XML files (#246)
* [ci] Update report_result to look in xml files for failures * Remove the custom_logger failure counter This change means we can just use "TEST" to mark the testcases, and we don't have to add in fake or placeholder IDs Jira: https://issues.redhat.com/browse/OSPRH-15511 * [zuul] Run jobs when there's a change to ci/report_results.yml
1 parent 46a2f9f commit 9dbc277

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

.zuul.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
- ci/vars-use-master-containers.yml
132132
- ci/use-master-containers.yml
133133
- ci/patch-openstack-version.yaml
134+
- ci/report_result.yml
134135
- functional-logging-tests-osp18:
135136
irrelevant-files: *irrelevant_files
136137
files:
@@ -140,6 +141,7 @@
140141
- ci/logging_tests_all.yml
141142
- ci/logging_tests_computes.yml
142143
- ci/logging_tests_controller.yml
144+
- ci/report_result.yml
143145
- functional-graphing-tests-osp18:
144146
voting:
145147
false
@@ -149,10 +151,12 @@
149151
- .zuul.yaml
150152
- ci/vars-graphing-test.yml
151153
- ci/run_graphing_test.yml
154+
- ci/report_result.yml
152155
- functional-metric-verification-tests-osp18:
153156
irrelevant-files: *irrelevant_files
154157
files:
155158
- roles/telemetry_verify_metrics/.*
156159
- .zuul.yaml
157160
- ci/vars-metric-verification-test.yml
158161
- ci/run_verify_metrics_osp18.yml
162+
- ci/report_result.yml

ci/report_result.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
vars_files:
2020
- vars/common.yml
2121
tasks:
22-
- name: "Find the XML file"
22+
- name: "Find the XML file(s)"
2323
ansible.builtin.shell:
2424
cmd: |
25-
find ~/.ansible.log/ -name *.xml
25+
find {{ custom_xml_output_dir }} -name *.xml
2626
register: xml_file_list
2727
ignore_errors: true
2828

@@ -54,28 +54,36 @@
5454
src: "{{ ansible_env.HOME }}/summary_results.log"
5555
dest: "{{ logs_dir }}/summary_result.log"
5656

57-
- name: "Check the results files for failed tasks"
57+
- name: Check the XML file for failed tasks
5858
hosts: controller
5959
gather_facts: true
6060
vars_files:
6161
- vars/common.yml
6262
tasks:
63-
- name: Grep the number of failed tasks
64-
ansible.builtin.shell:
65-
cmd: |
66-
grep "failed" {{ logs_dir }}/test_run_result.out
67-
register: tasks_failed
68-
# The RC from grep is 1 when there is no string matched (i.e. when there are no failures)
69-
ignore_errors: yes
63+
- name: "Get the matching lines in the results files"
64+
ansible.builtin.command:
65+
cmd: |
66+
grep -r "<testsuites .*>$" {{ custom_xml_output_dir }}/
67+
register: verbose_matches
68+
ignore_errors: true
69+
70+
- name: "Get the number of failed testcases"
71+
ansible.builtin.set_fact:
72+
tasks_failed: "{{ verbose_matches.stdout | regex_replace('.*failures=\"([0-9]*)\".*>', '\\1') | split('\n') | map('int') | sum }}"
7073

7174
# The RC from grep is 0 if the string is matched
75+
- name: Fail when there's a testcase failure
76+
ansible.builtin.fail:
77+
msg: There were {{ tasks_failed }} failed testcases.
78+
when: tasks_failed | int > 0 and verbose_matches.rc == 0
79+
7280
- name: Determine success or failure based on the number of failed tasks
7381
ansible.builtin.fail:
7482
msg: "The log file(s) contain failed task."
75-
when: tasks_failed.stdout_lines | length > 0 and tasks_failed.rc == 0
83+
when: tasks_failed | int > 0 and verbose_matches.rc == 0
7684

7785
# The RC from grep is 2 if an error occurred.
7886
- name: Fail if the file was not found (or other grep error)
7987
ansible.builtin.fail:
80-
msg: "{{ tasks_failed.stderr if tasks_failed.stderr | length > 0 else 'There was an error with grep.' }}"
81-
when: tasks_failed.rc > 1
88+
msg: "{{ verbose_matches.stderr if verbose_matches.stderr | length > 0 else 'There was an error with grep.' }}"
89+
when: verbose_matches.rc > 1

ci/vars/common.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
---
22
fvt_dir: "{{ ansible_env.HOME }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}"
33
logs_dir: "{{ ansible_env.HOME }}/ci-framework-data/logs/feature-verification-tests"
4+
custom_xml_output_dir: "~/.ansible.log/"

0 commit comments

Comments
 (0)