API Micro Focus ALM and Performance Center: Basics for Performance Testing Engineers
In this post, we are sharing our experience of using API Micro Focus ALM in the hope that load testing engineers who use LoadRunner or Performance Center will find it interesting. Working with API is useful for test automation, and/or to prepare for test launch with Jenkins or similar tools. We collected this list of examples and useful functions based on our experience, but you might also find good tips on Micro Focus’s own webpage.
Reading further, you will find a description of the main actions needed when creating an automation tool using the API service Application Lifecycle Management (ALM), which is used primarily to manage LoadRunner projects. The version we used when writing this post was ALM 12.60.
Test Automation
What is test automation?
Automated testing is a method in software testing that leverages automation tools to control the execution of tests instead of a human tester. It then compares actual test results with predicted or expected results. Automated testing offers greater efficiency and faster time-to-market for your projects. In PFLB, we often automate tests using HP ALM or Performance Center to save our clients’ time and money.
Where to use automated tests?
Automated tests are widely used in regression testing, during development, in DevOps, and even in production environments. To further enhance your testing capabilities, consider using an API load test tool that allows you to test Postman and Insomnia request collections for optimal scalability (learn more from the Load Testing API article). With mobile test automation, you can quickly scale your tests and boost coverage to accelerate delivery. Of course, no software can operate without an experienced testing engineer, otherwise we wouldn’t have 400+ of them on staff, but automated tests save time for these highly valuable specialists, letting them focus on challenging tasks instead of manually running the tests.
What is HP ALM?
HP ALM (Application lifecycle management) is a web-based tool that helps organizations to manage the application lifecycle right from project planning, requirements gathering, until testing and deployment, which otherwise is a time-consuming task. It enables all the stakeholders, namely, project managers, developers, testers, product owners, and business analysts, to interact and coordinate to achieve the project goals.
You will find some basics of how to use the API service Application Lifecycle Management (ALM) in the next part of the article. We do hope it will help you automate testing for your project.
Pages
Address
The full address is formed according to the following formula:
Url + /API_TYPE/rest/domains/ + Domain + /projects/ + Project + …
An example:
http://almhost1260.com/qcbin/rest/domains/
DOMAIN/projects/PROJECT/runs
Most of the pages can be viewed in both API ALM and API Performance Center (hence, both are mentioned above as API_TYPE).
/qcbin/ – API ALM
Main pages:
/LoadTest/ – API Performance Center
Main pages:
Except for the syntax in the names of the pages, most of the actions in these two APIs are the same.
Main Pages
/runs
Contains data on test runs.
http://almhost1260.com/loadtest/rest/domains/
DOMAIN/projects/PROJECT/runs
http://almhost1260.com/qcbin/rest/domains/
DOMAIN/projects/PROJECT/runs
You can request data about a specific test run:
…/runs?query={…} – filtering by query
…/runs/11111 – data on the test run with ID 11111
Actions with a specific running test:
…/runs/11111/Extended – extended data on the run
…/runs/11111/stopNow – stop the running test
If /runs/ contains many tests, a request without a date may return only a partial list.
/tests
Contains scripts for the Project.
http://almhost1260.com/loadtest/rest/domains/
DOMAIN/projects/PROJECT/tests
http://almhost1260.com/qcbin/rest/domains/
DOMAIN/projects/PROJECT/tests
An example of a request:
…/tests/11111 – data for a script with ID 11111
/test-instances
Contains test instances needed for launch.
http://almhost1260.com/qcbin/rest/domains/
DOMAIN/projects/PROJECT/test-instances
http://almhost1260.com/loadtest/rest/domains/
DOMAIN/projects/PROJECT/testInstances
An example of a request:
…/test-instances/11111 – data for an instance with ID 11111
Read further to find out how to authorize, which parameters to use, and what operations to apply in ALM.
Authorization in ALM
Sends a GET-request to an address:
http://almpc1260.delta.sbrf.com/qcbin/api/
authentication/sign-in
With headers:
An example of setting headers in Java:
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAccept(Arrays.asList(new MediaType[]{MediaType.APPLICATION_JSON}));
httpHeaders.setContentType
(MediaType.APPLICATION_JSON);
httpHeaders.set("Authorization","Basic [authorization code]");
Cookies are selected from the response:
Those cookies are attached to further requests to ALM in the Cookie header.
An example of an attached Cookie in Java:
httpHeaders.set("Cookie", almdto.getLWSSO_COOKIE_KEY());
httpHeaders.add("Cookie",
almdto.getQCSession());
httpHeaders.add("Cookie",
almdto.getALM_USER());
httpHeaders.add("Cookie",
almdto.getXSRF_TOKEN());
Parameters
alt
Method:
It includes the response format. Such a request is equal to using the header Accept.
Examples:
?alt=application/xml
?alt=application/json
fields
Method:
It brings back particular fields of elements from the list instead of all the fields. You can’t use it for singular elements.
Fields are divided with a comma. Fullstop shows which element of the page is the field related to.
Examples:
…/tests?fields=id – ID field for all the scripts
…/tests?fields=id,name – ID and name fields for all the scripts
…/tests?fields=id,test-folder.id – ID and test-folder.id fields for all the scripts
…/tests?fields=id,t-fldr.id,t-fldr.name – ID, t-fldr.id and t-fldr.name fields for all the scripts
order-by
Method:
Sorts results by a determined parameter. Fields and ascending/descending sorting can be included in the parameter.
Fields are put in squiggle brackets and divided by semicolon. Type of sorting is put in square brackets after the field name. Default sorting type is ascending.
Syntax:
order-by={field1[ASC];field2[DESC]}
Examples:
…/tests?order-by={id[ASC]} – sort by ID, ascending.
…/tests?order-by={status[DESC];name[ASC]} – sort by status, descending, and name, ascending.
…/tests?order-by={status;name[ASC]} – sort by status, ascending, and by name, ascending.
Used with fields:
…/tests?fields=id,name,test-folder.id,test-folder.name&order-by={test-folder.name[ASC]}
If order-by parameter is not used, default sorting is by ID of the element.
page-size
Method:
Used to limit the size of the response or the number of elements used.
Possible values:
Examples:
…/tests?page-size=10 – retrieves the first 10 scripts
…/tests?page-size=max – retrieves 2,000 elements max.
query
Method:
After a question mark, you can use parameter query={…}. Put the field names in squiggle brackets to mention the fields that will be used for filtration.
Formatting for page fields:
field[comparison“value”]
Comparison operators: >, <, >=, <=, =, <>
Logical operators: and, or, not
Semicolon is used for separation, equal to logical operator AND. Other logical operators between the fields are not supported.
Examples:
user-template[<5]
execution-date[>=’2021-09-29′]
Absence of a special sign means an equal mark:
user-template-12[“Max”]
Several parameters in one request are separated by a semicolon:
query={user-template-08[GOSUSLUGI_DCP_EXT];user-template-12[“Max”]}
Example:
http://almpc1260.delta.sbrf.com/qcbin/rest/
domains/LT_EFS/projects/GOS_LT_EFS/runs?query={execution-date[>='2021-10-01']}
Example of a query request in Java:
String parametr = "{test-id["" + testId + ""]}";
ResponseEntity<String> response = restTemplate.exchange(urlALM + "/testInstances?query=
{parametr}",
HttpMethod.GET,
entity,
String.class, parametr);
Read further to find out what operations can be used in ALM.
Operations with Elements
Overview
Method:
To view a full list of elements, send POST or GET request with an empty body to the page address.
Example:
http://almpc1260.delta.sbrf.com/qcbin/rest/
domains/LT_EFS/projects/GOS_LT_EFS/tests
– overview of the list of scripts.
To view data on a particular element from the list, add the element ID after the page name.
Example:
http://almpc1260.delta.sbrf.com/qcbin/rest/
domains/LT_EFS/projects/GOS_LT_EFS/tests/11111
– overview of script with ID 11111.
For more particular requests, go back to section Parameters above.
Create an element
Method:
Content (a script, a defect, etc.) in ALM can be created by using POST method to send the code of the element to an xml or json page.
Example:
http://almhost1260.com/loadtest/rest/
domains/DOMAIN/projects/PROJECT/defects
Request body:
<Entity Type=”defect”>
<Fields>
<Field Name=”detected-by”>
<Value>username</Value>
</Field>
<Field Name=”creation-time”>
<Value>2010-03-02</Value>
</Field>
<Field Name=”severity”>
<Value>2-Medium</Value>
</Field>
<Field Name=”name”>
<Value>Some Description</Value>
</Field>
</Fields>
</Entity>
<Entity Type=”defect”>
You can create several elements at a time this way. It is necessary to include one of the headers to do so:
Delete
Method:
To delete an element, send a request using DELETE method to the element’s address. The adress will be the same as for viewing, but for the method change.
Example:
http://almpc1260.delta.sbrf.com/qcbin/rest/
domains/LT_EFS/
projects/GOS_LT_EFS/tests/11111
– delete the script with ID 11111
Parameter used: ids-to-delete
This parameter allows to delete several elements at a time. To do so, use DELETE method to address the whole list, and then mention IDs of elements you want to delete, separated by a comma.
Example:
http://almpc1260.delta.sbrf.com/qcbin/rest/
domains/LT_EFS/projects/GOS_LT_EFS/tests?ids-to-delete=11111,22222,33333
– delete scripts with IDs 11111, 22222 and 33333.
Parameter used: force-delete-children
This parameter is used to delete child directories when deleting a directory from test-folders.
Possible values:
If the parameter force-delete-children is not used, child directories are not deleted by default.
Example:
…/test-folders/11111?force-delete-children=y – to delete child directories, where 11111 is an ID of a directory.
Change
Method:
You can change an element by using method PUT to send new values for the fields changed in xml or json.
Example:
http://almhost1260.com/loadtest/rest/domains/
DOMAIN/projects/PROJECT/defects/11111
– change description of the defect with ID 11111.
Request body:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Entity Type="defect">
<Fields>
<Field Name="description">
<Value>This is new description</Value>
</Field>
</Fields>
</Entity>
You can use the same way to change several elements at a time. To do so, put the element ID in the xml instead of the address. Include one of the headers, too:
Conclusions
Automating performance testing services saves either the time of your staff members, or of the contractor who is running the tests. Thus, in both cases, it saves customer’s money. Although there are many tools for test automation, performance testing does not yield effective results without the eye of an experienced engineer. Make sure you have one on your team, or let us know if we can help! Our expertise with 300+ projects and 400+ staff engineers lets us share our knowledge to make your application the best version of itself.
Related insights in blog articles
Top 5 JMeter Alternatives
It’s hard to find someone in the performance testing community who hasn’t heard of Apache JMeter. We love it for being open-source, free, feature-rich, protocol-friendly, and easily extendable. While JMeter remains a favorite, there are other tools that offer unique strengths and advantages. This article presents a comprehensive list of the top 5 JMeter alternatives, […]
How to Load Test API: A Full Guide
In today’s digital ecosystem, APIs form the backbone of diverse software applications, facilitating communication and data exchange for an interconnected digital world. However, as demand for these services grows, ensuring their robustness and ability to handle varying levels of traffic becomes crucial. This is where PFLB, a next-generation, cloud-based load testing tool, comes in. In […]
Top 8 Gatling Alternatives Overview
Gatling Cloud, a cloud-based extension of the open-source performance testing tool, is a powerful load testing solution with its benefits. Those include excellent scalability, no-code test builder, moderate price for virtual user hours (VUh), and numerous useful integrations. However, with its steep learning curve due to reliance on Scala/Java and setup (and overall) complexity, it […]
Top 10 BlazeMeter Alternatives
Over a decade ago, BlazeMeter reshaped the landscape of load testing by moving it to the cloud. Serving as a cloud-based execution platform for the well-known JMeter, it freed engineers from the burden of managing infrastructure and allowed them to focus solely on testing. The result was a significant reduction in operational complexity and a […]
Be the first one to know
We’ll send you a monthly e-mail with all the useful insights that we will have found and analyzed
People love to read
Explore the most popular articles we’ve written so far
- Cloud-based Testing: Key Benefits, Features & Types Dec 5, 2024
- TOP 10 Best Load Testing Tools for 2024 Nov 7, 2024
- Benefits of Performance Testing for Businesses Sep 4, 2024
- Android vs iOS App Performance Testing: What’s the Difference? Dec 9, 2022
- How to Save Money on Performance Testing? Dec 5, 2022