Corrélation dans LoadRunner avec l'exemple Web_Reg_Save_Param

Table des matières:

Anonim

Qu'est-ce que la corrélation?

La corrélation, comme son nom l'indique, est un mécanisme de définition d'une relation entre deux variables ou entités. Un dictionnaire le définit comme «une relation statistique entre deux ou plusieurs variables de sorte que des changements systématiques dans l'autre accompagnent des changements systématiques de la valeur d'une variable».

Dans ce tutoriel, nous allons en apprendre davantage sur

  • Pourquoi avons-nous besoin de corrélation?
  • Corrélation automatique
  • Corrélation manuelle
  • Comprendre la fonction Web_reg_save_param

Pourquoi avons-nous besoin de corrélation?

Comprenons la co-relation avec le scénario suivant.

Considérez que vous enregistrez un script à l'aide de LoadRunner.

Communication client-serveur

  1. Pendant l'enregistrement, le client envoie une demande au serveur pour démarrer une session
  2. Un serveur reçoit la demande et attribue un nouvel ID de session ABC
  3. Le client stocke l'ID de session ABC dans le script.
  4. Le client démarre la session avec l'ID ABC et envoie une demande à un serveur pour lui permettre d'enregistrer
  5. Le serveur reconnaît l'ID ABC et permet au client d'enregistrer le script

  1. Maintenant, étudions la communication client-serveur lors de la relecture
  2. Pendant la relecture, un client envoie une demande au serveur pour démarrer une session
  3. Un serveur reçoit la demande et attribue un nouvel ID de session XYZ
  4. Un client démarre la session avec l'ID de session ABC précédemment enregistré et envoie une demande au serveur pour lui permettre d'enregistrer
  5. Un serveur ne peut pas identifier l'ID ABC car il attendait l'ID XYZ qu'il a alloué et la session échoue.

Nous avons besoin d'une solution qui, pour capturer, analyser la valeur dynamique envoyée au moment de l'exécution et renvoyer cette valeur au serveur. Voici à quoi ressemblera la communication client-serveur avec cette solution

  1. Pendant la relecture, un client envoie une demande au serveur pour démarrer une session
  2. Un serveur reçoit la demande et attribue un nouvel ID de session ZZZ
  3. Un client analyse ce nouvel identifiant de session ZZZ à partir de la demande.
  4. Un client envoie une demande de démarrage de session avec l'ID ZZZ
  5. Un serveur reconnaît l'ID ZZZ et permet au client de rejouer le script

Ce n'est rien d'autre qu'une corrélation .

Cliquez ici si la vidéo n'est pas accessible

Dans le cas de VUGen, la corrélation est une relation de liaison entre une réponse et toute demande précédente.

Il existe diverses situations où une demande est basée sur une réponse précédemment reçue du serveur, telle qu'un ID de session, la date / heure du serveur qui est extraite du serveur. Ces valeurs sont différentes chaque fois que vous exécutez une application ou enregistrez un script. Évidemment, si l'exécution du script dépend d'une valeur renvoyée par le serveur, cela signifie que vous devez trouver un mécanisme où vous pouvez «attraper» la réponse du serveur et attacher aux requêtes attendues par le serveur. Ceci est généralement appelé corrélation dans LoadRunner.

En termes simples, la solution en utilisant la corrélation est:

  1. Capturer la valeur de sortie d'une étape
  2. Utilisez la valeur capturée ci-dessus pour servir d'entrée à toutes les étapes suivantes

La corrélation est classée en 2 catégories dans VUGen / LoadRunner:

  • Corrélation automatique
  • Corrélation manuelle

Corrélation automatique

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 : longueur d'une sous-chaîne de la valeur trouvée, à partir du décalage spécifié, à enregistrer dans le paramètre. Cet attribut est facultatif. La valeur par défaut est -1, indiquant d'enregistrer à la fin de la chaîne.

SaveOffset : décalage d'une sous-chaîne de la valeur trouvée, à enregistrer dans le paramètre. La valeur de décalage doit être non négative. La valeur par défaut est 0. Cet attribut est facultatif.

Recherche: la portée de la recherche où rechercher les données délimitées. Les valeurs possibles sont Headers (Rechercher uniquement les en-têtes), Body (rechercher uniquement les données du corps, pas les en-têtes), Aucune ressource (rechercher uniquement le corps HTML, à l'exclusion de tous les en-têtes et ressources) ou ALL (recherche du corps, des en-têtes et des ressources) . La valeur par défaut est ALL. Cet attribut est facultatif mais généralement préféré.