A transaction defines a set of end-user actions that represent the real user activities on an application. A transaction can have multiple requests or sequence of actions which hit the server at a predefined rate (SLA).
In terms of Micro Focus LoadRunner, transactions are used to measure the performance of the server. Each transaction measures the time it takes for the server to respond to specified Vuser requests. These requests can be simple tasks such as waiting for a response for a single query, or complex tasks, such as submitting several queries and generating a report.
A LoadRunner script can have an unlimited number of transactions/sub-transactions with a different name. Ideally, each user action should be captured in an individual transaction. Example: login, search, submit an order, logout, etc. Each transaction has its own section fenced by start and end transaction function. The controller measures the response time of a transaction starting from sending a request to the server to getting the full response from the server.
How to insert transactions in LoadRunner script?
There are 2 ways to insert transactions into the script.
1. While recording: When you start recording a script, you can see the ‘Insert Start Transaction’ button on a floating toolbar.
Click on ‘Insert Start Transactions’ or press ‘Ctrl+T’ button from the keyboard, add transaction name and click ‘OK’
Once you clicked ‘OK’, ‘Insert End Transaction’ button will be enabled.
Click ‘Insert End Transaction’ or press ‘Ctrl+Shift+T’ to end the transaction. After clicking on ‘Insert End Transaction’ you will see a list of started transactions, choose the one which you want to end. This option helps to avoid the error of open transactions.
Likewise, you can insert sub-transactions (i.e. one transaction within another transaction). Just make sure you follow the correct sequence of ending the transaction
2. After recording: Right-click on the script where you want to start the transaction, then either hover ‘Insert’ and click ‘Start Transaction‘.
or Select Design > Insert in Script > Start Transaction
or press ‘Ctrl+T’
The result of above-mentioned step is VuGen inserts an lr_start_transaction(“”); function into the Vuser script. You can add the transaction name as an argument of the function, like lr_start_transaction(“Login”). To end the transaction follow the same steps and choose ‘End Transaction’.
- The transaction name should be exactly same in ‘lr_start_transaction’ and ‘lr_end_transaction’ function.
- Avoid using a “. (period)”, “@ (at the rate)”, “: (colon)”, “< > & | (comparison/conditional operators)” or “, (comma)” symbol in a transaction name. These characters may cause errors to occur when attempting to open the Analysis Cross Results graphs.
- A failed transaction does not automatically set the script’s Replay status to Failed.
- Do not add think time, rendezvous point and flow logic inside a transaction.
Description of functions:
1. lr_start_transaction: This function starts a specified transaction in the script. The argument is considered as a string with the integer return type. This function returns 0 if it succeeds. It returns -1 if the transaction name is illegal.
2. lr_end_transaction: This function ends a specified transaction. The argument of transaction name is considered as a string and status is considered as an integer. This function returns 0 if it succeeds. It returns -1 if the transaction name is illegal or if there is no prior call to lr_start_transaction with a transaction of the same name.
You can manually set the status of the transaction or you can allow the script to detect it automatically.
- LR_PASS: Success (return 0)
- LR_FAIL: Failure (return 1)
- LR_AUTO: The value of status is automatically assigned. By default, this value is LR_PASS signifying a successful transaction (return 2)
- LR_STOP: Aborted (return 3)
status = site_active();
if (status == 0)
You may be interested: