Sie sind auf Seite 1von 56

Load runner

Bhargava

Dt:24/05/2011
www.mindteck.com

Components of load runner

Virtual User Generator

Creates Scripts as one Single User.

Load Runner Controller

Generates load and collects test results

Load Runner Analysis

Compiles and displays test results with graphical and statistical tools

Confidential Mindteck 2010

www.mindteck.com

VUGen

We use Virtual User Generator (VUGen) to record the


protocol from a vast variety of user applications.

Confidential Mindteck 2010

www.mindteck.com

Recording modes

HTML based scripts URL based scripts HTML based scripts :


HTML based mode, records script for every user action that is
performed during recording HTML based mode does recording as you perform clicks and doesnt give you inside information like what is happening behind the recording HTML mode is recommended for browser applications while URL mode is recommended for non-browser applications. Functions developed under this are

web_url web_link

web_submit_data web_submit_form
Confidential Mindteck 2010 | 4 | www.mindteck.com

URL based scripts


URL based mode records each and every browser request to the
server and resources received from the server

Functions developed under this


web_submit_data
web_concurrent_start web_concurrent_end

Confidential Mindteck 2010

www.mindteck.com

What is Parameterization

Parameterization is a process of replacing constants with


variable values.

Parameterizing a Vuser script has the following


advantages:
It reduces the size of the script. It provides the ability to test your script with different values

Parameterization involves the following tasks:


Replacing the constant values in the Vuser script with parameters Setting the properties and data source for the parameters

Confidential Mindteck 2010

www.mindteck.com

Parameter Types

File or Table Parameter Types XML Parameter Types Internal Data Parameter Types User-Defined Function Parameters

Confidential Mindteck 2010

www.mindteck.com

Parameterization

What are parameters Defining and creating parameters Defining Parameter Properties Data Assignment Methods Data Update Methods Internal Data Parameter Types

Confidential Mindteck 2010

www.mindteck.com

What are parameters

Username and Password should be parameterized if different credentials need to be used.

Confidential Mindteck 2010

www.mindteck.com

Parameterization Decision-Maker

Do not parameterize Is there a unique constraint? No

Is there a date constraint?

No Does data get cached? No

No
Is this a data dependent field?

Yes Yes

Yes Yes
Parameterize Parameterize Parameterize Parameterize

Confidential Mindteck 2010

10

www.mindteck.com

Data Assignment Methods


When using values from a file,
VuGen lets you specify the way in which you assign data from the source to the parameters. The following methods are available:

Sequential Random Unique

Confidential Mindteck 2010

11

www.mindteck.com

Data Assignment Methods


Sequential The Sequential method assigns data to a Vuser sequentially. As a running Vuser accesses the data table, it takes the next available row of data. If there are not enough values in the data table, VuGen returns to the first value in the table, continuing in a loop until the end of the test. Random The Random method assigns a random value from the data table to each Vuser at the start of the test run. Unique The Unique method assigns a unique sequential value to the parameter for each Vuser. In this case you must make sure there is enough data in the table for all the Vusers and their iterations. If you have 20 Vusers and you want to perform 5 iterations, your table must contain at least 100 unique values.

Confidential Mindteck 2010

12

www.mindteck.com

Data Update Methods

Confidential Mindteck 2010

13

www.mindteck.com

Data Update Methods


Examples Assume that your table/file has the following values: Kim; David; Michael; Jane; Ron; Alice; Ken; Julie; Fred Sequential Method If you specify update on Each iteration, all the Vusers use Kim in the first iteration, David in the second iteration, Michael in the third iteration, and so on. If you specify update on Each occurrence, all the Vusers use Kim in the first occurrence, David in the second occurrence, Michael in the third occurrence, and so on. If you specify update Once, all Vusers take Kim for all iterations.

Important: If you select the Sequential method and there are not enough values in the data table, VUGen returns to the first value in the table, continuing in a loop until the end of the test.

Confidential Mindteck 2010

14

www.mindteck.com

Data Update Methods


Random Method

If you specify update on Each iteration, the Vusers use


random values from the table for each iteration.

If you specify update on Each occurrence, the Vusers use


random values for each occurrence of the parameter.

