Korrelation i LoadRunner med web_reg_save_param Exempel

โšก Smart sammanfattning

Correlation in LoadRunner captures a dynamic server value, such as a session ID, and feeds it back into later requests so a recorded VuGen script replays successfully instead of failing on stale data.

  • ๐Ÿ”˜ Definition: Correlation binds a server response to every following request that depends on it.
  • โ˜‘๏ธ Symptom: Replay fails when a script returns a recorded session ID the server no longer recognises.
  • โœ… Automatiskt: VuGen rules and auto-detect compare two replays, yet cover only a small share of cases.
  • ๐Ÿงช Manuell: web_reg_save_param saves the value sitting between a left and a right boundary.
  • ๐Ÿ› ๏ธ Placering: Registration functions must sit above the step whose response carries the value.
  • ๐Ÿ“Š Utbetalning: Correlated scripts replay with fresh data and stay noticeably smaller.

Correlation in LoadRunner with web_reg_save_param

Vad รคr korrelation?

Correlation, as the name suggests, is a mechanism of defining a relationship between two variables or entities. A dictionary defines it as โ€œstatistical relation between two or more variables such that systematic changes in the other accompany systematic changes in the value of one variableโ€.

Varumรคrkesanmรคrkning: this tool shipped as HP and then Micro Focus LoadRunneroch รคr nu OpenText Professionell prestandateknik. Every correlation function below is unchanged, and the vendor spells the script generator VuGen.

Varfรถr behรถver vi korrelation?

Letโ€™s understand correlation with the following scenario.

Consider you are recording a script using LoadRunner.

Client-Server Communication during recording runs as follows, and the diagram summarises it:

  1. During Record, the client sends a request to the server to start a session
  2. En server tar emot begรคran och tilldelar ett nytt sessions-ID ABC
  3. Klienten lagrar sessions-id ABC i skriptet.
  4. Client starts the session with ID ABC and sends a request to a server to allow it to record
  5. Servern kรคnner igen ID ABC och lรฅter klienten spela in skriptet

Client-server session ID exchange while recording a LoadRunner script

Now, letโ€™s study the client-server communication during replay, shown after these steps:

  1. Under Replay skickar en klient en begรคran till servern om att starta en session
  2. En server tar emot begรคran och tilldelar ett nytt sessions-ID XYZ
  3. A Client starts the session with the previously recorded session ID ABC and sends a request to the server to allow it to record
  4. En server kan inte identifiera ID ABC eftersom den fรถrvรคntade sig ID XYZ som den har allokerat och sessionen misslyckas.

Session ID mismatch during replay when correlation is missing

We need a solution which can capture and parse the dynamic value sent at run-time and return this value back to the server. Here is how the client-server communication will look with this solution, as the diagram below shows:

  1. Under Replay skickar en klient en begรคran till servern om att starta en session
  2. En server tar emot begรคran och tilldelar ett nytt sessions-ID ZZZ
  3. En klient analyserar detta nya sessions-id ZZZ frรฅn begรคran.
  4. En klient skickar en begรคran om att starta sessionen med id ZZZ
  5. En server kรคnner igen ID:t ZZZ och lรฅter klienten spela upp skriptet igen

Correlation capturing the new session ID and returning it to the server

Detta รคr inget annat รคn korrelation.

The short video below walks through the same record-and-replay problem.

Klicka hรคr. om videon inte รคr tillgรคnglig

In case of VuGen, correlation is a binding relationship between a response and any preceding request.

There are various situations when a request is based on a previously received response from the server, such as a Session ID, or a server date and time which is fetched from the server. These values are different every time you run an application or record a script. Obviously, if the execution of the script depends upon a value returned by the server, it means you need to find a mechanism where you can โ€œcatchโ€ the server response and attach it to those requests which the server expects. This is typically called Correlation in LoadRunner.

Med enkla ord รคr lรถsningen genom att anvรคnda korrelation:

  1. Fรฅnga utdatavรคrde frรฅn ett steg
  2. Anvรคnd ovan fรฅngade vรคrde fรถr att fungera som input till alla efterfรถljande steg

Correlation is classified into 2 categories in VuGen/LoadRunner:

  • Automatisk korrelation
  • Manuell korrelation

