How to Automate Correlation in JMeter: A Guide to the BlazeMeter Auto Correlation Plugin
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.
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.
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.
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.
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
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.
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.