Skip to content

Commit d686811

Browse files
authored
Support multiple test contacts in the ReportPortal plugin (#3412)
1 parent b2eb7d2 commit d686811

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

docs/releases.rst

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ method are now executed in the exact order as listed in the config
1313
file. This fixes a problem which has been introduced in the recent
1414
``fmf`` update.
1515

16+
The :ref:`/plugins/report/reportportal` plugin now exports all
17+
test contact information, rather than just the first contact
18+
instance.
19+
1620

1721
tmt-1.40.0
1822
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/report/reportportal/data/test.fmf

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/bad:
22
summary: Failing test
3-
3+
contact:
4+
5+
46
test: echo "Something bad happened!"; false
57

68
/good:
79
summary: Passing test
8-
contact: tester_2@redhat.com
10+
contact: tester3@redhat.com
911
test: echo "Everything's fine!"
1012
id: 63f26fb7-69c4-4781-a06e-098e2b58129f
1113

tests/report/reportportal/test.sh

+10-1
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,19 @@ rlJournalStart
189189
# Check the rarities in the test attributes/parameters
190190
if [[ $jq_element == attributes ]]; then
191191
key="contact"
192+
192193
value="$(yq -r ".\"$test_name\".$key" test.fmf)"
193194
if [[ $value != null ]]; then
195+
if [[ "$value" == *","* ]]; then
196+
# Get the contact items as CSV (separated by a comma)
197+
value="$(yq -r ". | @csv" <<< $value)"
198+
fi
194199
rlAssertGrep "$key" tmp_attributes.json -A1 > tmp_attributes_selection
195-
rlAssertGrep "$value" tmp_attributes_selection
200+
201+
IFS=, read -r -a contact_items <<< "$value"
202+
for contact_item in "${contact_items[@]}"; do
203+
rlAssertGrep "$contact_item" tmp_attributes_selection
204+
done
196205
else
197206
rlAssertNotGrep "$key" tmp_attributes.json
198207
fi

tmt/steps/report/reportportal.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,8 @@ def execute_rp_import(self) -> None:
618618
if not test_name:
619619
test_name = test.name
620620
if test.contact:
621-
item_attributes.append({"key": "contact", "value": test.contact[0]})
621+
item_attributes += [
622+
{'key': 'contact', 'value': contact} for contact in test.contact]
622623
if test.summary:
623624
test_description = test.summary
624625
if test.web_link():

0 commit comments

Comments
 (0)