Transactions

Any sequence of interactions or page clicks may be grouped as a transaction. Transactions are mechanics to measure server response time for any operation. In simple words, the use of “Transaction” helps measure the time taken by the system for a particular request. It can be as small as a click of a button or an AJAX call upon losing focus from the text box.

Transactions are added by using following APIs:

  • ns_start_transaction(“transaction name”); – It acts as a marker to define the start of a transaction
  • ns_end_transaction(“transaction name”,status);  – It acts as a marker to define the end of a transaction

Need for Transactions

Transactions in Script are needed due to following reasons:

  • To measure server response time for a particular user request /action.
  • To measure server response time for a logical group of actions. For Example, to measure response time of a checkout having 3 pages, user can group them into a transaction to measure the response time of the group. This is done to enhance our scripts to get the real feel of end user and behavior of a real user.

Using Transactions in Script

User needs to follow the below mentioned steps to use transactions in the recorded script:

  1. Go to the Script Manager GUI and double click the flow.c file of the recorded script. The flow.c file is displayed. Place the cursor before the main URL and go to File > Insert > Start Transaction.

64

 Note User can also insert transactions by right-clicking on flow.c file, Insert >Start Transaction.

In C script, Transactions API can be used anywhere in the flow files. Start transaction is normally added before ns_web_url API and End Transaction before ns_page_think_time API.

Alternatively, start a transaction before the main URL and end the transaction after the URL.

Example:

void Flow1()
{
// Using transaction for home page
ns_start_transaction("HomePage");
ns_web_url("Homepage",   "URL=http://127.0.0.1/tours/index.html");
ns_end_transaction("HomePage", NS_AUTO_STATUS);
}
  1. The Add Start Transaction dialog box is displayed. Enter the Transaction name and click OK.

65

 Note User can use the NS_Variable as Transaction Name. Need to select the variable also from the drop-down list.If Transaction name is a variable, select the check box.
  1. The Start Transaction is added to the flow.c file with the name ns_start_transaction (“Home”) API.

66

  1. To end the transaction, place the cursor before ns_page_think_time API and go to File > Insert > End Transaction.

67

  1. The Add End Transaction dialog box is displayed. Enter the End Transaction name and click OK.

68

 Note User can use the NS_Variable as Transaction Name. Need to select the variable also from the drop-down list.If Transaction name is a variable, select the check box.
  1. The End Transaction is added to the flow.c file with the name ns_end_transaction(“Home”, NS_AUTO_STATUS).

69

  1. Similarly, add transaction for all other recorded pages of the Script.
    • ns_start_transaction(“Login”);
    • ns_end_transaction(“Login”, NS_AUTO_STATUS);
    • ns_start_transaction(“Flights”);
    • ns_end_transaction(“Flights”, NS_AUTO_STATUS);
    • ns_start_transaction(“FlightResults”);
    • ns_end_transaction(“FlightResults”,NS_AUTO_STATUS);
    • ns_start_transaction(“Payment”);
    • ns_end_transaction(“Payment”,NS_AUTO_STATUS);
    • ns_start_transaction(“Confirmation”);
    • ns_end_transaction(“Confirmation”,NS_AUTO_STATUS);
    • ns_start_transaction(“Logout”);
    • ns_end_transaction(“Logout”,NS_AUTO_STATUS);

Define Transaction

It defines a transaction for starting from a C variable. ns_define_transaction is used to define a transaction (not starting it). This is used when user wants to start a transaction using a C variable. So, define these transactions such that these names can be added in the hash table.

Adding a ‘Define’ Transaction

  1. Go to the Script Manager GUI and double click the flow.c file of the recorded script. The flow.c file is displayed. Go to File > Insert > Define Transaction. The Define Transaction dialog box is displayed.
  2. Enter the Transaction name and click OK.

Inline URL Transaction

It is used if user wants to create inline URL Transaction.

  1. Select the inline URL and right click over it.
  2. Go to Insert > Inline URL Transaction.
  3. Enter the transaction name and click OK.
  4. The transaction is added in the inline URL.

Repeat Inline URL

It is used to repeat an inline URL transaction.

  1. Select the inline URL and right click over it.
  2. Go to Insert > Repeat Inline URL.
  3. Select either the parameter or count and specified the value.
  4. Click OK.

Executing Script from Test Script

  1. Click Test Script option in Script Manager GUI.
  2. Clear the checkbox for Treat Page as Transaction.
  3. If user selects the checkbox for Treat Page as Transaction, then system considers all page status as one transaction.
  4. Also, select to override the page think time to zero to execute the script faster.

70

Verifying Executed Transactions

The executed transactions can be verified by the following ways:

  • Debug Trace Log
  • Progress Report
  • Dashboard GUI 

Verifying Executed Transactions from Debug Trace Log

71

Transaction Data in the progress.report

Field Description
Min Min shows the minimum time (sec) taken by the transaction in the whole test.
Avg Avg shows the average time (sec) taken by the transactions in a in the whole test.
Max Max tells about the maximum time (sec) taken by the transaction in the whole test.
Stddev Stddev tells about the standard deviation in the data (sec) in the whole test.
TOT This field specifies number of transactions have been successful out of completed transactions in the whole test.
Detail Transaction Report In this report there is information about the each and every Transaction, by name of the Transaction

Verifying Executed Transaction from Progress Report

There are seven transactions added in script. So, seven transactions should be executed in one session.

72

Verifying Executed Transaction from Dashboard GUI

  1. Open Test Run GUI.
  2. Click on Test Run in Test Run GUI.

73

  1. The Dashboard GUI is displayed.

Executed Transaction in Transaction Detail window (in tabular format)