buildtest.cli.report
¶
Module Contents¶
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 |
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(report_file=None, filter_args=None, format_args=None, latest=None, oldest=None)[source]¶
- Parameters
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
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
- format_fields = ['buildspec', 'command', 'compiler', 'endtime', 'errfile', 'executor', 'full_id', 'hostname',...¶
- filter_fields = ['buildspec', 'name', 'executor', 'state', 'tags', 'returncode']¶
- display_table¶
- _check_filter_fields(self)[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(self)[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
- load(self)[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(self)[source]¶
This method filters the report table input filter
--filter buildspec
. If entry found in buildspec cache we add to list
- _filter_by_names(self, 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(self, 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(self, 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(self, 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(self, 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(self)[source]¶
Displays list of format field which implements command
buildtest report --helpformat
- print_filter_fields(self)[source]¶
Displays list of help filters which implements command
buildtest report --helpfilter
- print_report(self, terse=None, noheader=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
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(self, 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
- _testid_lookup(self)[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.
- builder_names(self)[source]¶
Return a list of builder names in builder format which is in the form: <NAME>/<TESTID>.