From 316114814dfb267e02b85d65bd4b3bb834907cd6 Mon Sep 17 00:00:00 2001 From: mgirgisf Date: Tue, 3 Sep 2024 11:19:19 +0200 Subject: [PATCH 1/2] Add check container tests --- roles/common/README.md | 119 ++++++++++++++++++++++++ roles/common/defaults/main.yml | 2 + roles/common/tasks/container_status.yml | 13 +++ roles/common/tasks/main.yml | 10 ++ roles/common/vars/main.yml | 2 + 5 files changed, 146 insertions(+) create mode 100644 roles/common/README.md create mode 100644 roles/common/defaults/main.yml create mode 100644 roles/common/tasks/container_status.yml create mode 100644 roles/common/tasks/main.yml create mode 100644 roles/common/vars/main.yml diff --git a/roles/common/README.md b/roles/common/README.md new file mode 100644 index 00000000..62f30101 --- /dev/null +++ b/roles/common/README.md @@ -0,0 +1,119 @@ +common +========= + +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 + 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. + + + hosts: controller + gather_facts: no + vars: + proj_out_file: verify_logging_projects_exist_lresults.log + 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 +------------------ + +alexy@redhat.com diff --git a/roles/common/defaults/main.yml b/roles/common/defaults/main.yml new file mode 100644 index 00000000..28cf403f --- /dev/null +++ b/roles/common/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for roles/common diff --git a/roles/common/tasks/container_status.yml b/roles/common/tasks/container_status.yml new file mode 100644 index 00000000..72c96c88 --- /dev/null +++ b/roles/common/tasks/container_status.yml @@ -0,0 +1,13 @@ +--- +- name: "[TEST] verify container status" + ansible.builtin.shell: + cmd: | + podman ps -a --format "{{ '{{.Names}} {{.Status}}' }}" | grep "{{ container_name }}" | awk '{print $2}' + changed_when: false + register: container_status + +- name: Fail if container is not 'Up' + ansible.builtin.fail: + msg: "Container '{{ container_name }}' is not in 'Up' status. Current status: {{ container_status.stdout }}" + when: + - "'Up' not in container_status.stdout" \ No newline at end of file diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml new file mode 100644 index 00000000..aaee4037 --- /dev/null +++ b/roles/common/tasks/main.yml @@ -0,0 +1,10 @@ +--- +# All containers need to be up in order for this task to pass +- name: "[TEST] verify status of multiple containers" + ansible.builtin.include_tasks: + file: container_status.yml + loop: "{{ containers }}" + loop_control: + label: "{{ item }}" + vars: + container_name: "{{ item }}" diff --git a/roles/common/vars/main.yml b/roles/common/vars/main.yml new file mode 100644 index 00000000..f83eed77 --- /dev/null +++ b/roles/common/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for roles/common From a728912e5626fad1ca206311634a527e6c9ad0cc Mon Sep 17 00:00:00 2001 From: Muneesha Yadla Date: Thu, 26 Sep 2024 23:12:33 -0400 Subject: [PATCH 2/2] OSPRH-9659 Add service tests to the logging job adding the tasks from https://github.com/infrawatch/feature-verification-tests/pull/123 into a spearate PR --- roles/common/tasks/main.yml | 6 ++++++ roles/common/tasks/service_tests.yml | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 roles/common/tasks/service_tests.yml diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index aaee4037..629003e3 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -8,3 +8,9 @@ label: "{{ item }}" vars: container_name: "{{ item }}" + +--- +- name: "[TEST] Verify service for logging" + ansible.builtin.include_tasks: + file: service_tests.yml + tags: test diff --git a/roles/common/tasks/service_tests.yml b/roles/common/tasks/service_tests.yml new file mode 100644 index 00000000..4e27b3fd --- /dev/null +++ b/roles/common/tasks/service_tests.yml @@ -0,0 +1,7 @@ +--- +- name: Verify service is running + ansible.builtin.shell: + cmd: | + oc get service -n "{{ service_nspace }}" "{{ service_name }}" + changed_when: false + register: output \ No newline at end of file