From 03ed468a3459563bbcb85fc766aa7c63c3b6d139 Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Wed, 27 Nov 2024 18:44:39 +0000 Subject: [PATCH 1/2] [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. --- roles/common/tasks/cr_tests.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/roles/common/tasks/cr_tests.yml b/roles/common/tasks/cr_tests.yml index a9eaccd03..a019ff28c 100644 --- a/roles/common/tasks/cr_tests.yml +++ b/roles/common/tasks/cr_tests.yml @@ -9,13 +9,21 @@ failed_when: - result.rc != 0 -- name: Verify that a CR is ready + # 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: | + {{ "TEST " if condition_type | length >0 }}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: - - item.condition_type is defined From 9180cdd651e7be85b21e0d6809644393bd6f8fc3 Mon Sep 17 00:00:00 2001 From: Emma Foley Date: Fri, 14 Feb 2025 20:36:24 +0000 Subject: [PATCH 2/2] Add conditions to task Mark as a test only if the tasks is run --- roles/common/tasks/cr_tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/roles/common/tasks/cr_tests.yml b/roles/common/tasks/cr_tests.yml index a019ff28c..6fbc046b2 100644 --- a/roles/common/tasks/cr_tests.yml +++ b/roles/common/tasks/cr_tests.yml @@ -18,7 +18,7 @@ condition_type: "{{ item.condition_type if item.condition_type is defined else '' }}" - name: | - {{ "TEST " if condition_type | length >0 }}Verify that the {{ item.kind }} {{ item.name }} CR is {{ condition_type }} + {{ 'TEST ' if condition_type | length > 0 }}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: | @@ -27,3 +27,6 @@ changed_when: false failed_when: - result.stdout != "True" + when: + - common_cr_ready_test_id is defined + - condition_type | length > 0