Load Runner Tutorial
Load Runner Tutorial
com
LoadRunner
Understanding The LoadRunner
The actions that a Vuser performs during the scenario are described in a
Vuser script. When you run a scenario, each Vuser executes a Vuser script.
The Vuser scripts include functions that measure and record the
performance of the server during the scenario. To measure the performance
of the server, you define transactions.
Transactions measure the time that it takes for the server to respond
to tasks submitted by Vusers. For instance, you can define a transaction that
measures the time it takes for the server to process a request to view the
balance of an account and for the information to be displayed at the ATM.
You insert rendezvous points into Vuser scripts to emulate heavy user load
on the server.
Using the Controller, you control all the Vusers in a scenario from a
single workstation. When you execute a scenario, the LoadRunner Controller
distributes each Vuser in the scenario to a host. The host is the machine that
executes the Vuser script, enabling the Vuser to emulate the actions of a
human user. Vuser scripts include functions that measure and record system
performance during load-testing sessions. During a scenario run, you can
monitor the network and server resources. Following a scenario run, you can
view performance analysis data in reports and graphs.
You can easily create and run load-testing scenarios by following the
LoadRunner testing process below. The following illustration outlines the
testing process:
Successful load testing requires that you develop a thorough test plan.
A clearly defined test plan will ensure that the LoadRunner scenarios that
you develop will accomplish your load testing objectives.
To each Vuser in a scenario, you assign a Vuser script and a host to run
the script.
events that occur during each testing session. Thus, for example, a scenario
defines and controls the number of users to emulate, the actions that they
perform, and the machines on which they run their emulations.
GUI Vusers
Database Vusers
Because Database Vusers are not reliant on client software, you can use
Database Vusers to test server performance even before the client software
has been developed. Further, because Database Vusers do not have a user
interface, system resources are not used, and you can therefore run large
numbers of Database Vusers on a single workstation.
The following example illustrates the use of Database Vusers: Suppose
that you have a database server that maintains your customer information.
The information is accessed by numerous customer service personnel who
are located throughout the country. The database server receives the
queries, processes the requests, and returns responses to field personnel.
You want to test the response times of the server when numerous service
personnel simultaneously access the server. Using LoadRunner, you could
create several hundred Database Vusers, each Vuser accessing the server
database. The Database Vusers enable you to emulate and measure the
performance of your server under the load of many users. You develop a
Database Vuser script to define the actions of a Database Vuser. A Database
Vuser script includes functions that control the script execution, specify the
input that the Vuser submits to the server, and measure the server
performance.
You develop Database Vuser scripts either by recording with
LoadRunner’s Vuser Script Generator (VuGen) or by using LoadRunner’s
Vuser script templates. For the database server example above, you could
create a Database Vuser script that performs the following actions:
The structure and content of a Vuser script differ from one Vuser type
to another.
For example, Database Vuser scripts always have three sections, are written
in a code that resembles C, and include SQL calls to a database server. In
contrast, GUI Vuser scripts have only one section, and are written in TSL (test
script language). The following diagram outlines the process of developing a
Vuser script.
To verify that the script runs correctly, you run it in stand-alone mode.
When your script runs correctly, you incorporate it into a LoadRunner
scenario.
About VuGen
VuGen greatly simplifies the task of creating Vuser scripts by reducing the
need for manual programming. Each Vuser script that you create with VuGen
can communicate directly with a server by executing calls to the server API—
without relying on client software. You can therefore use Vusers to check
server performance even before the user interface of the client software has
been fully developed.
Before you begin recording, you must create a Vuser script. If you are
recording a Java, Baan, or RTE application, you can also record into an
existing script.
Start VuGen.
Select Start > Programs > LoadRunner > Virtual User Generator.
The VuGen window opens.
Click the New button. The New Virtual User dialog box opens with a list
of the supported Vuser script types.
If the Start Recording dialog box is not open, click the Start Recording
button. The Start Recording dialog box opens.
Note that you can add command line parameters to your application by
filling them in manually in the Program to Record box, to the right of the
application name. For example: starts plus32.exe, and connects the user
Peter to the server Neptune.
f:\orant\bin\plus32.exe peter@neptune
After recording typical user actions, select the vuser_end section from
the floating toolbar.
Perform the log off procedure. VuGen records the procedure into the
vuser_end section of the script.
Click Stop Recording on the Recording toolbar. The main VuGen
window displays all the recorded statements.
Click Save to save the recorded session. The Save As dialog box opens
(for new Vuser scripts only). Specify a script name.
After recording a script, you can manually edit the script in VuGen’s
main window. VuGen creates a series of configuration, data, and source code
files during recording . These files are used to execute the Vuser actions. You
can display the contents of each of these sections in the main VuGen
window. You can display the contents of only a single section at a time. To
display a section, highlight its name in the Sections box.
When you create a Vuser script, you can enhance its capabilities by adding
Vuser functions. For example, you can add debugging code, or functions that
Testing Tools – LoadRunner
# 16 #
For QTP Documents visit: www.gcreddy.com
Inserting Transactions
Click the arrow for a list of open transactions. Select the transaction to
close. Click OK to accept the transaction name. LoadRunner inserts an
lr_end_transaction statement into the Vuser script. For example, the
following function indicates the end of the trans1 transaction:
lr_end_transaction(“trans1”, LR_AUTO);
Type a name for the rendezvous point in the Name box. Click OK to
accept the rendezvous name. VuGen inserts an lr_rendezvous
statement into the Vuser script. For example, the following function
defines a rendezvous point named rendezvous1:
lr_rendezvous(“rendezvous1”);
Inserting Comments
To insert a comment:
Note: You can insert comments into your script even after you complete a
recording session, by selecting Insert > Comment from the VuGen menu.
/*
* This is the first query
*/
LoadRunner Controller
The Controller window opens with the LoadRunner Controller dialog box
inside.
Wizard: Creates a scenario with the aid of the LoadRunner Scenario wizard,
an interactive, step-by-step guide to creating a scenario.
New: Creates a new scenario.
Open an existing scenario: Opens an existing scenario.
Show at Startup: If you do not want this window to appear the next time
you start LoadRunner, clear the “Show at Startup” check box. Once you clear
this checkbox, when you open the Controller, the window layout from the
last time you worked with the Controller appears.
Title bar Displays the name of the scenario on which you are currently
working.
Menu bar Displays the menus from which you select commands.
Tool bar Provides shortcuts for selecting commands. Clicking on a button
executes a command.
Status bar Provides information on the current state of the scenario.
Vuser window Displays a list of all the virtual users that can take part in the
scenario. You also create Vusers using this window.
Host window Displays the list of machines that can execute Vuser scripts
during the scenario.
Script window Displays a list of all the Vuser scripts that you can assign to
Vusers.
Rendezvous window Displays the Vusers that simultaneously perform
tasks during the scenario.
Output window Displays error and notification messages generated by
Vusers during scenario execution.
Transaction window Displays all the transactions that will be measured
during scenario execution.
A scenario describes the events that occur during each load testing
session. A scenario contains lists of hosts, Vusers, Vuser scripts, transactions,
and rendezvous points. You create a scenario using the LoadRunner
Controller. After you create the scenario, LoadRunner saves the information
in a scenario file (. lrs). You use the commands in the File menu to create,
open, save, and close scenario files. Some of these commands are available
from the toolbar.
The New command creates a completely new scenario. Note that the
New command clears all the information displayed in the Controller windows.
To create a new scenario, choose File > New, or click the New button.
You can also create a new scenario by using the Scenario wizard. The
wizard is an interactive, step-by-step guide to creating a scenario. To create
a new scenario by using the Scenario wizard, select File > Scenario Wizard.
Choose File > Open, or click the Open button. The File Open dialog box
opens.
Click a file in the File Name list or type a file name in the File Name
box.
Click OK. The File Open dialog box closes and the scenario appears in
the LoadRunner Controller.
Saving a Scenario
Closing a Scenario
Filtering Information
You use the Filters box to filter the information that appears in a
window. There is a Filters box in the toolbar in each window.
To filter information:
Click the arrow on the Filters list. The list of available filters appears.
Sorting Information
You use the Sort list to sort the information that appears in a window.
There is a
Sort box in the toolbar in each window.
Create a Scenario
To develop a scenario, you create a host list, a script list and a Vuser
list. This describes how to create a host list—the list of machines, or hosts,
that execute Vuser scripts during a scenario run.
Hosts are the machines on which Vusers run their scripts. The host list
displays the machines that can run Vusers during scenario execution. You
can add both UNIX and Windows machines to the host list. The Host window
displays the host list and the following information for each host:
The Host window has its own menu in the Controller menu bar, and a tool
bar that lets you create and manage the host list.
Each time you run a scenario, some hosts may be unavailable. You can
temporarily remove (disable) hosts from the list.
You use the Host window in the LoadRunner Controller to add hosts to the
host list. After you create a host, you can set and modify the attributes for
the new host.
Start the LoadRunner Controller and open the Host window. The Host
menu appears in the LoadRunner menu bar.
Choose Host > Add. The Host Information dialog box opens.
If the host is UNIX-based, set the login information for the host. By
default, LoadRunner uses your NT user name for the UNIX login. In
other words, if your NT login is lrunner, the Controller will log on to the
host as lrunner. You can also specify to login to the UNIX machine as
another user.
7 Click OK to close the Host Information dialog box. The host name you
entered appears in the Host window; the host status is set to DOWN.
Open the Host window. The Host menu appears in the LoadRunner
menu bar.
Click a host in the Host window. The host is highlighted.
Choose Host > Details. The Host Information dialog box opens.
Open the Host window. The Host menu appears in the LoadRunner
menu bar.
Click a host in the Host window. The host is highlighted.
Choose Host > Details. The Host Information dialog box opens.
Click the Vuser Types tab.
In the Initialization Quota boxes, enter the maximum number of Vusers
of each type that the host will initialize simultaneously.
Click OK to close the dialog box.
GUI Vusers running on the specified host will access this file.
Open the Host window. The Host menu appears in the LoadRunner
menu bar.
Click a host in the Host window. The host entry is highlighted.
Choose Host > Details. The Host Information dialog box opens.
Click the WinRunner tab, and then click one of the following options:
When a host runs a Vuser script, the Vuser generates results that
describe the execution of the script. By default, these results are saved
temporarily on a local drive of each host—until they are collated by the
Controller to a central location. Alternatively, you can select to save the
results directly to a shared network drive. The way in which the scenario
results are saved is set globally for all the hosts in the scenario, you can
change the way in which individual hosts save their results.
Open the Host window. The Host menu appears in the LoadRunner
menu bar.
Click a host in the Host window. The host entry is highlighted.
Double-click the host or choose Host > Details. The Host Information
dialog box appears. Ensure that the Runtime File Storage tab is visible.
Before you run a scenario, you can select which hosts will run Vusers.
This compensates for the possibility that some hosts will be unavailable. For
example, a machine may already be in use when you want to run the
scenario. You select which hosts will take part in the scenario by using the
Enable and Disable commands. Disabling a host temporarily removes it from
the list. Enabling a host reinstates it.
Disabling Hosts
When you disable a host, the host will not execute Vuser scripts during
a scenario execution.
To disable a host:
Open the Host window. The Host menu appears in the LoadRunner
menu bar.
Click a host in the Host window. The host is highlighted.
Click the Disable button or choose Host > Disable. The host name
changes from black to gray. The host is disabled.
Enabling Hosts
To enable a host:
To develop a scenario, you create a host list, a script list, and a Vuser
list. This describes how to create a script list—the list of all the Vuser scripts
that Vusers can run during scenario execution.
You use the Script window in the LoadRunner Controller to add scripts
to the script list. After you create a script, you can set and modify the details
of the new script.
When you add a script to the script list, ensure that the Controller can
recognize the script’s path. During run time, the Controller sends a copy of
the scripts to the Vuser hosts.
Start the LoadRunner Controller and open the Script window. The
Script menu
appears in the LoadRunner menu bar.
Choose Script > Add. The Vuser Script Information dialog box opens.
Click the browse button to the right of the Path box. The Open dialog
box appears.
In the “Files of Type” box select the Vuser type, and then select the
path and file name of the new script.
Click Open to select the files. The Open dialog box closes, and the new
script name and its Vuser type appear in the Vuser Script Information
dialog box.
In the Command Line box, type any command line options to use when
running the script. For example: -x value -y value
You can modify the details of a script in the script list using the Vuser
Script Information dialog box.
Start the LoadRunner Controller and open the Script window. The
Script menu appears in the LoadRunner menu bar.
Click a script in the Script window. The script is highlighted.
Choose Script > Details. The Vuser Script Information dialog box
opens, displaying the details of the selected script.
Modify the details as necessary. Note that you cannot modify the
transactions, rendezvous, or Vusers associated with a script.
Click OK to close the Vuser Script Information dialog box and save the
changes. The modified script details appear in the Script window.
You can customize the way that the Controller executes a Vuser script by
configuring the script’s run-time settings. You can modify these settings
using the LoadRunner Controller by choosing Script > Runtime Settings. You
can also modify the settings using the Vuser Script Generator (VuGen). The
run-time settings can be set in the following areas: Think Time, Iterations,
Log, and Web.
To develop a scenario, you create a host list, a script list, and a Vuser
list. This describes how to create the Vuser list—the list of all the Vusers that
can run during scenario execution.
You create the Vuser list in the Vuser window. The Vuser window has a
menu in the LoadRunner menu bar, and a tool bar that lets you create and
manage the Vuser list. You can also use the Vuser window to control Vusers
while running a scenario.
Creating Vusers
You create a Vuser by specifying the Vuser script that the Vuser will
run, and a host to run the script. You can assign the same Vuser script to
many Vusers.
Note: The type of Vuser script that you select determines the type of Vuser
created: selecting a DB Vuser script creates a DB Vuser; selecting a GUI
Vuser script creates a GUI Vuser; selecting an RTE Vuser script creates an
RTE Vuser.
To create Vusers:
Start the LoadRunner Controller, display the Vuser window, and click in
the Vuser side of the window. The Vuser menu appears in the
LoadRunner menu bar.
Choose Vuser > Add. The Vuser Information dialog box appears.
In the Quantity box, enter the number of Vusers that you want to
create.
Select a host in the Host Name list. Select New to open the Host
Information dialog box and add a host to the list.
Select a script in the Script Name list. To see the rendezvous points
and transactions defined in the Vuser script, click the Script tab. To add
a new script to the list, click New to open the Vuser Script Information
dialog box.
Click OK to close the Virtual User Information dialog box. The new
Vusers appear in the Vuser window. LoadRunner assigns unique ID
numbers to the Vusers. If you did not create a Vuser Group,
LoadRunner creates the Vuser Group G1 and assigns the Vusers to it.
Scheduling Vusers
After you create a Vuser, you can schedule the Vuser by setting:
To schedule a Vuser:
Open the Vuser window, and click in the Vuser side of the window. The
Vuser menu appears in the LoadRunner menu bar.
Choose Vuser > Details. The Vuser Information dialog box appears.
Click the Scheduling tab.
You can use Vuser Groups to organize the Vusers in a scenario into
manageable groups. You create Vuser Groups that contain Vusers with
shared or similar characteristics. For example, you can create a Vuser Group
for all Vusers that run the same Vuser script.
Open the Vuser window. The Vuser menu appears in the LoadRunner
menu bar.
Click anywhere in the Vuser Group column. The Vuser Group menu
appears in the LoadRunner menu bar.
Choose Group > Add. The Vuser Group Information dialog box opens.
In the Name box, enter the name of the Vuser Group and then click OK.
The new Vuser Group appears at the bottom of the Vuser Group list in
the Vuser window.
In the Command Line box, type any command line options to use when
running the group. For example: -x value -y value
Note: At run time, the Group command line options will be joined together
with any Vuser script command line options. If the Group and the script
specified the same option with different values, then the value defined for
the Group is used.
Note: When you renumber Vusers, the Vusers are assigned new ID numbers.
This may conflict with previous results.
After you create a Vuser Group, you can schedule the group by setting:
The amount of time after the start of the scenario that the group must
wait before it starts running
The amount of time the group will run
Open the Vuser window, and click in the Vuser Group (left) side of the
window. The Group menu appears in the LoadRunner menu bar.
Choose Group > Details. The Group Information dialog box opens.
Start Delays the start the Vuser Group when you run a scenario.
You enter the delay time in minutes. Note that if you delay the
start of a specific Vuser (via the Vuser Information dialog box),
the Vuser delay begins only after any Vuser Group delay time
has passed.
Run for Runs all the Vusers in the Vuser Group for a specified
amount of time from when the Vuser Group started. You enter
the time in minutes.
Click OK to close the dialog box.
When you run a scenario, the Vusers are assigned to their hosts and
execute their Vuser scripts. During scenario execution, LoadRunner:
While the scenario runs, you can pause and stop individual Vuser Groups and
Vusers; monitor each Vuser in the scenario; and view error and notification
messages generated by the Vusers
You can run all the Vusers in a scenario, or you can select the specific Vuser
Groups and Vusers that you want to run. This section describes how to run
an entire scenario.
Initializing Vusers
To initialize a Vuser:
Running Vusers
To run a Vuser:
Pausing Vusers
To pause a Vuser:
Stopping Vusers
Stopping a Vuser stops script execution. If you stop a Vuser, the Vuser
still appears in the Vuser list.
To stop a Vuser:
While you run a scenario, you can manually release Vusers from a
rendezvous
before the Controller releases them.
Monitoring Vusers
During scenario execution, you can use the Vuser window to monitor
the actions of all the Vusers in the scenario. This section describes how to
monitor Vusers running on Windows-based and UNIX platforms. In addition to
monitoring UNIX Vusers, you can view the actions that they perform. While a
scenario is running you can monitor the state of each Vuser. The Status field
of each Vuser displays the current state of the Vuser. The following table
describes all possible Vuser states.
Choose Vuser > Show Group Totals, or click the Show Totals button.
Choose Vuser > Hide Group Totals, or click the Hide Totals button.
While the scenario runs, the Vusers and hosts send error and
notification messages to the Controller. You can view these messages in the
Output window. The messages in this window are cleared at the start of
scenario execution.
Testing Tools – LoadRunner
# 44 #
For QTP Documents visit: www.gcreddy.com
Choose Output > Export To File, or click the Export button. The Output
messages are saved to a file.
Choose Output > Remove All, or click the Remove All button. The
Output window is cleared of all messages.
After running a scenario, you can use LoadRunner’s graphs and reports
to analyze the performance of your client/server system.
In order to view a report, you must generate the report from the
LoadRunner Analysis window. LoadRunner reports are displayed in a Report
Viewer. You can print, save, or export the data using the viewer.
When you run a scenario, LoadRunner stores the scenario results in the
specified directory. When you run the analysis, LoadRunner processes the
data and formats them into a database. The formatted data is used to
generate reports and graphs. You can instruct LoadRunner to run the
analysis automatically at the end of a scenario by selecting Results > Auto
Load Analysis.
To display reports:
Select Results > Analyze Results, or click the Analysis button. The
Analysis window opens.
From the Reports menu choose a report. The report is generated and
displayed. You can display multiple copies of the same report.
Each report is displayed in its own report viewer. Each viewer contains
a header
and a toolbar.
Report Header
The header displays general scenario information.
Each report viewer has a toolbar that lets you perform operations on
displayed reports.
Zoom: Toggles between an actual size, full page, and magnified views of the
report.
Print: Prints the displayed report.
Export to file: Exports the displayed information to a disk file.
Export to mail: Mails the displayed information using Microsoft Mail.
After running a scenario, you can analyze the Vuser activity that
occurred during the scenario to check that the scenario ran as planned.
The Running Virtual User graph displays the number of Vusers that
executed Vuser scripts during each second of a scenario run. Only Vusers in
the RUNNING and RENDEZ states are included in the graph. Vusers in the
LOADING, READY and PAUSE states are not displayed.
This graph is useful for determining the Vuser load on your server at any
given moment. The x-axis represents the elapsed time (in seconds) since the
start of the scenario run. The y-axis represents the number of running Vusers
in the scenario. For example, the above graph indicates that there was a
maximum load of thirty Vusers. Until the 37th second of the scenario run,
Vusers were gradually loading. Thereafter, the number of running Vusers
decreased to twenty, and then to ten.
In the above report, the rendezvous policy was set to All Arrived,
requiring all 50 Vusers to arrive at the rendezvous point. In the first
rendezvous, 40 Vusers were released after the timeout period while 10
Vusers were manually released by the operator. In the next rendezvous, all
50 Vusers arrived. In the last rendezvous, two Vusers never arrived, causing
the others to reach the timeout.
The x-axis represents the elapsed time (in seconds) since the start of
the scenario run. The y-axis represents the number of transactions
successfully performed during the scenario run. For example, the above
graphs indicate that in the 224th second of the scenario, nine query
transactions were successfully completed. The response time at that point
was 49 seconds.
The following example uses a Web Vuser script. Web Vuser statements
return zero for success and a positive value for failure. The Web Vuser script
below tries to access an HTML page using a GET statement. If the GET
request succeeds, the script assigns the LR_PASS status to the transaction. If
the GET request fails, the script assigns LR_FAIL to the transaction. On the
Transactions per Second (Failed) graph, the x-axis represents the elapsed
time (in seconds) since the start of the scenario run. The y-axis represents
the number of transactions unsuccessfully performed during the scenario.
lr_start_transaction(“wizard”);
if (URL("http://www.wizard.com/index.html") == 0)
lr_end_transaction(“wizard”, LR_PASS);
else {
lr_end_transaction(“wizard”, LR_FAIL);
lr_log_message("Wizard home page not returned");
}
For example, the above graph indicates that in the 33rd second of the
scenario, nine insert_row transactions failed. The Failed Transaction report
provides detailed information about the beginning, end, and duration of the
failed, yet completed transaction.
The Failed Vuser report provides details about all Vusers that were in
the ERROR, ABORTED, or DONE:FAILED states during the scenario execution.
The Ready At and Running At times are relative to the computer’s system
clock.
In this scenario, one Vuser failed, two had errors, and three were
aborted.
After running a scenario, you can create graphs and reports to help
you locate
bottlenecks and analyze overall Vuser performance. You can determine if the
transaction response time was adequate, and how your system handled a
load of many users.
the graph. When working with reports, you can export the data in ASCII
format or in a custom format for common spreadsheet applications.
Percentile Graph
The x-axis indicates the number of running Vusers, and the y-axis
indicates average transaction time in seconds. In the above graph, the
execution time for the top_sales transaction increases with the number of
running Vusers. For twenty running Vusers, the response time for the
transaction was 3.5 seconds.
The x-axis specifies the name of the transaction. The y-axis shows the
time, rounded off to the nearest second, taken to perform each transaction.
For example, the above graph displays the statistics of the query
transaction. The transaction was performed in a minimum time of 24
seconds, an average time of 36 seconds, and a maximum time of 42
seconds.
The report shows similar information in table form. The information in
the table is not rounded off to the nearest second, as it is in the graph.
The x-axis specifies the name of the Vuser and the Group to which it
belongs. The y-axis shows the time, in seconds, it takes to perform each
transaction. For example, the above graph displays transaction processing
times for the Vusers in the group15. Vuser two performed the query
transaction in a minimum of 25 seconds, an average of 32 seconds, and a
maximum of 40 seconds.
The Start time and the End time in this report refer to the system time
at the beginning and end of a transaction. The Result field contains the final
transaction status, either Pass or Fail.