If you specify update Once, all Vusers take the first


randomly assigned value for all the iterations.

Confidential Mindteck 2010

15

www.mindteck.com

Data Update Methods


Unique Method

If you specify update on Each iteration, for a test run of 3


iterations, the first Vuser takes Kim in the first iteration, David in the second, and Michael in the third. The second Vuser takes Jane, Ron and Alice. The third Vuser, Ken, Julie, and Fred.

If you specify update on Each occurrence, then the Vuser


uses a unique value from the list for each occurrence of the parameter.

If you specify update Once, the first Vuser takes Kim for all
iterations, the second Vuser takes David for all iterations, and so on.
Confidential Mindteck 2010 | 16 | www.mindteck.com

Data File Replacement Methods

Sequential Vuser Iteration

Random

Unique

Vuser 1

Vuser 2 Vuser 3 Vuser 4

1 2 3 4

a a b c c d d h

a b c d

a f b e c j d g

e f g h
|

a l b m c k d n
17 |

i j k l

a i b c c e d b

m n
param1

o p

Confidential Mindteck 2010

www.mindteck.com

Internal Data Parameter Types


Internal data includes data such as:

Date/Time Group Name Iteration Number

Load Generator Name


Random Number Unique Number Vuser ID

Confidential Mindteck 2010

18

www.mindteck.com

Internal Data Parameter Types


Date/Time

Date/Time replaces the


parameter with the current date and/or time.

Select a format from the


format list or specify your own format.

The format should


correspond to the date/time format recorded in your script.
Confidential Mindteck 2010 | 19 | www.mindteck.com

Internal Data Parameter Types


Symbol c #c H I M S p d m b B Description complete date and time in digits complete date as a string and time hours (24 hour clock) hours (12 hour clock) minutes seconds AM or PM day month in digits (01-12) month as a string - short format (e.g. Dec) month as a string - long format (e.g. December)

y
Y

year in short format (e.g. 03)


year in long format (e.g. 2003)

Confidential Mindteck 2010

20

www.mindteck.com

Internal Data Parameter Types


Iteration Number Iteration Number replaces the
parameter with the current iteration number.

Select one of the available


formats or create a new one.

Click Close to save the settings


and close the Parameter Properties dialog box.

Confidential Mindteck 2010

21

www.mindteck.com

Internal Data Parameter Types


Load Generator Name Load Generator Name replaces
the parameter with the name of the Vuser scripts load generator. The load generator is the computer on which the Vuser is running.

Select one of the available


formats or create a new one.

Click Close to save the settings


and close the Parameter Properties dialog box.

Confidential Mindteck 2010

22

www.mindteck.com

Internal Data Parameter Types


Random Number Random Number replaces the
parameter with a random number.

Confidential Mindteck 2010

23

www.mindteck.com

Internal Data Parameter Types


To set the properties for the Random Number parameter type:

Enter a range defining the set of possible parameter values. You


specify minimum and maximum values for the range of random numbers.

Select a Number format, indicating the length of the random


number. Specify %01lu (or %lu) for one digit, %02lu for two digits, and so on. You can view a sample of how VuGen will display the value, in the Sample value box.

Select an update method, instructing the Vuser when to update


parameter valuesEach occurrence, Each iteration, or Once.

Click Close to accept the settings and close the Parameter


Properties dialog box.

Confidential Mindteck 2010

24

www.mindteck.com

Internal Data Parameter Types


Unique Number Unique Number replaces the
parameter with a unique number.

When you create a Unique


Number type parameter, you specify a start number and a block size. The block size indicates the size of the block of numbers assigned to each Vuser.

Confidential Mindteck 2010

25

www.mindteck.com

Internal Data Parameter Types


Vuser ID Vuser ID replaces the
parameter with the ID number assigned to the Vuser by the Controller during a scenario run.

When you run a script from


VuGen, the Vuser ID is always 1.

This is not the ID number that


appears in the Vuser window -it is a unique ID number generated at runtime.

Confidential Mindteck 2010

26

www.mindteck.com

Questions - To Review Your Skills


Parameterize Username and Password through script view. Parameterize Departure and Return Dates such that Return Date is 1
week after Departure Date.

