Sunteți pe pagina 1din 14

HP LoadRunner 11.

00
Lab Exercises

COURSE OVERVIEW
In this course, students will learn how to create and execute performance tests using
LoadRunner. Each topic is supported by hands-on exercises that are based on reallife examples designed to provide you with the knowledge necessary to automate
performance testing in the Web environment using LoadRunner. The class focuses on
quality assurance and tool usage, with associated lab work to enforce the skills.

COURSE TOPICS
o
o
o
o
o
o
o
o
o

LoadRunner UI/Basic record and replay


Recording Options
Runtime Settings
Transactions
Parameterization
Replay Verification
Correlation: Manual and Automatic

Scenario Setup, Running and Monitoring


Results Analysis

PREREQUISITES

A general understanding of applications and systems architectures, which includes:


o business processes
o 2 Tier/3 Tier architecture
A general understanding of http communication protocol
Knowledge of C programming language a plus but not required

INTENDED AUDIENCE

QA Managers
Performance Test Team Leads
Performance Test Script Developers

Apr 2011

HP Restricted

LRPage 1

LoadRunner 11 Training

1. Script Recording
In this exercise, you will explore Virtual User Generator UI and its Recording
Options and will perform a basic recording.
Launch and configure demo Application
a. Use LR11 image
b. Verify that Xitami web server is launch (the X icon on the system tray is
displayed). If not, go to the image Desktop and launch Start Web Server
c. On the Desktop, find and launch HP Web Tours application.
d. Click the Sign-up now link and submit your own username and password.
No need to enter First/Last name nor address.
e. Re-launch HP Web Tours application and make sure you can login with
your username and password.
f.

Logout and close browser.

Basic recording
g. On the Desktop, find and launch Virtual User Generator.
h. Select File New for a new script. Make sure New Single Protocol script
and category: Popular protocols are selected. Select Web
(HTTP/HTML) protocol.

LR2

i.

Click OK

j.

In the Start Recording window fill in as below:

HP Restricted

August 2010

HP ALM-QC 11.0

k. Click on Options button


l.

Under General Script make sure Close all AUT processes when
recording stops is enabled.

m. Click OK
n. Click OK on the Start Recording window
o. VuGen (Virtual User Generator) should be converted to a recording toolbar, and
the application should be launched automatically.
p. Login to the application using your newly created <username> and
<password>
q. Click Login
r. Click on Flights button on the left panel
s. On the recording bar, change vuser_init to Action in the Recording
into Action selection box.
t.

Select:
i. Departure City: London
ii. Arrival City: Paris
iii. Enable Round-trip ticket Checkbox

u. Click Continue
v. Click Continue again to take the 1st available flight
w. On the Payment Details page, enter:
i. First Name: <your name>
ii. Last Name: <your name>
iii. Credit Card Number: <any number>
x. Click Continue
y. On the Invoice page, click on Flights button
z. On the recording bar, change Action to vuser_end in the Recording
into Action selection box.
aa. Click on Sign off
bb. Stop recording by clicking on the Stop button.
cc. Save script as exercise1

Apr 2011

HP Restricted

LRPage 3

LoadRunner 11 Training

2. Script Replaying
In this exercise, you will replay the script as well as perform basic configuration on
recording options and runtime settings.
Basic Replaying
a) In VuGen, go to Tools General Options and configure as below:

b) Go to Runtime Settings. Make sure under Internet Protocol Proxy, No


Proxy is selected
c) Click on the Run button. Did it replay successfully? What is displayed in Replay
log?
Recording Options and Runtime Settings
1) Save script exercise1 as exercise2
2) Click on the Edit Recording Options button
3) Under General Script, change generate think time greater than
threshold from 3 to 60. Click OK
4) Under VuGen, click on Tools Regenerate script Click OK on the warning.
5) Do you see any lr_think_time() statement in the script? Why or why not?
6) Click the Runtime Setting button. Under General Run logic, change the
number of iterations to 2.
7) Under General Pacing, select After the previous iteration ends and
select with a Random delay of between 3 sec to 5 sec.

LR4

HP Restricted

August 2010

HP ALM-QC 11.0

8) Under General Miscellaneous, enable define each step as a


