Skip to content

Commit cb1d8e5

Browse files
committed
[common] Update the CR tests to mark one as optional
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.
1 parent 59e50c1 commit cb1d8e5

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

roles/common/tasks/cr_tests.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
- name: Verify that a CR exists {{ common_cr_test_id }}
1+
---
2+
- name: |
3+
Verify that the {{ item.kind }} {{ item.name }} CR exists
4+
{{ common_cr_test_id }}
25
ansible.builtin.command:
36
cmd: |
47
oc get {{ item.kind }} {{ item.name }}
@@ -7,14 +10,21 @@
710
failed_when:
811
- result.rc != 0
912

10-
- name: Verify that a CR is ready {{ common_cr_ready_test_id }}
13+
# This is added so that the task name will be rendered correctly
14+
# If item.condition_type is used and it doesn't exist, then the
15+
# literal template text will appear as the task name
16+
# e.g. "Verify that the {{ item.kind }} {{ item.name }} CR is {{ item.condition_type }}"
17+
- name: Set the condition type
18+
ansible.builtin.set_fact:
19+
condition_type: "{{ item.condition_type if item.condition_type is defined else '' }}"
20+
21+
- name: |
22+
Verify that the {{ item.kind }} {{ item.name }} CR is {{ condition_type }}
23+
{{ common_cr_ready_test_id if condition_type | length > 0 }}
1124
ansible.builtin.command:
1225
cmd: |
13-
oc get {{ item.kind }} {{ item.name }} -o jsonpath='{.status.conditions[?(@.type=="{{ item.condition_type }}")].status}{"\n"}'
26+
oc get {{ item.kind }} {{ item.name }} -o jsonpath='{.status.conditions[?(@.type=="{{ condition_type }}")].status}{"\n"}'
1427
register: result
1528
changed_when: false
1629
failed_when:
1730
- result.stdout != "True"
18-
when:
19-
- common_cr_ready_test_id is defined
20-
- item.condition_type is defined

0 commit comments

Comments
 (0)