Automatisk korrelation

LoadRunner tillhandahรฅller en mekanism fรถr att enkelt utfรถra korrelation pรฅ automatiskt sรคtt.

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.

Automatisk korrelation kan delas in i tre kategorier:

  • Autoupptรคck korrelation
  • Regelbaserad korrelation
  • Korrelera alla uttalanden
Regelnamn Nรคr ska du anvรคnda
Autoupptรคck korrelation Detect and correlate dynamic data for application servers supported by LoadRunner
Regelbaserad Anvรคnds nรคr du arbetar med en applikationsserver som inte stรถds fรถr vilken sammanhanget รคr kรคnt.
Korrelera alla Hjรคlper till att korrelera all dynamisk data pรฅ ett blind sรคtt.

ร„ven om automatisk korrelation verkar enklare, kan den vara felbenรคgen och fungerar i hรถgst 5 % av fallen. Det รคr alltid lรคmpligt att anvรคnda manuell korrelation.

Fรถr att konfigurera automatisk korrelation vid inspelningstillfรคllet, utfรถr nedanstรฅende konfiguration i Record Time Setting efter att ett skript har spelats in.

Click on Record =>Recording Options (or click Ctrl +F7), shown in the menu below,

VuGen Record menu with the Recording Options entry selected

Nedanstรฅende fรถnster รถppnas:

VuGen Recording Options window listing the recording configuration nodes

Klicka pรฅ Korrelation =>Konfiguration โ€“ nedanstรฅende fรถnster รถppnas.

Correlation Configuration pane listing application rule sets such as ASPNET

Hรคr behรถver du markera som kontrollerat mot alla ansรถkningar (ASPNET) mm, som anvรคnds i din รคmnesansรถkan. Pรฅ hรถger sida kan du se reglerna som kommer att upptรคcka mรถjliga kandidater fรถr korrelation, t.ex. _VIEWSTATE. Du kan ocksรฅ lรคgga till fler applikationer eller anpassade regler genom att klicka pรฅ knappen Ny regel.

Du kan ocksรฅ klicka pรฅ REGLER, du kommer att se nedan:

Correlation Rules pane with the Rules Scan option available

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.

Vi kommer att fรถrstรฅ API som anvรคnds fรถr korrelation senare. Det รคr dock lรคmpligt att anvรคnda HTML-jรคmfรถrelse istรคllet fรถr textjรคmfรถrelse.

Nรคr du har valt nรฅgra regler, klicka pรฅ OK-knappen fรถr att stรคnga fรถnstren.

Click on the toolbar button shown here VuGen toolbar button used to regenerate the recorded script from the 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.

Observera att om du utfรถr korrelation manuellt eller anvรคnder automatisk korrelation, kommer kodbiten att innehรฅlla exakt samma syntax och funktion.

Steg fรถr att autokorrelera ett skript:

  1. Spela in ett manus
  2. Spela om manus
  3. Identifiera de vรคrden som ska korreleras
  4. Vรคlj vรคrdena och klicka pรฅ knappen autokorrelera
  5. Verifiera skriptet genom att kรถra igen. En framgรฅngsrik kรถrning betyder framgรฅngsrik korrelation.

Dricks:

  • Korrelation hjรคlper till att kรถra ditt skript med olika vรคrden
  • Korrelation minskar ocksรฅ storleken pรฅ ditt skript

Manuell korrelation

Manuell korrelation handlar om att skriva kod direkt i ditt skript fรถr att tillgodose stรคndigt fรถrรคnderliga vรคrden. Vi kan dela upp det i fรถljande steg:

  1. Bestรคm vรคrdet som ska fรฅngas
  2. Hitta hรถger och vรคnster textgrรคns fรถr vรคrdet som ska fรฅngas (WEB)
  3. Ta reda pรฅ vilken fรถrekomst av textgrรคnserna som ska anvรคndas
  4. Lรคgg till en web_reg_save_param-funktion till skriptet, ovanfรถr kodbiten som begรคr att sidan med vรคrdet ska fรฅngas
  5. Lรคgg till ett parameternamn, vรคnster grรคns, hรถger grรคns och fรถrekomst till funktionen
  6. Parametrisera det dynamiska vรคrdet i skriptet varje gรฅng det intrรคffar
  7. Verifiera korrekt utfรถrande
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);

