Kicking off ALM Lab Management Test Runs via REST API

Testing. KeyboardIt’s no secret that HPE ALM’s new lab management features are gaining a lot of ground in today’s automated testing arena. More and more organizations are required to exist in multi-vendor/multi-tool environments. With testing assets within and outside the HPE ALM environment, the lab management functionality can be used to bring both worlds together. Here you can schedule test runs via time slots, run tests in real time, or use outside CI servers such as Jenkins to manage those runs.

However, many organizations want to create their own testing dashboard to kick off tests and only utilize HPE ALM as more of a test/requirement/defect repository.

The first step to creating your own testing dashboard is to figure out the commands needed to send to HPE ALM to have the test set run. In looking at the REST API documentation for HPE ALM, there are no examples of how to kick off a lab management test set via REST. However, we know that there must be commands/methods available in REST API to do this, since Jenkins and other CI servers have the ability to kick off lab management test set runs in HPE ALM.

After much investigation and reverse engineering, the methods and commands that HPE ALM uses to run lab management test sets can be ascertained. The following are the prerequisites:

  1. An HPE ALM premier license (you cannot do this with an HPE QC enterprise license, since lab management cannot be used)
  2. A project with the lab extension for functional and performance testing enabled via the site admin
  3. A test set in HPE ALM test lab of functional type, containing HPE UFT GUI scripts (this type of execution cannot be performed on default test sets)
  4. An HPE UFT machine set up with HPE ALM lab service (installed from tools/ add-ins page)

Below is an example of how you could kick off a functional test set in a lab-management-enabled project. In this example, HPE ALM 12.50 was being used, but it should work for all versions of HPE ALM.net from 11.50 and up. This example is also using a free rest client called Advanced Rest Client.

alm-auth

The first step is to authenticate and create a rest session in HPE ALM. (This step can be slightly different depending on the HPE ALM version. Just consult your version’s REST API guide for how to get the session authentication).

Now click “Send.” Once you get the response, you will need to get the cookie to use for our next REST API request.

alm-auth-2

Create a new rest request. There is a prerequisite for this; you’ll need to know what the test set ID of the target test set is. In my example, it is test set ID 2.

The type of request needs to be a “POST,” and the request is sent to this URL:  http://YourALMServerAddressHere:8080/qcbin/rest/domains/YourProjectDomainHere/projects/YourProjectHere/test-sets/YourTestSetIDHere/startruntestset

The header in the request needs to contain the following values:

  • Content-Type: application/xml
  • Accept: application/xml
  • Cookie: This should be your cookie copied from the previous rest authentication statement
  • ProtocolVersion: HTTP/1.1
  • URI: /qcbin/rest/domains/YourProjectDomainHere/projects/YourProjectHere/test-sets/YourTestSetIDHere/startruntestset
  • PtAL: Value for this does not matter, but this MUST be in the header for it to work
  • UserAgent: Java/1.8.0_20
  • Connection: keep-alive

You MUST also include a payload for this request. The following is the payload that I sent:

<Entity><Fields><Field Name=”duration”><Value>30</Value></Field><Field Name=”vudsMode”><Value>false</Value></Field><Field Name=”reservationId”><Value>-1</Value></Field></Fields></Entity>

alm-auth-3

Then click “Send.”

alm-auth-4

You can see at the bottom it created a time slot with an ID of 1011.

alm-auth-5

Once you have mastered kicking off a lab management run via REST API, you can then parameterize the request and create a test running dashboard in your programming language of choice.

Cheers!

 

Facebooktwittergoogle_pluspinterestlinkedinmail

Leave a Reply