Last updated: Jul 27, 2020 11:34
The following video illustrates how you can use the Public API to retrieve test execution reports in JSON format.
To see the full Java code sample see the export-api-sample in the Perfecto Git repository. Similar samples in other languages can be found in the Reporting-Samples folder (look for the export-api-sample in each language folder) in the Git repository.
Obtain a personal security token
The API requires the use of the Perfecto Security Token. Follow the procedure detailed in the Security Token documentation before proceeding.
Use the desired API to export data
The API provides two options for retrieving Report information:
- Retrieve the Execution Driver Report data
- Retrieve the Single Test Report data.
Retrieve the execution driver report
The following HTTP GET command is used to retrieve a list of the test executions in your lab
The following URL query parameters can be added to the URL to filter the number of returned executions.
|startExecutionTime||<Unix time>||The start time, in milliseconds from midnight January 1, 1970 GMT - Epoch/Unix Time|
|endExecutionTime||<Unix time>||The end time, in milliseconds from midnight January 1, 1970 - GMT Epoch/Unix Time|
|externalId||<Driver execution id>||Filter the data to show reports that match a specific driver execution|
|tags||<Reporting tag>||Filter the data to show reports that match a specific tag|
|jobName||<CI Job Name>||Filter the data to show reports that match a specific job name|
|jobNumber||<CI Job Number>||Filter the data to show reports that match a specific job number|
The page of the report to return. A page is defined to include up-to 500 items (execution/report units of information).
Default value: 1 - the first 500 items are returned.
Notes regarding time units:
- The endExecutionTime parameter is only relevant if the startExecutionTime is included.
- If using the Epoch Converter tool to generate the Unix time - convert the resulting time to milliseconds by multiplying the result by 1000.
- To programmatically convert human readable dates to Unix time use the information provided at the end of the Epoch Converter page under the heading Convert from human readable date to epoch, but do not divide the result by 1000 to maintain the millisecond Unix time value.
Notes regarding other filter parameters:
- Request can combine any number of the filter parameters (externalId, tags, jobName, jobNumber) to achieve the filtered list.
- To check if there are additional pages in the response - the metadata field includes a truncated item with value true when there are additional resource items stored for the Execution Driver Report. Use the _page parameter to access the additional pages. See an example of using the _page parameter in GitHub.
Add the following header parameters to the request:
<Your personal security token>
The Execution Driver Report is returned as a JSON structure with two sections:
- resources - that provide information regarding the different information items included in the report. Each "page" of the report response is limited to 500 information items.
- metadata - provides high-level information regarding the report. Two fields may be important for further processing:
- truncated - indicates whether there are additional resource information items not included in the current page.
- processingStatus - indicates if all resource information items have completed processing at time of report retrieval.
The following is an example response for test executions:
The information for each test is listed as a "resource". In particular:
- The "id" field below identifies the particular test (the TEST_ID) and can be used to retrieve the Single Test Report for the test.
- The "reportURL" field provides the link to the Single Test Report for the test associated with the "id". The format of the URL is: https://<reporting-server>/test/<TEST_ID>
- Includes information on the device "platform" of the test,
- Provides the Jenkins job-name and build-number of the test and the user's project name and version information.
- The "executionEngine" field provides the Perfecto MCM version used for the execution.
- Provides links to the video segments included for the test.
- Provides links to the artifacts generated for this execution:
- VITALS - links to the vitals report generated if script activates the Start Vitals command.
- NETWORK - links to the pcap file generated for tracking network activity.
- DEVICE_LOGS - links to the logs file generated for the execution.
Retrieve Single Test Report (STR) data
The following HTTP GET command is used to retrieve the list of commands associated with a single test execution:
The <TEST_ID> is taken from the Execution Driver Report, in the "id" field of the resource. In the example response, above, the <TEST_ID> would be: 5ad4888888c00080dd75a
Add the following parameters to the header section of the request:
|PERFECTO-AUTHORIZATION||<Your personal security token>|
The following shows a JSON response for the request to retrieve STR data: