From ad65d54649b3f7e81d43ac7de9aec5c11a867eb6 Mon Sep 17 00:00:00 2001 From: Otto Sabart Date: Sun, 8 Dec 2024 22:12:06 +0100 Subject: [PATCH 1/4] Export all the test contacts to the reportportal --- tmt/steps/report/reportportal.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tmt/steps/report/reportportal.py b/tmt/steps/report/reportportal.py index 190ae0ae37..f80d7f62c9 100644 --- a/tmt/steps/report/reportportal.py +++ b/tmt/steps/report/reportportal.py @@ -618,7 +618,8 @@ def execute_rp_import(self) -> None: if not test_name: test_name = test.name if test.contact: - item_attributes.append({"key": "contact", "value": test.contact[0]}) + item_attributes += [ + {'key': 'contact', 'value': contact} for contact in test.contact] if test.summary: test_description = test.summary if test.web_link(): From 5379f351865544203ceddd7a5d2cbccaf2917513 Mon Sep 17 00:00:00 2001 From: Otto Sabart Date: Sun, 8 Dec 2024 22:14:16 +0100 Subject: [PATCH 2/4] Prepare a test for multiple test contacts --- tests/report/reportportal/data/test.fmf | 6 ++++-- tests/report/reportportal/test.sh | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/report/reportportal/data/test.fmf b/tests/report/reportportal/data/test.fmf index ca1829b8a7..237c13c8e2 100644 --- a/tests/report/reportportal/data/test.fmf +++ b/tests/report/reportportal/data/test.fmf @@ -1,11 +1,13 @@ /bad: summary: Failing test - contact: tester@redhat.com + contact: + - tester1@redhat.com + - tester2@redhat.com test: echo "Something bad happened!"; false /good: summary: Passing test - contact: tester_2@redhat.com + contact: tester3@redhat.com test: echo "Everything's fine!" id: 63f26fb7-69c4-4781-a06e-098e2b58129f diff --git a/tests/report/reportportal/test.sh b/tests/report/reportportal/test.sh index 345dc8ace7..17b53cd8fb 100755 --- a/tests/report/reportportal/test.sh +++ b/tests/report/reportportal/test.sh @@ -191,6 +191,14 @@ rlJournalStart key="contact" value="$(yq -r ".\"$test_name\".$key" test.fmf)" if [[ $value != null ]]; then + # TODO: Fix the test here! The output of yq is list of + # contact in the case of multiple contacts (test==/bad) + # and a string in a case when one contact is provided + # for the test (test==/good). We must somehow handle + # both situations. + # + # If yq returns list, we must check both contacts in the response JSON + # If yq returns just a string value, we must check only one contact in the response JSON rlAssertGrep "$key" tmp_attributes.json -A1 > tmp_attributes_selection rlAssertGrep "$value" tmp_attributes_selection else @@ -201,6 +209,10 @@ rlJournalStart rlAssertNotGrep "$key" tmp_attributes.json fi + # REMOVE ME: just for testing + #echo "EXITING OMG" + #exit 99 + rm tmp_attributes* done From 699ad55827ccba1fb1af50cba5e2b321ff1af557 Mon Sep 17 00:00:00 2001 From: Otto Sabart Date: Wed, 11 Dec 2024 16:03:18 +0100 Subject: [PATCH 3/4] Fix the test to support multiple test contacts --- tests/report/reportportal/test.sh | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/tests/report/reportportal/test.sh b/tests/report/reportportal/test.sh index 17b53cd8fb..cd80aa3314 100755 --- a/tests/report/reportportal/test.sh +++ b/tests/report/reportportal/test.sh @@ -189,18 +189,19 @@ rlJournalStart # Check the rarities in the test attributes/parameters if [[ $jq_element == attributes ]]; then key="contact" + value="$(yq -r ".\"$test_name\".$key" test.fmf)" if [[ $value != null ]]; then - # TODO: Fix the test here! The output of yq is list of - # contact in the case of multiple contacts (test==/bad) - # and a string in a case when one contact is provided - # for the test (test==/good). We must somehow handle - # both situations. - # - # If yq returns list, we must check both contacts in the response JSON - # If yq returns just a string value, we must check only one contact in the response JSON + if [[ "$value" == *","* ]]; then + # Get the contact items as CSV (separated by a comma) + value="$(yq -r ". | @csv" <<< $value)" + fi rlAssertGrep "$key" tmp_attributes.json -A1 > tmp_attributes_selection - rlAssertGrep "$value" tmp_attributes_selection + + IFS=, read -r -a contact_items <<< "$value" + for contact_item in "${contact_items[@]}"; do + rlAssertGrep "$contact_item" tmp_attributes_selection + done else rlAssertNotGrep "$key" tmp_attributes.json fi @@ -209,10 +210,6 @@ rlJournalStart rlAssertNotGrep "$key" tmp_attributes.json fi - # REMOVE ME: just for testing - #echo "EXITING OMG" - #exit 99 - rm tmp_attributes* done From cdee5d9d382392f13997a2ec4c388e8f59b341a3 Mon Sep 17 00:00:00 2001 From: Otto Sabart Date: Tue, 17 Dec 2024 15:14:11 +0100 Subject: [PATCH 4/4] Add a release note --- docs/releases.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/releases.rst b/docs/releases.rst index 94be241686..c22382f7a2 100644 --- a/docs/releases.rst +++ b/docs/releases.rst @@ -13,6 +13,10 @@ method are now executed in the exact order as listed in the config file. This fixes a problem which has been introduced in the recent ``fmf`` update. +The :ref:`/plugins/report/reportportal` plugin now exports all +test contact information, rather than just the first contact +instance. + tmt-1.40.0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~