Parameterize No. of Passengers with Iteration Number, Random


Number and Unique Number.

Parameterize Departure City and Arrival City with update method as


Sequential/Each Iteration.

Execute parameterized script with update method as Sequential/Once. Execute parameterized script with update method as Random/Each
Iteration.

Execute parameterized script with update method as Random/Once. Execute parameterized script with update method as Unique/Each
Iteration.

Execute parameterized script with update method as Unique/Once.


Confidential Mindteck 2010 | 27 | www.mindteck.com

Configuration of Run Time Settings

Run-Time Settings Run Logic Pacing Log Settings Think Time Network Run-Time Settings Browser Settings Internet Preferences Miscellaneous Run-Time Setting
Confidential Mindteck 2010 | 28 | www.mindteck.com

Runtime Settings

The run-time settings define the


way that the script runs. Example:

Emulate a user who responds


immediately to output from the server, or a user who stops and thinks before each response.

To specify how many times the


Vuser should repeat its set of actions.

Confidential Mindteck 2010

29

www.mindteck.com

Run Logic

LoadRunner repeats all of


the Actions the specified number of times.

Init and End sections are


not iterated.

Confidential Mindteck 2010

30

www.mindteck.com

Pacing
The Pacing Run-Time settings
let you control the time between iterations.

The pace tells the Vuser how


long to wait between iterations of your actions.

You instruct the Vusers to


start each iteration using one of the following methods: As soon as the previous
iteration ends.

After the previous iteration ends


with a fixed/random delay of / to seconds.

At fixed/random intervals, every

Confidential Mindteck 2010

31

www.mindteck.com

..Pacing
As soon as the previous iteration ends:
The new iteration begins as soon as possible after the previous iteration
ends.

After the previous iteration ends with a fixed or random delay of


Starts each new iteration a specified amount of time after the end of the
previous iteration. Specify either an exact number of seconds or a range of time. For example, you can specify to begin a new iteration at any time between 60 and 90 seconds after the previous iteration ends.

At fixed or random intervals, every [to ] seconds:


Specify the time between iterationeither a fixed number of seconds or a
range of seconds from the beginning of the previous iteration. For example, you can specify to begin a new iteration every 30 seconds, or at a random rate ranging from 30 to 45 seconds from the beginning of the previous iteration. Each scheduled iterations will only begin when the previous iteration is complete.

Confidential Mindteck 2010

32

www.mindteck.com

Log
To determine how much
information should be logged to the output.

Standard Log: Creates a


standard log of functions and messages sent during script execution to use for debugging.

Extended Log:
Parameter Substitution Data returned by Server

Advanced Trace

Confidential Mindteck 2010

33

www.mindteck.com

Think Time

Ignore think time: Ignore the recorded think time. Replay the think time: As recorded:
Example: lr_think_time(10) waits ten seconds.

Multiply recorded think time by:


Example: If a think time of four seconds was recorded, you can
instruct your Vuser to multiply that value by two, for a total of eight seconds. To reduce the think time to two seconds, multiply the recorded time by 0.5.

Use random percentage of the recorded think time:


Example: If the think time argument is 4, and you specify a
minimum of 50% and a maximum of 150%, the lowest think time can be two (50%) and the highest value six (150%).

Limit think time to: Limit the think times maximum value.
Confidential Mindteck 2010 | 34 | www.mindteck.com

Speed Simulation settings


Using the Speed Simulation
settings, you can select a bandwidth that best emulates the environment under test.

Available Options:
Use maximum bandwidth:
Vusers run at the maximum bandwidth that is available over the network.

Use bandwidth: Indicate a


specific bandwidth level for your Vuser to emulate.

Use custom bandwidth: Indicate


a bandwidth limit for your Vuser to emulate.
Confidential Mindteck 2010 | 35 | www.mindteck.com

Browser Settings
You can set the browser
properties in the following areas:

User-Agent (browser to be
emulated)

Simulate browser cache Download non-HTML resources Simulate a new user each
iteration

You can also set advanced


options for caching and checking for newer resources.

Confidential Mindteck 2010

36

www.mindteck.com

.. Browser Settings

User-Agent (browser to be emulated):


