Skip to content

Commit bb6a042

Browse files
authored
Add container tests to logging job (#219)
* [ci] Add container tests to the logging job The test check for the containers that should exist on the compute node. Co-authored-by: "Alex Yefimov <[email protected]>" * [common] Update container tests Add an additional fail condition and make the fail_msg more verbose Update the container tests to use elevated permissions * [ci][common] Use separate play for tests requiring elevated priviledges The container tests need elevated permissions to run on the compute nodes. This is not always going to be the case, so become is added to a separate play to only elevate priviliges for some tests.
1 parent d339fae commit bb6a042

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

ci/logging_tests_computes.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,21 @@
2222
- name: "Run the tests from the common role"
2323
ansible.builtin.import_role:
2424
name: common
25+
26+
- name: "Run container tests which require root on compute nodes"
27+
hosts: computes
28+
gather_facts: true
29+
become: true
30+
ignore_errors: true
31+
environment:
32+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
33+
PATH: "{{ cifmw_path }}"
34+
vars:
35+
common_container_test_id: "RHOSO-12753"
36+
common_container_list:
37+
- ceilometer_agent_compute
38+
- node_exporter
39+
tasks:
40+
- name: "Run the tests from the common role"
41+
ansible.builtin.import_role:
42+
name: common

roles/common/tasks/container_test.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,32 @@
66
changed_when: false
77
register: container_status
88

9+
- name: Show the container name and status
10+
ansible.builtin.debug:
11+
var: container_status.stdout
12+
13+
- when: container_status.stdout | length == 0
14+
block:
15+
- name: Show the containers
16+
ansible.builtin.shell:
17+
cmd: |
18+
podman ps -a --format "{{ '{{.Names}} {{.Status}}' }}"
19+
changed_when: false
20+
register: debug_output
21+
22+
- name: Show the output of container list
23+
ansible.builtin.debug:
24+
var: debug_output.stdout_lines
25+
926
- name: |
1027
TEST Verify {{ container_name }} container status
1128
{{ common_container_test_id }}
1229
ansible.builtin.assert:
1330
that:
31+
- "container_status.stdout | length != 0"
1432
- "'unhealthy' not in container_status.stdout"
1533
success_msg: "Container '{{ container_name }}' is in 'healthy' status."
16-
fail_msg: "Container '{{ container_name }}' is not in 'healthy' status. Current status: {{ container_status.stdout }}"
34+
fail_msg: |
35+
Container does not meet the required conditions:
36+
{%- if container_status.stdout | length == 0 %}Container name did not match any existing containers;{% endif %}
37+
{%- if "unhealthy" in container_status.stdout %}Container status is unhealthy;{% endif %}

0 commit comments

Comments
 (0)