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

Add pod tests to logging job #149

Merged
merged 11 commits into from
Oct 15, 2024
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
mgirgisf marked this conversation as resolved.
Show resolved Hide resolved
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"
Copy link
Contributor

@mgirgisf mgirgisf Oct 10, 2024

Choose a reason for hiding this comment

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

we have this block without any tasks , Is that expected ? can you add please some comments.

hosts: controller
gather_facts: no
ignore_errors: true
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
vars:
common_pod_test_id: "RHOS0-12672"
mgirgisf marked this conversation as resolved.
Show resolved Hide resolved
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"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are passing except for logging-loki-gateway, which has two instances, so the second task fails because there are \n in the pod name.

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"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is passing

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
mgirgisf marked this conversation as resolved.
Show resolved Hide resolved
- 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
------------------

[email protected]
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 }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Once the custom_logger is merged, we can go back in and rename these tasks.

The new task name format will be:

name: |
  <prefix> <task_name>
  <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
Loading