transaction.
9) Click OK on the Runtime Settings window. Replay the script again.
10) How many times (iterations) did the script replay? Was there a delay between iteration
1 and 2? How much delay was it?
Review Questions
a) What is the difference between Single protocol and Multiple protocol script?
b) Why is it a good idea to record in Chapter 1, step y) before logging out?
c) Did your initial recording attempt generate extra steps because of your
unfamiliarity to the application? An example would be the generation of extra steps
because you might went to the wrong page. How would you fix the script? What
would be a recommendation to minimize such extra effort?
Review Answers
a) Single protocol can record only 1 communication protocol while multiple protocols
can record a pre-defined combination of 2 or more communication protocols. The
multiple protocol combination is pre-defined; meaning user cannot freely mix and
match any arbitrary combinations. Also, each valid combination is licenses
independently.
b) In the runtime settings chapter we will talk about running the Action section with
multiple iterations. With that setup, step s) to go back to the initial page (the page
where application is at, at the beginning of the Action section) is sometimes
necessary to maintain the coherence of the business process flow.
c) To clean-up unnecessary recorded steps, simply highlight the step, and hit Delete.
A good recommendation would be to get yourself familiar with the subject business
process first, by performing a few dry runs before starting the recording. This will
minimize or eliminate the need to correct mistype steps.

Apr 2011

HP Restricted

LRPage 5

LoadRunner 11 Training

3. Transactions
In this exercise, you will create a transaction within the script and explore transaction
differences between 2 types of recording.
Add Transaction
a) Take script exercise2 and Save As exercise3.
b) Verify that Tree View is selected for the script.
c) Select the Action section
d) Highlight the first step (Welcome.pl)
e) Click on Insert Start Transaction button
f)

Name it InsertOrder. Click OK

g) Highlight the step BEFORE the last step in Action (usually reservations.pl_3)
h) Click on Insert End Transaction button.
i)

Select the default (Transaction Name: InsertOrder, Transaction status =


LR_AUTO)

j)

Click OK

k) Replay the script. What is the reported transaction time? Where can you find the
information?
Recording Web (Click and Script)
l)

Perform another recording using the steps in Exercise 1, but instead of using Web
(HTTP/HTML) select Web (Click and Script). Save the script as
exercise2a.

m) In exercise2a, select the Action section


n) Highlight the first step (usually webTour)
o) Click on Insert Start Transaction button
p) Name it InsertOrder. Click OK
q) Highlight the second to last step. Click on Insert End Transaction button.
r)

Select the default (Transaction Name: InsertOrder, Transaction status =


LR_AUTO)

s) Click OK
t)

LR6

Replay the script. What is the reported transaction time? It is different from the
transaction time reported in exercise2? Why?

HP Restricted

August 2010

HP ALM-QC 11.0

Review Questions
a) Why is transaction reported in exercise2a different from that reported in
exercise3?
b) What are some other ways you can insert a new transaction to the script?
Review Answers
a) VuGen is trapping recording events at different communication level when using
Web (HTTP/HTML) versus Web (Click and Script). Web (HTTP/HTML) is
trapping at the HTTP level, while Web (Click and Script) is trapping at the
DOM (Document Object Model). Since during replay the time needed for Web
(HTTP/HTML) script is less (communicating at a lower HTTP level and bypassing
the DOM level, the reported transaction time is less.
b) Transaction can be inserted using drag and drop method in Task View, and
transaction can also be inserted during recording, which is the recommended way
since we dont need to understand where exactly within the script is the start and
end of the transaction.

Apr 2011

HP Restricted

LRPage 7

LoadRunner 11 Training

4. Parameterization
In this exercise, you will create a parameter inside the recorded script.

Create a Parameter
a) Open script exercise3 and save it as exercise4.
b) Set the script in the Tree View, highlight the step Submit Form:
reservations.pl
c) Right-click and select properties
d) Click on the ABC button next to the numPassenger field.

e)
f)
g)
h)
i)
j)
k)
l)
m)
n)
o)
LR8

Enter PassengerCount on Parameter Name field.


Select Random Number on the Parameter Type field.
Click on properties button on the pop-up window.
Select Min=1 and Max=10. Keep the format to be %lu
Select Update value: On each iteration at the bottom of the window.
Click Close. Click OK on the Select or Create Parameter window.
Click OK on the window.
Click on the Edit Runtime settings button.
In the Run Logic section, change iteration to 3.
In Log section, select Extended Log with Parameter Substitution enabled.
Click OK
HP Restricted

August 2010

HP ALM-QC 11.0

p) Replay the script. Did the script replay successfully?


q) Now create 2 additional parameters named FirstName and LastName using a
File parameter type. Which step should the parameter be on?
r) Enter your own 3 rows of data for the first and last name.
s) Use Random on Select Next Row
t) Predict the parameter value behavior using Simulate Parameter with 10 vusers
and 6 iterations.
u) Replay the script. Did it work?

Review Questions
a) Which VuGen script step should you implement against for exercise step q)?
b) What will happen if invalid data (e.g. A departing city not shown in the application
drop-down list) is being entered as a parameter value?