All Internet Vuser headers include a User-Agent header that
identifies the type of browser (or toolkit for Wireless) that is being emulated.

Simulate browser cache:


A cache is used to keep local copies of frequently accessed
documents and thereby reduces the time connected to the network. By default, cache simulation is enabled. When the cache is disabled, Vusers will ignore all caching functionality and download all of the resources for every request.

Cache URLs requiring content (HTML):


This option instructs VuGen to cache only the URLs that require
the HTML content. The content may be necessary for parsing, verification, or correlation. When you select this option, HTML content is automatically cached. This option is enabled by default.

Confidential Mindteck 2010

37

www.mindteck.com

.. Browser Settings

Check for newer versions of stored pages every visit


to the page:
This setting instructs the browser to check for later versions of the
specified URL, than those stored in the cache. This option generates more traffic during the scenario or session execution. By default, browsers do not check for newer resources, and therefore this option is disabled.

Download non-HTML resources


Instructs Vusers to load graphic images when accessing a Web
page during replay. When real users access a Web page, they wait for the images to load. Therefore, enable this option if you are trying to test the entire system, including end-user time (enabled by default). To increase performance and not emulate real users, disable this option.

Confidential Mindteck 2010

38

www.mindteck.com

.. Browser Settings

Simulate a new user each iteration:


Instructs VuGen to reset all HTTP contexts between
iterations to their states at the end of the init section. This setting allows the Vuser to more accurately emulate a new user beginning a browsing session. It deletes all cookies, closes all TCP connections, clears the emulated browsers cache. This option is enabled by default

Confidential Mindteck 2010

39

www.mindteck.com

Internet Preferences

Use the Internet


Protocol
Preferences node in the
Run-Time Settings tree, to set the settings related to the following areas:

Image and Text Checks Generating Web Performance Graphs Advanced Web RunTime Options
Confidential Mindteck 2010 | 40 | www.mindteck.com

.. Internet Preferences

Image and Text Checks:


The Enable image and text checks option allows the Vuser to
perform verification checks during replay by executing the verification functions: web_find or web_image_check.

This option only applies to statements recorded in HTML-based


mode. Vusers running with verification checks use more memory than Vusers who do not perform checks (disabled by default).

Generating Web Performance Graphs:


Instructs a Vuser to collect data used to create Web Performance
graphs. You view the Hits per Second, Pages per Second, and Response Bytes per Second (Throughput) graphs during test execution using the online monitors and after test execution using the Analysis.
Confidential Mindteck 2010 | 41 | www.mindteck.com

Miscellaneous Run-Time Settings

You can set the following


Error Handling Multithreading Automatic Transactions

Miscellaneous run-time options for a Vuser script:

Click the Run-Time

Settings button or select Vuser > Run-Time Settings to display the Run-Time Settings dialog box. Select the General: Miscellaneous node from the tree in the left pane.
Confidential Mindteck 2010 | 42 | www.mindteck.com

. Miscellaneous Run-Time Settings


Error Handling
Continue on Error:

This setting instructs Vusers to continue script execution when an error occurs. This option is turned off by default, indicating that the Vuser will exit if an error occurs.

Fail open transactions on lr_error_message.

This option instructs VuGen to mark all transactions in which an lr_error_message function was issued, as Failed. The lr_error_message function is issued through a programmed If statement, when a certain condition is met.

Generate Snapshot on Error:

This option generates a snapshot when an error occurs. You can see the snapshot by viewing the Vuser Log and double-clicking on the line at which the error occurred.
Confidential Mindteck 2010 | 43 | www.mindteck.com

. Miscellaneous Run-Time Settings


It is not recommended to enable both the Continue on Error and
Generate Snapshot on Error options in a load test environment. This configuration may adversely affect the Vusers performance.

Multithreading Vusers support multithread environments. The primary advantage of a


multithread environment is the ability to run more Vusers per load generator.

The Controller uses a driver program (such as mdrv.exe or r3vuser.exe) to


run your Vusers. If you run each Vuser as a process, then the same driver program is launched (and loaded) into the memory again and again for every instance of the Vuser. This limits the numbers of Vusers that can be run on any load generator.

