buildtest.cli.report
¶
Module Contents¶
Classes¶
|
Functions¶
|
Check if input is an integer by running int(). If its successful we |
|
Entry point for |
|
This method will print summary for report file which can be retrieved via |
|
Print output of |
Attributes¶
- buildtest.cli.report.logger¶
- buildtest.cli.report.is_int(val)[source]¶
Check if input is an integer by running int(). If its successful we return True otherwise returns False
- class buildtest.cli.report.Report(configuration, report_file=None, filter_args=None, format_args=None, start=None, end=None, failure=None, passed=None, latest=None, oldest=None, count=None, pager=None, detailed=None, color=None)[source]¶
- Parameters
configuration (buildtest.config.SiteConfiguration) – Instance of SiteConfiguration class that is loaded buildtest configuration.
report_file (str, optional) – Full path to report file to read
filter_args (str, optional) – A comma separated list of Key=Value pair for filter arguments via
buildtest report --filter
format (str, optional) – A comma separated list of format fields for altering report table. This is specified via
buildtest report --format
start (datetime, optional) – Fetch run for all tests discovered filered by starttime. This is specified via
buildtest report --start
end (datetime, optional) – Fetch run for all tests discovered filered by endtime. This is specified via
buildtest report --end
failure (bool, optional) – Fetch failure run for all tests discovered. This is specified via
buildtest report --fail
passed (bool, optional) – Fetch passed run for all tests discovered. This is specified via
buildtest report --pass
latest (bool, optional) – Fetch latest run for all tests discovered. This is specified via
buildtest report --latest
oldest (bool, optional) – Fetch oldest run for all tests discovered. This is specified via
buildtest report --oldest
count (int, optional) – Fetch limited number of rows get printed for all tests discovered. This is specified via
buildtest report --count
pager (bool, optional) – Enabling PAGING output for
buildtest report
. This can be specified viabuildtest report --pager
color (str, optional) – An instance of a string class that tells print_report what color the output should be printed in.
- format_field_description¶
- filter_field_description¶
- format_fields¶
- filter_fields¶
- display_table¶
- _check_filter_fields()[source]¶
This method will validate filter fields
buildtest report --filter
by checking if field is valid filter field. If one specifies an invalid filter field, we will raise an exception- Raises
BuildTestError – Raise exception if its in invalid filter field. If returncode is not an integer we raise exception
- _check_format_fields()[source]¶
Check all format arguments (–format) are valid, the arguments are specified in format (–format key1=val1,key2=val2). We make sure each key is valid format field.
- Raises
BuildTestError – If format field is not valid
- _check_start_and_end_fields()[source]¶
Check start argument (–start) and end argument (–end) are valid. The start argument is specified in format (–start yyyy-mm-dd), end argument in format (–end yyyy-mm-dd), or both (–start yyyy-mm-dd –end yyyy-mm-dd).
- Raises
BuildTestError – If –start is greater than –end or –end is greater than current time - datetime.datetime.now()
- load()[source]¶
This method is responsible for loading report file. If file not found or report is empty dictionary we raise an error. The report file is loaded if its valid JSON file and returns as dictionary containing entire report of all tests.
- Raises
SystemExit – If report file doesn’t exist or path is not a file. If the report file is empty upon loading we raise an error.
- filter_buildspecs_from_report()[source]¶
This method filters the report table input filter
--filter buildspec
. If entry found in buildspec cache we add to list
- filter_by_start_end(test)[source]¶
This method will return a boolean (True/False) to check if test should be included from report. Given an input test, we check if a test record has ‘starttime’ and ‘endtime’ fields in range specified by
--start
and--end
by the user. If there is a match we returnTrue
. AFalse
indicates the test will not be incldued in report.- Parameters
test (dict) – Test record loaded as dictionary
- _filter_by_names(name)[source]¶
Filter test by name of test. This method will return True if record should be processed, otherwise returns False
- Parameters
name (str) – Name of test to filter
- _filter_by_tags(test)[source]¶
This method will return a boolean (True/False) to check if test should be skipped from report. Given an input test, we check if test has ‘tags’ property in buildspec and if tagnames specified by
--filter tags
are found in the test. If there is a match we returnFalse
. ATrue
indicates the test will be filtered out.- Parameters
test (dict) – Test recorded loaded as dictionary
- _filter_by_executor(test)[source]¶
Filters test by
executor
property given input parameterbuildtest report --filter executor:<executor>
. If there is no match we returnTrue
otherwise returnsFalse
.- Parameters
test (dict) – Test recorded loaded as dictionary
- _filter_by_state(test)[source]¶
This method filters test by
state
property based on input parameterbuildtest report --filter state:<STATE>
. If there is no match we returnTrue
otherwise returnsFalse
.- Parameters
test (dict) – Test recorded loaded as dictionary
- _filter_by_returncode(test)[source]¶
Returns True/False if test is filtered by returncode. We will get input returncode in filter field via
buildtest report --filter returncode:<CODE>
with one in test and if there is a match we returnTrue
otherwise returnsFalse
.- Parameters
test (dict) – Test recorded loaded as dictionary
- print_format_fields()[source]¶
Displays list of format field which implements command
buildtest report --helpformat
- print_filter_fields()[source]¶
Displays list of help filters which implements command
buildtest report --helpfilter
- print_raw_filter_fields()[source]¶
Print list of filter fields which implements command
buildtest report --filterfields
- print_raw_format_fields()[source]¶
Print list of format fields which implements command
buildtest report --formatfields
- print_report(terse=None, row_count=None, noheader=None, title=None, count=None, color=None)[source]¶
This method will print report table after processing report file. By default we print output in table format but this can be changed to terse format which will print output in parseable format.
- Parameters
terse (bool, optional) – Print output int terse format
row_count (bool, optional) – Print total number of records from the table
noheader (bool, optional) – Determine whether to print header in terse format
title (str, optional) – Table title to print out
count (int, optional) – Number of rows to be printed in terse format
color (str, optional) – An instance of a string class that tells print_report what color the output should be printed in.
In this example, we display output in tabular format which works with
--filter
and--format
option.bash-3.2$ buildtest report --filter name=root_disk_usage --format name,state,returncode Reading report file: /Users/siddiq90/Documents/GitHubDesktop/buildtest/var/report.json +-----------------+---------+--------------+ | name | state | returncode | +=================+=========+==============+ | root_disk_usage | PASS | 0 | +-----------------+---------+--------------+ | root_disk_usage | PASS | 0 | +-----------------+---------+--------------+ | root_disk_usage | PASS | 0 | +-----------------+---------+--------------+
In terse format each output is separated by PIPE symbol (|*). The first row contains headers followed by content of the report.
bash-3.2$ buildtest report --filter name=root_disk_usage --format name,state,returncode --terse name|state|returncode root_disk_usage|PASS|0 root_disk_usage|PASS|0 root_disk_usage|PASS|0
You can avoid printing the header table by specifying –no-header option
bash-3.2$ buildtest report --filter name=root_disk_usage --format name,state,returncode --terse --no-header root_disk_usage|PASS|0 root_disk_usage|PASS|0 root_disk_usage|PASS|0
- latest_testid_by_name(name)[source]¶
Given a test name return test id of latest run
- Parameters
name (str) – Name of test to search in report file and retrieve corresponding test id
- get_random_tests(num_items=1)[source]¶
Returns a list of random test names from the list of available test. The test are picked using random.sample
- Parameters
num_items (int, optional) – Number of test items to retrieve
- _testid_lookup()[source]¶
Return a dict where key represents full id of test and value is a dictionary containing two values
name
andbuildspec
property which contains name of test and path to buildspec file.
- lookup()[source]¶
Create a lookup dictionary with keys corresponding to name of test names and values are list of test ids.
from buildtest.cli.report import Report r = Report() r.lookup() {'exit1_fail': ['913ce128-f425-488a-829d-d5d898113e8b', '54fc3dfe-50c5-4d2c-93fc-0c26364d215d', '70971081-84f9-462e-809b-a7d438a480bf'], 'exit1_pass': ['775a5545-bac5-468d-994d-85b22544306b', '0e908a64-fc81-4606-8ef4-78360563618e', '17082a05-ba32-4ef1-a38a-c2c6ea125bae', '3f50a73c-e333-4bbb-a722-aa5d72f98ac1', '964cd416-ad91-42be-bc1c-e25119f6df5d']}
- builder_names()[source]¶
Return a list of builder names in builder format which is in the form: <NAME>/<TESTID>.
- get_random_builder_names(num_items=1)[source]¶
Return a list of random builder names from report file.
- Parameters
num_items (int, optional) – Number of items to retrieve
- buildtest.cli.report.report_cmd(args, configuration, report_file=None)[source]¶
Entry point for
buildtest report
command
- buildtest.cli.report.report_summary(report, configuration, detailed=None, color=None)[source]¶
This method will print summary for report file which can be retrieved via
buildtest report summary
command :param report: An instance of Report class :type report: buildtest.cli.report.Report :param detailed: An instance of bool, flag for printing a detailed report. :type detailed: bool :param color: An instance of str, color that the report should be printed in :type color: str
- buildtest.cli.report.print_report_summary_output(report, table, pass_results, fail_results, color=None, detailed=None)[source]¶
Print output of
buildtest report summary
.- Parameters
report (buildtest.cli.report.Report) – An instance of Report class
table (rich.table.Table) – An instance of Rich Table class
pass_results (buildtest.cli.report.Report) – An instance of Report class with filtered output by
state=PASS
fail_results (buildtest.cli.report.Report) – An instance of Report class with filtered output by
state=FAIL
color (str) – An instance of a string class that tells print_report_summary what color the output should be printed in.
detailed (bool, optional) – Print detailed output of the report summary if
buildtest report summary --detailed
is specified