Skip to content

Commit

Permalink
[ci][common] Use separate play for tests requiring elevated priviledges
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
elfiesmelfie committed Feb 18, 2025
1 parent 78074c8 commit e36d53b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
23 changes: 18 additions & 5 deletions ci/logging_tests_computes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
journal_list:
- ceilometer_agent_compute
- nova_compute
common_container_test_id: "RHOSO-12753"
common_container_list:
- ceilometer_agent_compute
- ceilometer_agent_ipmi
- node_exporter
common_file_test_id: "RHOSO-12754"
common_file_list:
- /etc/rsyslog.d/10-telemetry.conf
Expand All @@ -27,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
7 changes: 4 additions & 3 deletions roles/common/tasks/container_test.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
---
# The containers are run by root, so need to become true
- name: Get container status
become: true
ansible.builtin.shell:
cmd: |
podman ps -a --format "{{ '{{.Names}} {{.Status}}' }}" | grep {{ container_name }}
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
Expand All @@ -34,4 +36,3 @@
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 %}
Container '{{ container_name }}' is not in 'healthy' status. Current status: {{ container_status.stdout }}

0 comments on commit e36d53b

Please sign in to comment.