Skip to content

Commit

Permalink
Support multiple test contacts in the ReportPortal plugin (#3412)
Browse files Browse the repository at this point in the history
  • Loading branch information
seberm authored Jan 9, 2025
1 parent b2eb7d2 commit d686811
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
6 changes: 4 additions & 2 deletions tests/report/reportportal/data/test.fmf
Original file line number Diff line number Diff line change
@@ -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

Expand Down
11 changes: 10 additions & 1 deletion tests/report/reportportal/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +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
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
Expand Down
3 changes: 2 additions & 1 deletion tmt/steps/report/reportportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit d686811

Please sign in to comment.