Transaction Handling

Handling transactions in LoadRunner

The actual activities of an application by real users are represented by a series of end-user actions called transactions. Multiple requests or a series of actions sent to the server with a fixed frequency (SLA) can be included in a transaction.

     Micro Focus LoadRunner uses transactions to measure server performance. Each transaction counts the number of seconds it takes for the server to respond to a given Vuser request. These requests can be simple processes, such as waiting for a response to a single question, or complex processes, such as submitting multiple questions and creating a report.

There is no limit to the number of transactions or subtransactions a LoadRunner script can have, each with a unique name. Ideally, each user activity is recorded in a separate transaction. To illustrate: login, search, sort, log out, etc. Each transaction has a separate section that is divided into a start and end transaction function. The controller measures the time it takes for a transaction to complete, from when the request is sent to the server until the complete response is received.

LoadRunner - Transaction Handling - Response Time

Image:01

How can transactions be added to a LoadRunner script?

Transactions can be added to the script in two different ways.

1. During recording: A floating toolbar with the “Insert Start Transaction” button is visible when you start recording a script.

LoadRunner Insert Start Transaction Option

Image:02

To add a transaction name, click “Add” or “Ctrl+T” on the keyboard and then “Insert Start Transactions”.

LoadRunner Add Transaction Name

Image:03

The ‘Insert Final Transaction’ button becomes active when you click ‘OK’.

LoadRunner Insert End Transaction Option

Image:04

To end the transaction, click “Insert End Transaction” or press “Ctrl+Shift+T”. Choose the transaction you want to cancel from a list of transactions started after clicking “Insert Final Transaction”. This option helps to avoid the open transaction error.
LoadRunner Started Transactions

Image:05

You can also insert subtransactions, or one transaction inside another. Make sure you complete the transaction in the correct order by following the steps.

Transaction vs Sub-transaction

Image:06

2. After burning: Right-click the script at the desired location after burning, then choose “Start Transaction” or hover over “Insert”.

Start Transaction

Image:07

or choose Layout. Start transaction after inserting in script

Start Transaction

Image:08

or click ‘Ctrl+T’.

The above step causes VuGen to call lr_start_transaction(“”); in the Vuser script. The name of the transaction can be passed as input to the function, for example, lr_start_transaction(“Start session”). Follow the same procedures and select “Finish transaction” to complete the transaction.

Observation:

  • In the ‘lr_start_transaction’ and ‘lr_end_transaction’ functions, the transaction name must match absolutely.
  • A transaction name cannot contain the symbols “. (dot), “@ (at the rate), “: (colon), ” > & | (comparison/conditional operators),” or “, (comma). When trying to open the graphs of the cross-scan results, certain characters may cause problems.
  • Script replay status is not always updated to Failed after a failed transaction.
  • Think time, rendezvous, and flow logic should not be included in a transaction.

The features are described as:

  1. lr_start_transaction: first This function starts a certain scripted transaction. The argument is treated as a string of integer return type. If this method is successful, 0 is returned. If the transaction name is not allowed, -1 is returned.
  2. lr_end_transaction: The function closes an existing transaction. The transaction name parameter is treated as a string, while the transaction status argument is treated as an integer. If successful, this method returns 0. If there has not been a previous call to lr_start_transaction with a transaction of the same name, or if the transaction name is illegitimate, it returns -1.
    • Success (returns 0) for LR_PASS.
    • Fail (return 1): LR_FAIL
  3. LR_AUTO: The status value is determined automatically. This default value is LR_PASS, which indicates a successful transaction (return 2).
    • Canceled (return 3), LR_STOP

      Example
    • lr_start_transaction(β€œ01_HomePage”);
    • status = active_site();
    • if (status == 0)
    • lr_end_transaction(β€œ01_HomePage”, LR_PASS);
    • otherwise
    • lr_end_transaction(β€œ01_HomePage”, LR_FAIL);
    • or choose Layout. Start transaction after insert in script

Scroll to Top