Most of the actions that you can perform in the Eggplant Performance Analyzer user interface (UI) can also be automated by using the REST API. This ability could be useful if you run performance tests on a regular basis and want to automate the process of analyzing the data and generating a report. For example, you could use the REST API to integrate Analyzer into a continuous integration (CI) environment.
Starting the REST Server
The REST server is a standalone web server that listens for HTTP requests on a specified port. The path to the REST server is as follows:
To start the REST server, run
analyzerRest.exe from the command line. By default, the REST server listens for requests on port 5000. You can specify a different port number by using the
-p command line option:
analyzerRest.exe -p 8888
Sending requests to the REST server
HTTP requests should be directed to the host and port on which the REST server is listening. In addition, you will need to specify the path of the particular method you wish to execute. For example, to list all the available workspaces and comparisons on the localhost, you would send an HTTP GET request to:
All responses received from the REST server will have the MIME type
application/json. For example, the request above would generate a response such as:
"Workspace 1": "http://localhost:5000/analyzer/api/1.0/Workspace%201"
You can parse the response to extract the information you need. For example, the response above tells you the URL to go to for information on the Workspace 1 workspace.
Each HTTP response will also have an HTTP response code. A code in the 200 range (e.g.,
201) indicates that the request was successful. A code in the 400 range (e.g.,
404) indicates that there was a problem with the HTTP request that was sent.
If a particular method requires you to send a POST request, then any POST data should be sent with the header
Content-Type: application/json, and the POST data should be encoded in JSON format. For example, to import a test run into the analysis database, you would send a request such as:
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
"path": "C:\\workspaces\\My Workspace\\projects\\My Project\\runs\\My Series\\My Test.1"
In most programming languages, you will only need to set the
Content-Type header explicitly; the other headers will usually be set automatically.