Wednesday, July 27, 2016

Correlation in Loadrunner

Correlation

Loadrunner handles the processto capture the Dynamic value in each run of script when different VUsers running in Performance testing Excecution,
There are two types of Correlation
  1. Automatic Correlation
  2. Manual Correlation
Automatic Correlation:

We have two ways of achieving automatic correlation.
  • Enable Correlation during recording
  • Scan for Correlation
“Enable Correlation during recording” is the option is in Recording Options -->HTTP Properties. If we know the occurrences of dynamic value with in Scenario, Enable correlation during recording is used. LoadRunner has a Predefined set of rules for correlation called as Auto-Correlation Library.
  • Select “Enable Correlation during recording”.  We can enable or disable a specific rule by selecting or clearing the check box adjacent to the rule.
  • Click on New Rule. We will pass LB, RB and Parameter name (Parameter Prefix).
  • We can also specify where to look for the dynamic value such as Header, Body, etc.
  • Web_reg_save_param ( ) will be written in the script wherever the dynamic value occurs within specified boundaries.
Enabled Auto correlation
  • Built in correlation
  • User Define Correlation
Load runner maintains set predefined rules called auto correlation library. If the dynamic value found among these rules, load runner automatically inserts the web_reg_save_param (“parameter name”,”LB’, “RB”, LAST) in the script pane
  • Select “Enable Correlation during recording”.  We can enable or disable a specific rule by selecting or clearing the check box adjacent to the rule.
  • Click on New Rule. We will pass LB, RB and Parameter name (Parameter Prefix).
  • We can also specify where to look for the dynamic value such as Header, Body, etc.
Web_reg_save_param ( ) will be written in the script wherever the dynamic value occurs within specified boundaries

Scan for correlation:
Once you record the script, you have to replay the script than we need to use the scan for correlation. One you replay the script, replay log will be created. when we do a scan for correlation the vugen will compare the recording log with the replay log and highlight the differences between them. we click on the correlation button on the right side of the log window to correlate the differences.
Automatic Correlation cannot ensure that we have captured all the dynamic values (especially when may miss user specific data). This is the main reason we cannot depend on automatic correlation.

Manual Correlation

To ensure that script is fully correlated. We need to go for manual correlation as well
In manual correlation we have to identify the dynamic data  that is generated by the server and correlate them by using function web_reg_save_param(“parameter name”, “LB”,”RB”,LAST);
We can identify the dynamic values by recording the script in three times.
  • Record with user 1 (business flow)
  • Record with user 1 (same as above)
  • Record with user 2 (same step as above but with different input values)
  1. Compare the first two scripts by using windiff or any other tool which highlights the session specific dynamic values (ex: session id, pnr number, order number, engine id etc)
  2. Compare the first and third scripts by using windiff this will highlights the “user specific” dynamic values (for ex: already registered credit card information, his membership details etc..)
If found any differences, using generation log we can get the left boundary and then move to replay log there we will capture the left and right boundaries  and insert the web_reg_save_param function in the script pane by using add event. Add event tells us exactly where the correlation function will be inserted in the script pane.
  • Web_reg_save_param (“parameter name”,”LB”,”RB”, LAST);
Here parameter name, LB, and RB are mandatory arguments. The optional arguments of the web_reg_save_param () are ORD, Search, Not Found, Save Length, Save Offset.

List of Attributes

Parameter Name:Parameter name is used to replace with dynamic value. This is mandatory argument
LB: The left boundary of the parameter or the dynamic data. If you do not specify an LB value, it uses all of the characters from the beginning of the data as a boundary. Boundary parameters are case–sensitive and do not support regular expressions. To further customize the search text, use one or more text flags.
RB: The right boundary of the parameter or the dynamic data. If you do not specify an RB value, it uses all of the characters until the end of the data as a boundary. Boundary parameters are case–sensitive and do not support regular expressions. To further customize the search text, use one or more text flags.
ORD: It indicates the number of occurrences of the dynamic value between same left and right boundaries. The default value of ord is 1. If you specify "All," it saves the parameter values in an array. Search: The scope of the search—where to search for the delimited data. The possible values are Headers (Search only the headers), Body (search only body data, not headers), No resource (search only the HTML body, excluding all headers and resources), or ALL (search body, headers, and resources). The default value is ALL.
NOTFOUND: when boundaries of dynamic value were not found we will use this option to handle the function. "NotFound=error" causes an error to be raised when a boundary is not found and execution will stop. "NotFound=warning" does not issue an error. If the boundary is not found, it sets the parameter count to 0, and continues executing the script. The "warning" option is ideal if you want to see if the string was found, but you do not want the script to fail.
Note: If Continue on Error is enabled for the script, then even when NOTFOUND is set to "error", the script continues when the boundary is not found, but an error message is written to theExtendedlogfile.
SaveLen: The length of a sub–string of the found value, from the specified offset, to save to the parameter. The default is –1, indicating to save to the end of the string.
SaveOffset: The offset of a sub–string of the found value, to save to the parameter. The offset value must be non–negative. The default is 0.

No comments:

Post a Comment