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 container tests to logging job #219

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ci/logging_tests_computes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,21 @@
- name: "Run the tests from the common role"
ansible.builtin.import_role:
name: common

- name: "Run container tests which require root on compute nodes"
hosts: computes
gather_facts: true
become: true
ignore_errors: true
environment:
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
PATH: "{{ cifmw_path }}"
vars:
common_container_test_id: "RHOSO-12753"
common_container_list:
- ceilometer_agent_compute
- node_exporter
tasks:
- name: "Run the tests from the common role"
ansible.builtin.import_role:
name: common
24 changes: 23 additions & 1 deletion roles/common/tasks/container_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,33 @@
changed_when: false
register: container_status

- name: Show the container name and status
ansible.builtin.debug:
var: container_status.stdout

- when: container_status.stdout | length == 0
block:
- name: Show the containers
ansible.builtin.shell:
cmd: |
podman ps -a --format "{{ '{{.Names}} {{.Status}}' }}"
changed_when: false
register: debug_output

- name: Show the output of container list
ansible.builtin.debug:
var: debug_output.stdout_lines

# NOTE: leaving the existing fail message to get the status and see if it is okay
- name: |
TEST Verify {{ container_name }} container status
{{ common_container_test_id }}
ansible.builtin.assert:
that:
- "container_status.stdout | length != 0"
- "'unhealthy' not in container_status.stdout"
success_msg: "Container '{{ container_name }}' is in 'healthy' status."
fail_msg: "Container '{{ container_name }}' is not in 'healthy' status. Current status: {{ container_status.stdout }}"
fail_msg: |
Container does not meet the required conditions:
{%- if container_status.stdout | length == 0 %}Container name did not match any existing containers;{% endif %}
{%- if "unhealthy" in container_status.stdout %}Container status is unhealthy;{% endif %}