Load Test Correlation

Load Test Correlation

In today’s world, we have to deal with various behaviors of systems while communicating with one another. In most cases, to carry on with…

Load Test Correlation

In today’s world, we have to deal with various behaviors of systems while communicating with one another. In most cases, to carry on with test scenarios, we need to fetch the dynamic responses from preceding requests and pass it to the subsequent ones. By simply parsing and passing the needed data to the next caller provides a smooth transition during the test execution process (Load Test Correlation).

Storyline:

Since load/stress testing scenarios are based on mutual interactions between the client and remote, the need of correlation is a technical state every performance tester encounters at some point. To establish a strong bond with your test flow, JMeter comes with a handy feature: Regular Expression Extractor under Post Processors.

Tagline:

Reliability of your tests depends on the frequency of buggy occurrences, how robust your design is and how ready you are for unexpected situations.

When using static parameters is not enough…

After spending some time and going through the basics of JMeter, it is inevitable not to get stuck with handling dynamic data in your complex scenarios. At this very point, correlation kicks in.

Getting the data parsed from the response on the fly and passing it to the next request, plays a vital role in your test flow. Jmeter supports correlation with its “Regular Expression Extractor” which provides smooth data transition by using regular expressions and applies the parsed data on another sampler in our flow.

Why regular expressions?

Regular expressions are a set of symbols & characters which are used to build a pattern to match character combinations in strings. Regular expressions are very popular and used widely in programming languages and very easy to get used to.

JMeter’s regular expressions are provided by Jakarta ORO framework based on Perl5 Regex Engine. There are many great tutorials, websites, and articles about it, so take your time and you should be writing your style of patterns in no time.

How JMeter handles correlation…

JMeter’s Regular Expression Extractor helps us fetch any portion of data from the response by using regular expressions. Since applying the regular expressions on the response is a post process, this explains why Regular Expression Extractor is located under Post-Processors.

After matching the set of characters by using the Extractor, this value is set to a variable for future use on another sampler.

Getting to the point…

Regex Extractor has a few options we need to know in advance.

A. Apply To:

Main Sample -produced by the primary request- and/or Sub Sample -produced by any request made related to the primary request- can be picked to apply the regular expression.

B. Response Field To Check:

A Regex can be applied to a part of the response message such as custom-header, body etc…

C. Reference Name:

This is the name of the variable which stores the matched data. This variable can later be called from another request by simply using the following syntax: ${}

D. Regular Expression:

Your regex pattern goes here.

E. Template:

Regex may have more than one group. Templates — regex group index- are used to match the group that contains the data.

F. Match No:

Multiple matched sets might return for a regex pattern. By setting the match number, data-to-store is chosen from the result set and set to the variable -reference name-.

G. Default Value:

If there is no match to the regex, then the default value is set to the variable.

If you wonder how this technique is applied in practice, please go ahead and take a look at the following link;

HTTP Live Streaming Performance Test

Happy Load Testing…

Originally published at loadium.com on March 21, 2018.