Name:
Location: Richmond, Virginia, United States

Friday, August 15, 2008

CORRELATE – WHAT & HOW ?

When recording a script, Vugen simply listens to the client talking to the server and writes it down. It contains complete transcript of everything that was said like the time, month and the requests. The replies can be found in the recording log or the generation log.

We want the VuGen to pretend to be a client. The script tells VuGen what to tell to the server to successfully fool it. We want the server to believe that Vugen is a real client and thus send the requested information.

The script which we record has the hard-coded information of the original conversation which may not be enough to fool the server during replay and hence will have to be correlated for the changing values.

What is Correlation?
Correlation is capturing dynamic values passed between server to client. The values which were hard-coded in the initial request to the server, will be converted into a parameter and then use this parameter in the script in place of the original value. During replay, the replay engine will now listen to what the server sends and when it makes requests to the server, sends this new value (parameter) back to the server, thus fooling the server into believing it is talking to a real client.

Following diagram illustrates a typical example where correlation is required. Client requests page A, the response comes back page A and an ID of 123 which will be hard-coded in the script. During the same session the client can perform another request for page B with criteria to pull a report for the current month June for a certain amount.
During replay which can be done perhaps a month later, eventhough the ID is supposed to be ‘789’, the Vuser sends ‘123’ to the server causing a failure. Also when the script is played a month later in July, Vuser still is sending June in the request, causing the script to fail.

We will need to correlate these values so that correct value is sent to the server. This will allow many Vusers to replay the script many times and at different times, placing load on to the server.

How to Correlate a web Script ?

Correlation can be done in 2 ways:
1. Automatically
2. Manually
I will discuss here the steps to perform manual Correlation.

1. Record two copies of the script with the same business process and data:
  • Record script1 on the desired business process and save it.
  • Record script2, repeating the same business processes and with the same data used in recording script1.

2. Find the dynamic value to capture:

  • From script2, go to Tools --> Compare to Vuser, and choose script1.
  • WDiff tool will open and display the two scripts side by side. It will automatically highlight the lines which have differences in them.
    NOTE: Sometimes, comparing of two scripts cannot detect dynamic values. Imagine, that you recorded this script:

"Name=ID", "Value=367", ENDITEM,

"Name=CurrentMonthID", "Value=6", ENDITEM, ...

It's obvious, that ID should be correlated. What about CurrentMonthID parameter? Second recorded script can contain "Value=5" too. And it's possible, that your script will work correctly during the month June (6th month is June), and will not work from July.

  • Locate the first difference and take a note of it. Search the script1 for that difference. That is the original value hard-coded into the script1 that was different in script2. Highlight this value and copy it.

3. Find Server’s response, containing the dynamic value:

  • Replay the script by enabling extended log from script Run time settings. Make sure to select the option ‘Data returned by server’.
  • Open Replay log and find server's response, which contains dynamic values of ID.
    NOTE : For single protocol, go to Recording log
    For multiple protocol, go to generation log.
  • Press CTRL+F to bring up the find window. Paste the value you copied in step 2 and search downwards. We are looking for the first occurrence of this value in the log.
    NOTE: sometimes the value which we are searching may be long and the value may have gotten broken and may display the continuation in the next line in the logs.
  • If you find the value, scroll up in the log and make sure the value was sent as a part of response from the server. If the value first appears as part of sending request, then the value originated on the client side and does not need to be correlated, but rather parameterized.

4. Where to place web_reg_save_param function?

  • After confirming that the first occurrence was part of a received response from the server, go back to the place where you located the dynamic value inside the replay log.
  • There will be corresponding Action.c() at the beginning of that line with a number in the brackets. That is the number of the line in the script where we need to put the web_reg_save_param() function. The function should go right above that line in the script.
  • Double click that line number, script will be opened at that line, right above which we will place the the web_reg_save_param() function.

web_submit_data("generateteldata.jsp", "Action=http://consumerPortal/SRM/jsp/generateReport.jsp", "Method=POST", "RecContentType=text/html", ...

This means that server's response for generateteldata.jsp page contains dynamic values which should be correlated.

5. Capture dynamic value:
This can be done in two ways. They use the same function - web_reg_save_param()

Ø Manual capturing from Script-view.

This method does manual writing of web_reg_save_param function.

Ø Automatic capturing from Tree-view.

§ Open the Tree view

§ click "View recording snapshot only"

§ select generateteldata.jsp page from tree view

§ select "Body" to view body of server's response

§ You will see recorded values of ID. Now, select value of first dynamic value, right-click, and select "Create parameter":


§ After that you will see the message box:


§ You can create parameter for dynamic value.If you want to replace all occurrences of dynamic value ("715E19...") in script, click "Yes".

To not replace all occurrences, click "No".

NOTE: Replacing all occurrences of dynamic value can lead to incorrect results. It's more preferable to replace occurrences one by one with "Search and Replace" dialog.

§ Click "No" button.

§ Return to Script-view and see changes. There are new lines, inserted before generateteldata.jsp page:

// [WCSPARAM WCSParam_Text1 40 715E19300D670ED77773BBF066DAAAE2866484B8] Parameter {WCSParam_Text1} created by Correlation Studio

web_reg_save_param("WCSParam_Text1",

"LB=window.parent.setrentbody(\"",

"RB=\"",

"Ord=1",

"RelFrameId=1",

"Search=Body",

"IgnoreRedirections=Yes",

LAST);

§ web_reg_save_param() function finds and saves a text string from the next server's response. In other words, it captures a dynamic value.

In this example, web_reg_save_param function will save the captured value into WCSParam_Text1 parameter. The function finds the left boundary (window.parent. setrentbody (" and after that it finds the right boundary ". The string, found between left and right boundaries, will be saved to WCSParam_Text1 parameter.

Ord attribute indicates the ordinal position of captured value. In the example (Ord=1), we capture the value between first left boundary and left one. "Search=Body" means search in a body of server's response.

6. Replace every occurrence of dynamic value in script with the parameter:

  • Open "Search and Replace" window and replace one-by-one hard-coded values with the parameter.

Why it is important?

Imagine, that you have the following code:

web_submit_data("somepage", ...

"Name=OrderNumber", "Value=125", ENDITEM,

"Name=UserID", "Value=125",

If you create parameter for UserID, and perform replacing of all occurrences of its value ("125"), then it will produce the code:

web_submit_data("somepage", ...

"Name=OrderNumber", "Value={WCSParam_Text1}", ENDITEM,

"Name=UserID", "Value={WCSParam_Text1}",

It may be wrong! OrderNumber can be static value and be equal to 125, while UserID may change.

7. Verify Changes

After above manipulations, our script will insert ={WCSParam_Text1} in place of the dynamic value. The statement "{WCSParam_Text1}" means "get value of WCSParam_Text1 parameter".

So, algorithm changes to:

  • when server returns different values of ID
  • then web_submit_data captures and places them into WCSParam_Text1 parameter
  • after that we use {WCSParam_Text1} to get current values of parameters and use them in scripts.

Something Extra: Ord Attribute.
How can we find the value for the Ord attribute?

Remember the line number we found in Action.c() where the first occurrence to the dynamic value occurred (step 4).

In the replay log, go to the first occurrence of this line number. Begin searching for the Left Boundary or the right boundary until you find the first occurrence of the correlating string in the body. Keep a count of the number of Left/Right Boundary skipped until you found the correlating string, this count is the ORD value.

0 Comments:

Post a Comment

<< Home