Skip to content

Commit

Permalink
[common] Update the CR tests to mark one as optional
Browse files Browse the repository at this point in the history
Only include the test_id if the condition_type is defined.
Set a default for the condition_type so that the task name is rendered
correctly in output plugins.
  • Loading branch information
elfiesmelfie committed Jan 29, 2025
1 parent 59e50c1 commit cb1d8e5
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions roles/common/tasks/cr_tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
- name: Verify that a CR exists {{ common_cr_test_id }}
---
- name: |
Verify that the {{ item.kind }} {{ item.name }} CR exists
{{ common_cr_test_id }}
ansible.builtin.command:
cmd: |
oc get {{ item.kind }} {{ item.name }}
Expand All @@ -7,14 +10,21 @@
failed_when:
- result.rc != 0

- name: Verify that a CR is ready {{ common_cr_ready_test_id }}
# This is added so that the task name will be rendered correctly
# If item.condition_type is used and it doesn't exist, then the
# literal template text will appear as the task name
# e.g. "Verify that the {{ item.kind }} {{ item.name }} CR is {{ item.condition_type }}"
- name: Set the condition type
ansible.builtin.set_fact:
condition_type: "{{ item.condition_type if item.condition_type is defined else '' }}"

- name: |
Verify that the {{ item.kind }} {{ item.name }} CR is {{ condition_type }}
{{ common_cr_ready_test_id if condition_type | length > 0 }}
ansible.builtin.command:
cmd: |
oc get {{ item.kind }} {{ item.name }} -o jsonpath='{.status.conditions[?(@.type=="{{ item.condition_type }}")].status}{"\n"}'
oc get {{ item.kind }} {{ item.name }} -o jsonpath='{.status.conditions[?(@.type=="{{ condition_type }}")].status}{"\n"}'
register: result
changed_when: false
failed_when:
- result.stdout != "True"
when:
- common_cr_ready_test_id is defined
- item.condition_type is defined

0 comments on commit cb1d8e5

Please sign in to comment.