Browse code

Move process-stackviz role from Tempest to Devstack

process-stackviz role currently defined in Tempest repo[1] and used
in tempest jobs. Issue with having it in branchless Tempest is that any
fix in that role cannot be backported to older Tempest. Also stackviz is
not Tempest things it is only used by Tempest jobs.

Stackviz can be considered as a service similar to Tempest so inatlling it in
Devstack side make sense. Also that will give us advantage to handle the
branch specific fixes or backpoting the fixes.

This can solve the current issues we are facing on rocky branch
- https://zuul.opendev.org/t/openstack/build/c1e2da80537448bfb24331fb4198a931/console#4/0/29/controller

[1] https://opendev.org/openstack/tempest/src/branch/master/roles/process-stackviz

Change-Id: I0ba1fd05c6391cd8bb978119ecfbb891def2d497

Ghanshyam Mann authored on 2020/06/20 00:31:38
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,22 @@
0
+Generate stackviz report.
1
+
2
+Generate stackviz report using subunit and dstat data, using
3
+the stackviz archive embedded in test images.
4
+
5
+**Role Variables**
6
+
7
+.. zuul:rolevar:: devstack_base_dir
8
+   :default: /opt/stack
9
+
10
+   The devstack base directory.
11
+
12
+.. zuul:rolevar:: stage_dir
13
+   :default: "{{ ansible_user_dir }}"
14
+
15
+   The stage directory where the input data can be found and
16
+   the output will be produced.
17
+
18
+.. zuul:rolevar:: zuul_work_dir
19
+   :default: {{ devstack_base_dir }}/tempest
20
+
21
+   Directory to work in. It has to be a fully qualified path.
0 22
new file mode 100644
... ...
@@ -0,0 +1,3 @@
0
+devstack_base_dir: /opt/stack
1
+stage_dir: "{{ ansible_user_dir }}"
2
+zuul_work_dir: "{{ devstack_base_dir }}/tempest"
0 3
new file mode 100644
... ...
@@ -0,0 +1,70 @@
0
+- name: Devstack checks if stackviz archive exists
1
+  stat:
2
+    path: "/opt/cache/files/stackviz-latest.tar.gz"
3
+  register: stackviz_archive
4
+
5
+- debug:
6
+    msg: "Stackviz archive could not be found in /opt/cache/files/stackviz-latest.tar.gz"
7
+  when: not stackviz_archive.stat.exists
8
+
9
+- name: Check if subunit data exists
10
+  stat:
11
+    path: "{{ zuul_work_dir }}/testrepository.subunit"
12
+  register: subunit_input
13
+
14
+- debug:
15
+    msg: "Subunit file could not be found at {{ zuul_work_dir }}/testrepository.subunit"
16
+  when: not subunit_input.stat.exists
17
+
18
+- name: Install stackviz
19
+  when:
20
+    - stackviz_archive.stat.exists
21
+    - subunit_input.stat.exists
22
+  block:
23
+    - include_role:
24
+        name: ensure-pip
25
+
26
+    - pip:
27
+        name: "file://{{ stackviz_archive.stat.path }}"
28
+        virtualenv: /tmp/stackviz
29
+        virtualenv_command: '{{ ensure_pip_virtualenv_command }}'
30
+        extra_args: -U
31
+
32
+- name: Deploy stackviz static html+js
33
+  command: cp -pR /tmp/stackviz/share/stackviz-html {{ stage_dir }}/stackviz
34
+  when:
35
+    - stackviz_archive.stat.exists
36
+    - subunit_input.stat.exists
37
+
38
+- name: Check if dstat data exists
39
+  stat:
40
+    path: "{{ devstack_base_dir }}/logs/dstat-csv.log"
41
+  register: dstat_input
42
+  when:
43
+    - stackviz_archive.stat.exists
44
+    - subunit_input.stat.exists
45
+
46
+- name: Run stackviz with dstat
47
+  shell: |
48
+    cat {{ subunit_input.stat.path }} | \
49
+      /tmp/stackviz/bin/stackviz-export \
50
+        --dstat "{{ devstack_base_dir }}/logs/dstat-csv.log" \
51
+        --env --stdin \
52
+        {{ stage_dir }}/stackviz/data
53
+  when:
54
+    - stackviz_archive.stat.exists
55
+    - subunit_input.stat.exists
56
+    - dstat_input.stat.exists
57
+  failed_when: False
58
+
59
+- name: Run stackviz without dstat
60
+  shell: |
61
+    cat {{ subunit_input.stat.path }} | \
62
+      /tmp/stackviz/bin/stackviz-export \
63
+        --env --stdin \
64
+        {{ stage_dir }}/stackviz/data
65
+  when:
66
+    - stackviz_archive.stat.exists
67
+    - subunit_input.stat.exists
68
+    - not dstat_input.stat.exists
69
+  failed_when: False