Skip to content

Commit

Permalink
Merge pull request #149 from infrawatch/efoley_add_pod_test_to_logging
Browse files Browse the repository at this point in the history
Add pod tests to logging job
  • Loading branch information
mgirgisf authored Oct 15, 2024
2 parents 35c1956 + da24821 commit 9ecc35c
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 2 deletions.
1 change: 1 addition & 0 deletions ci/ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ roles_path = ../roles:/usr/share/ansible/roles:/etc/ansible/roles:~/.ansible/rol

[custom_logger]
output_dir = /$HOME

5 changes: 5 additions & 0 deletions ci/logging_tests_all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- name: Run the compute node tests
ansible.builtin.import_playbook: logging_tests_computes.yml

- name: Run the controller tests
ansible.builtin.import_playbook: logging_tests_controller.yml
121 changes: 121 additions & 0 deletions ci/logging_tests_controller.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
- name: "Verify logging projects, endpoints, credentials, nodes, pods, services, manifests and subscriptions"
hosts: controller
gather_facts: no
ignore_errors: true
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
vars:
common_pod_test_id: "RHOS0-12672"
common_pod_status_str: "Running"
common_pod_nspace: openstack-operators
common_pod_list:
- telemetry-operator-controller-manager
- dataplane-operator-controller-manager

- name: "Verify logging pods are running in openstack"
hosts: controller
gather_facts: no
ignore_errors: true
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
vars:
common_pod_test_id: "RHOSO-12752"
common_pod_status_str: "Running"
common_pod_nspace: openstack
common_pod_list:
- openstackclient
tasks:
- name: "Verify Running Pods"
ansible.builtin.import_role:
name: common


- name: "Verify logging pods are running in openshift-operators-redhat"
hosts: controller
gather_facts: no
ignore_errors: true
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
vars:
common_pod_test_id: "RHOSO-12673"
common_pod_status_str: "Running"
common_pod_nspace: openshift-operators-redhat
common_pod_list:
- loki-operator-controller-manager

tasks:
- name: "Verify Pods running"
ansible.builtin.import_role:
name: common

- name: "Verify logging pods are running in openshift-logging"
hosts: controller
gather_facts: no
ignore_errors: true
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
vars:
common_pod_test_id: "RHOSO-12676"
common_pod_status_str: "Running"
common_pod_nspace: openshift-logging
common_pod_list:
- cluster-logging-operator
- collector
- logging-loki-compactor
- logging-loki-distributor
#- logging-loki-gateway
- logging-loki-index-gateway
- logging-loki-ingester
- logging-loki-querier
- logging-loki-query-frontend
- logging-view-plugin

### see JIRA LOG-5431 if pods not running
tasks:
- name: "Verify Pods running"
ansible.builtin.import_role:
name: common

- name: "Verify logging pods are running in minio-dev"
hosts: controller
gather_facts: no
ignore_errors: true
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
vars:
common_pod_test_id: "RHOSO-12674"
common_pod_status_str: "Running"
common_pod_nspace: minio-dev
common_pod_list:
- minio

tasks:
- name: "Run pod running tests"
ansible.builtin.import_role:
name: common


- name: "Verify logging pods have complete status in openstack"
hosts: controller
gather_facts: no
ignore_errors: true
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
vars:
common_pod_test_id: "RHOSO-12679"
common_pod_nspace: openstack
common_pod_status_str: "Completed"
common_pod_list:
- logging-edpm-deployment-openstack-edpm-ipam
tasks:
- name: "Run pods completed tests"
ansible.builtin.import_role:
name: common

5 changes: 3 additions & 2 deletions ci/vars-logging-test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
post_deploy_00_fvt_logging_computes:
source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/logging_tests_computes.yml"
# pre_tests or post_tests are also options for when the FVT roles are run
post_deploy_00_fvt_logging:
source: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/logging_tests_all.yml"
config_file: "{{ ansible_user_dir }}/{{ zuul.projects['github.com/infrawatch/feature-verification-tests'].src_dir }}/ci/ansible.cfg"
type: playbook
post_deploy_99_collect_results:
Expand Down
78 changes: 78 additions & 0 deletions roles/common/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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.

The available tasks tests are:

* pod tests

Requirements
------------

The requirements vary according to the tests run.

For the pod tests, access to a kubernetes cluster and the oc command is needed,
this is done by passing the KUBECONFIG env var and PATH into the play.

The following tools are also needed:
* grep
* awk

Role Variables
--------------
Variable required for all tasks to run

For pod_tests.yml tasks:

common_pod_test_id
- polarion ID number for each test.
common_pod_list
- list of pods to validate
common_pod_status_str
- status of pods to check
common_pod_nspace
- list of projects where pods exist


Dependencies
------------

None

Example Playbook
----------------

The tasks run in this role are dependant on the vars that are configured
As such, the role can be called multiple times within the same play, with the
tests being configured at the task level (e.g. with import_role) or the vars
can be set at the play level.

- hosts: controller
gather_facts: no
ignore_errors: true
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
vars:
common_pod_test_id: "RHOSO-12752"
common_pod_status_str: "Running"
common_pod_nspace: openstack
common_pod_list:
- openstackclient
tasks:
- name: "Verify Running Pods"
ansible.builtin.import_role:
name: common


License
-------

Apache 2

Author Information
------------------

alexy@redhat.com
8 changes: 8 additions & 0 deletions roles/common/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: "Run pod tests"
when:
- common_pod_list is defined
- common_pod_nspace is defined
- common_pod_status_str is defined
ansible.builtin.include_tasks: "pod_tests.yml"
loop: "{{ common_pod_list }}"
31 changes: 31 additions & 0 deletions roles/common/tasks/pod_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
- block:
# expects that one line will be returned
# todo: define what hapens when there are multiple pods returned
- name: Get Pod Instance name "{{ common_pod_status_str }}"
ansible.builtin.shell:
cmd: |
oc get pods -n "{{ common_pod_nspace }}" | grep "{{ item }}" | grep "{{ common_pod_status_str }}" | awk '{print $1;}'
register: podinstance
failed_when:
- podinstance.stdout_lines | length != 1
changed_when: false

- name: Check pod {{ common_pod_test_id }}
ansible.builtin.command:
cmd: |
oc get pod -n "{{ common_pod_nspace }}" "{{ podinstance.stdout }}"
register: output
changed_when: false
failed_when:
- output.rc != 0
- podinstance.stdout == ""
rescue:
- name: Get Pod Instance "{{ item }}"
ansible.builtin.shell:
cmd: |
oc get pods -n "{{ common_pod_nspace }}" | grep "{{ item }}"
register: podinstance
failed_when:
- podinstance.stdout_lines | length == 0
changed_when: false

0 comments on commit 9ecc35c

Please sign in to comment.