Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subresults support for reportportal report plugin #3331

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
363b1f3
Import the tmt subresults into the ReportPortal
seberm Nov 12, 2024
9e6054e
Add more hints/todos
seberm Nov 13, 2024
3f657c8
Add very basic release note
seberm Nov 13, 2024
22f166f
Differentiate between start times and end times
seberm Nov 14, 2024
d761603
Prepare basic subresults tests
seberm Nov 14, 2024
25ca286
Ensure the subresult end-time is set correctly
seberm Nov 14, 2024
d8c2984
Improve the log messages
seberm Nov 14, 2024
ed549a2
First fixes of reportportal tests
seberm Nov 15, 2024
c9b836e
Add special handling of subresult items which do have the child items
seberm Nov 15, 2024
8dae40d
More changes to reportportal tests to make it more stable and handle …
seberm Nov 15, 2024
229f12c
Finish the child item, not a parent item
seberm Nov 19, 2024
087f29f
Separate code for uploading result logs into a separate method
seberm Nov 19, 2024
85445f0
Upload the subresult logs
seberm Nov 19, 2024
3678814
Non-functional changes, remove unnecessary
seberm Nov 22, 2024
89e394d
Prepare draft tests for beakerlib phases
seberm Dec 5, 2024
a23a479
More test fixes, still WIP
seberm Dec 12, 2024
f99a2f1
More fixes to tests/subtests
seberm Jan 20, 2025
1cb3259
Remove the TMT_TREE check for subtests
seberm Jan 20, 2025
ecd3ba0
Implements failures method for SubResult same way as for Result
seberm Jan 21, 2025
346b62e
Propagate the write_out_failures also for subresults
seberm Jan 21, 2025
62690b9
Small refactoring of subresult start time
seberm Jan 27, 2025
a6cfa56
Revert "Non-functional changes, remove unnecessary"
seberm Jan 27, 2025
61fde05
Use index instead of checking the log_path
seberm Jan 27, 2025
f89135c
Fix a possibly undefined test_end_time
seberm Jan 27, 2025
6d0c1bf
Remove unnecessary comment
seberm Jan 28, 2025
aef6a3c
Make uploading of tmt optional for reportportal plugin
seberm Jan 29, 2025
984a4f9
Speak about keys, not the options
seberm Jan 29, 2025
641c073
Fix the test for multiple test contacts
seberm Jan 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
Releases
======================


A new ``upload-subresults`` key has been introduced for the
:ref:`/plugins/report/reportportal` plugin, allowing the import of
tmt subresults as child test items into ReportPortal. This
behavior is optional and is disabled by default.


tmt-1.42.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
41 changes: 41 additions & 0 deletions tests/report/reportportal/data/beaker-phases-subresults.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
. /usr/share/beakerlib/beakerlib.sh || exit 1


rlJournalStart
rlPhaseStartSetup "phase-setup"
rlRun "tmp=\$(mktemp -d)" 0 "Create tmp directory"
rlRun "pushd $tmp"
rlPhaseEnd

rlPhaseStartTest "phase-test pass"
rlRun -s "echo mytest-pass" 0 "Check output"
rlAssertGrep "mytest-pass" "$rlRun_LOG"
rlPhaseEnd

rlPhaseStartTest "phase-test fail"
rlRun -s "echo mytest-fail" 0 "Check output"
rlAssertGrep "this-will-intentionally-fail" "$rlRun_LOG"
rlPhaseEnd

rlPhaseStartTest "phase-test multiple tmt-report-result"
rlRun "echo bkr_good_log > bkr_good.log"
rlRun "echo bkr_bad_log > bkr_bad.log"
rlRun "echo bkr_weird_log > bkr_weird.log"
rlRun "echo bkr_skip_log > bkr_skip.log"
rlRun "echo bkr_good_rhts_log > bkr_good_rhts.log"

# This will create more subresults for each
# tmt-report-result/rhts-report-result call
rlRun "tmt-report-result -o bkr_good.log extra-tmt-report-result/good PASS"
rlRun "tmt-report-result -o bkr_bad.log extra-tmt-report-result/bad FAIL"
rlRun "tmt-report-result -o bkr_weird.log extra-tmt-report-result/weird WARN"
rlRun "tmt-report-result -o bkr_skip.log extra-tmt-report-result/skip SKIP"
rlRun "rhts-report-result extra-rhts-report-result/good PASS bkr_good_rhts.log"
rlPhaseEnd

rlPhaseStartCleanup "phase-cleanup"
rlRun "popd"
rlRun "rm -r $tmp" 0 "Remove tmp directory"
rlPhaseEnd
rlJournalEnd
3 changes: 2 additions & 1 deletion tests/report/reportportal/data/plan.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ summary: Testing the integration of tmt and Report Portal via its API
discover:
how: fmf
provision:
how: local
how: container
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reportportal tests are not designed to run in the GH CI. Instead, they should be executed locally by a developer against a specific ReportPortal instance. That's why I think it's preferable to run them in a container or using the '-h virtual' option. I am not "--feeling-safe" enough to run them locally :).

execute:
how: tmt
report:
how: reportportal
project: test_tmt
upload-subresults: true

context:
component: tmt
Expand Down
20 changes: 20 additions & 0 deletions tests/report/reportportal/data/test.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,23 @@
/weird:
summary: An error encountered
test: this-is-a-weird-command

/subresults:
summary: Test the tmt subresults (ReportPortal child items)
test: |
tmt-report-result /subtest/good PASS
tmt-report-result /subtest/fail FAIL
tmt-report-result /subtest/weird WARN

/subresults-restraint:
result: restraint
test: |
tmt-report-result /subtest-restraint/good PASS
tmt-report-result /subtest-restraint/fail FAIL
tmt-report-result /subtest-restraint/weird WARN

# TODO: Enable test of subresults for beakerlib phases
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seberm a TODO item?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, first, I need to stabilize the existing tests, and then I plan to uncomment the beakerlib tests. We're still working on it with @4N0body5.

#/subresults-beakerlib:
# summary: Test the Beakerlib phases are propagated as tmt subresults
# framework: beakerlib
# test: ./beaker-phases-subresults.sh
200 changes: 120 additions & 80 deletions tests/report/reportportal/test.sh

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions tmt/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ class SubResult(BaseResult):
SubCheckResult.from_serialized(check) for check in serialized]
)

@staticmethod
def failures(log: Optional[str], msg_type: str = 'FAIL') -> str:
""" Filter stdout and get only messages with certain type """
return Result.failures(log, msg_type)


@dataclasses.dataclass
class PhaseResult(BaseResult):
Expand Down
3 changes: 3 additions & 0 deletions tmt/schemas/report/reportportal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ properties:
ssl-verify:
type: boolean

upload-subresults:
type: boolean

when:
$ref: "/schemas/common#/definitions/when"

Expand Down
Loading