If you run each Vuser as a thread, the Controller launches only one
instance of the driver program (such as mdrv.exe), for every 50 Vusers (by default). This eliminates the need for multiple re-loading of the driver program/process saves much memory space, thereby enabling more Vusers to be run on a single load generator.

Confidential Mindteck 2010

44

www.mindteck.com

. Miscellaneous Run-Time Settings

Automatic Transactions
You can instruct LoadRunner to handle every step or
action in a Vuser script as a transaction. This is called using automatic transactions. LoadRunner assigns the step or action name as the name of the transaction. By default, automatic transactions per action are enabled.

To enable automatic transactions per step, check the


Define each step as a transaction check box. (disabled by default)

Confidential Mindteck 2010

45

www.mindteck.com

Questions - To Review Your Skills

Execute 2 iterations of load test script recorded only in


Action Class. Execute 5 iterations of load test script recorded in vuser_init, Action and vuser_end classes.

Execute scripts by using different options available for


Pacing run-time setting. Execute scripts by using different options available for Log run-time setting.

Execute scripts by using different options available for


Think Time setting. Notice the difference in time taken for script execution when browser cache is simulated and when it is disabled.

Verify the use of Continue on Error option.


Confidential Mindteck 2010 | 46 | www.mindteck.com

Correlation

What is correlation
Types of Correlation Automatic Correlation Manual Correlation

Confidential Mindteck 2010

47

www.mindteck.com

What is Correlation
Sometime, after creating a script, a simple playback fail even though
the recording of the same actions succeeded.

Many applications use dynamic values that change each time you use
the application. For example, some servers assign a unique session ID for every new session. When you try to replay a recorded session, the application creates a new session ID that differs from the recorded session ID.

LoadRunner addresses this issue through correlation. Correlation


saves the changing values to a parameter.

When running the emulation, the Vuser does not use the recorded
valueinstead, it uses the new value assigned to it by the server.

Confidential Mindteck 2010

48

www.mindteck.com

Automatic Correlation
You will instruct VuGen to insert a step that saves the original session
ID to a parameter. In each replay session, VuGen saves the new unique session ID to a parameter. In the subsequent steps, it uses the saved value instead of the originally recorded value.

Record a new script with the same steps that you recorded previously
and save the script as Basic_Tutorial_Cor.

Click Verify Replay in the Task Pane and click the Start Replay button
at the bottom of the instruction pane. VuGen runs the new script. You may notice several error messages in the Replay Log tab in the Output window, indicated by the red-colored text.

Click Verify Replay in the Task Pane to view the Last Replay Summary

Confidential Mindteck 2010

49

www.mindteck.com

Automatic Correlation
Click the link Show and resolve dynamic server values in the
instruction pane under the heading Dynamic Server Values.

VuGen scans the script, searching for differences between the


recorded values and the playback values.

VuGen displays a list of these differences that may require


correlation in the Correlation Results tab in the Output window.

Select the first entry in the Correlation Results tab, and click
Correlate.

Confidential Mindteck 2010

50

www.mindteck.com

Manual Correlation
Record a new script save the script as Manual_Cor_1. Record another script using the same steps as above and save the
script as Manual_Cor_2.

Now for script Manual_Cor_2, click on Tools > Compare with script
option and select Manual_Cor_1 script to compare with.

Notice that a WDiff window is displayed, showing both the scripts


and the differences in recording are highlighted in yellow color.

Confidential Mindteck 2010

51

www.mindteck.com

Manual Correlation

Confidential Mindteck 2010

52

www.mindteck.com

Manual Correlation

Notice that there is a difference in the userSession value in


both the scripts.

Navigate to Script view and add the following line to the


code:
web_reg_save_param("myval", "LB=userSession value=", "RB=>", LAST );

Now search for the userSession value and replace the


hard-coded valye by parameter as: {myval}

Replay the script and notice that it plays back successfully.

Confidential Mindteck 2010

53

www.mindteck.com

Manual Correlation

Confidential Mindteck 2010

54

www.mindteck.com

Questions - To Review Your Skills

What is correlation and why is it done? Perform Automatic correlation on the script. Perform Manual correlation on the script.

Confidential Mindteck 2010

55

www.mindteck.com

Thank You
www.mindteck.com