Skip to content

Commit 76955cc

Browse files
authored
Merge branch 'alexy_logging2' into alexy_logging
2 parents 474a140 + 5db5aba commit 76955cc

File tree

13 files changed

+306
-2
lines changed

13 files changed

+306
-2
lines changed

.ansible-lint

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ exclude_paths:
33
- ci/
44
- roles/telemetry_autoscaling
55
- roles/telemetry_logging
6-
- roles/qe_common
6+
- roles/commmon
77
skip_list:
88
- command-instead-of-module # Using command rather than module
99
- galaxy
1010
- meta-no-info # meta/main.yml should contain relevant info
1111
- risky-shell-pipe # Shells that use pipes should set the pipefail option
1212
- unnamed-task # All tasks should be named
13-
- var-naming[no-role-prefix] # Variables names from within roles should use role_name_ as a prefix
1413
- yaml # Violations reported by yamllint

roles/common/README.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
common
2+
=========
3+
4+
The tests in this role are not specific to any one functional area but are an aggregate of common tests that can be used in all OSP 18.0/OCP jobs.
5+
6+
Requirements
7+
------------
8+
9+
None
10+
11+
Role Variables
12+
--------------
13+
Variable required for all tasks to run:
14+
15+
For container_tests.yml tasks:
16+
17+
container_test_id
18+
container_list
19+
- list of containers to validate
20+
21+
For cred_tests.yml tasks:
22+
23+
cred_test_id
24+
cred_list
25+
- list of credentials to validate
26+
27+
For endpoint_tests.yml tasks:
28+
29+
endpoint_test_id
30+
endpoint_list
31+
- list of endpoints to validate
32+
33+
For file_tests.yml tasks:
34+
35+
file_test_id
36+
file_list
37+
- list of files to verify
38+
39+
For node_tests.yml tasks:
40+
41+
node_test_id
42+
node_list
43+
- list of nodes to validate
44+
45+
For proj_test.yml tasks:
46+
47+
proj_test_id
48+
proj_list
49+
- list of projects to validate
50+
51+
For pod_tests.yml tasks:
52+
53+
pod_test_id
54+
pod_list
55+
- list of pods to validate
56+
pod_status_str
57+
- status of pods to check
58+
pod_nspace
59+
- list of projects where pods exist
60+
61+
For service_tests.yml tasks:
62+
63+
service_test_id
64+
service_list
65+
- list of services to validate
66+
service_nspace
67+
- project where services are running
68+
69+
For manifest_tests.yml tasks:
70+
71+
manifest_test_id
72+
manifest_list
73+
- list of package manifests to validate
74+
75+
For subscription_tests.yml tasks:
76+
77+
subscription_polar_id
78+
subscription_list
79+
- list of subscriptions to validate
80+
subscription_nspace
81+
- project where the subscription lives
82+
83+
84+
Dependencies
85+
------------
86+
87+
None
88+
89+
Example Playbook
90+
----------------
91+
92+
Typically, for this role the tests should *not* use a "main.yml" and import or include all the tests in the role. On the contrary, a tests should explicitly include specific tests needed for a given job.
93+
94+
95+
hosts: controller
96+
gather_facts: no
97+
vars:
98+
proj_out_file: verify_logging_projects_exist_lresults.log
99+
proj_list:
100+
- openshift-openstack-infra
101+
- openshift
102+
- openstack-operators
103+
- openshift-logging
104+
105+
tasks:
106+
- name: Run projects tests
107+
ansible.builtin.import_role:
108+
name: common
109+
110+
111+
License
112+
-------
113+
114+
Apache 2
115+
116+
Author Information
117+
------------------
118+
119+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
3+
- name: Get container status
4+
ansible.builtin.shell:
5+
cmd: |
6+
podman ps -a --format "{{ '{{.Names}} {{.Status}}' }}" | grep "{{ item }}" | awk '{print $2;}'
7+
change_when: false
8+
register: container_status
9+
failed_when: container_status.stdout != "Up"

roles/common/tasks/cred_tests.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
3+
- name: Verify logging credentials "{{ item }}"
4+
ansible.builtin.shell:
5+
cmd: |
6+
oc get crd "{{ item }}"
7+
changed_when: false
8+
register: output
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
3+
- name: Get Endpoint
4+
ansible.builtin.shell:
5+
cmd: |
6+
oc project openstack
7+
kubectl exec openstackclient -- openstack endpoint list --service="{{ item[0] }}" --service="{{ item[1] }}" --interface="{{ item[2] }}"
8+
changed_when: false
9+
register: output

