diff --git a/ci/logging_tests_controller.yml b/ci/logging_tests_controller.yml index 76e17fb0..98df9a70 100644 --- a/ci/logging_tests_controller.yml +++ b/ci/logging_tests_controller.yml @@ -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 diff --git a/roles/common/README.md b/roles/common/README.md index 7bc55eda..3e33f12b 100644 --- a/roles/common/README.md +++ b/roles/common/README.md @@ -35,6 +35,14 @@ For pod_tests.yml tasks: common_pod_nspace - list of projects where pods exist +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: @@ -101,6 +109,15 @@ can be set at the play level. - openshift-openstack-infra - openshift + - 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 ------- diff --git a/roles/common/tasks/crd_tests.yml b/roles/common/tasks/crd_tests.yml new file mode 100644 index 00000000..e618d204 --- /dev/null +++ b/roles/common/tasks/crd_tests.yml @@ -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 }}" + ansible.builtin.assert: + that: + - "'NotFound' not in output.stderr" + success_msg: "CRD {{ item }} is found." + fail_msg: "CRD {{ item }} not found. Error: {{ output.stderr }}" \ No newline at end of file diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 1d3597a0..8259664e 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -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 @@ -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 + 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 }}" \ No newline at end of file + loop: "{{ common_container_list }}" + diff --git a/roles/common/tasks/manifest_tests.yml b/roles/common/tasks/manifest_tests.yml index 6b2ebfa5..63e03aa7 100644 --- a/roles/common/tasks/manifest_tests.yml +++ b/roles/common/tasks/manifest_tests.yml @@ -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 diff --git a/roles/common/tasks/pod_tests.yml b/roles/common/tasks/pod_tests.yml index 74c35470..97e2b5b7 100644 --- a/roles/common/tasks/pod_tests.yml +++ b/roles/common/tasks/pod_tests.yml @@ -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: |