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

Reportportal should note guest hostname for investigation #3209

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 21 additions & 3 deletions tmt/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,26 @@ class ResultGuestData(SerializableContainer):

name: str = f'{tmt.utils.DEFAULT_NAME}-0'
role: Optional[str] = None
primary_address: Optional[str] = None

@classmethod
def from_test_invocation(
cls,
*,
invocation: 'tmt.steps.execute.TestInvocation') -> 'ResultGuestData':
"""
Create a guest data for a result from a test invocation.

A helper for extracting interesting guest data from a given test
invocation.

:param invocation: a test invocation capturing the test run and results.
"""

return ResultGuestData(
name=invocation.guest.name,
role=invocation.guest.role,
primary_address=invocation.guest.primary_address)


# This needs to be a stand-alone function because of the import of `tmt.base`.
Expand Down Expand Up @@ -253,8 +273,6 @@ def from_test_invocation(
default_ids.update(ids)
ids = default_ids

guest_data = ResultGuestData(name=invocation.guest.name, role=invocation.guest.role)

_result = Result(
name=invocation.test.name,
serial_number=invocation.test.serial_number,
Expand All @@ -267,7 +285,7 @@ def from_test_invocation(
duration=invocation.real_duration,
ids=ids,
log=log or [],
guest=guest_data,
guest=ResultGuestData.from_test_invocation(invocation=invocation),
data_path=invocation.relative_test_data_path)

return _result.interpret_result(ResultInterpret(
Expand Down
4 changes: 2 additions & 2 deletions tmt/steps/execute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ def _process_results_partials(
:returns: list of results.
"""

test, guest = invocation.test, invocation.guest
test = invocation.test

custom_results = []
for partial_result_data in results:
Expand Down Expand Up @@ -795,7 +795,7 @@ def _process_results_partials(
partial_result.serial_number = test.serial_number

# Enforce the correct guest info
partial_result.guest = ResultGuestData(name=guest.name, role=guest.role)
partial_result.guest = ResultGuestData.from_test_invocation(invocation=invocation)

# For the result representing the test itself, set the important
# attributes to reflect the reality.
Expand Down
9 changes: 8 additions & 1 deletion tmt/steps/report/reportportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,14 @@ def go(self, *, logger: Optional[tmt.log.Logger] = None) -> None:
item_attributes = attributes.copy()
if result:
test_time = result.start_time or self.time()
# for multi-host tests store also provision name and role

# for guests, save their primary address
if result.guest.primary_address:
item_attributes.append({
'key': 'guest_primary_address',
'value': result.guest.primary_address})

# for multi-host tests store also guest name and role
if result.guest.name != 'default-0':
item_attributes.append(
{'key': 'guest_name', 'value': result.guest.name})
Expand Down
Loading