Skip to content
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

[logging] Add crd test to logging job #158

Merged
merged 10 commits into from
Oct 29, 2024
18 changes: 18 additions & 0 deletions ci/logging_tests_controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,21 @@
ansible.builtin.import_role:
name: common

- name: "Verify the crds exist"
hosts: controller
gather_facts: no
ignore_errors: true
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
vars:
common_crd_test_id: "RHOSO-12670"
common_crd_list:
- alertingrules.loki.grafana.com
- lokistacks.loki.grafana.com
- recordingrules.loki.grafana.com
- rulerconfigs.loki.grafana.com
tasks:
- name: "Run the crds tests"
ansible.builtin.import_role:
name: common
17 changes: 17 additions & 0 deletions roles/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ For pod_tests.yml tasks:
common_pod_nspace
- list of projects where pods exist

mgirgisf marked this conversation as resolved.
Show resolved Hide resolved
For crd_tests.yml tasks:

common_crd_test_id
- polarion ID number for each test.
common_crd_list
- list of crd to validate



For project_tests.yml tasks:

Expand Down Expand Up @@ -101,6 +109,15 @@ can be set at the play level.
- openshift-openstack-infra
- openshift

- name: "Verify crd"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: "Verify crd"
- name: "Verify crd"

ansible.builtin.import_role:
name: common
vars:
common_crd_test_id : "crd_test_id"
common_crd_list:
- list of crd to validate


License
-------

Expand Down
14 changes: 14 additions & 0 deletions roles/common/tasks/crd_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
- name: Verify CRD "{{ item }}"
ansible.builtin.shell:
cmd: |
oc get crd "{{ item }}"
changed_when: false
register: output

- name: Verify CRD is found "{{ common_crd_test_id }}"
mgirgisf marked this conversation as resolved.
Show resolved Hide resolved
ansible.builtin.assert:
that:
- "'NotFound' not in output.stderr"
success_msg: "CRD {{ item }} is found."
fail_msg: "CRD {{ item }} not found. Error: {{ output.stderr }}"
20 changes: 15 additions & 5 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
- name: "Run pod tests"
- name: "Verify pod - {{ common_pod_test_id }}"
when:
- common_pod_test_id is defined
- common_pod_list is defined
- common_pod_nspace is defined
- common_pod_status_str is defined
Expand All @@ -9,20 +10,29 @@

- name: "Run project tests"
when:
- common_project_test_id is defined
- common_project_list is defined
ansible.builtin.include_tasks: "project_tests.yml"
loop: "{{ common_project_list }}"

- name: "Run manifest tests"
when:
- manifest_test_id is defined
- manifest_list is defined
- common_manifest_test_id is defined
- common_manifest_list is defined
ansible.builtin.include_tasks: "manifest_tests.yml"
loop: "{{ manifest_list }}"
loop: "{{ common_manifest_list }}"

- name: "Run crd tests"
when:
- common_crd_test_id is defined
- common_crd_list is defined
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either the common_crd_test_id should be checked here, or made optional in crd_tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the other tests also.

ansible.builtin.include_tasks: "crd_tests.yml"
loop: "{{ common_crd_list }}"

- name: "Verify container tests"
when:
- common_container_list is defined
- common_container_test_id is defined
ansible.builtin.include_tasks: "container_test.yml"
loop: "{{ common_container_list }}"
loop: "{{ common_container_list }}"

2 changes: 1 addition & 1 deletion roles/common/tasks/manifest_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
register: pack_name
changed_when: false

- name: Get packagemanifest "{{ manifest_test_id }}"
- name: Get packagemanifest "{{ common_manifest_test_id }}"
ansible.builtin.shell:
cmd: |
oc get packagemanifests | grep "{{ pack_name.stdout }}" | wc -l
Expand Down
2 changes: 1 addition & 1 deletion roles/common/tasks/pod_tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- block:
# expects that one line will be returned
# todo: define what hapens when there are multiple pods returned
# todo: define what happens when there are multiple pods returned
- name: Get Pod Instance name "{{ common_pod_status_str }}"
ansible.builtin.shell:
cmd: |
Expand Down
Loading