Code anteckningar: both snippets appear exactly as published. Watch the ordinals: Ord=l och RelFrameId=l use a lower-case L, and VuGen expects the digit 1.

Manuell korrelation kan gรถras av VUser Comparison. Stegen i VUser Comparison-metoden fรถr korrelation kan delas upp enligt nedan:

  1. Identifiera dynamiska vรคrden som behรถver korreleras
  2. Find the server response containing the Dynamic value
  3. Fรฅnga det dynamiska vรคrdet i en parameter
  4. Ersรคtt varje fรถrekomst av det dynamiska vรคrdet med parametern
  5. Verifiera รคndringar

Understanding the 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

Versionsnotering: current VuGen releases treat web_reg_save_param_ex as the successor to the original function, and web_reg_save_param_regexp as the choice when the boundaries themselves change. The original example still runs.

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.

Hรคr gรฅr vi med funktionsdetaljerna:

web_reg_save_param(Parameternamn , Vรคnster grรคns , Hรถger grรคns )

Lista รถver attribut

The table below collects every attribute the function accepts, whether it is mandatory, and what it controls.

Attribut Nรถdvรคndig? Vad den gรถr
Konvertera Frivillig HTML_TO_URL converts HTML-encoded data to a URL-encoded data format. HTML_TO_TEXT converts HTML-encoded data to plain text format.
Ignorera omdirigeringar Optional, default โ€œIgnore Redirections=Noโ€ When set to Yes and the server response is redirection information (HTTP status code 300-303, 307), that response is not searched. The GET request goes to the redirected location and the search runs on the response from there.
LB Krรคvs 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.
HITTADES INTE Optional, default โ€œerrorโ€ Handling when a boundary is not found and an empty string is generated. โ€œNot found=errorโ€ raises an error. โ€œNot found=warningโ€ (โ€œNot found=emptyโ€ in earlier versions) instead sets the parameter count to 0 and continues, which is ideal when you want to see whether the string was found without failing the script. With Continue on Error enabled the script continues even under โ€œerrorโ€, but the extended log records it.
ORD Optional, default 1 Indicates the ordinal position or instance of the match. If you specify โ€œAll,โ€ it saves the parameter values in an array. The use of Instance instead of ORD is supported for backward compatibility, but deprecated.
RB Krรคvs 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.
RelFrameID Frivillig The hierarchy level of the HTML page relative to the requested URL. The possible values are ALL or a number. RelFrameID is not supported in GUI level scripts.
SparaLen Optional, default -1 The length of a sub-string of the found value, from the specified offset, to save to the parameter. The default saves to the end of the string.
SparaOffset Optional, default 0 The offset of a sub-string of the found value, to save to the parameter. The offset value must be non-negative.
Sรถk Optional, default ALL 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).

Once the script replays cleanly, add parametrisering, transaktioner och kรถrtidsinstรคllningar, run it from the Regulator, and read the result in Analys as part of wider Prestandatester och Lasttestning.

Vanliga frรฅgor

Replay it twice with the extended log on and compare the responses. Any value the server issues fresh each run โ€” session IDs, tokens, timestamps โ€” is a candidate.

web_reg_save_param matches between fixed left and right boundaries. web_reg_save_param_regexp matches a regular expression, so it copes when the boundaries themselves change.

Yes. Machine learning can diff two replay responses and rank the fields that change, far faster than a manual scan. Treat the ranking as a shortlist a human still confirms.

GitHub Copilot drafts the function call and its arguments from a comment. It cannot see the server response, so every boundary it suggests must be checked against real traffic.

It is a registration function: it registers a search against the next response VuGen receives. Placed after the request, nothing is left to scan and the parameter stays empty.

The boundaries did not match. Usual causes are a case mismatch, a boundary that appears only on another page, or searching Body when the value sits in the headers.

No. Parameterization feeds your own input data into a script from a data file. Correlation captures a value the server generates at run-time and passes it back. Most scripts need both.

Yes, often more of it. Bearer tokens, CSRF fields and JSON identifiers change every session, so REST and single-page traffic is full of candidates even without an HTML form.

Sammanfatta detta inlรคgg med: