The Concept of Correlation and It's Importance in Performance Test Scripts


What is meant by Correlation?

If I speak technically, Correlation is the process of handling dynamic values inside the scripts. 

What are dynamic values?

The sting/value which is generated by the server and not static in nature.

Concept: 


Just for making you understand, I'm using a simple example here.

Let's say you want to login to an application (say www.mydemoptapp.com) to update your profile.

Hence, your way to do the same should be as follow:

Launch the URL --> Login to application --> Click on View Information --> Update my Profile --> Logout.

So, there are multiple steps involved in doing the required task, here each step is called a business transaction in Performance Testing. The entire end to end (Launch to Logout) flow is represented as a scenario.

For interacting with application a connection needs to established which can be done by the server.

But to uniquely identify an user, the server generates a dynamic value to each user/action.  We will see how it happens

This is what happens during the Launch transaction:




Whenever you launch a website's URL in the browser, it directly reaches the respective target server. The target server accepts the request sent by the client, processes it and the respond back to the client. Here, the common parameters involved in client's request is just a URL "www.mydemoptapp.com".

This is what happens during the Login transaction:



This time, user sends a request to login to the page. The requests parameters in this step are username and password. Server accepted the request and generated a unique ID (demouser001). Server expects this ID from next requets coming from the same client.

This is what happens during the View_Profle_Transaction transaction:



Client/User understood that session ID must be sent to the server and it should be the same as server generated in the preceding action's response.

This is how server behaves and client - server architecture works.

Note: Just for making the stuff clear I used session ID. But in real time, The name of these dynamic values will be changed for example: CSRF token, Session Token, View state, Event validation and form key.

Now Let us understand why do we need to correlate these dynamic values:

Well, I would like to take two cases into consideration for making you aware on this.

As you already know that once you record a application using Jmeter, the values will be hard coded inside the requests (which means they are static until you change). Assume that you have recorded this www.mydemoptapp.com site using AB user and the server has generated a session ID for this as "ABUserSessionID01" during recording time.

Let's see the Jmeter body for both login and view profile transactions during recording.



Now you wanted to replay the same script with user "XY user". So you just replaced "AB User" with "XY User" in the entire script. You were not able to replace Session ID as you don't know what would be the session for XY User until server generates it.

Let's see the Jmeter body for both login and view profile transactions during replay.




 I hope you understand till now. Now pay much attention to the below image.

Once you replay the script, Launch and login transactions were getting passed because there was no dynamic value present inside the script. But server had thrown an error while replaying View profile transaction as there was a dynamic value (Session ID) which needs to be correlated. Since, You did not do the correlation, script has been failed.

For better understanding, see the below image:




Explanation:

Once you logged in as XY user, server has generated "XYUserSessionID19" session in the back-end. But you have sent some other user's session ID for XY user. Hence, server was unable to validate your session Id and thrown an error. If you would have known this new session ID before you run the script, You would have changed this as well. Isn't it?

But you cannot know what server has generated until you replay the script. So it is impossible to replace the dynamic strings manually. To do this, you need to have something which can do the same task during run time. That something is called is correlation.


In our next topic I will write on how to correlate. :)





No comments:

Post a Comment