Online Library  
We document every best practice in technology and domain, and continuously build our online library.

Performance Testing - Scripting Part 2

When people move from functional test automation to performance test automation, there is always a question on how to handle dynamic data. All functional automation tools provide data driven test, where you feed data in a csv file or spreadsheet. But how to get or extract data that is sent by server? Most of the functional tools provide GetRunTimeValues from UI. This will dump the UI data in an array, from that we can extract the data we want. But in load test, when 1000s of vusers are running, we do not have UI at all. How do we handle dynamic data?

Look at this sequence of events.

Client sends request REQ1. This is to get the list of purchase orders (PO).
Server sends response RES1. This has a lot of purchase order IDs.
Client must choose the first purchase order from response RES1 and pass that in request REQ2 with a few modified values.

You do not know what PO ID will come from server. That is purely dynamic data. Unless you send one of those IDs coming in RES1, the REQ2 will fail. All these are happening in background without you seeing UI. To achieve this, you need to do correlation.

Correlation means - extract some details from a response, and pass that as part of subsequent requests.

All load testing tools use the same principle to handle correlation. The response is a pure html text. See this example. List of POs are coming like this.

<tr class="po"><td>POID</td><td>CUSTOMERID</td><td>PODATE</td></tr>
<tr class="po"><td>9235</td><td>Navy Corp</td><td>01-10-2013</td></tr>
<tr class="po"><td>9845</td><td>Blue Minds</td><td>10-05-2013</td></tr>
<tr class="po"><td>9876</td><td>Blue Fields</td><td>06-03-2013</td></tr>
<tr class="po"><td>9989</td><td>Red Grove</td><td>07-04-2013</td></tr>

When I send REQ1, after sometime, the table data may be different in response. Hence every time, it is necessary that we get the first row from the response. How do we extract the row 1? There are 5 rows in the table and the first row is the header.

Here is the simple trick. "Chase the data". I want to pick up 9235. Locate what appears to its left and what appears to its right. The text <tr class="po"><td> appears to its left and </td> appears to its right. But there are 5 such rows, where I can see the same left and right text. But this 9235 text appears in the 2nd position or ordinal. So if we tell the load test script, to locate the text with <tr class="po"><td> as left boundary and </td> as right boundary, it will give me an array [POID, 9235, 9845, 9876, 9989]. In this array, my text appears in ordinal 2. Look at this command.

locate_dynamic_data(dynavar1, LB=<tr class="po"><td>, RB=</td>, Ordinal=2);

where, dynavar1 is the variable to which it will load the value, LB is left boundary and RB is right boundary. When load test tool sees this instruction/command, it will scan the response, locate the text as per your LB, RB and Ordinal, and will give the extracted data in variable dynavar1. Once it is in variable, you can pass that to subsequent requests.

Everywhere, you see dynamic data, you need to correlate. You need to ensure that the correlation command gets proper data from the response. If response itself is not received or the text you look for is not present, subsequent requests may fail. You need to handle that part in scripting.

In java framework, in web apps, there is usually a dynamic text jessionid; same way, in apps, you will see a dynamic text __VIEWSTATE__, __VIEWINFO__. Unless you handle these framework related dynamic text, load test script will not work. But the load test tools are intelligent. Whenever the text during recording and text during replay are changing, they give a warning to the tester, that these changing areas are potential correlation areas. Hence pay attention when tools warn you on dynamic data.

Online Learning

Online learning helps you to learn from anywhere, anytime. We help you to do self-assessment as well.

The whole world can learn for free.
FloodGates - The Ultimate Load Testing Tool

FloodGates tests your web app with 1000s of users and ensures performance.

Use FloodGates for load, stress, volume, endurance and performance tests.
Bug Tracker and Test Management Tool
  Home | Careers | Contact Us | FAQ | Development Solutions | Testing Services | Customers | Partners | Resources| Company

© Softsmith