Still Grappling with the Headaches of Manual Correlation in Performance Test Scripts

Still Grappling with the Headaches of Manual Correlation in Performance Test Scripts


And yes, I know it can be a headache to carry out manual correlation. Just a few days ago, I had to manage all the cookies for my web application because the cookie manager in JMeter wasn’t handling them correctly in an automated way. Can you imagine how much time I spent doing the correlation for the cookies?

Correlation is a critical aspect of performance testing, ensuring that dynamic data, such as session IDs or tokens, are correctly handled between requests.

Due to its complexity and the amount of time it requires, several tools and plugins have been developed to automate it. From my experience using various tools or plugin (including one I developed a few years ago), it's evident that while these tools can significantly simplify "or not" the correlation process, manual intervention is often necessary to ensure accuracy.

I know friends some colleagues who have started using automated correlation solutions, especially in JMeter, even without fully understanding the manual correlation process. But what if these "semi-automated" solutions can't handle your app? This is why it's essential to understand this process.

In my opinion, understanding and performing manual correlation is essential for any performance tester to achieve a precise and reliable script.

These code examples are just portions of the scripts built from the three tools. We will soon be hosting an online workshop showing a complete example with these tools JMeter-Gatling-Locust. Stay tuned!

Firstly, What is Correlation?

Correlation is the process of capturing dynamic data from a server's response to a request and then using this data in subsequent requests. This is essential for maintaining session state, dynamic values updates, etc... and ensuring that the test scripts simulate real user interactions accurately.

Lets see this with a real example.

Example Scenario

Let’s consider a simple scenario with two requests: HomePage and Login POST.

Request 1: HomePage

Description:

  • The HomePage request is the first request sent to the server.
  • It retrieves the homepage and any necessary tokens required for further interactions.

Request:

Request: HomePage

Response: The server responds with the homepage HTML, which includes a securityToken in the JavaScript section.

Response Example:

Response: HomePage

In this response, the securityToken value '02454ce177e373e37c262703029f03df' is dynamically generated by the server and must be captured in HomePage and reused in the Login POST request.

Request 2: Login POST

Description:

  • The Login POST request is where the actual login credentials (username and password) are sent to the server along with the securityToken.
  • This token ensures that the login request is valid and originates from the server's login page.


Request:

Request: Login Post

Form Data:

Request Form Data: Login Post

Manual Correlation Process

To handle this manually, follow these steps:

  1. Capture the SecurityToken from the HomePage Response: Extract the securityToken value from the response of the HomePage request.
  2. Use the Extracted SecurityToken in the Login POST Request: Insert the captured securityToken value dynamically into the Login POST request.


Using JMeter

HomePage Request: Extract SecurityToken

  • Add a Regular Expression Extractor to the HomePage request to capture the securityToken.

Extractor - JMeter UI.


Login POST Request

Replace the extracted securityToken.

Replace the extracted


Using Gatling

Step 1: HomePage Request

  • Configure the HomePage request in Gatling and extract the securityToken.

Extract the

Step 2: Login POST Request

  • Use the extracted securityToken in the Login POST request.

Replace the extracted


Using Locust

Step 1: HomePage Request

  • Configure the HomePage request in Locust and extract the securityToken.

Extract the


Step 2: Login POST Request

  • Use the extracted securityToken in the Login POST request.

Replace the extracted


Conclusion

Understanding and implementing manual correlation is crucial for accurate performance testing. By following these detailed steps, you can ensure that dynamic values are correctly handled, leading to more reliable test results.

If you have any questions or need further assistance.

You can practice in my Performance Scripting Demo Web App, feel free to reach out!



Shazim Surmawala

Principal QA Automation Engineer at Xplor Technologies

2 个月

This looks great Delvis, looking forward to more such articles covering complex performance testing concepts explained in a simplistic manner ??

Great Delvis! A lot of work behind it!

Saumya Rai

Software Engineering leader, Driving Excellence in Product Quality

2 个月

Sharing our day today learnings on bigger platform is commendable

要查看或添加评论,请登录

社区洞察

其他会员也浏览了