Skip to content

Commit

Permalink
Adjust code to use results_for_tests()
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaarreell committed Sep 18, 2024
1 parent be35e18 commit b666d13
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions tmt/steps/report/reportportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

import tmt.log
import tmt.steps.report
from tmt.base import Test
from tmt.result import Result, ResultOutcome
from tmt.result import ResultOutcome
from tmt.utils import field, yaml_to_dict

if TYPE_CHECKING:
Expand Down Expand Up @@ -512,35 +511,17 @@ def go(self, *, logger: Optional[tmt.log.Logger] = None) -> None:
self.verbose("uuid", suite_uuid, "yellow", shift=1)
self.data.suite_uuid = suite_uuid

# prepare data for test reporting
# report_queue is a list[tuple(serial_number, result)]
report_queue: list[tuple[int, Optional[Result]]] = []
tests_executed: set[int] = set()
# collect results per serial_number and populate queue of serial_numbers to report
result: Optional[Result] = None # hint for mypy
for result in self.step.plan.execute.results():
tests_executed.add(result.serial_number)
report_queue.append((result.serial_number, result))
# now extend the queue with tests that were not executed
# and populate tests_db
tests_db: dict[int, Test] = {}
test: Optional[Test] = None # hint for mypy
for test in self.step.plan.discover.tests():
tests_db[test.serial_number] = test
if test.serial_number not in tests_executed:
report_queue.append((test.serial_number, None))

# now we can proceed with the actual reporting, we report each serial_number and result
for (serial_number, result) in report_queue:
for result, test in self.step.plan.execute.results_for_tests(
self.step.plan.discover.tests()):
test_time = self.time()
test = tests_db.get(serial_number)
test_name = None

# TODO: for happz, connect Test to Result if possible
# (but now it is probably too hackish to be fixed)

item_attributes = attributes.copy()
if result:
serial_number = result.serial_number
test_name = result.name
test_time = result.start_time or self.time()
# for multi-host tests store also provision name and role
Expand All @@ -558,6 +539,7 @@ def go(self, *, logger: Optional[tmt.log.Logger] = None) -> None:

# update RP item with additional attributes if test details are available
if test:
serial_number = test.serial_number
if not test_name:
test_name = test.name
if test.contact:
Expand All @@ -574,7 +556,6 @@ def go(self, *, logger: Optional[tmt.log.Logger] = None) -> None:
if not re.search(envar_pattern, key)]

if create_test:

if ((self.data.upload_to_launch and launch_per_plan)
or self.data.upload_to_suite):
test_description = self.append_description(test_description)
Expand Down

0 comments on commit b666d13

Please sign in to comment.