Корелация в LoadRunner с пример Web_Reg_Save_Param

Съдържание:

Anonim

Какво е корелация?

Корелацията, както подсказва името, е механизъм за определяне на връзката между две променливи или обекти. Речникът го определя като „статистическа връзка между две или повече променливи, така че систематичните промени в другата да придружават системни промени в стойността на една променлива“.

В този урок ще научим за

  • Защо се нуждаем от корелация?
  • Автоматична корелация
  • Ръчна корелация
  • Разбиране на функцията Web_reg_save_param

Защо се нуждаем от корелация?

Нека разберем взаимовръзката със следния сценарий.

Помислете, че записвате скрипт с помощта на LoadRunner.

Комуникация клиент-сървър

  1. По време на Record клиентът изпраща заявка до сървъра за започване на сесия
  2. Сървър получава заявката и разпределя нов идентификатор ABC на сесията
  3. Клиентът съхранява идентификатора на сесията ABC в скрипта.
  4. Клиентът започва сесията с ID ABC и изпраща заявка до сървър, за да му позволи да записва
  5. Сървърът разпознава ID ABC и позволява на клиента да запише скрипта

  1. Сега, нека проучим комуникацията клиент-сървър по време на повторно възпроизвеждане
  2. По време на повторно възпроизвеждане клиент изпраща заявка до сървъра за започване на сесия
  3. Сървър получава заявката и разпределя нов идентификатор на сесия XYZ
  4. Клиентът стартира сесията с предварително записан идентификатор на сесия ABC и изпраща заявка до сървъра, за да му позволи да запише
  5. Сървърът не може да идентифицира ID ABC, тъй като очаква ID XYZ, който е разпределил и сесията е неуспешна.

Имаме нужда от решение, което да улавя анализирането на динамичната стойност, изпратена по време на изпълнение, и връщането на тази стойност обратно към сървъра. Ето как ще изглежда комуникацията клиент-сървър с това решение

  1. По време на повторно възпроизвеждане клиент изпраща заявка до сървъра за започване на сесия
  2. Сървър получава заявката и разпределя нов идентификатор на сесия ZZZ
  3. Клиент анализира тази нова сесия с идентификатор ZZZ от заявката.
  4. Клиентът изпраща заявка за започване на сесия с идентификатор ZZZ
  5. Сървърът разпознава ID ZZZ и позволява на клиента да възпроизведе скрипта

Това не е нищо друго освен корелация .

Щракнете тук, ако видеоклипът не е достъпен

В случай на VUGen, корелацията е обвързваща връзка между отговор и всяка предходна заявка.

Има различни ситуации, когато заявка се основава на предварително получен отговор от сървъра, като например идентификатор на сесия, дата / час на сървъра, който се извлича от сървъра. Тези стойности са различни всеки път, когато стартирате приложение или записвате скрипт. Очевидно е, че ако изпълнението на скрипта зависи от стойност, върната от сървъра, това означава, че трябва да намерите механизъм, където можете да „хванете” отговора на сървъра и да го прикачите към тези заявки, които сървърът очаква. Това обикновено се нарича корелация в LoadRunner.

С прости думи, решението с помощта на Correlation е:

  1. Уловете изходната стойност от стъпка
  2. Използвайте стойността по-горе, за да служи като вход за всички следващи стъпки

Корелацията е класифицирана в 2 категории във VUGen / LoadRunner:

  • Автоматична корелация
  • Ръчна корелация

Автоматична корелация

LoadRunner provides a mechanism to easily perform correlation in automatic fashion.

VUGen will require you to run a recorded script at least two times so it can internally compare the varying values in the server response.

Automatic correlation can be classified into 3 categories:

  • Auto-Detect Correlation
  • Rule-Based Correlation
  • Correlating All Statements
Rule Name When to Use
Auto-detect Correlation Detect and correlate dynamic data for application servers supported by HP LoadRunner
Rule-Based Used when working with a non-supported application server for which the context is known.
Correlate All Helps correlate all dynamic data in blind fashion.

Though Automatic Correlation seems simpler, it can be error-prone and works in not more than 5% of the cases. It is always advisable to use manual correlation.

To configure automatic correlation at the time of recording, perform below configuration in Record Time Setting after a script has been recorded.

Click on Record =>Recording Options (or click Ctrl +F7),

>

Below window will open:

Click on Correlation =>Configuration - below window will open.

Here, you need to mark as checked against all applications (ASPNET) etc., which are used in your subject application. On the right-hand side, you can see the rules which will detect possible candidates for correlation e.g. _VIEWSTATE. You can also add more applications or custom rules by clicking on New Rule button.

You can also click on RULES, you will see as below:

In order for Automatic Correlation to work, you need to ensure Rules Scan is marked as checked. If you click on automatically correlate values found, VUGen will not prompt you with the choice once a correlation candidate is found, instead, it will just correlate them.