roles/common/tasks/file_tests.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
3+
- name: Get stats for file
4+
ansible.builtin.stat:
5+
path: "{{ item }}"
6+
register: fstats
7+
failed_when:
8+
- fstats.stat.pw_name != "root"
9+
- fstats.stat.size | int < 300
10+
- not fstats.stat.exists
11+
- not fstats.stat.isreg
12+

roles/common/tasks/main.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
- name: "Verify container - {{ container_test_id }}"
3+
when: container_list is defined
4+
ansible.builtin.include_tasks: "container_tests.yml"
5+
loop: "{{ container_list }}"
6+
7+
8+
- name: "Verify credential - {{ cred_test_id }}"
9+
when: cred_list is defined
10+
ansible.builtin.include_tasks: "cred_tests.yml"
11+
loop: "{{ cred_list }}"
12+
13+
14+
- name: "Verify endpoint in OSP - {{ endpoint_test_id }}"
15+
when: endpoint_list is defined
16+
ansible.builtin.include_tasks: "endpoint_tests.yml"
17+
loop: "{{ endpoint_list }}"
18+
19+
20+
- name: "Verify file - {{ file_test_id }}"
21+
when: file_list is defined
22+
ansible.builtin.include_tasks: "file_tests.yml"
23+
loop: "{{ file_list }}"
24+
25+
26+
- name: "Verify manifest - {{ manifest_test_id }}"
27+
when: manifest_list is defined
28+
ansible.builtin.include_tasks: "manifest_tests.yml"
29+
loop: "{{ manifest_list }}"
30+
31+
32+
- name: "Verify OSP node - {{ node_test_id }}"
33+
when: node_list is defined
34+
ansible.builtin.include_tasks: node_tests.yml
35+
loop: "{{ node_list }}"
36+
37+
38+
- name: "Verify pod - {{ pod_test_id }}"
39+
when:
40+
- pod_list is defined
41+
- nspace is defined
42+
- pod_status_str is defined
43+
ansible.builtin.include_tasks: "pod_tests.yml"
44+
loop: "{{ pod_list }}"
45+
46+
47+
48+
- name: "Verify project - {{ proj_test_id }}"
49+
when: proj_list is defined
50+
ansible.builtin.include_tasks: "proj_tests.yml"
51+
loop: "{{ proj_list }}"
52+
53+
54+
- name: "Verify service - {{ service_test_id }}"
55+
when:
56+
- service_list is defined
57+
- nspace is defined
58+
ansible.builtin.include_tasks: "service_tests.yml"
59+
loop: "{{ service_list }}"
60+
61+
62+
- name: "Verify subscription - {{ subscription_test_id }}"
63+
when: subscription_list is defined
64+
ansible.builtin.include_tasks: "subscription_tests.yml"
65+
loop: "{{ subscription_list }}"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
3+
- name: Get number of packages
4+
ansible.builtin.shell:
5+
cmd: |
6+
echo "{{ item }}" | awk '{print $2;}'
7+
register: num_expected
8+
changed_when: false
9+
10+
- name: Get package name
11+
ansible.builtin.shell:
12+
cmd: |
13+
echo "{{ item }}" | awk '{print $1;}'
14+
register: pack_name
15+
changed_when: false
16+
17+
- name: Get packagemanifest
18+
ansible.builtin.shell:
19+
cmd: |
20+
oc get packagemanifests | grep "{{ pack_name.stdout }}" | wc -l
21+
register: num_found
22+
changed_when: false
23+
failed_when: num_expected.stdout != num_found.stdout

roles/common/tasks/node_tests.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
3+
- name: Get running node
4+
become: true
5+
ansible.builtin.shell:
6+
cmd: |
7+
virsh list --state-running | grep "{{ item }}" | awk '{print $2;}'
8+
register: nodefound
9+
changed_when: false
10+
11+
- name: Get node status
12+
become: true
13+
ansible.builtin.shell:
14+
cmd: |
15+
virsh list --state-running | grep "{{ item }}" | awk '{print $3;}'
16+
register: output
17+
changed_when: false
18+
failed_when: output.stdout != "running"

roles/common/tasks/pod_tests.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
3+
- name: Get Pod Instance "{{ pod_status_str }}"
4+
ansible.builtin.shell:
5+
cmd: |
6+
oc get pods -n "{{ pod_nspace }}" | grep "{{ item }}" | grep "{{ pod_status_str }}" | awk '{print $1;}'
7+
register: podinstance
8+
changed_when: false
9+
10+
- name: Check terminated pod
11+
ansible.builtin.shell:
12+
cmd: |
13+
oc get pod -n "{{ pod_nspace }} {{ podinstance.stdout }}"
14+
register: output
15+
changed_when: false
16+
failed_when:
17+
- output.rc != 0
18+
- podinstance.stdout == ""
19+
20+

0 commit comments

Comments
 (0)