4 minute read time

Introduction to the Performance Center 12.55 REST API

by in Application Delivery Management

alex.png

 

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:

  1. User authentication
  2. 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 

1.jpg

 

Now let’s open Postman, build a REST call, and execute it:

  1. Select the GET
  2. For the URL, enter the address of your Performance Center server.
  3. Click the Headers tab, and add a new header: type “Authorization” at Key column and paste the value from the Base64 encoder at Value 2.jpg

     

    4. Click Send. The following response is displayed: 

3.jpg

 

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:4.jpg

 

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:5.jpg

 

Now we are ready to build a REST call:

  1. Select the POST
  2. For the URL, enter the name of the domain and project that contains the test which you plan to run.
  3. 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. 

6.jpg

 

4.  Click the Body tab, and enter XML describing the requested run. Use the Test ID and Test Instance ID         you found earlier:

<Run xmlns="http://www.hp.com/PC/REST/API">
 <PostRunAction>Collate And Analyze</PostRunAction>
 <TestID>2</TestID>
 <TestInstanceID>2</TestInstanceID>
 <TimeslotDuration>
 <Hours>0</Hours>
 <Minutes>30</Minutes>
 </TimeslotDuration>
 <VudsMode>false</VudsMode>
</Run>

 5. Click Send.

           The response status should be “201 Created”.7.jpg

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:8.jpg

  

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:9.jpg

 

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.

 Conclusion

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

Labels:

Performance Testing
  • Also, would you be able to help with the api that can help read the report.html directly? It appears to be .zip

  • Hi, First of all, thanks for the introduction - its very detailed, helpful. There are some places it can be improved/corrected. 1)Results/{ID}/Data - Request example of this section is missing the {ProjectName} field. Can this be corrected please? GET http:///LoadTest/rest/domains/{domainName}/projects/ /Runs/{ID}/Results/{ResultId}/data 2)Runs/{runID}/Extended - Response example for this section claims that response contains the details like start time, end time, transactions - passed and failed status, etc, etc however, it contains only below tags; 47 4321 Collate And Analyze 1234 false 88 99 Finished Not Completed

  • A very nice and informative article.

    - Could you please also share the link for your next blog post on how to make REST calls using programming language. I searched but didn't found. 

    - After the test is triggered and run through the rest api call, can we also call & get the collated test results or html report of test results through REST API call? If Yes, please help me understand how?

  • Good article.

    Outside of being able to automate the execution of a load test outside of the PC UI, how have you and PC customers made use of the REST API?