We will understand API used for correlation later. However, it is advisable to use HTML comparison instead of text comparison.

Once you’ve selected any rules, click on OK button to close the windows.

Click on from menu and VUGen will regenerate script (without having to record) with new configurations. VUGen will automatically add a required piece of code to handle correlation. We will look at the sample in more detail in Manual Correlation.

Please note, if you perform correlation manually or use automatic correlation, the piece of code will contain exactly same syntax and function.

Steps to auto-correlate a script:

  1. Record a script
  2. Replay script
  3. Identify the values to be correlated
  4. Select the values and click the auto-correlate button
  5. Verify the script by running again. A successful run means successful correlation.

Tip:

  • Correlation helps run your script with different values
  • Correlation also reduces the size of your script

Manual Correlation

Manual correlation is about writing code directly into your script to cater for ever-changing values. We can split it into below steps:

  1. Determine the value to capture
  2. Find the right and left text boundaries of the value to capture (WEB)
  3. Find which occurrence of the text boundaries should be used
  4. Add a web_reg_save_param function to the script, above the piece of code which requests the page with the value to capture
  5. Add a parameter name, left boundary, the right boundary, and occurrence to the function
  6. Parameterize the dynamic value in the script every time it occurs
  7. Verify correct execution
web_reg_save_param (" OracleAppJSESSIONID3","LB/IC=JSESSIONID=","RB/IC=;","Ord=l","Search=headers","RelFrameId=l",LAST);web_reg_save_param("Siebel_Analytic_ViewState2","LB/IC=ViewState\" value=\"","RB/IC=\"","Ord=1","Search=Body","RelFrameId=l",LAST);

Manual correlation can be done by VUser Comparison. Steps in VUser Comparison method of Correlation can be split as below:

  1. Identify Dynamic values that need to be correlated
  2. Find Servers response containing the Dynamic value
  3. Capture the Dynamic value in a parameter
  4. Replace every occurrence of the Dynamic value with the parameter
  5. Verify Changes

Understanding Web_reg_save_param function

VUGen provides multiple functions or APIs to correlate candidates, including:

  • web_reg_save_param
  • web_reg_save_param_ex
  • web_reg_save_param_regexp
  • web_reg_save_param_xpath

While a brief introduction is being provided here, for a detailed understanding of functions and their parameters, open VUGen, write function (or use Steps Toolbox), move a cursor on the function and click F1 - get yourself acquainted with VUGen help and make a habit. You will have to deal with it a lot when working in the industry.

Here we go with the function details:

web_reg_save_param(Parameter Name , Left Boundary , Right Boundary )

List of Attributes

Convert: The possible values are:

HTML_TO_URL: convert HTML-encoded data to a URL-encoded data format

HTML_TO_TEXT: convert HTML-encoded data to plain text format; this attribute is optional.

Ignore Redirections: If "Ignore Redirections=Yes" is specified and the server response is redirection information (HTTP status code 300-303, 307), the response is not searched. Instead, after receiving a redirection response, the GET request is sent to the redirected location, and the search is performed on the response from that location.

This attribute is optional. The default is "Ignore Redirections=No".

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. To further customize the search text, use one or more text flags. This attribute is required. See the Boundary Arguments section.

NOTFOUND: The handling option when a boundary is not found, and an empty string is generated.

"Not found=error", the default value, causes an error to be raised when a boundary is not found.

"Not found=warning" ("Not found=empty" in earlier versions), 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 the extended log file.

This attribute is optional as well.

ORD: Indicates the ordinal position or instance of the match. The default instance is 1. If you specify "All," it saves the parameter values in an array. This attribute is optional.

Note: The use of Instance instead of ORD is supported for backward compatibility, but deprecated.

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. To further customize the search text, use one or more text flags. This attribute is required. See the Boundary Arguments section.

RelFrameID: The hierarchy level of the HTML page relative to the requested URL. The possible values are ALL or a number. Click RelFrameID Attribute for a detailed description. This attribute is optional.

Note: RelFrameID is not supported in GUI level scripts.

SaveLen : Дължината на подниза на намерената стойност, от посоченото отместване, за запазване в параметъра. Този атрибут не е задължителен. По подразбиране е -1, което показва, че трябва да се запише в края на низа.

SaveOffset : Отместването на подниза на намерената стойност, за да се запише в параметъра. Стойността на отместването трябва да е неотрицателна. По подразбиране е 0. Този атрибут не е задължителен.

Търсене: Обхватът на търсенето - къде да търсите разделените данни. Възможните стойности са Headers (Търсене само в хедърите), Body (търсене само на данни на тялото, но не заглавия), No resource (търсене само на HTML тялото, с изключение на всички заглавия и ресурси) или ALL (тяло на търсене, заглавия и ресурси) . Стойността по подразбиране е ALL. Този атрибут не е задължителен, но обикновено е предпочитан.