How to Automate Correlation in JMeter: A Guide to the BlazeMeter Auto Correlation Plugin
May 5, 2023

How to Automate Correlation in JMeter: A Guide to the BlazeMeter Auto Correlation Plugin

API Testing

In correlation, dynamic values are identified in HTTP requests and responses, extracted, and replaced in subsequent requests with variables. Correlation is a critical stage in test development, but it is also very difficult and time-consuming. In this blog post, we go through the new capabilities of the AutoCorrelation JMeter plugin, to enable a faster, easier, and less error-prone process.

This blog post will discuss what correlation of dynamic values is, the challenges of correlation, how auto correlation works and why you should use it, and a step-by-step tutorial on BlazeMeter’s Auto Correlation plugin. 

The webinar this blog is based on is available for viewing at the bottom of the page.

Back to top

What is Correlation?

Correlation is the process of identifying dynamic values — such as session IDs, CSRF tokens, and timestamps — in HTTP requests and responses, extracting them and replacing them in subsequent requests with variables. Dynamic values are values that change each time a request is made. Correlation is necessary for recorded test scripts to work properly when running them. 

For example, when testing a login page that requires a unique session ID and CSRF token for each user, correlation ensures that each virtual user receives a unique session ID and CSRF token. Otherwise, you’re not simulating real user traffic.

In JMeter, correlation is typically achieved by extracting dynamic values from responses using Regular Expressions or other extractors and storing them in variables. Then, those variables are used in subsequent requests.

Back to top

The Challenges of Correlation

Correlation is an important process, but it is not challenge-free. Correlation can become very complicated, very quickly. There can be many different values that need to be correlated, which makes it hard to manage and can result in an erroneous process.

In addition, the correlation process is almost entirely manual. Testers need to find out which values to extract and then run the tests again. This makes it very time-consuming, and an inordinate amount of time is spent in dynamic value correlation. This also adds to it being prone to errors.

Third, maintaining correlation is difficult. Correlation is an iterative process that requires working with extractors and variables again and again, constantly. This also makes it non-scalable.

This is where automated correlation can help.

Back to top

Automatic Correlation Plugin Benefits 

Automatic correlation can be a very valuable tool for testers and developers. The main benefits of using automatic correlation include:

  • Saving time and effort - Automating the correlation process accelerates the test creation process and reduces manual labor so users are free to focus on other aspects of performance testing.
  • Reducing the risk of errors and inaccuracies - Automation enables users to replay scenarios and detect errors, which helps identify and resolve correlation-related issues more quickly. This reduces the risk of manual errors, leading to more reliable test results.
  • Improving performance testing efficiency - Automation streamlines the correlation process and allows teams to execute tests more quickly.
  • Providing a good user-experience - The automation is offered through an intuitive and user-friendly interface, making it easy for even novice users to create and apply correlation rules.
Back to top

Automatic Correlation Plugin Use Cases 

Despite its advantages, automated correlation is not a silver bullet. It is especially recommended in the following use cases:

  • When testing an e-commerce website, Auto Correlation can automatically handle changes in shopping cart IDs or session tokens.
  • When testing a mobile app, it can handle changes in device IDs or authentication tokens. 
  • For handling changes in APIs that are outside of the tester’s control. For example, if a third-party API that your application relies on changes its behavior, Auto Correlation can automatically adjust your test scripts to account for these changes.
  • When testing HTTP/HTTPS traffic authentication and or session management
  • And more
Back to top

How Does the Automatic Correlation Plugin Work? 

The AutoCorrelation Recorder

Built on top of BlazeMeter's Correlation Plugin for JMeter, automatic correlation enables recording a scenario just like the traditional JMeter Proxy Recorder. Then, it identifies where correlation is needed and offers to replace the values with variables. In addition, the correlation recorder also enables saving and loading templates of correlation rules that were created with the plugin.

The recorder now offers a Wizard Window. This Wizard acts as a guided interface for creating and applying correlation rules in BlazeMeter. It streamlines the correlation process and saves time, especially compared to manual correlation using regular expressions.

The plugin also adds the ability to replay scenarios and automatically detect errors, which saves time and effort. This feature enables developers to ensure the accuracy and stability of their applications, minimizing the risk of issues arising in production.

Back to top

The AutoCorrelation Recorder: A Tutorial 

Now, let’s see how to use the AutoCorrelation recorder, step-by-step. You can find a more detailed explanation, here.

1. First, install the correlation plugin, if you haven’t already.

2. Go to File -> Templates and find the bzm - Correlation Recorder

3. The template adds a Thread Group and a Recording Controller 

4. Configure the bzm - Correlation Recorder if you need to, or keep the default configuration as follows:

5. Click “Start” to start recording.

Traffic will be directed through the proxy on the localhost. JMeter will automatically create the required certificate.

All you have to do is make sure your device’s proxy settings are set to a manual proxy and that the certificate that JMeter created is trusted by the browser or OS.

6. Now, you can run through the scenario you are testing. For example, logging in to a website with a username and password and then browsing through some of the pages and performing actions on them.

7. Once you have stopped the recording, JMeter will open this dialog box.

8. The test is now running in the background. When completed, the Wizard will pop up with a report of the correlation analysis results and a suggestion to fix them. 

By clicking “yes”, you will get the suggestions, which you then choose which you want the plugin to correlate for you.

When you record a test, the plugin will ask if you want to play it back. This is where the errors are detected:

Then, the Auto Correlation plugin asks if you want it to attempt to correlate automatically:

 

You have the option to either use correlation rules you've saved before, or use automatic comparison process to get suggestions on what to correlate.

9. You will then choose which correlations you want to apply and the Auto Correlation plugin applies them.

Run the test again, and you will see the successful results in the “View Results Tree.”

If you go into the requests, you will see them updated. For example, regular expression extractors that have been added to the requests, capturing the variables and putting them in headers.

You can also save correlation rules for future use as a template in the “Suggestions” panel, to save even more time and increase accuracy.

 

That’s it! Correlation made simple.

Back to top

Bottom Line

Manual correlation of dynamic elements is a huge drain on time and resources for teams. Now, with the BlazeMeter Auto Correlation plugin, that time and those resources spent are reduced to a fraction of what they were. That way, the team can focus on what is most important: developing a high-quality app.

Ready to start testing with BlazeMeter?

Start Testing Now

 

Webinar: Ignite Your Performance Testing With BlazeMeter Auto Correlation

 

 

Back to top