English

Manual Correlation in Performance Testing

Correlation is the hard part of designing scripts in performance testing, usually includes fetching dynamic values on the server’s responses and include them to successive requests. According to Blazemeter’s blog “Correlation is the process of capturing and storing the dynamic value from the server and passing it on to next requests. A value is considered dynamic when it can return different data for each iterating request, it’s a critical process during performance testing scripting, because if it isn’t handled correctly, our script will become useless”.

It can be difficult and time-consuming, as you need to identify what is dynamic first; find the response that you can extract from and match all the occurrences in requests for that regular expression extraction, in addition, most of the time there are several dynamic values, with different structures and regular expressions associated.

How Correlation Works?

Performance testing must run with dynamic values every time and simulate the same behavior of the relationship between the client-server and request-response. The essential component of performance testing is realistically emulating user-base impact on a servers’ infrastructure by instantiating hundreds or thousands of virtual users. A VU is a lightweight software object that generates HTTP traffic. Its main job is to be indistinguishable from a real user from the server’s perspective. Unlike a real client, they are not designed to execute JavaScript or fully emulate the browser’s behavior. Therefore, VUs do not implement correlation mechanisms. Instead, they just replay the traffic as it was recorded while using a small footprint, so hundreds or even thousands of users can be emulated from a single machine. Therefore, correlation must be created manually.

To identify what is dynamic in a script, we can compare either two recorded scripts with the same functionalities or user actions. The most effective way to know if something is different is to compare it with something else. However, we can identify some dynamic values ​​associated with the programming language, such as: SessionID, Token, Application context or state, etc..

  • Session is the variable you can write to that will persist from the moment they hit your site until they close the browser. (barring any timeouts).
  • Token-based authentication is a security technique that authenticates the users who attempt to log in to a server, a network, or some other secure system, using a security token provided by the server.
  • Application context or state In client/server systems, the server needs to have the application context of every user to process its requests correctly, one example of a dynamic values that carries application state is the ViewState ASP.NET applications, it’s the variable that holds the current state of the page, which is held in a hidden field in the page.

Original recording that contains dynamic values “Iteration 1”

A dynamic value is received in the first GET request – Value XYZ12345, and used dynamically the same value in the next POST request – Value XYZ12345

Execution without correlation “Iteration 2”

A dynamic value is received in the first GET request – Value ABC12345, but instead of using the same value, in the post request, it used the original recorded value in the next POST request – Value XYZ12345.

Execution with correlation “Iteration 2

A dynamic value is received in the first GET request – Value ABC12345, manual correlation in JMeter takes the value it received in the GET request and uses it in next POST request – Value ABC12345.

Let’s start manual correlation in JMeter. Keep in mind the last figure.

If we need to extract information from a server’s response, the easiest way is to use Regular Expressions. Jmeter include a Regular Expression Extractor, it’s designed to extract dynamic value from server responses using Regular Expressions.

We have two requests GET LOGIN and POST LOGIN.

There is a dynamic value from response GET LOGIN.  VALUE=”ABC12345″

<FORM>

<INPUT NAME=”LOGIN”/>

<INPUT NAME=”PASS”/>

<INPUT NAME=”SESSIONID”/>

TYPE=”HIDDEN”

     VALUE=”ABC12345″      

</FORM>

Our regular expression is VALUE=”(.+?)“, we will extract the Value from GET LOGIN.

And then use it in the next request POST LOGIN.

Experience plays a vital key in correlation. Experienced performance testers or software developers can easily identify the correlation by simply parsing the script, but the Correlation is a critical process when you are dealing with SessionID, Tokens, and Application context or state form technology or programing language. Feel free to contact us. SQA advisory provides consulting and training in all phases of Performance Testing.