-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge qe_common role #123
base: master
Are you sure you want to change the base?
Merge qe_common role #123
Changes from 64 commits
8c98ef2
46a758f
71c049f
cdae659
3dc4358
245c2a1
f72fd4d
2bf3caa
76c49d2
37fa0d9
da302a4
02e3e31
904235b
f15fcb8
9cdb01e
f024c30
3e339eb
66c3cae
822132c
9afdba5
3c5da9d
083b4cf
33f737c
3469919
139e9bc
67efe0d
36f184a
26ce391
6951245
7239334
b5997ef
f8557fd
fdc11fc
23ef3d7
5e84642
0e20dda
664ddc5
abb808b
79f004d
31a702f
bfbe01c
2155f88
b42f3e1
d6527b5
a836f64
e325278
dbce856
9b55e78
5ec4c85
3bda671
86bc4c4
cc8994b
606fc82
7e50ef4
ffb00b3
d47e091
39c2ff1
705a2cd
9b3451a
f8c40ad
6e3283c
44884f5
5db5aba
ac94272
a8891d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,119 @@ | ||||||
common | ||||||
========= | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
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. | ||||||
|
||||||
Requirements | ||||||
------------ | ||||||
|
||||||
None | ||||||
|
||||||
Role Variables | ||||||
-------------- | ||||||
Variable required for all tasks to run: | ||||||
|
||||||
For container_tests.yml tasks: | ||||||
|
||||||
container_test_id | ||||||
container_list | ||||||
- list of containers to validate | ||||||
|
||||||
For cred_tests.yml tasks: | ||||||
|
||||||
cred_test_id | ||||||
cred_list | ||||||
- list of credentials to validate | ||||||
|
||||||
For endpoint_tests.yml tasks: | ||||||
|
||||||
endpoint_test_id | ||||||
endpoint_list | ||||||
- list of endpoints to validate | ||||||
|
||||||
For file_tests.yml tasks: | ||||||
|
||||||
file_test_id | ||||||
file_list | ||||||
- list of files to verify | ||||||
|
||||||
For node_tests.yml tasks: | ||||||
|
||||||
node_test_id | ||||||
node_list | ||||||
- list of nodes to validate | ||||||
|
||||||
For proj_test.yml tasks: | ||||||
|
||||||
proj_test_id | ||||||
proj_list | ||||||
- list of projects to validate | ||||||
|
||||||
For pod_tests.yml tasks: | ||||||
|
||||||
pod_test_id | ||||||
pod_list | ||||||
- list of pods to validate | ||||||
pod_status_str | ||||||
- status of pods to check | ||||||
pod_nspace | ||||||
- list of projects where pods exist | ||||||
|
||||||
For service_tests.yml tasks: | ||||||
|
||||||
service_test_id | ||||||
service_list | ||||||
- list of services to validate | ||||||
service_nspace | ||||||
- project where services are running | ||||||
|
||||||
For manifest_tests.yml tasks: | ||||||
|
||||||
manifest_test_id | ||||||
manifest_list | ||||||
- list of package manifests to validate | ||||||
|
||||||
For subscription_tests.yml tasks: | ||||||
|
||||||
subscription_polar_id | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These var names need to be updated to match the updated var names (*_test_id) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
subscription_list | ||||||
- list of subscriptions to validate | ||||||
subscription_nspace | ||||||
- project where the subscription lives | ||||||
|
||||||
|
||||||
Dependencies | ||||||
------------ | ||||||
|
||||||
None | ||||||
|
||||||
Example Playbook | ||||||
---------------- | ||||||
|
||||||
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. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be removed. The behaviour has changed to work by setting appropriate vars to select the tests that run. The vars are set and then used by the role on import. Ideally, the vars would have the <role_name>_ prefix to them There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
|
||||||
hosts: controller | ||||||
gather_facts: no | ||||||
vars: | ||||||
proj_out_file: verify_logging_projects_exist_lresults.log | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The project_out_file is not mentioned elsewhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
proj_list: | ||||||
- openshift-openstack-infra | ||||||
- openshift | ||||||
- openstack-operators | ||||||
- openshift-logging | ||||||
|
||||||
tasks: | ||||||
- name: Run projects tests | ||||||
ansible.builtin.import_role: | ||||||
name: common | ||||||
|
||||||
|
||||||
License | ||||||
------- | ||||||
|
||||||
Apache 2 | ||||||
|
||||||
Author Information | ||||||
------------------ | ||||||
|
||||||
[email protected] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
|
||
- name: Get container status | ||
ansible.builtin.shell: | ||
cmd: | | ||
podman ps -a --format "{{ '{{.Names}} {{.Status}}' }}" | grep "{{ item }}" | awk '{print $2;}' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For readability, I recommend using something instead of item. You can use a useful variable name, and tell the loop in main to use that same var name for its loop var. The syntax would be similar to: https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_loops.html#stacking-loops-via-include-tasks, but without the nested loops. Here's an example playbook:
|
||
changed_when: false | ||
register: container_status | ||
failed_when: container_status.stdout != "Up" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
|
||
- name: Verify logging credentials "{{ item }}" | ||
ansible.builtin.shell: | ||
cmd: | | ||
oc get crd "{{ item }}" | ||
changed_when: false | ||
register: output | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a fail condition for this? Does it need one? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
|
||
- name: Get Endpoint | ||
ansible.builtin.shell: | ||
cmd: | | ||
oc project openstack | ||
kubectl exec openstackclient -- openstack endpoint list --service="{{ item[0] }}" --service="{{ item[1] }}" --interface="{{ item[2] }}" | ||
Comment on lines
+6
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if the endpoint doesn't exist? Does the openstackclient return a non-zero return code? |
||
changed_when: false | ||
register: output |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
|
||
- name: Get stats for file | ||
ansible.builtin.stat: | ||
path: "{{ item }}" | ||
register: fstats | ||
failed_when: | ||
- fstats.stat.pw_name != "root" | ||
- fstats.stat.size | int < 300 | ||
- not fstats.stat.exists | ||
- not fstats.stat.isreg | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
- name: "Verify container - {{ container_test_id }}" | ||
when: container_list is defined | ||
ansible.builtin.include_tasks: "container_tests.yml" | ||
loop: "{{ container_list }}" | ||
|
||
|
||
- name: "Verify credential - {{ cred_test_id }}" | ||
when: cred_list is defined | ||
ansible.builtin.include_tasks: "cred_tests.yml" | ||
loop: "{{ cred_list }}" | ||
|
||
|
||
- name: "Verify endpoint in OSP - {{ endpoint_test_id }}" | ||
when: endpoint_list is defined | ||
ansible.builtin.include_tasks: "endpoint_tests.yml" | ||
loop: "{{ endpoint_list }}" | ||
|
||
|
||
- name: "Verify file - {{ file_test_id }}" | ||
when: file_list is defined | ||
ansible.builtin.include_tasks: "file_tests.yml" | ||
loop: "{{ file_list }}" | ||
|
||
|
||
- name: "Verify manifest - {{ manifest_test_id }}" | ||
when: manifest_list is defined | ||
ansible.builtin.include_tasks: "manifest_tests.yml" | ||
loop: "{{ manifest_list }}" | ||
|
||
|
||
- name: "Verify OSP node - {{ node_test_id }}" | ||
when: node_list is defined | ||
ansible.builtin.include_tasks: node_tests.yml | ||
loop: "{{ node_list }}" | ||
|
||
|
||
- name: "Verify pod - {{ pod_test_id }}" | ||
when: | ||
- pod_list is defined | ||
- nspace is defined | ||
elfiesmelfie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- pod_status_str is defined | ||
ansible.builtin.include_tasks: "pod_tests.yml" | ||
loop: "{{ pod_list }}" | ||
|
||
|
||
|
||
- name: "Verify project - {{ proj_test_id }}" | ||
when: proj_list is defined | ||
ansible.builtin.include_tasks: "proj_tests.yml" | ||
loop: "{{ proj_list }}" | ||
|
||
|
||
- name: "Verify service - {{ service_test_id }}" | ||
when: | ||
- service_list is defined | ||
- nspace is defined | ||
elfiesmelfie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ansible.builtin.include_tasks: "service_tests.yml" | ||
loop: "{{ service_list }}" | ||
|
||
|
||
- name: "Verify subscription - {{ subscription_test_id }}" | ||
when: subscription_list is defined | ||
ansible.builtin.include_tasks: "subscription_tests.yml" | ||
loop: "{{ subscription_list }}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
|
||
- name: Get number of packages | ||
ansible.builtin.shell: | ||
cmd: | | ||
echo "{{ item }}" | awk '{print $2;}' | ||
register: num_expected | ||
changed_when: false | ||
|
||
- name: Get package name | ||
ansible.builtin.shell: | ||
cmd: | | ||
echo "{{ item }}" | awk '{print $1;}' | ||
register: pack_name | ||
changed_when: false | ||
|
||
- name: Get packagemanifest | ||
ansible.builtin.shell: | ||
cmd: | | ||
oc get packagemanifests | grep "{{ pack_name.stdout }}" | wc -l | ||
register: num_found | ||
changed_when: false | ||
failed_when: num_expected.stdout != num_found.stdout |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe these tests are valid. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
|
||
- name: Get running node | ||
become: true | ||
ansible.builtin.shell: | ||
cmd: | | ||
virsh list --state-running | grep "{{ item }}" | awk '{print $2;}' | ||
register: nodefound | ||
changed_when: false | ||
|
||
- name: Get node status | ||
become: true | ||
ansible.builtin.shell: | ||
cmd: | | ||
virsh list --state-running | grep "{{ item }}" | awk '{print $3;}' | ||
register: output | ||
changed_when: false | ||
failed_when: output.stdout != "running" |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,20 @@ | ||||||||||
--- | ||||||||||
|
||||||||||
- name: Get Pod Instance "{{ pod_status_str }}" | ||||||||||
ansible.builtin.shell: | ||||||||||
cmd: | | ||||||||||
oc get pods -n "{{ pod_nspace }}" | grep "{{ item }}" | grep "{{ pod_status_str }}" | awk '{print $1;}' | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this fails, there is no indication until the next task. The next task will fail if there is nothing returned from here.
Suggested change
|
||||||||||
register: podinstance | ||||||||||
changed_when: false | ||||||||||
|
||||||||||
- name: Check terminated pod | ||||||||||
ansible.builtin.shell: | ||||||||||
cmd: | | ||||||||||
oc get pod -n "{{ pod_nspace }} {{ podinstance.stdout }}" | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Please don't apply these suggestions, they are reflective of what is going on in PR#149 |
||||||||||
register: output | ||||||||||
changed_when: false | ||||||||||
failed_when: | ||||||||||
- output.rc != 0 | ||||||||||
- podinstance.stdout == "" | ||||||||||
|
||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
|
||
- name: Verify Project exists - "{{ item }}" | ||
ansible.builtin.shell: | ||
cmd: | | ||
oc project "{{ item }}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will switch to a different project. This may cause unexpected behaviour of subsequent commands are run without a
(please verify that this command is correct) A more efficient approach might be to get the project list and then loop through the output to make sure that all the expected project are there. |
||
register: output | ||
changed_when: false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- name: Verify Service Running - "{{ item }}" | ||
ansible.builtin.shell: | ||
cmd: | | ||
oc get service -n "{{ service_nspace }}" "{{ item }}" | ||
register: output | ||
changed_when: false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
|
||
- name: Verify subscription | ||
ansible.builtin.shell: | ||
cmd: | | ||
oc get subscriptions -n "{{ subscription_nspace }}" "{{ item }}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO, this should have a similar format to the endpoint tests, so that a single loop can cover multiple namespaces. |
||
register: output | ||
changed_when: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.