This post was written by Alex Geifman from the Performance Center Quality Team
Micro Focus Performance Center 12.55 provides the following tools for developing automation scenarios and integrating Performance Center into a CI routine:
- Performance Center Rest API
- Performance Center Administration Rest API
- Dockerized Load Generators
- Jenkins Plugin
This article is the first in a series of short articles that will describe each of these aforementioned tools.
Let’s start with an introduction to the Performance Center 12.55 Rest API.
Performance Center 12.55 testing center of excellence exposes much of its functionality through Rest API. Examples of operations that are enabled by the REST API include: authenticating the PC user, creating test folders, uploading scripts, and creating and running load tests
In this article, you will learn how to perform a REST call to Performance Center, and how to interpret the response.
To be able to send REST calls you need to install a REST client. In this article, we will use Postman (https://www.getpostman.com/).
A REST call consists of several parts: HTTP Method, URL, Headers, and Body (there are more but let’s concentrate on the most important ones). See the Performance Center REST API documentation for the URL, HTTP Method, Header, and Cookie to use for each REST call, and the format of the request body (if it is required).
The method can be GET, POST, PUT, DELETE and PATCH. Note: GET and POST are the mostly commonly-used (see the API documentation for the differences between them, and when to use each method).
Let’s now make the following REST calls using the Performance Center REST API:
- User authentication
- Run performance test
User authentication using the Performance Center REST API
Every Performance Center REST session should start with the authentication REST call.
To create the authentication request header, encode the string "<user name>:<password>" using Base64. For details, see the Authenticate call in the PC REST API documentation.
In this example, we are using Base 64 encoding (https://www.base64encode.org/), where the Performance Center user name is admin and the password is admin123. The string to be encoded will be: admin:admin123
Now let’s open Postman, build a REST call, and execute it:
- Select the GET
- For the URL, enter the address of your Performance Center server.
- Click the Headers tab, and add a new header: type “Authorization” at Key column and paste the value from the Base64 encoder at Value
4. Click Send. The following response is displayed:
The response status should be “200 OK”.
The response contains the cookies: “LWSSO_COOKIE_KEY” and “QCSession”. These cookies are required for every subsequent Performance Center REST call. Note: Postman automatically adds them to every request.
Start a performance test run using the Performance Center REST API
To start a performance test, you need to know the Test ID and Test Instance ID of the test you are about to run. The easiest way to get this information is to log on to the Performance Center project, open the Test Plan view, and select the test.
The Test ID appears in parenthesis next to the Test name:
Scroll to the bottom of the General Details list, and click the Assign To: link. The Test Instance ID is displayed in the Assign and Select Test Set dialog box:
Now we are ready to build a REST call:
- Select the POST
- For the URL, enter the name of the domain and project that contains the test which you plan to run.
- Click the Headers tab, and add Content-Type: application/xml. Content-Type describes the format of the data you are sending to the Performance Center server.
4. Click the Body tab, and enter XML describing the requested run. Use the Test ID and Test Instance ID you found earlier:
<PostRunAction>Collate And Analyze</PostRunAction>
5. Click Send.
The response status should be “201 Created”.
The response body contains XML describing the test run. The run ID is “35” and the current run state is “Initializing”.
You can get the run state by using Performance Center REST API call “Get Run Status”. For details, see the PC REST API documentation.
In this REST call, you need to provide the Run ID that you obtained from the previous step:
The run state is currently “Running” (in the previous call it was “Initializing”). Seeing this update means the performance test started successfully.
You can keep executing this REST call until the run state becomes “Before Collating Results”. Since the post-run action is “Do Not Collate”, getting a run state of “Before Collating Results” means that the test has finished:
For details on how to run a performance test using the Performance Center REST API, see Start a Test Run in the PC REST API documentation.
This blog post provided an introduction to the Performance Center REST API, and showed you how to send REST calls to the Performance Center server using a REST client.
In the next blog post, you will learn how to make REST calls using programming language, including:
- How to create scenarios (including logging on, starting a performance test, and monitoring performance test status).
- How to execute scenarios by a simple click, or by integrating them into a CI or automation routine.
This will unleash the real potential of using REST APIs.
In my next article, I will discuss how to create and update performance test REST calls.
For more information, visit our online PC REST API documentation