Understanding Correlation in OpenScript

One of the most important topics, (if not the most important) in load testing is correlation. Script correlation is the key to your load tests performing well and sending true load to the server, but what is correlation? And why is it so important? We can define it as follows:



The recreation of the user’s application interactions by mapping dynamic data into subsequent requests


But what those that mean?
So lets start by remembering that during a load test we are reproducing the HTTP requests and mapping those to user interactions.Having said that let's think about a blog being updated, each entry of the blog will have an id e.g:

<form method=post action='myblogUpdate.jsp'>
<input type='hidden' name='postID' value='98765'>
name:    <input type='text' name='name' size=30>
email:   <input type='text' name='email'>
subject: <input type='text' name='subject' size=30>
</form>

On submitting that would generate a post request with the following values:


postID=98765
name=aname
email=some@email.com
subject= My dog and I

Every time a virtual user sends a request to the server, it will send a different postID which will be dictated by the server. During recording we will have recorded as a value to the postID parameter the number 98765, but if each user sends the same postID back to the server the results of the load test will be unreliable and it may not even work, so we need to make sure that we are updating that parameter value for every request with the unique id dictated by the server.

OpenScript uses 2 methods to correlate a value, XPath and regular expressions, it will also look for JavaScript literals.

The XPath method, will use XPath standard functionality to search for the value that needs to be correlated. The method in the Java code view to correlate the above parameter would look like this:

http.solveXpath("INPUT_36_0", ".//INPUT[@name='postID']/@value", "98765", 0);

The XPath expression is looking for an input filed with the name postID. Once it's found the value it will store it as a variable, in the example above the variable is called INPUT_36_0.

The regular expression method will use a regular expression to find a value within a page, in the code view it will look like this:

http.solve("INPUT_37_0", "<iinput type='hidden' name='postID' value='(.+?)'>", null, false, Source.Html, 0);

The method will extract the value of the regular expression and store it in a variable called INPUT_37_0. The Source.Html parameter means that it will look in the Html section, we could also have parameters in the Response Headers.


There is also the Script Literal Group. Lets have a look at the Java method to understand what is it doing:

http.solveGroupJavaScript("JAVASCRIPT_18_0:1:18:0:0");


When we look closely we are only passing one parameter, however this string is using the : character to build a separate list of arguments, the first parameter is the variable name, JAVASCRIPT_18_0, the second parameter indicates it is looking at JavaScript 1 or VBScript 0, the third 18 and fourth 0 are zero based indexes which will be used to locate the string literals and finally the last parameter 0, will indicate if the value is a string (0) or an integer (1).

Manual Correlation.

So lets now have a look at how we can correlate parameters manually:

First we will need to identify the value that we need to correlate, looking at the previous example that is the postID value:

1.JPG

Once located we will need to substitute the value for variable:

2.JPG

In the wizard under script variables select create new variable:

3.JPG

After we click next, the wizard will look at the previous pages in the script for the postID value:

3.JPG
Note from the example above, that opensript has located the value in step one and has identified the following regular expression:

<input type='hidden' name='postID' value='(.+?)'>
Because we are happy with this result we will click next to complete the process.


This step is very important, here is where we specify where the source value for the variable can be found and how we are going to extract it.

The next screen will verify our selection.

5.JPG

Finally we will name the variable and close the wizard

6.JPG

Once that is done, note the change of syntax in the postID value {{varPostID,86944}} that means that we substituted the postID value, the static 86944 to the variable value of varPostID. The original recorded value remains in the tree view as reference.

7.JPG

Also note that in steep 1 we are declaring the variable:

8.JPG

Now next time we play back the script we will extract the value of the postID from the server response and build a new request containing such value.


Comments:

You have some really good posts on here, however it took me a while to find this blog, why dont you promote this blog more often?

Posted by pantry moths on February 25, 2010 at 05:26 PM GMT #

Hi, We are using OATS tool. we are using Oracle OpenScript for record the "nca" application. How to fetch dynamic value in open script? where we have to see server response once complete the recording? iam not able to find in java coding? please give me the answer. Thanks in advance, Hari

Posted by hari on March 09, 2011 at 03:54 AM GMT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

bocadmin_ww

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today