Review Answers
a) Usually step Submit Form: reservations.pl_3. This is the step where you can
find the first and last name to be submitted to the web server.
b) The replay will fail. As a pre-requisite, all load test data should be verified before
usage.

Apr 2011

HP Restricted

LRPage 9

LoadRunner 11 Training

5. Verification
In this exercise, you will implement a text verification within the recorded script.
a) Take script exercise4 and save as exercise5.
b) In Tree View, go to step Submit Form: reservations.pl_3
c) Go to the HTML View on the right. On the Recording Snapshot, highlight
Thank you for booking through WebTours
d) Right-click and select Add a Text Check (web_reg_find)
e) Enable Save Count checkbox and name it Count
f)

LR10

Replay the script. How many occurrences do we have for the text?

HP Restricted

August 2010

HP ALM-QC 11.0

6. Correlation
In this exercise, you will fix a correlation issue within the script.
a) Open script exercise3 and save it as exercise6.
b) Create 2 parameters against the departure and arrival city and name them FromCity
and ToCity respectively.
c) Set the parameter with 2 rows of data:
i. London,Paris
ii. San Francisco,Sydney
d) Set Runtime Settings Run Logic to run 2 iterations.
e) Replay the script. Did it work? Why or why not?
f)

Try finding the problem and fixing it.

g) Upon finishing this exercise we will review the solution in class.


Review Questions
a. What seems to be the problem? How was it fixed?
b. Is there a more automated way of solving the problem?
Review Answers
a) Issue is related to correlation, where the recorded outbound and inbound flight
is hard-coded within the script. Solution is to perform correlation to replace hardcoded value with a dynamic placeholder.
b) Yes, using Automatic Correlation either during recording (Recording Options
Correlation) or Scan for Correlations. Bear in mind though that automation of
correlation does not always cover necessary correlation need. Manual
correlation technique needs to be performed often in reality.

Apr 2011

HP Restricted

LRPage 11

LoadRunner 11 Training

7. Scenario Creation and Execution


In this exercise, you will create as well as execute a scenario
Create and Execute Scenario
a) On the LR11 image Desktop, find and launch Controller.
b) In the New Scenario window, select Manual Scenario and drag script
exercise6 to the right panel.
c) Click OK
d) Setup the Scheduler to be as follows:

e) Create a new SLA with Total Hits per run for the whole scenario with value =
200.
f)

Go to Run tab and setup a windows resource monitoring with the default resource
measurement.

g) On the Controller, on the menu bar, select Results Result settings and make a
note of where the result directory is. (i.e. the Directory box)
h) Save the scenario as exercise7.
i)
LR12

Replay the scenario.


HP Restricted

August 2010

HP ALM-QC 11.0

j)

Did the server successful in handling the load?

k) How many
i. Passed Transactions,
ii. Failed Transactions,
iii. Hits/Second did the scenario achieved?
iv. Any errors?

Review Questions:
a. In the New Scenario window, how do we know the absolute path of the
script?
b. How many vuser licenses will this scenario use? Where do you see that?
c. Was the actual vuser running behavior exactly the same as what dynamic
schedule predicts? Why or why not?
d. Where can we find whether the scenario achieves its load testing goal?

Review Answers:
a. Right-click on any script and select Show Path
b. if the Initialize each vuser before it runs is selected, the scenario will
use 4 vuser license maximum, since the maximum number of both initialized
and running vusers will be 4. On the other hand, youll need 6 (4 + 2) vusers
if Initialize all vusers simultaneously is selected.
c. The runtime schedule is usually different from what is shown in the dynamic
scheduler, in part because time needed to initialize a vuser might be
unpredictable, plus operators can manually change behavior of the run by
adding or stopping vusers.
d. We can only obtain this information under Analysis.

Apr 2011

HP Restricted

LRPage 13

LoadRunner 11 Training

8. Result Analysis
In this exercise, you will explore Analysis application and generate graphs and
reports.
a) On the LR 11 image Desktop, open the Enablement Folder.
b) Locate \result1\ Validation01_09-30-05.lra. Double-click to launch it.
c) Go to Summary Report item on the left panel, what should testers report the
transaction time of S1 T04 ECHO Login to be?
d) Play around with features like granularity, merge graphs, drill-down, autocorrelateetc

Review Questions:
e. What should be reported as transaction time for S1 T04 ECHO Login?
Review Answers:
e. A more accurate number should be the 90th Percentile, reporting 6.732.

LR14

HP Restricted

August 2010

S-ar putea să vă placă și