tmt.steps.report package

Submodules

tmt.steps.report.display module

class tmt.steps.report.display.ReportDisplay(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: ReportPlugin[ReportDisplayData]

Show test results on the terminal.

Give a concise summary of test results directly on the terminal. List individual test results in verbose mode.

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
details(result: Result, verbosity: int, display_guest: bool) None

Print result details.

Parameters:
  • result – a test result to display.

  • verbosity – how verbose should the report be. Generally equal to number of --verbose/-v options given on command line. For 1, display only test name and its result, 2 will add log paths, and 3 or more would show the test output as well.

  • display_guest – if set, guest multihost name would be part of the report.

go(*, logger: Logger | None = None) None

Discover available tests

class tmt.steps.report.display.ReportDisplayData(name: str, how: str, order: int = 50, summary: str | None = None, display_guest: str = 'auto')

Bases: ReportStepData

display_guest: str = 'auto'

tmt.steps.report.html module

class tmt.steps.report.html.ReportHtml(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: ReportPlugin[ReportHtmlData]

Format test results into an HTML report.

Example config:

report:
    how: html
    open: true

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
go(*, logger: Logger | None = None) None

Process results

prune(logger: Logger) None

Do not prune generated html report

class tmt.steps.report.html.ReportHtmlData(name: str, how: str, order: int = 50, summary: str | None = None, open: bool = False, absolute_paths: bool = False, display_guest: str = 'auto')

Bases: ReportStepData

absolute_paths: bool = False
display_guest: str = 'auto'
open: bool = False

tmt.steps.report.junit module

class tmt.steps.report.junit.ImplementProperties

Bases: object

Define a properties attribute.

This class can be used to easily add properties attribute by inheriting it.

class PropertyDict

Bases: TypedDict

Defines a property dict, which gets propagated into the final template properties.

name: str
value: str
property properties: list[PropertyDict]
class tmt.steps.report.junit.ReportJUnit(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: ReportPlugin[ReportJUnitData]

Save test results in chosen JUnit flavor format.

When flavor is set to custom, the template-path with a path to a custom template must be provided.

When file is not specified, output is written into a file named junit.xml located in the current workdir.

Store plugin name, data and parent step

check_options() None

Check the module options

cli_invocation: 'tmt.cli.CliInvocation' | None = None
go(*, logger: Logger | None = None) None

Read executed tests and write junit

prune(logger: Logger) None

Do not prune generated junit report

class tmt.steps.report.junit.ReportJUnitData(name: str, how: str, order: int = 50, summary: str | None = None, file: tmt._compat.pathlib.Path | None = None, flavor: str = 'default', template_path: tmt._compat.pathlib.Path | None = None, prettify: bool = True, include_output_log: bool = True)

Bases: ReportStepData

file: Path | None = None
flavor: str = 'default'
include_output_log: bool = True
prettify: bool = True
template_path: Path | None = None
class tmt.steps.report.junit.ResultWrapper(wrapped: Result | SubResult, subresults_context_class: type[ResultsContext])

Bases: ImplementProperties

The context wrapper for tmt.Result.

Adds possibility to wrap the tmt.Result and dynamically add more attributes which get available inside the template context.

property subresult: ResultsContext

Override the tmt.Result.subresult and wrap all the tmt.result.SubResult instances into the ResultsContext.

class tmt.steps.report.junit.ResultsContext(results: list[Result] | list[SubResult])

Bases: ImplementProperties

The results context for Jinja templates.

A class which keeps the results context (especially the result summary) for JUnit template. It wraps all the tmt.Result instances into the ResultWrapper.

Decorate/wrap all the Result and SubResult instances with more attributes

property duration: int

Returns the total duration of all tests in seconds

property errored: list[ResultWrapper]

Returns results of tests with error/warn outcome

property failed: list[ResultWrapper]

Returns results of failed tests

property passed: list[ResultWrapper]

Returns results of passed tests

property skipped: list[ResultWrapper]

Returns results of skipped tests

tmt.steps.report.junit.make_junit_xml(phase: ReportPlugin[Any], flavor: str = 'default', template_path: Path | None = None, include_output_log: bool = True, prettify: bool = True, results_context: ResultsContext | None = None, **extra_variables: Any) str

Create JUnit XML file and return the data.

Parameters:
  • phase – instance of a tmt.steps.report.ReportPlugin.

  • flavor – name of a JUnit flavor to generate.

  • template_path – if set, the provided template will be used instead of a pre-defined flavor template. In this case, the flavor must be set to custom value.

  • include_output_log – if enabled, the <system-out> tags are included in the final template output.

  • prettify – allows to control the XML pretty print.

  • results_context – if set, the provided ResultsContext is used in a template.

  • extra_variables – if set, these variables get propagated into the Jinja template.

tmt.steps.report.polarion module

class tmt.steps.report.polarion.ReportPolarion(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: ReportPlugin[ReportPolarionData]

Write test results into an xUnit file and upload to Polarion

Store plugin name, data and parent step

cli_invocation: 'tmt.cli.CliInvocation' | None = None
go(*, logger: Logger | None = None) None

Go through executed tests and report into Polarion

prune(logger: Logger) None

Do not prune generated xunit report

class tmt.steps.report.polarion.ReportPolarionData(name: str, how: str, order: int = 50, summary: str | None = None, file: tmt._compat.pathlib.Path | None = None, upload: bool = True, project_id: str | None = None, title: str | None = None, description: str | None = None, template: str | None = None, use_facts: bool = False, planned_in: str | None = None, assignee: str | None = None, pool_team: str | None = None, arch: str | None = None, platform: str | None = None, build: str | None = None, sample_image: str | None = None, logs: str | None = None, compose_id: str | None = None, fips: bool = False, prettify: bool = True, include_output_log: bool = True)

Bases: ReportStepData

arch: str | None = None
assignee: str | None = None
build: str | None = None
compose_id: str | None = None
description: str | None = None
file: Path | None = None
fips: bool = False
include_output_log: bool = True
logs: str | None = None
planned_in: str | None = None
platform: str | None = None
pool_team: str | None = None
prettify: bool = True
project_id: str | None = None
sample_image: str | None = None
template: str | None = None
title: str | None = None
upload: bool = True
use_facts: bool = False

tmt.steps.report.reportportal module

class tmt.steps.report.reportportal.LogFilterSettings(size: 'Size' = <Quantity(1, 'megabyte')>, is_traceback: bool = False)

Bases: object

is_traceback: bool = False
size: Size = <Quantity(1, 'megabyte')>
class tmt.steps.report.reportportal.ReportReportPortal(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: ReportPlugin[ReportReportPortalData]

Report test results to a ReportPortal instance via API.

For communication with Report Portal API is necessary to provide following options:

  • token for authentication

  • url of the ReportPortal instance

  • project name

In addition to command line options it’s possible to use environment variables:

export TMT_PLUGIN_REPORT_REPORTPORTAL_${MY_OPTION}=${MY_VALUE}

Assuming the URL and token are provided by the environment variables, the plan config can look like this:

report:
    how: reportportal
    project: baseosqe

context:
    ...

environment:
    ...

Where the context and environment sections must be filled with corresponding data in order to report context as attributes (arch, component, distro, trigger, compose, etc.) and environment variables as parameters in the Item Details.

Other reported fmf data are summary, id, web link and contact per test.

Two types of data structures are supported for reporting to ReportPortal:

  • ‘launch-per-plan’ mapping (default) that results in launch-test structure.

  • ‘suite-per-plan’ mapping that results in launch-suite-test structure.

Supported report use cases:

  • Report a new run in launch-suite-test or launch-test structure

  • Report an additional rerun with ‘launch-rerun’ option and same launch name (->Retry items) or by reusing the run and reporting with ‘again’ option (->append logs)

  • To see plan progress, discover and report an empty (IDLE) run and reuse the run for execution and updating the report with ‘again’ option

  • Report contents of a new run to an existing launch via the URL ID in three ways: tests to launch, suites to launch and tests to suite.

Store plugin name, data and parent step

TMT_TO_RP_RESULT_STATUS = {ResultOutcome.ERROR: 'FAILED', ResultOutcome.FAIL: 'FAILED', ResultOutcome.INFO: 'SKIPPED', ResultOutcome.PASS: 'PASSED', ResultOutcome.SKIP: 'SKIPPED', ResultOutcome.WARN: 'FAILED'}
append_description(curr_description: str) str

Extend text with the launch description (if provided)

check_options() None

Check options for known troublesome combinations

cli_invocation: 'tmt.cli.CliInvocation' | None = None
construct_launch_attributes(suite_per_plan: bool, attributes: list[dict[str, str]]) list[dict[str, str]]
property datetime: str
execute_rp_import() None

Execute the import of test, results and subresults into ReportPortal

get_defect_type_locator(session: Session, defect_type: str | None) str
go(*, logger: Logger | None = None) None

Report test results to the endpoint

Create a ReportPortal launch and its test items, fill it with all parts needed and report the logs.

handle_response(response: Response) None

Check the endpoint response and raise an exception if needed

property headers: dict[str, str]
rp_api_get(session: Session, path: str) Response
rp_api_post(session: Session, path: str, json: Any) Response
rp_api_put(session: Session, path: str, json: Any) Response
property url: str
class tmt.steps.report.reportportal.ReportReportPortalData(name: str, how: str, order: int = 50, summary: Optional[str] = None, url: Optional[str] = None, token: Optional[str] = None, project: Optional[str] = None, launch: Optional[str] = None, launch_description: Optional[str] = None, launch_per_plan: bool = False, suite_per_plan: bool = False, upload_to_launch: Optional[str] = None, upload_to_suite: Optional[str] = None, launch_rerun: bool = False, defect_type: Optional[str] = None, log_size_limit: 'Size' = <Quantity(1, 'megabyte')>, traceback_size_limit: 'Size' = <Quantity(50, 'kilobyte')>, exclude_variables: str = '^TMT_.*', api_version: str = 'v1', artifacts_url: Optional[str] = None, ssl_verify: bool = True, launch_url: Optional[str] = None, launch_uuid: Optional[str] = None, suite_uuid: Optional[str] = None, test_uuids: dict[int, str] = <factory>)

Bases: ReportStepData

api_version: str = 'v1'
artifacts_url: str | None = None
defect_type: str | None = None
exclude_variables: str = '^TMT_.*'
launch: str | None = None
launch_description: str | None = None
launch_per_plan: bool = False
launch_rerun: bool = False
launch_url: str | None = None
launch_uuid: str | None = None
log_size_limit: Size = <Quantity(1, 'megabyte')>
project: str | None = None
ssl_verify: bool = True
suite_per_plan: bool = False
suite_uuid: str | None = None
test_uuids: dict[int, str]
token: str | None = None
traceback_size_limit: Size = <Quantity(50, 'kilobyte')>
upload_to_launch: str | None = None
upload_to_suite: str | None = None
url: str | None = None

Module contents

class tmt.steps.report.Report(*, plan: Plan, data: _RawStepData | list[_RawStepData] | None = None, name: str | None = None, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: Step

Provide test results overview and send reports.

Initialize and check the step data

DEFAULT_HOW: str = 'display'
cli_invocation: 'tmt.cli.CliInvocation' | None = None
cli_invocations: list['tmt.cli.CliInvocation'] = []
go(force: bool = False) None

Report the results

summary() None

Give a concise report summary

wake() None

Wake up the step (process workdir and command line)

class tmt.steps.report.ReportPlugin(*, step: Step, data: StepDataT, workdir: Literal[True] | Path | None = None, logger: Logger)

Bases: GuestlessPlugin[ReportStepDataT, None]

Common parent of report plugins

Store plugin name, data and parent step

classmethod base_command(usage: str, method_class: type[Command] | None = None) Command

Create base click command (common for all report plugins)

cli_invocation: 'tmt.cli.CliInvocation' | None = None
go(*, logger: Logger | None = None) None

Perform actions shared among plugins when beginning their tasks

how: str = 'display'
class tmt.steps.report.ReportStepData(name: str, how: str, order: int = 50, summary: str | None = None)

Bases: StepData