Skip to content

Commit 112ec6b

Browse files
sauragarclaude
andcommitted
Add stackviz integration for tempest test results
This commit adds automatic stackviz HTML report generation for tempest test results in the test_operator role. Changes: - Add generate-stackviz.yml task file to handle stackviz generation - Integrate stackviz generation into run-test-operator-job.yml - Add cifmw_test_operator_generate_stackviz config variable - Add STACKVIZ_INTEGRATION.md documentation The integration automatically: 1. Finds tempest_results.subunit.gz in collected logs 2. Decompresses the subunit file 3. Runs stackviz-export to generate interactive HTML 4. Stores output in <artifacts_basedir>/stackviz/html/ Users can disable this feature by setting: cifmw_test_operator_generate_stackviz: false Signed-off-by: Saurabh Agarwal <[email protected]> Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent fa76f14 commit 112ec6b

File tree

4 files changed

+278
-0
lines changed

4 files changed

+278
-0
lines changed

roles/test_operator/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ cifmw_test_operator_storage_class: "{{ cifmw_test_operator_storage_class_prefix
4242
cifmw_test_operator_delete_logs_pod: false
4343
cifmw_test_operator_privileged: true
4444
cifmw_test_operator_selinux_level: "s0:c478,c978"
45+
cifmw_test_operator_generate_stackviz: true
4546
cifmw_test_operator_crs_path: "{{ cifmw_basedir }}/artifacts/test-operator-crs"
4647
cifmw_test_operator_log_pod_definition:
4748
apiVersion: v1
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Stackviz Integration for Tempest Results
2+
3+
## Overview
4+
This integration automatically generates HTML visualization reports from Tempest test results using Stackviz. The reports are generated automatically after each Tempest run when using the test_operator role.
5+
6+
## Files Modified/Created
7+
8+
### New Files
9+
- `tasks/generate-stackviz.yml` - Main task file that handles stackviz HTML generation
10+
11+
### Modified Files
12+
- `tasks/run-test-operator-job.yml` - Added include statement to call stackviz generation after log collection
13+
- `defaults/main.yml` - Added `cifmw_test_operator_generate_stackviz` configuration variable
14+
15+
## How It Works
16+
17+
1. **After tempest completes**, logs are collected from the test-operator PVCs
18+
2. **The script searches** for `tempest_results.subunit.gz` in the artifacts directory
19+
3. **Decompresses** the gzipped subunit file
20+
4. **Runs stackviz-export** to convert subunit data to interactive HTML
21+
5. **Stores the HTML report** in `<artifacts_basedir>/stackviz/html/index.html`
22+
23+
## Configuration
24+
25+
### Enable/Disable Stackviz Generation
26+
```yaml
27+
# In your scenario file or playbook variables
28+
cifmw_test_operator_generate_stackviz: true # Default: true
29+
```
30+
31+
Set to `false` to disable stackviz generation.
32+
33+
## Output Location
34+
35+
After a successful tempest run, the stackviz HTML report will be available at:
36+
```
37+
~/ci-framework-data/tests/test_operator/stackviz/html/index.html
38+
```
39+
40+
You can open this file directly in a web browser:
41+
```bash
42+
firefox ~/ci-framework-data/tests/test_operator/stackviz/html/index.html
43+
```
44+
45+
Or via file:// URL in your browser.
46+
47+
## Dependencies
48+
49+
The role will automatically install required dependencies:
50+
- `python3-pip` (system package)
51+
- `stackviz` (Python package via pip)
52+
53+
## Integration with CI/CD Artifacts
54+
55+
To publish the stackviz HTML to your CI/CD system, you can add a task after the test_operator role runs:
56+
57+
### Example: Publishing to Jenkins/Zuul Artifacts
58+
```yaml
59+
- name: Upload stackviz HTML to artifacts storage
60+
ansible.builtin.copy:
61+
src: "{{ cifmw_test_operator_artifacts_basedir }}/stackviz/"
62+
dest: "{{ zuul.executor.log_root }}/stackviz/"
63+
remote_src: true
64+
when: stackviz_html_path is defined
65+
```
66+
67+
### Example: Publishing to S3/Swift
68+
```yaml
69+
- name: Upload stackviz to object storage
70+
amazon.aws.s3_sync:
71+
bucket: "{{ ci_artifacts_bucket }}"
72+
file_root: "{{ cifmw_test_operator_artifacts_basedir }}/stackviz/html"
73+
key_prefix: "tempest-results/{{ zuul.build }}/stackviz"
74+
when: stackviz_html_path is defined
75+
```
76+
77+
## Troubleshooting
78+
79+
### Subunit file not found
80+
If you see the warning "No tempest_results.subunit.gz file found", check:
81+
1. Tempest actually ran and completed
82+
2. Logs were successfully collected from the PVCs
83+
3. The expected file path: `{{ cifmw_test_operator_artifacts_basedir }}/**/tempest_results.subunit.gz`
84+
85+
### Stackviz export failed
86+
Check the ansible output for the error message. Common issues:
87+
- Corrupted subunit file
88+
- Incompatible stackviz version
89+
- Insufficient disk space
90+
91+
### Installation failures
92+
If stackviz installation fails:
93+
```bash
94+
# Manually install stackviz
95+
sudo pip3 install stackviz
96+
97+
# Or use a specific version
98+
sudo pip3 install stackviz==0.28
99+
```
100+
101+
## Example Usage
102+
103+
```yaml
104+
- name: Run tempest tests with stackviz
105+
hosts: controller
106+
vars:
107+
cifmw_test_operator_generate_stackviz: true
108+
cifmw_test_operator_artifacts_basedir: "/home/zuul/tempest-artifacts"
109+
roles:
110+
- test_operator
111+
```
112+
113+
## Future Enhancements
114+
115+
Potential improvements for this integration:
116+
1. Add support for comparing multiple test runs
117+
2. Integration with ReportPortal for centralized test reporting
118+
3. Automatic upload to centralized artifact storage
119+
4. Email notifications with stackviz report links
120+
5. Support for other test frameworks (tobiko, etc.)
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
- name: Generate stackviz HTML from tempest results
18+
when:
19+
- not cifmw_test_operator_dry_run | bool
20+
- cifmw_test_operator_generate_stackviz | default(true) | bool
21+
- run_test_fw == 'tempest'
22+
block:
23+
- name: Find tempest_results.subunit.gz file in collected logs
24+
ansible.builtin.find:
25+
paths: "{{ cifmw_test_operator_artifacts_basedir }}"
26+
patterns: "tempest_results.subunit.gz"
27+
file_type: file
28+
recurse: true
29+
register: subunit_files
30+
31+
- name: Process stackviz generation
32+
when: subunit_files.matched > 0
33+
block:
34+
- name: Set subunit file path
35+
ansible.builtin.set_fact:
36+
tempest_subunit_gz: "{{ subunit_files.files[0].path }}"
37+
38+
- name: Display subunit file location
39+
ansible.builtin.debug:
40+
msg: "Found tempest subunit file at: {{ tempest_subunit_gz }}"
41+
42+
- name: Create stackviz output directory
43+
ansible.builtin.file:
44+
path: "{{ cifmw_test_operator_artifacts_basedir }}/stackviz"
45+
state: directory
46+
mode: "0755"
47+
48+
- name: Check if stackviz is installed
49+
ansible.builtin.command: which stackviz-export
50+
register: stackviz_check
51+
failed_when: false
52+
changed_when: false
53+
54+
- name: Install stackviz
55+
when: stackviz_check.rc != 0
56+
block:
57+
- name: Ensure pip is available
58+
ansible.builtin.package:
59+
name: python3-pip
60+
state: present
61+
become: true
62+
63+
- name: Install stackviz via pip
64+
ansible.builtin.pip:
65+
name: stackviz
66+
state: present
67+
executable: pip3
68+
become: true
69+
70+
- name: Decompress subunit file
71+
ansible.builtin.command:
72+
cmd: >
73+
gunzip -c {{ tempest_subunit_gz }}
74+
chdir: "{{ cifmw_test_operator_artifacts_basedir }}/stackviz"
75+
register: decompressed_subunit
76+
changed_when: false
77+
78+
- name: Write decompressed subunit to file
79+
ansible.builtin.copy:
80+
content: "{{ decompressed_subunit.stdout }}"
81+
dest: "{{ cifmw_test_operator_artifacts_basedir }}/stackviz/tempest_results.subunit"
82+
mode: "0644"
83+
84+
- name: Check if decompressed subunit file exists
85+
ansible.builtin.stat:
86+
path: "{{ cifmw_test_operator_artifacts_basedir }}/stackviz/tempest_results.subunit"
87+
register: subunit_file
88+
89+
- name: Generate stackviz HTML from subunit file
90+
when: subunit_file.stat.exists
91+
block:
92+
- name: Run stackviz-export
93+
ansible.builtin.command:
94+
cmd: >
95+
stackviz-export
96+
{{ cifmw_test_operator_artifacts_basedir }}/stackviz/tempest_results.subunit
97+
{{ cifmw_test_operator_artifacts_basedir }}/stackviz/html
98+
chdir: "{{ cifmw_test_operator_artifacts_basedir }}/stackviz"
99+
register: stackviz_export
100+
failed_when: false
101+
102+
- name: Display stackviz export status
103+
ansible.builtin.debug:
104+
msg: |
105+
Stackviz export completed with return code: {{ stackviz_export.rc }}
106+
{% if stackviz_export.rc == 0 %}
107+
HTML report available at: {{ cifmw_test_operator_artifacts_basedir }}/stackviz/html/index.html
108+
{% else %}
109+
Stackviz export failed. Check logs for details.
110+
Output: {{ stackviz_export.stdout }}
111+
Error: {{ stackviz_export.stderr }}
112+
{% endif %}
113+
114+
- name: Set stackviz HTML path fact
115+
when: stackviz_export.rc == 0
116+
ansible.builtin.set_fact:
117+
stackviz_html_path: "{{ cifmw_test_operator_artifacts_basedir }}/stackviz/html/index.html"
118+
119+
- name: Verify stackviz HTML was generated
120+
when: stackviz_export.rc == 0
121+
ansible.builtin.stat:
122+
path: "{{ stackviz_html_path }}"
123+
register: stackviz_html
124+
125+
- name: Display success message
126+
when:
127+
- stackviz_export.rc == 0
128+
- stackviz_html.stat.exists
129+
ansible.builtin.debug:
130+
msg: |
131+
========================================
132+
Stackviz HTML Report Generated Successfully!
133+
========================================
134+
Location: {{ stackviz_html_path }}
135+
136+
To view the report, open the following file in your browser:
137+
file://{{ stackviz_html_path }}
138+
========================================
139+
140+
- name: Warn if decompressed subunit file was not created
141+
when: not subunit_file.stat.exists
142+
ansible.builtin.debug:
143+
msg: |
144+
WARNING: Decompressed subunit file was not created.
145+
This may indicate an issue with decompressing {{ tempest_subunit_gz }}.
146+
Skipping stackviz generation.
147+
148+
- name: Warn if no subunit file found
149+
when: subunit_files.matched == 0
150+
ansible.builtin.debug:
151+
msg: |
152+
WARNING: No tempest_results.subunit.gz file found in tempest logs.
153+
Stackviz HTML generation skipped.
154+
Expected location: {{ cifmw_test_operator_artifacts_basedir }}/**/tempest_results.subunit.gz

roles/test_operator/tasks/run-test-operator-job.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@
7979
- not testpod_timed_out
8080
ansible.builtin.include_tasks: collect-logs.yaml
8181

82+
- name: Generate stackviz HTML report from tempest results
83+
ansible.builtin.include_tasks: generate-stackviz.yml
84+
8285
- name: Get list of all pods
8386
kubernetes.core.k8s_info:
8487
kubeconfig: "{{ cifmw_openshift_kubeconfig }}"

0 commit comments

Comments
 (0)