Vous êtes sur la page 1sur 610

LoadRunner for the Web 7.

0 Student Workbook

LoadRunner for the Web 7.0 Copyright 1994 - 2001 by Mercury Interactive Corporation All rights reserved. All text and figures included in this publication are the exclusive property of Mercury Interactive Corporation, and may not be copied, reproduced, or used in any way without the express permission in writing of Mercury Interactive. Information in this document is subject to change without notice and does not represent a commitment on the part of Mercury Interactive. Mercury Interactive may have patents or pending patent applications covering subject matter in this document. The furnishing of this document does not give you any license to these patents except as expressly provided in any written license agreement from Mercury Interactive. LoadRunner, TestDirector, TestSuite, WebTest, WinRunner, and XRunner are registered trademarks of Mercury Interactive Corporation in the United States of America and/or other countries. Action Tracker, Astra LoadTest, Astra QuickTest, Astra SiteManager, Astra SiteTest, Change Viewer, Dynamic Scan, Fast Scan, Link Doctor, QuickTest, RapidTest, Topaz, Topaz Prism, Visual Testing, and Visual Web Display, are trademarks of Mercury Interactiv in the United States of America and/or other countries. This document also contains Registered Trademarks, Trademarks and Service Marks that are owned by their respective companies or organizations. Mercury Interactive Corporation disclaims any responsibility for specifying which marks are owned by which companies or organizations. If you have any comments or suggestions about this document, please send them via e-mail to: Training Development@merc-int.com Mercury Interactive Corporation 1325 Borregas Avenue Sunnyvale, CA 94089 Tel. (408)822-5200 (800) TEST-911 Fax. (408)822-5300

LR7WEB-04

OVERVIEW This course covers issues of load testing and functional testing under load for intranet and Internet client/server systems. This course focuses on the importance of emulating real users and teaches students to use LoadRunner tools to:
s s s

create Web Virtual Users (Vusers) run load test scenarios analyze and interpret load test results

COURSE OUTLINE for LOADRUNNER for the WEB 7.0

Duration: Labs: Intended Audience:

Four days Approximately 50% of the class is devoted to lab exercises Quality assurance engineers, performance engineers, technical managers, and others who may be required to perform load analysis on Web systems Knowledge of the Windows 2000 or NT interface and environment High-level knowledge of the Web client/server paradigm

Prerequisites:

Course Outline: Planning an Effective Load Test The importance of planning Obtaining, organizing and analyzing system usage information Determining fields to parameterize and the data to use Creating and Enhancing Web Virtual Users (Vusers) Recording user actions Measuring specific business processes Verifying functionality under load Parameterizing input data LoadRunner Scenarios Defining scenario goals based on planning Defining and connecting to load generators Selecting and configuring performance monitors Options and run-time settings for specific purposes Troubleshooting errors Analyzing Scenario Execution Finding bottlenecks in a system Drilling down in graphs Merging graphs Creating cross result graphs Advanced Topics How VuGen records and replays user actions Correlating (capturing and reusing) dynamic values manually Correlating automatically during and after recording Adding code and logic to the Vuser Making output logs more informative Emulating different IP addresses during load testing

Table of Contents

Introduction ............................................................................................ ix Part 1: Creating Web Virtual Users

1 2 3 4 5

Planning an Effective Load Test ..........................................................1-1 Exercises ....................................................................................... 1-19 Recording .............................................................................................2-1 Exercises ....................................................................................... 2-47 LoadRunner Transactions ....................................................................3-1 Exercises ....................................................................................... 3-23 Verification Checkpoints .......................................................................4-1 Exercises ....................................................................................... 4-39 Data Parameterization .........................................................................5-1 Exercises ....................................................................................... 5-45

Part 2: Web Scenarios & Analysis

6 7

Manual Scenarios ................................................................................6-1 Exercises ....................................................................................... 6-55 Goal-Oriented Scenarios ......................................................................7-1 Exercises ....................................................................................... 7-39

Part 3: Data Correlation

8 9 10

Manual Correlation ...............................................................................8-1 Exercises ....................................................................................... 8-49 Automatic Correlation After Recording ................................................9-1 Exercises ....................................................................................... 9-19 Automatic Correlation During Recording ...........................................10-1

Part 4: Advanced Topics

11 12 13 A B C

Custom Output Messages .................................................................11-1 Exercises ..................................................................................... 11-33 Understanding Record and Playback ................................................12-1 IP Spoofing ........................................................................................13-1 Appendix: Answers to Questions ........................................................ A-1 Appendix: Test Specifications ............................................................. B-1 Appendix: Scaling the Web ................................................................. C-1

vi

Typographical Conventions
s s s

Actual items to type are written in courier font. An arrow (>) is used to indicate cascading menus. (File > Open) Any italic text between brackets should be replaced with the appropriate information. (<Number of Items>) Italic text without brackets are used to indicate buttons, check boxes, etc. (Press the Next button.) List items appear in quotation marks. (Select Carol) NOTES contain information that you need to know to do the lab exercises successfully. TIPS provide alternate ways of performing actions or time-saving techniques but are not essential knowledge for the lab exercises.

s s

vii

viii

Introduction

Introduction ix

Mercury Interactive
Product Training

LR7WEB-04

x LoadRunner for the Web 7.0

$ERXW 0HUFXU\ ,QWHUDFWLYH

Company Profile
Incorporated in August, 1989 IPO in October, 1993 NASDAQ: MERQ S&P 500 in June, 2000 Headquarters in Silicon ValleyOffices world wide
2

Introduction xi

0HUFXU\ ,QWHUDFWLYH 6ROXWLRQV


ERP Customizations
SAP Oracle PeopleSoft Siebel

Application Performance Monitoring


ActiveAgent ActiveTest ActiveWatch/APM Topaz Prism

Products
and

Services
Web C/S - Databases
LoadRunner TestDirector WinRunner WinRunner WebTest LoadRunner TestDirector Astra QuickTest Astra LoadTest
3

xii LoadRunner for the Web 7.0

*HWWLQJ 6XSSRUW
Documentation Online help Web Site Training Consulting Technical Support Users Conference

Introduction xiii

*HWWLQJ 6XSSRUW
http://support.merc-int.com/
Our site helped us to earn the Software Technical Assistance Recognition (STAR) Award Support Center Practices Certification WebStar Service Award from the Software Support Professionals Association Enter specific issues directly into our support database Monitor the status of your open issue

support@merc-int.com
E-mail convenience

(408)822-5400
6 am - 5 pm Pacific Standard Time
5

xiv LoadRunner for the Web 7.0

&XVWRPHU 6XSSRUW :HE 6LWH


http://support.mercuryinteractive.com World Wide User Community of 23,000+ Self Help Features Mercury Interactive Knowledgebase (1000s of solutions) Customer Knowledgebase User Discussion Forums (1000s Q&A each quarter) Submit/Update/Track Support Cases Online Patches & Service Packs Product Alerts and Announcements Online Documentation Company Promotions Customer Reward Program
6

Introduction xv

LoadRunner 7.0 for the Web Introduction

xvi LoadRunner for the Web 7.0

+RZ 7KLV &RXUVH ,V 2UJDQL]HG


Creating and enhancing web virtual users for load testing web applications

Creating and running load test scenarios, and analyzing their results

Advanced Topics

Introduction xvii

2EMHFWLYHV RI WKH &RXUVH


Understand the issues involved in load testing Web applications Learn your responsibilities as the LoadRunner expert Learn how to perform successful load tests using LoadRunner tools

xviii LoadRunner for the Web 7.0

:K\ /RDG 7HVW <RXU :HE $SSOLFDWLRQ"


The failure of a mission-critical web application can be costly Assure performance and functionality under real-world conditions Locate potential problems before your customers do

10

Introduction xix

DEFINITION

.H\ 7HUPV 8VHG LQ 7KLV &RXUVH

/RDG 7HVW
A load test is many concurrent users running the same program to see whether a system handles the load without compromising functionality or performance.

11

xx LoadRunner for the Web 7.0

EXAMPLE

/RDG 7HVW 2EMHFWLYHV

TEST TYPE Performance

OBJECTIVE How many concurrent users can the system handle before response time exceeds 15 seconds? Can the system serve 1000 concurrent users, or will some users get error pages?

Functionality Under Load

12

Introduction xxi

EXAMPLE

)XQFWLRQDO YV /RDG 7HVWLQJ


Functional test
TEST TYPE Functionality OBJECTIVE Do business processes function correctly after implementation? OBJECTIVE Is response time acceptable according to specifications? Do business processes function properly under heavy load?
13

Load test

TEST TYPE Performance

Functionality under load

xxii LoadRunner for the Web 7.0

:KHQ ,V /RDG 7HVWLQJ 1HHGHG"


Planning and Design Evolution
How many users can be added without decreasing system performance? What is the best server to support 1000 users?

Development
Does the system response time meet requirements?

Production
What is the cause of performance degradation?

Deployment
Is the system reliable enough to go into production?
14

Introduction xxiii

0DQXDO 7HVWLQJ ,V 3UREOHPDWLF


All of you, click the GO button again

Do you have the testing resources? Testing personnel Client machines How do you synchronize users? How do you collect and analyze results? How do you achieve test repeatability?
Coordinator

Web server

Database server

Testers

Internet

Load Generation

System Under Test


15

The limitations of manual testing make it difficult to achieve meaningful load test results.

xxiv LoadRunner for the Web 7.0

7KH /RDG5XQQHU 6ROXWLRQ


Controller

Overcomes resource limitations Replaces testers with Virtual Users Runs many Vusers on few machines Analysis Controller manages the Vusers Meaningful results with analysis tools Repeatable tests with scripted actions

Vuser host Internet Vusers Load Generation

Web server

Database server

System Under Test


16

LoadRunner provides you with tools that address the issues of manual testing.

Introduction xxv

DEFINITION

.H\ 7HUPV 8VHG LQ 7KLV &RXUVH

9LUWXDO 8VHU 9XVHU


A Vuser is a script of recorded user actions. When played back, the script interacts with a Web application just like a real user.

Vusers are central to the implementation of LoadRunner

17

xxvi LoadRunner for the Web 7.0

7KH /RDG5XQQHU 6ROXWLRQ


Provides support for many protocols and APIs

18

Introduction xxvii

7KH /RDG5XQQHU 6ROXWLRQ


Provides monitors for many servers and resources Web servers Web application servers Firewalls Streaming media Networks Database servers System resources

19

xxviii LoadRunner for the Web 7.0

7KH /RDG5XQQHU 6ROXWLRQ


Virtual User Generator Creates the Vusers which load the system under test Creates and runs scenarios; manages Vusers, machines, and monitors Displays test results using graphical and statistical tools

LoadRunner Controller

LoadRunner Analysis

20

These are the LoadRunner tools you will work with to implement load testing for the Web.

Introduction xxix

/RDG5XQQHU ([SHUW :RUNIORZ 7KH %LJ 3LFWXUH


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

LoadRunner
VUGEN

LoadRunner
CONTROLLER& ANALYSIS

NOTE: This is the process for a LoadRunner expert. In this course some steps may be presented in a different order to facilitate the learning process.

21

Planning - Gather and document all relevant information about the system for the load test. Create Web Vusers - Use the Virtual User Generator (VuGen) to automate user actions of the selected business processes that you will test. Create Scenarios - Use LoadRunners Controller to set up the load test environment by putting together the hardware, the Virtual Users (Vusers) and the conditions under which the load test will be run. Run Scenarios & Analyze Results - Run the load test and compile the results for analysis using LoadRunners Controller. Use the analysis tools to organize and display the results. Tune the System - Analysis of results should reveal areas of the system that require adjustment. Repeat the load test to confirm that system adjustments had the desired effect.

xxx LoadRunner for the Web 7.0

/RDG 7HVWLQJ ,V D 7HDP (IIRUW


Team Member
Project Manager Functional Expert

Main Responsibility
Manages the Web site implementation Provides expertise on the business functionality of the Web site Creates the multi-user load on the system Analyzes and tunes the database server

LoadRunner Expert Database Performance Basis Expert Web Server Performance Basis Expert

Analyzes and tunes the Web server

22

Load testing should be done after all functional testing is completed. As the LoadRunner Expert, you must work with your teammates to achieve successful load test results.

Introduction xxxi

/RDG5XQQHU 7HDP 5HVSRQVLELOLWLHV


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

Project Manager Functional Expert LR Expert

Project Manager Functional Expert LR Expert LR Expert LR Expert LR Expert

Server Expert(s) Sys Admin

Server Expert(s) Sys Admin

23

The LoadRunner Experts tasks and responsibilities extend to five phases of the load testing process. Remember that successful load testing is a team effort, and you need to rely on each of your teammates expertise to succeed.

xxxii LoadRunner for the Web 7.0

Part 1: Creating Web Virtual Users

Planning an Effective Load Test

Planning an Effective Load Test 1-1

2EMHFWLYHV
In this lesson, you will learn: What preliminary information to gather before load testing your system Where useful information about your system might be obtained Effective techniques for organizing system information How to use system information to plan load tests

1-2 LoadRunner for the Web 7.0

DEFINITION

.H\ 7HUPV 8VHG LQ 7KLV &RXUVH

%XVLQHVV 3URFHVV
A business process is a set of user actions performed with an application to accomplish a business task.

Examples: Login to a Web site Look up flight information Buy a book


3

Planning an Effective Load Test 1-3

EXAMPLE

$XWRPDWH WKH /RJLQ 3URFHVV


USER ACTIONS 1. Open the Login page 2. Type a valid user ID 3. Type a valid password 4. Click the Login button 5. Check that the site displays the Welcome page

Automate the login process to ensure that it functions correctly under a heavy load 1. Start recording with VuGen 2. Manually log in to the Web site 3. Stop recording 4. Play back the recording to make sure it works the way you want it to

1-4 LoadRunner for the Web 7.0

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

1.1 Get system usage information 1.2 Decide which business processes to test 1.3 Document business process properties 1.4 Determine which fields to parameterize 1.5 Establish which data to use
5

Planning an Effective Load Test 1-5

 *HW 6\VWHP 8VDJH ,QIRUPDWLRQ


Purpose: Decide which business processes to automate Prioritize business processes to be automated Provide information for building load tests Useful formats for displaying system usage information: Task Distribution Diagram Transaction Mix User Profile

Note: The diagrams and profiles mentioned on this and subsequent slides must be created by the tester. LoadRunner provides no tools to create them. These are intended as examples only. The tester may find other ways to organize information that are more useful.

1-6 LoadRunner for the Web 7.0

:KHUH WR *HW 6\VWHP ,QIRUPDWLRQ


Experienced users System Administrators IT Managers IT documentation Online statistics Web developers Webmasters

Planning an Effective Load Test 1-7

8VHIXO :D\V WR 2UJDQL]H 6\VWHP ,QIRUPDWLRQ


Task Distribution Diagram which business tasks? how many operations at what times of the day? Transaction Mix how many operations on average, how many at peaks? how much database activity? how much risk to business if task fails? User Profile which tasks does each real user perform? what is ratio of different tasks for each user?

NOTE: The diagrams and profiles in the following illustrations must be created by the user.

1-8 LoadRunner for the Web 7.0

EXAMPLE

1.1 GET SYSTEM USAGE INFORMATION

7DVN 'LVWULEXWLRQ 'LDJUDP 


Business Processes
Create new account Search for title Purchase book View shopping cart
Night

Hours to be emulated
40 30
Day40

75 1200 210 150 150 200 130 170 600 100 140

Night

1000 180

Administrative Processes
*Invoice processing *System backup
12 am

50 1
2

50 1
4

50

50

10

12 pm

10

12

*Not a Web task

ONLINE BOOKSTORE (typical day, hundreds of users)


9

The task distribution diagram displays the throughput of all business processes relative to the timeline of a working day. By displaying the information in this format, you can isolate peak times of usage.

Planning an Effective Load Test 1-9

EXAMPLE

1.1 GET SYSTEM USAGE INFORMATION

7DVN 'LVWULEXWLRQ 'LDJUDP 


TASK
Log in Create new user account Create order Update order Ship order *Billing batch *Delivery batch *System backup
12 am

Night

Day 220 250 10

Hour to be emulated
210 15 180 30 50 90 12 210 40 90 220 40 70 10 180 30

Night

170

20 60 11
2

25 50 14
4

16 40 12
6 8 10 12 pm 2 4 6 8 10 12

ORDER PROCESSING INTRANET (peak day, 600 users)


*Not a Web task

10

There may be more than one peak load time depending upon seasonal, accounting or other factors. As a recommendation, you should start load testing by emulating a normal days throughput. You should then proceed to test the peak times (or a sample of the peak times depending on your testing time schedule).

1-10 LoadRunner for the Web 7.0

EXAMPLE

DECIDE WHICH BUSINESS PROCESSES TO TEST

7UDQVDFWLRQ 0L[
Which business process to automate?
Business process name Log in Create new account Create order Update order Ship order Typical day Peak day Web server activity Database activity Light Moderate Moderate Moderate Heavy Risk

70/hr

 
210/hr 15/hr 180/hr 30/hr 90/hr

Heavy Moderate Moderate Moderate Moderate

High Low

  

10/hr 130/hr 20/hr 40/hr

  

Mod. High

High

Selection criteria:

 High throughput  High in database I/O  High business risk


11

The Transaction mix displays system usage information in terms of the Web system, rather than of the users. Besides transactions, throughput and peak load times, the information can be expanded to include such things as:
s s s s

Web server activity DB interaction Legacy system interaction Level of risk if the transaction should malfunction

You might have to rely on Functional Experts, Project Managers and End Users to gather the information shown in this diagram. Usually, the users are interviewed about what business processes they perform and how often they perform them.

Planning an Effective Load Test 1-11

EXAMPLE

1.1 GET SYSTEM USAGE INFORMATION

8VHU 3URILOH
Who are the users? How many are there?
Users B.P. 1- Enter Orders 2 - Update Orders 3 - Calc. F.F. Miles 4 - Calc. Sales Business Process

What tasks do the users perform? How often do users do their tasks?
Freq. Flyer Agent (50) 25 10 70 5 8 Manager (30) Type and number of users

Reservation Agent (170) 100 50

Task frequency (throughput per hour)


12

1-12 LoadRunner for the Web 7.0

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

1.1 Get system usage information 1.2 Decide which business processes to test 1.3 Document business process properties 1.4 Determine which fields to parameterize 1.5 Establish which data to use
13

Planning an Effective Load Test 1-13

DECIDE WHICH BUSINESS PROCESS TO TEST

+RZ WR 8VH WKH ,QIRUPDWLRQ


Some criteria for decision making: Which processes have the highest business risk ("mission critical")? Which processes are most frequently used? What are the peak load times? peak hours of the day peak days of the month, quarter, or year Which processes are linked (data dependent)? Which processes are resource intensive?

14

1-14 LoadRunner for the Web 7.0

 'RFXPHQW %XVLQHVV 3URFHVV 3URSHUWLHV


The purpose is to obtain information necessary to create Virtual Users (Vusers), such as: User actions Expected results of each action Input data fields Valid data for input

15

You, as the LoadRunner Expert, might not know how to complete a particular business process (e.g., what data to use). By getting all of the process properties (information) from the Functional Expert or any other real user, creating Vusers becomes a much simpler task.

Planning an Effective Load Test 1-15

EXAMPLE

'RFXPHQW %XVLQHVV 3URFHVV 3URSHUWLHV


USER ACTIONS Type valid user id Type valid password Click Login button INPUT DATA Existing user IDs Corresponding passwords Welcome page appears EXPECTED RESULT

16

1-16 LoadRunner for the Web 7.0

6XPPDU\
Gather and organize system usage information Use the selection criteria when deciding which business processes to test Document business processes properties user actions expected result valid data

17

Planning an Effective Load Test 1-17

1-18 LoadRunner for the Web 7.0

Exercises

Overview
Your company, Mercury Tours, is a medium-sized travel and tours company. As part of its campaign to increase sales, Mercury Tours plans to expand its travel and tours business into e-commerce. An external Web site has been built to serve its customers via the Internet. The system has been built, customized and configured. It is stable. Everything works for one user. Now load testing can begin. As the LoadRunner Expert, it is your responsibility to use LoadRunners VuGen and Controller to create the required load on the system. In addition to creating the required load, you will also use LoadRunners analysis tools to assess the results. In the following pages, we will present information about the system to be load tested in the form of a Planning Specification. The Planning Spec. is intended to represent the sort of documentation you would have to put together yourself if it were a real life situation. After each lesson, a portion of the Planning Spec. will be followed by some exercises. You will need the information contained in the Planning Spec. to do the exercises.

Planning an Effective Load Test 1-19

Planning Specification

Flight Application Web Site Usage

TASK DISTRIBUTION FOR NORMAL BUSINESS DAY


3am 6 am 13 system backup 12 9 am 15 12pm 3 pm 6pm 25 22 19 9pm 17 12

30 17 search for flights 16

15 30 display itinerary

11 12 11 delete reservation 16 18 14 book a flight 12 18 30 19

11

15 11 register new user account 46 29 112 82

11

TOTAL

13

23 31

76

28

Source: Mercury Tours MIS Dept.

1-20 LoadRunner for the Web 7.0

TASK DISTRIBUTION FOR PRE-HOLIDAY TRAVEL


3am 6 am 24 system backup 9 am 20 30 12pm 3 pm 6pm 70 70 36 9pm 50 24 12

50 40 30 search for flights 30 4

20 50 display itinerary 2

8 2 delete reservation 40 36 24

16

30 24 book a flight 30

20 40 16 20 register new user account 96 208 158 120

TOTAL

24

70

144 40

Source: Mercury Tours MIS Dept.

Planning an Effective Load Test 1-21

Transaction Mix
Transaction Name Search for flight Display itinerary Book a flight Delete flight reservation Create new user account Normal Day Peak Thruput 25 30 PreHoliday Peak Thruput 70 50

System Usage

DB Usage heavy heavy

Risk

transaction processed from the client side, generates server activity transaction processed from the client side, query for existing flight reservations generates server activity generates activity in the database server, returns server output to confirm transaction completion generates activity in the database server, returns server output to confirm transaction completion adds new member to the customer database, user may proceed to member login

low med

30

40

heavy

high

12

low

low

15

40

low

high

1-22 LoadRunner for the Web 7.0

Selected Business Transactions to Automate


Mercury Tours has determined the three key business transactions for load testing.

BUSINESS TRANSACTION
Display Itinerary Book a Flight Create New User Account

NORMAL LOAD
30 30 15

PEAK LOAD
50 40 40

Planning an Effective Load Test 1-23

Review Questions
Refer to the information presented in the Planning Specification to answer the following questions. 1. What are some of the ways you could have obtained the information shown in the Task Distribution Diagrams? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 2. How does the information in a Task Distribution Diagram help you to build a Transaction Mix? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 3. What information is gathered in the Transaction Mix that is not displayed in the Task Distribution Diagram? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 4. Where would you get the additional information (not in the Task Distribution Diagram) which appears in the Transaction Mix? ________________________________________________________________________ ________________________________________________________________________

1-24 LoadRunner for the Web 7.0

5. What criteria would you use to select Web transactions for load testing? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________

Planning an Effective Load Test 1-25

1-26 LoadRunner for the Web 7.0

Recording

Recording 2-1

2EMHFWLYHV
In this lesson you will learn: How to create a Vuser script by recording user actions with the Virtual User Generator (VuGen) How to play back the Vuser and review the run results How to structure a Vuser based on planning

2-2 LoadRunner for the Web 7.0

$ERXW 9XVHUV
Different types available (partial list) E-Business Wireless ERP Client/Server RTE This course deals only with Web Vusers

Recording 2-3

PROCESS

&UHDWLQJ D 9XVHU 6FULSW2YHUYLHZ


1. Document the business process 2. Create and enhance a Vuser with VuGen CREATE 2.1 record user actions 2.2 insert measuring transactions 2.3 insert verification checkpoints 2.4 parameterize input data 2.5 correlate reused data

ENHANCE

3. Run the Vuser to verify correct execution

After testing, assign the script to a LoadRunner scenario


4

2-4 LoadRunner for the Web 7.0

$ERXW 9X*HQ
Records HTTP communication between the browser and the Web server Uses the recording to create Virtual Users (Vusers) which can be run to emulate real users Provides the means to enhance recordings verify that business processes are functioning correctly measure the performance of business processes on your Web site run each business process with many sets of data

During recording, VuGen invokes the browser and hooks into the HTTP communication layer. HTTP (Hypertext Transfer Protocol) is the language that Web clients and Web servers use to communicate with each other. By means of these communications hooks, VuGen can capture the communication between the browser and Web server. VuGen generates a Vuser script from this process. More in-depth details about the recording process are discussed later in this course.

Recording 2-5

CREATE A VUSER

5HFRUG 8VHU $FWLRQV


Browser
Web Application

VuGen
send URL1 receive web page

Web server Internet

VuGen launches the browser and taps into its HTTP communication VuGen captures the HTTP communication while you work in your application The captured communication becomes part of a Vuser script which can be played back
6

2-6 LoadRunner for the Web 7.0

CREATE A VUSER

(QKDQFH WKH 9XVHU 6FULSW


Vuser Script
start transaction send {test_url} receive web page end transaction page checkpoint

Insert measuring transactions Insert verification checkpoints Parameterize input data Correlate reused data

These topics are discussed in more detail in later lessons


7

Recording 2-7

CREATE A VUSER

5XQ WKH 9XVHU


Vuser Script
start transaction send {test_url} receive web page end transaction page checkpoint
Web server Internet

Play it back to verify that it runs correctly

The running Vuser interacts with a Web application like a real user

The server(s) that are required to handle the requests from the browser dont know the difference between a real user and a Vuser.

2-8 LoadRunner for the Web 7.0

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

2.1 Record User Actions 2.2 Add LoadRunner transactions 2.3 Add verification checks 2.4 Parameterize Input Data 2.5 Correlate reused data 2.6 Verify correct execution
9

Recording 2-9

DEFINITION

.H\ 7HUPV 8VHG LQ 7KLV &RXUVH

$FWLRQ
A recorded business process or series of steps that, when played back, emulates a real user performing the same steps.

10

2-10 LoadRunner for the Web 7.0

$ERXW $FWLRQV
An Action is composed of Steps Each Step is
a user action, server response, or a LoadRunner enhancement step represented by an icon
Server response step (cookie)

User action step (URL)

LoadRunner enhancement step (think time)


11

Recording 2-11

'HILQLWLRQV
Business process
A user interacting with an application to accomplish a business task

User actions
What a user does to interact with an application, e.g., type, click, react to system responses

Virtual User (Vuser)


The recorded user actions that automate a business process. A Vuser may contain multiple Actions.

LoadRunner Transaction
An end-to-end measurement of one or more user actions within an action (browser-to backend-to browser)

Action
A group of recorded steps; an organizational unit in a recorded Vuser script
12

2-12 LoadRunner for the Web 7.0

9X*HQ :LQGRZ

RECORD PANE PAGE VIEW TREE VIEW REPLAY PANE

LOG PANE

13

Replay information is optional. It may be toggled on and off in the Correlation tab of the General Options dialog.

Recording 2-13

9X*HQ :LQGRZ

FRQWLQXHG

HTML VIEW

14

2-14 LoadRunner for the Web 7.0

/RDG5XQQHU 9X*HQ ,V WKH 9XVHU 'HYHORSPHQW (QYLURQPHQW


Record Toolbar

Run Start, Pause, Stop Recording Insert Rendezvous Insert Comment

New Action File Select Action File Recording Options

15

VuGen is the integrated development environment that allows you to record user actions, modify and play back Vusers.

Recording 2-15

6HW 5HFRUGLQJ 2SWLRQV5HFRUGLQJ


HTML
browser/context sensitive records as Web objects "high level"

URL
HTTP/analog Web objects are used as function arguments NOTE: Move the pointer over any item to see its description in the Hint frame "low level"
16

HTML or URL recording is one of the more important choices the tester must make.

2-16 LoadRunner for the Web 7.0

%HQHILWV RI +70/ 5HFRUGLQJ


Reduces need to capture dynamic values
action tag values and hidden data are NOT hard coded they are retrieved from memory during playback if they are dynamic, the Vuser still runs

Script is only as big as the business processone step per page

17

Recording 2-17

'LVDGYDQWDJHV RI +70/ 5HFRUGLQJ


Scripts are less scalable Memory (cache) is searched during playback
requires more memory requires more CPU power

18

2-18 LoadRunner for the Web 7.0

%HQHILWV RI +773 5HFRUGLQJ


Flexibility
support for Java Applets and ActiveX objects on the page ability to replay on Unix

Scalabilityscripts are more scalable than HTML scripts because they require fewer resources

19

Recording 2-19

'LVDGYDQWDJHV RI +773 5HFRUGLQJ


Scripts require more correlation (nothing is retrieved from cache) Context-sensitive checks wont work (parser is disabled)* Scripts are large (all images and frames are recorded as separate steps)

* Use web_reg_save_param to search for specific text

20

2-20 LoadRunner for the Web 7.0

6HW 5HFRUGLQJ 2SWLRQV&RUUHODWLRQ


Correlation is discussed in a separate lesson

21

Recording 2-21

6HW 5HFRUGLQJ 2SWLRQV%URZVHU


These options give you more control when you start recording

22

2-22 LoadRunner for the Web 7.0

6HW 5HFRUGLQJ 2SWLRQV5HFRUGLQJ 3UR[\


If Restore proxy settings is not checked, your browser may not work correctly after you have finished recording

23

Recording 2-23

6HW 5HFRUGLQJ 2SWLRQV$GYDQFHG


Think time steps simulate human users by pausing between user actions Check Record think-time Gives you real user emulation You can exclude think-times from playback (and Analysis) if desired
24

2-24 LoadRunner for the Web 7.0

 5HFRUG 8VHU $FWLRQV


1. Invoke VuGen 2. Click Start Recording 3. Enter URL of site under test and click OK

25

The logon and logoff may be recorded inside the action if you wish.

Recording 2-25

 5HFRUG 8VHU $FWLRQV

FLOATING RECORD TOOLBAR

Perform task with Web application

26

2-26 LoadRunner for the Web 7.0

 5HFRUG 8VHU $FWLRQV

Click Stop Recording to close browser

27

Note the events counter in the title bar of the Record toolbar. That counter should increment during recording. If it does not, you should stop recording and find out what the problem is.

Recording 2-27

*RRG 3UDFWLFHV
Know the data and page flow before recording During recording add LoadRunner transactions wherever a measurement is needed* add verification checkpoints* rename steps to make them more descriptive add comments liberally as reference points Save the Vuser script before running it the first time

* LoadRunner transactions and verification checkpoints are discussed in separate lessons

28

2-28 LoadRunner for the Web 7.0

,QVHUW 5HQGH]YRXV

RSWLRQDO

Rendezvous points make faster Vusers wait for slower ones When released from rendezvous point, Vusers do same action at same time Tester can determine at which points to apply maximum load

29

Recording 2-29

,QVHUW 5HQGH]YRXV

RSWLRQDO

30

2-30 LoadRunner for the Web 7.0

:HE ,FRQV DQG 8VDJH ([DPSOHV


URL
Vuser begins at this URL or selects a bookmark

Submit Form/Data
Vuser sends a form or data to the server

Image
Vuser clicks on a hyperlinked image

Service
Set cookie

Link
Vuser clicks on a hyperlinked page 31

Recording 2-31

6FULSW 9LHZ
Script View shows "the code behind the icon tree"

Status bar shows current line number of cursor

32

2-32 LoadRunner for the Web 7.0

5HQDPLQJ DQ $FWLRQ
To enhance Test Tree readability: 1. Click action name 2. Type new name 3. Press Enter

33

Actions 2-33

5HQDPLQJ D 6WHS ,Q WKH ,FRQ 7UHH


To enhance Test Tree readability: 1. Select a step to rename 2. Right-click the step icon 3. Select "Properties" from pop-up menu 4. Click General tab of Properties dialog 5. Overwrite default name with a descriptive name and click OK

34

As you gain experience with VuGen, you will find that renaming icons is very useful. The tree becomes much more descriptive which makes Vuser maintenance much easier.

2-34 LoadRunner for the Web 7.0

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

2.1 Record User Actions 2.2 Add LoadRunner transactions 2.3 Add verification checks 2.4 Parameterize Input Data 2.5 Correlate reused data 2.6 Verify correct execution
35

Recording 2-35

&RQWUROOLQJ 9XVHU 5XQWLPH %HKDYLRU


General Options Show Run-Time Viewer during playback Toggle reporting on/off Give result directories meaningful names Save web pages returned during playback
36

The Run-Time Viewer displays only the Web pages received from the server, not the pages sent to the server.
s s s s

Show browser during replay is checked by default. The reporting options are checked by default. Prompt for result directory is unchecked by default. Save correlation information during replay is checked by default.

2-36 LoadRunner for the Web 7.0

&RQWURO 9XVHU 5XQWLPH %HKDYLRU


Click RunTime Settings Log tab: Create a results log, output.txt Standard log is the default in VuGen*

*In the Controller, the default is "Disable logging."

37

Output.txt is overwritten each time a Vuser script is run. To preserve a copy of this log, make a copy of it, then rename the copy.

Recording 2-37

5XQ7LPH 6HWWLQJV7KLQN 7LPH 7DE


Default Run-Time Setting is "Ignore think times" (VuGen only*)

*In the Controller, the default is "Play think times as recorded."

38

2-38 LoadRunner for the Web 7.0

6HOHFW 5HVXOWV 'LUHFWRU\

RSWLRQDO

Click the Run toolbar icon Accept the default, or type a results directory name Select Results Directory pop-up can be turned off in the General Options
39

You may create a new results directory for each run. The General Option Prompt for results directory is unchecked by default. When it is unchecked, new results overwrite the last results. You may find that in many cases, it is unnecessary to keep permanent results until you begin load testing.

Recording 2-39

&UHDWH WKH 5HVXOWV 'LUHFWRU\


C:\ Web_project + ScriptName1 ScriptName2 + data result1 + + + + Icons Iteration0 Iteration1 Report

Tester creates this part

VuGen creates this part

Action1.c Output.txt

40

The results of each iteration of a script are stored separately. The Iteration0 directory is for system use and should be ignored by the tester.

2-40 LoadRunner for the Web 7.0

2.6 VERIFY CORRECT VUSER EXECUTION

5HYLHZ 7HVW 5HVXOWV

Details pane Tree pane

Vuser

result1

Results.qtp
41

The Test Results window displays the results of:


s s s

the entire test run each iteration of the run each step of each iteration

Recording 2-41

2.6 VERIFY CORRECT VUSER EXECUTION

5HYLHZ 9LVLWHG :HE 3DJHV

42

2-42 LoadRunner for the Web 7.0

2.6 VERIFY CORRECT VUSER EXECUTION

5HYLHZ WKH ([HFXWLRQ /RJ


Logging must be enabled in RunTime Settings Look in the Execution Log tab below icon tree pane The log is a sequential display of execution and result for each step
43

The Execution Log is useful for debugging your Vusers. This tab shows messages about system events that occurred when the Vuser was running. The level of detail can be controlled by the Run-Time Settings in VuGen. NOTE: Any line containing the word Error (with a capital E only) will be colored red in the Execution Log. Please refer to the VuGen documentation for more information.

Recording 2-43

6XPPDU\
An action contains recorded user actions may or may not contain application startup, login, logout a Vuser may contain multiple actions Use Recording Options to control recording behavior Use General Options and Run-Time Settings to control Vuser run behavior Check the Test Results window and the Execution Log after running to make sure the Vuser ran correctly

44

2-44 LoadRunner for the Web 7.0

Planning Specification (continued):


Book a Flight
USER ACTIONS
1 Invoke the Web browser, type http://localhost/MercuryWebTours/ for the URL address and press Enter. Type the name in the User Name box. Type the password in the Password box.

EXPECTED RESULTS
The Mercury Tours home page appears. The members login name appears in the Member name box. The members password appears as a string of asterisks in the Password box. The Mercury Tours FLIGHT FINDER page appears. The Find Flight page appears with the following flight information fields: - Type - Passengers - Departing From - On - Arriving In - Returning - Service Class - Airline The SELECT FLIGHT page appears and returns all values of available flights. The BOOK A FLIGHT page appears. - First Name - Last Name - Number

2 3

4 5

Click the Sign-In button. Type the following data in the indicated fields on the FLIGHT FINDER page.

Click the CONTINUE button.

7 8

Select the first available flight and click the CONTINUE button. Type the following data in the indicated fields on the BOOK A FLIGHT page.

Actions 2-45

USER ACTIONS
9 Click the SECURE PURCHASE button.

EXPECTED RESULTS
The FLIGHT CONFIRMATION page appears. It contains confirmation of the reserved flight, and the flight and customer details.

10

Verify that the FLIGHT CONFIRMATION page appears, and that the page contains the text Your itinerary has been booked!. Verify the flight number. Flight details appear in the FLIGHT CONFIRMATION page.

11

2-46 LoadRunner for the Web 7.0

Exercises

Preliminary Setup
This exercise may be skipped only if the setup has already been verified. As shipped, the Mercury Tours Demo Web Site has several boxes checked on the Administration page and no users in the database. Unless those boxes are unchecked, and at least one user is inserted, students will not be able to complete the exercises for this or any other lesson. 1. Start the Server. From the Windows Start menu, select Start Server from the Mercury Tours program group. Verify that the Start Server window displays the following line: Apache/1.3.17 <Win32> ApacheJServ/1.1.2 running... After verifying, minimize the window. 2. Start the browser. 3. Navigate to the Mercury Tours Web site. In the URL space, type:

http://localhost/servlets/com.mercurytours.servlet. WelcomeServlet
This is the URL for the training Web site. Press Enter. 4. Navigate to the Administration page. Sign in with User Name admin and Password mercury. Make sure that all boxes on the Administration page are unchecked. If any are checked, uncheck them. 5. Click the SUBMIT button. This should be done whether you had to uncheck any boxes or not.

Recording 2-47

6. Navigate to the REGISTER page for new users. Click the REGISTER link in the Mercury Tours home page. The REGISTER page appears. 7. Complete the new member information. Enter values from the table for the fields shown. Leave blank any fields not shown in the table.

FIELD First Name Last Name Country UserName Password Confirm Password

VALUE Joseph Frisbee United States jojo bean bean

8. Finish registering the new user. Click SUBMIT. 9. Test the new account information. Click the SIGN-IN link in the Thank you message. Wait for the SIGN-ON page to appear. Sign in to Mercury tours using the new user name and password. 10. Sign off and close the browser.

2-48 LoadRunner for the Web 7.0

Exercise A: Create a Web Vuser


In these exercises you will create Web Vusers by recording on the training Web site. You will also run the Vusers you create, and review the test results.

IMPORTANT: Wait for all resources to download before performing the next step. Sometimes the status line says Done. but the browser downloads more after the progress bar has reset.

Record the Sign-In


In this section, you will create a Vuser that signs in to the training Web site and purchases a flight, by using VuGen to record an action containing those steps. 1. Invoke the Virtual User Generator (VuGen). From the Windows Start menu, select Virtual User Generator from the LoadRunner program group. 2. Create a new Web Vuser. Select File > New from the VuGen menu, or click the New button on the VuGen toolbar. The New Virtual User dialog box opens. Expand the E-Business folder, select Web (HTTP/HTML), and click OK. 3. Make sure that VuGen recording mode is HTML. Click the Recording Options toolbar button to open the dialog box. In the Recording tab, make sure that HTML-based script is selected for the Recording Mode, then click OK to close the dialog. 4. Rename Action1 to BookFlight. Right-click Action1 in the Actions pane and select Rename Action from the pop-up menu. The Action1 label opens for editing. Overwrite Action1 with BookFlight and press Enter.

Recording 2-49

5. Start recording into BookFlight. Make sure that the first line in VuGens main window says BookFlight Select Vuser > Start Recording or click the Start recording your application toolbar button. The Start Recording dialog opens. If the following URL is not already present in the URL box, then type it in:
http://localhost/servlets/com.mercurytours.servlet. WelcomeServlet

Leave Record the application startup checked, and click OK. Was the site under test invoked successfully by VuGen? ________________________________________________________________________ Why is it necessary for VuGen to invoke the browser? ________________________________________________________________________ ________________________________________________________________________ 6. In the browser, sign in to Mercury Tours as jojo. Type jojo in the User Name field under the Find A Flight section. Type bean in the Password field. Click the Sign-In button. The FLIGHT FINDER page appears. In VuGen, what is it that indicates that the sign-in was recorded? ________________________________________________________________________ ________________________________________________________________________ 7. In Vugen, rename the com.mercurytours.servlet.SignonServlet step to FindFlight. Right-click the . . . Signon.Servlet tree icon and select Properties from the pop-up menu. The Submit Data Step dialog box opens. Click the General tab. Overwrite the entire contents of the Step Name box with FindFlight. Click OK.

2-50 LoadRunner for the Web 7.0

Record a Flight Purchase


1. In the browser, enter the flight details to search for available flights. Accept the defaults for all fields on the FLIGHT FINDER page except those shown in the table below.

FIELD Departing From Arriving In


2. Click CONTINUE.

VALUE San Francisco New York

3. In Vugen, rename the com.mercurytours.servlet.ReservationServlet step to SelectFlight. 4. In the browser, accept the default flights for both directions of the round trip. By default, the first available flight is already selected for each direction when the SELECT FLIGHT page appears. Click the CONTINUE button. 5. In Vugen, rename the com.mercurytours.servlet.PurchaseServlet step to PurchaseFlight in the icon tree. 6. In the browser, type in the required credit card information. On the BOOK A FLIGHT page, fields which require data entry have red labels. Enter the passenger name and credit card number. Use data from the table.

FIELD First Name Last Name Number

VALUE Joseph Frisbee 987654321

7. Click SECURE PURCHASE.

Recording 2-51

Was the Flight Confirmation page received from the Web server? ________________________________________________________________________ 8. Rename the . . . PurchaseServlet2 step to ConfirmFlight.

Record the Sign-Off


1. End the business process by signing off from the Web site. In the browser, click the SIGN-OFF link (near the top of the page). 2. Stop recording. Click the Stop button in the floating Record toolbar. 3. Save the recording as: \web_project\Vusers\Lab2vuser1 Select File > Save As, or click the Save toolbar button. NOTE: For training purposes, a test framework was set up on one of your local drives under \web_project. The training will refer to this framework when saving and opening lab exercises. Was the Vuser added to the framework? ________________________________________________________________________ In light of the information gathered from the Transaction Mix, why is BookFlight considered a key business process to automate for load testing? ________________________________________________________________________

Play Back and Verify Correct Execution


1. Set VuGen to prompt for a results directory. Select Tools > General Options. The General Options dialog box opens. Click the Display tab. Check the Prompt for results directory check box. Make sure that Generate report... and Display report... are checked. Click OK to save the options and close the dialog box.

2-52 LoadRunner for the Web 7.0

2. Run the Vuser you created. Select Vuser > Run or press the Run button on the VuGen toolbar. Click OK to accept the default results directory result1. 3. Review the execution results. In the Test Results window, what indicates that the Vuser run passed? ________________________________________________________________________ ________________________________________________________________________ 4. Review the Iteration 1 Summary. Click the Iteration 1 icon. 5. Display the Flight Confirmation page that VuGen captured during playback. Click the + sign to expand Iteration 1 in the Test Results icon tree. Click the step Web Submit Form: ConfirmFlight.

TIP

You can also expand all steps beneath a selected step by selecting View > Expand All, or by pressing the asterisk key [*] on the numeric keypad. (The other asterisk key will not work.) Was an image of the Flight Confirmation page captured by the Test Results? ________________________________________________________________________ What are the file name and extension of the file that displays the test results? ________________________________________________________________________ 6. Review the Execution Log at the bottom of the VuGen window. To what do the messages in the Execution Log refer? ________________________________________________________________________ ________________________________________________________________________

Recording 2-53

7. Close the Test Results window. Click the close icon at the upper right corner of the title bar, or select File > Exit from the Test Results menu. 8. Close the Run-Time Viewer. If the window is restored, click the close icon at the upper right corner of the title bar. If the window is minimized, right-click the icon, and select Close from the popup menu. 9. Close Lab2vuser1. Select File > Close.

2-54 LoadRunner for the Web 7.0

Review Questions
Validate your understanding of this lesson by answering the following questions: 1. For what purpose are Vusers created? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 2. What tools does VuGen provide to help you analyze Vuser run results? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________

Recording 2-55

2-56 LoadRunner for the Web 7.0

LoadRunner Transactions

LoadRunner Transactions 3-1

2EMHFWLYHV
In this lesson, you will learn: What a LoadRunner transaction is How a LoadRunner transaction functions in a recorded script How to implement LoadRunner transactions

3-2 LoadRunner for the Web 7.0

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

2.1 Record User Actions 2.2 Add LoadRunner transactions 2.3 Add verification checks 2.4 Parameterize Input Data 2.5 Correlate reused data 2.6 Verify correct execution
3

LoadRunner Transactions 3-3

DEFINITION

.H\ 7HUPV 8VHG LQ 7KLV &RXUVH

/RDG5XQQHU 7UDQVDFWLRQ
An end-to-end (browser-to backend-to browser) measurement of one or more user actions within an action file.

3-4 LoadRunner for the Web 7.0

$ERXW 7UDQVDFWLRQV
Definition and placement of transactions should be part of the planning process Implemented by adding Start Transaction and End Transaction steps May overlap and may be nested May be added during or after recording

LoadRunner Transactions 3-5

:K\ $GG /RDG5XQQHU 7UDQVDFWLRQV"


Transactions are LoadRunners only means for measuring performance Measure high risk business processes Able to measure a single step or a group of steps Allow performance comparison between different load tests Help to identify performance problems

3-6 LoadRunner for the Web 7.0

EXAMPLE

:KDW /RDG5XQQHU 7UDQVDFWLRQV 0HDVXUH


A LoadRunner transaction measures the system performance resulting from one or more user actions
Transaction 1 measure the login actions Transaction 2 - measure everything that happens after the login

Transaction 3 - measure only the save order action

A LoadRunner transaction measures start to end performance of any user action that is made from the browser. Start to end means from the time an action occurs in the browser to the time the server response to that action appears in the browser. Transaction measuring statements may be used to measure the duration of a particular business process or to measure specific events such as save, update and delete.

LoadRunner Transactions 3-7

+RZ 7UDQVDFWLRQV :RUN


Browser

VuGen
start transaction send URL1 receive web page end transaction
Internet

Web server

LoadRunner transactions measure the interval between the time an HTTP request is sent from the browser to the time the HTTP server response is received by the browser

3-8 LoadRunner for the Web 7.0

BEST PRACTICE

ADD LOADRUNNER TRANSACTIONS

'XULQJ 5HFRUGLQJ

1. Click the Start Transaction toolbar button

2. Type a Transaction Name and click OK

LoadRunner Transactions 3-9

BEST PRACTICE

ADD LOADRUNNER TRANSACTIONS

'XULQJ 5HFRUGLQJ

3. Complete the user actions for the process to be measured 4. Click the End Transaction toolbar button

10

3-10 LoadRunner for the Web 7.0

7KH 6WDUW DQG 6WRS 7UDQVDFWLRQ ,FRQV

Common icons and usage examples


Start Transaction Set starting point for measurement End Transaction Set end point for measurement

11

LoadRunner Transactions 3-11

ADD LOADRUNNER TRANSACTIONS

$IWHU 5HFRUGLQJ

1. Select the first step to be measured 2. Click the Start Transaction button from VuGens main toolbar 3. Select the last step to be measured 4. Click the End Transaction button from the toolbar 5. Select Transaction Status (optional)

12

3-12 LoadRunner for the Web 7.0

ADD LOADRUNNER TRANSACTIONS AFTER RECORDING

&KRRVH 7UDQVDFWLRQ 6WDWXV


LR_AUTO (the default) use this when you want LoadRunner to detect the transaction status automatically LR_PASS / LR_FAIL use these when you want to set the transaction status manually in the code

13

LoadRunner Transactions 3-13

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

2.1 Record User Actions 2.2 Add LoadRunner transactions 2.3 Add verification checks 2.4 Parameterize Input Data 2.5 Correlate reused data 2.6 Verify correct execution
14

3-14 LoadRunner for the Web 7.0

 9HULI\ &RUUHFW ([HFXWLRQ


1. Click the Run toolbar button 2. Select a results directory (optional)

15

Deselect Prompt for results directory in Display tab of General Options dialog box if you would rather have that as the default.

LoadRunner Transactions 3-15

2.5 VERIFY CORRECT EXECUTION

&KHFN ([HFXWLRQ /RJ

16

3-16 LoadRunner for the Web 7.0

EXAMPLE

/RDG5XQQHU 7UDQVDFWLRQ $QDO\VLV

Transaction Response Times

Transaction Name

LoadRunner Analysis is covered in detail later


17

LoadRunner Transactions 3-17

$XWRPDWLF 7UDQVDFWLRQV
Measure performance of every test step automatically Compare individual steps to each other to an entire business process

18

3-18 LoadRunner for the Web 7.0

$XWRPDWLF 7UDQVDFWLRQV

Enable Automatic Transactions in the Run-Time Settings dialog box, General tab

NOTE: Automatic Transactions show up only in LoadRunners Analysis graphs and reports, not in VuGens Execution Log. Automatic Transactions will be covered in more detail later.

19

You can configure VuGen to measure every action of the Vuser automatically. At the testers option, VuGen can add the action name and line number to the name of each automatic transaction for a step. Toggle that option on and off in the Preferences tab of the Run-Time Settings dialog.

LoadRunner Transactions 3-19

6XPPDU\
Use LoadRunner transactions to measure: end-to-end response times of specific steps in the business process the entire business process every step in the business process automatically Add LoadRunner transactions during or after recording Use automatic LoadRunner transactions to measure every step without manually inserting transactions
20

3-20 LoadRunner for the Web 7.0

LoadRunner Transactions 3-21

Planning Specification (continued):


Sign in and Display Itinerary Determine how long the sign in and display itinerary process took.
USER ACTIONS
1 Invoke the Web browser, type http://localhost/servlets/com.mercurytours .servlet.WelcomeServlet for the URL address, and press the Enter button. Type a valid user name in the User Name box. Type a valid password in the Password box.

EXPECTED RESULTS
The Mercury Tours home page appears.

2 3

The typed characters are displayed in the User Name box. The users password appears as a series of asterisks in the Password box. A query is sent to the database to match an existing value for registered user name and password. If a match is found, the Mercury Tours FLIGHT FINDER page appears. A Query is sent to the database to search for all flights reserved for the logged in user name. The ITINENARY page appears and displays all values returned by the database in response to the query.

Click the Sign-In button.

After the FLIGHT FINDER page appears, click the ITINERARY button.

3-22 LoadRunner for the Web 7.0

Exercises

LoadRunner transaction steps can be added to a script during recording and after recording. These exercises show you how to do both.

Exercise A: Add a Transaction During Recording

Create Vuser to Display Itinerary


Based on the lesson presented and the planning specification, why would you want to add a LoadRunner transaction for the Display Itinerary process? ________________________________________________________________________ ________________________________________________________________________ 1. Create a new Web Vuser in VuGen. 2. Rename Action1 to DisplayItinerary. Right-click Action1 in the Actions pane and select Rename Action from the pop-up menu. The Action1 label opens for editing. Overwrite Action1 with DisplayItinerary and press Enter. 3. Start recording into DisplayItinerary. If the following URL is not already present in the URL box, then type it in:
http://localhost/servlets/com.mercurytours.servlet. WelcomeServlet

Leave Record the application startup checked, and click OK. 4. Sign in to the Mercury Tours Web site as jojo using the password bean.

LoadRunner Transactions 3-23

5. Wait for the FLIGHT FINDER page to appear, then start a LoadRunner transaction to measure displaying the itinerary. Click the Insert Start Transaction button from the floating Record toolbar. The Start Transaction dialog opens. Type display_itinerary in the Transaction Name field, and click OK. 6. Navigate to the Itinerary page. In the browser, click the ITINERARY link. 7. End the display_itinerary transaction using status LR_AUTO. Click the Insert End Transaction button on the floating Record toolbar. The End Transaction dialog opens with display_itinerary already in the Transaction Name box. Make sure the Transaction Status is LR_AUTO. Click OK. How many flight reservations are listed in the itinerary? ________________________________________________________________________ 8. In the browser, click SIGN-OFF and wait for the SIGN-ON page to appear. 9. Stop recording. 10. Save the script as: Lab3vuser1

Verify Correct Execution


1. Play back the test script. Click OK to accept the default results directory result1. In the Execution Log, how long did the display_itinerary transaction take in seconds? (HINT: Look at the blue line that begins: Notify Transaction display_itinerary ended with Pass status....) ________________________________________________________________________

3-24 LoadRunner for the Web 7.0

2. Close the Test Results window and the Run-Time Viewer.

Exercise B: Add a Transaction After Recording


Continue working with Lab3vuser1 created in the previous exercise. 1. Insert a LoadRunner start transaction step to measure sign-in performance. Select DisplayItinerary from the Actions list. Right-click the step com.mercurytours.servlet.SignonServlet in the icon tree, and select Insert Before from the pop-up menu. The Add Step dialog opens. Select Start Transaction from the Step Type list, and click OK. The Start Transaction window opens. Type sign-in in the Transaction Name field and click OK. 2. Insert a LoadRunner end transaction step. Right-click the ...SignonServlet step again, and select Insert After. In the Add Step dialog select End Transaction from the list, and click OK. Click OK to accept sign-in as the Transaction Name and LR_AUTO as the Transaction Status. 3. Save the Vuser. 4. Run the modified Lab3vuser1. Click OK to accept the default results directory result2. How long did the sign-in transaction take in seconds? ________________________________________________________________________ 5. Close the Test Results window, the Run-Time Viewer, and Lab3vuser1.

LoadRunner Transactions 3-25

Review Questions
1. What is the purpose of a LoadRunner transaction? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 2. What is the purpose of measuring a business process from start to end? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 3. What is the easiest way to get measurements for each step of a recorded script? For an entire action? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________

3-26 LoadRunner for the Web 7.0

Verification Checkpoints

Verification Checkpoints 4-1

2EMHFWLYHV
In this lesson you will learn: The definition and function of a checkpoint The importance of functional testing under load Visual cues to check for during load testing The types of checks in VuGen what can be verified on a web page how VuGen verifies Web application functionality How to add verification checkpoints during recording

4-2 LoadRunner for the Web 7.0

:K\ 8VH &KHFNSRLQWV"


Verify correct functionality under load A transaction may report a pass even though the business process failed To ensure synchronization when a backup server is used
EXAMPLE Business Process Problem Slideshow Display image Wrong image is displayed Search Results Page Find an item "Not found" on right page Shopping Site

Any Link is broken

Verify functionality under loadBecause a few users do not stress the system, business processes may sometimes perform correctly under the load of just a few users. Transaction passes; business process failsUnder the stress of many concurrent users, a server might not be able to send back the proper pages, thus preventing the business process from functioning properly. Synchronization of multiple serversWhen a backup server is moved to production, its wise to verify that the backup truly mirrored the former production server.

Verification Checkpoints 4-3

DEFINITION

.H\ 7HUPV 8VHG LQ 7KLV &RXUVH

)XQFWLRQDO 7HVWLQJ 8QGHU /RDG


Confirming that all business processes complete properly while the server handles concurrent usage.

4-4 LoadRunner for the Web 7.0

%XVLQHVV 3URFHVV ,V &RPSOHWHG

text visual cue

Expected result appears; verification passes

The appearance of expected visual cues indicates that the server can send the proper pages back and that the load is being properly handled.

Verification Checkpoints 4-5

%XVLQHVV 3URFHVV 1RW &RPSOHWHG

Expected result does not appear; verification fails

4-6 LoadRunner for the Web 7.0

DEFINITION

.H\ 7HUPV 8VHG LQ 7KLV &RXUVH

&KHFNSRLQW
A checkpoint is a step in a Vuser script which verifies whether a visual cue appeared as expected.

Verification always results in a PASS or FAIL status


7

Verification Checkpoints 4-7

REVIEW

/RDG5XQQHU 9HULILFDWLRQ &KHFNSRLQWV


Vuser
start transaction send URL1 receive web page end transaction page checkpoint

Verification tells you whether a Web application is behaving as intended


8

4-8 LoadRunner for the Web 7.0

$ERXW &KHFNSRLQWV
Allow you to verify the content returned by your Web application pages, images, text, objects, tables image source, broken links Implemented with checkpoint steps Report pass or fail to Test Results window and to Execution Log Can be inserted during recording or afterward

Verification Checkpoints 4-9

:KLFK 9LVXDO &XHV &RQILUP %XVLQHVV 3URFHVV 6XFFHVV"


EXAMPLE CASE SCENARIOS Where in the business process might load overwhelm the server(s) and cause failure? What visual cues in the browser indicate success? Web-based bookseller Search Submit order Order Entry Intranet Site Inserting a sales order into the database Order number appears Extranet news photo archive Image request

Results page instead of error message

Expected image displayed

10

4-10 LoadRunner for the Web 7.0

+RZ 9LUWXDO 8VHUV 9HULI\ )XQFWLRQDOLW\


LoadRunner (1) captures the information (determined by the user) used to perform the check. (2) during playback, compares the actual value on the web page to the expected value. (3) sends the comparison result (the "status") as either PASS or FAIL to a file. You can see the result in the Test Results window and the Execution Log after the run.

11

Verification Checkpoints 4-11

+RZ /RDG5XQQHU 9HULILHV


ACTUAL EXPECTED

COMPARE Actual matches expected ? RESULT

Test Results PASS

12

4-12 LoadRunner for the Web 7.0

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

2.1 Record User Actions 2.2 Add LoadRunner transactions 2.3 Add verification checks 2.4 Parameterize Input Data 2.5 Correlate reused data 2.6 Verify correct execution
13

Verification Checkpoints 4-13

&KHFNSRLQWV*RRG 3UDFWLFHV
Add text and image checks during recording Give the checkpoint a name that describes what is being verified Make sure that Enable checks is checked in the Run-Time Settings, General tab, before running the recorded Vuser script

14

One reason to add checks during recording is that it might be easier than trying to remember where they should go by looking at the recorded script, especially if you are unfamiliar with the application under test.

4-14 LoadRunner for the Web 7.0

,PDJH &KHFN
Check
Image

Example usage
Did the Web page display the correct image?

15

Verification Checkpoints 4-15

'HWHUPLQH 9LVXDO &XHV WR 9HULI\

Same image whenever page is loaded

Use image check

16

Once you have determined the visual cue(s) which verify the functionality of the business process, the next step is to determine the type of check to use. Determination should be made based on the content and appearance of the visual cue. Because visual cues vary in content and appearance, VuGen provides different types of checks you can use to verify that the business process is functioning properly.

4-16 LoadRunner for the Web 7.0

$ERXW /RDG5XQQHU ,PDJH &KHFNV


Only the image name is storednot the image itself An image check verifies that the image name is referenced in the Web page The following slides show:
how to determine the image name how to use the image name to create an image check

17

Verification Checkpoints 4-17

BEST PRACTICE

&UHDWLQJ DQ ,PDJH &KHFN'XULQJ 5HFRUGLQJ


1. While recording, get the image name a. In the browser, right click on image to be checked b. Select "Save Picture As" from pop-up menu
18

4-18 LoadRunner for the Web 7.0

BEST PRACTICE

&UHDWLQJ DQ ,PDJH &KHFN'XULQJ 5HFRUGLQJ


c. Copy existing file name using Ctrl + C d. Click Cancel

NOTE: If the file extension (.gif, .jpg, etc.) does not appear, type it in the File name edit field yourself before copying

19

The Save Picture dialog appears with the name of the image file automatically displayed in the File name field. Copy the name and extension of the file. There might be instances where the file extension (.gif, .jpg, etc.) doesnt automatically appear. Append the extension by typing it in the box manually, then perform the copy.

Verification Checkpoints 4-19

BEST PRACTICE

&UHDWLQJ DQ ,PDJH &KHFN'XULQJ 5HFRUGLQJ


2. Add the step a. Click the Insert After toolbar button b. The Add Step dialog opens c. Expand Web Checks, select "Image Check," and click OK. The Image Check Properties dialog opens.
20

4-20 LoadRunner for the Web 7.0

BEST PRACTICE

&UHDWLQJ DQ ,PDJH &KHFN'XULQJ 5HFRUGLQJ


3. Paste the file name into Image Check Properties a. Check the Image server file name (SRC attribute) check box b. Paste the file name into the edit box using Ctrl + V

21

The image file name pasted into the check properties becomes the expected result of the check.

Verification Checkpoints 4-21

BEST PRACTICE

&UHDWLQJ DQ ,PDJH &KHFN'XULQJ 5HFRUGLQJ


a. Click the General tab

4. Rename the step

b. Change the Step Name from default "web_image_check" to a more descriptive name c. Click OK to finish

22

Providing a more descriptive name for this check makes it easier to follow the actions in the icon tree.

4-22 LoadRunner for the Web 7.0

BEST PRACTICE

&UHDWLQJ DQ ,PDJH &KHFN'XULQJ 5HFRUGLQJ


The image check step is displayed in the Icon Tree under the page where the image appears

23

Verification Checkpoints 4-23

7H[W &KHFN
Check
Text

Example usage
Did the business process complete successfully?

24

4-24 LoadRunner for the Web 7.0

BEST PRACTICE

ADD VERIFICATION CHECKS

7H[W &KHFN'XULQJ 5HFRUGLQJ


1. Select text to check in the browser 2. Click the Text Check toolbar buttonthe check is added automatically 3. Continue recording
25

Verification Checkpoints 4-25

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

2.1 Record User Actions 2.2 Add LoadRunner transactions 2.3 Add verification checks 2.4 Parameterize Input Data 2.5 Correlate reused data 2.6 Verify correct execution
26

4-26 LoadRunner for the Web 7.0

SETUP FOR EXECUTION

(QDEOH &KHFNV LQ 5XQ7LPH 6HWWLQJV

27

In order for the Vuser to perform the checks, the Verification checks check box in the Preferences tab must be checked. Use this option to make sure that the Vuser is running correctly. Because performing checks can slow down the Vuser execution, you might want to uncheck this setting during actual load tests.

Verification Checkpoints 4-27

VERIFY CORRECT EXECUTION

&KHFN 7HVW 5HVXOWV :LQGRZ

FAILED EXAMPLE Test Status = Failed Check/Text = Red


28

4-28 LoadRunner for the Web 7.0

VERIFY CORRECT EXECUTION

&KHFN 7HVW 5HVXOWV :LQGRZ

PASSED EXAMPLE Test Status = Passed Check/Text = Green


29

Verification Checkpoints 4-29

VERIFY CORRECT EXECUTION

&KHFN 9X*HQ ([HFXWLRQ /RJ


FAILED EXAMPLE

PASSED EXAMPLE
30

4-30 LoadRunner for the Web 7.0

ADD VERIFICATION CHECKS

7H[W &KHFN $IWHU 5HFRUGLQJ

1. Right-click a step and select "Insert After" from the pop-up menu 2. Expand Web Checks, select "Text Check," and click OK. The Text Check Properties dialog opens.

31

Verification Checkpoints 4-31

ADD VERIFICATION CHECKS

7H[W &KHFN$IWHU 5HFRUGLQJ


3. Type the text to check in the Search for box 4. Type left and right boundaries (optional) 5. Click the General tab 6. Overwrite "web_find" with a more descriptive name

32

4-32 LoadRunner for the Web 7.0

ADVANCED

&KHFNLQJ IRU DQ (UURU 3DJH


Q: If you check for an error page and the error page is found, should the Vuser pass? A: No.

Q: So, how do you make NOT finding the text a PASS condition, and finding the text a FAIL condition?
33

Verification Checkpoints 4-33

ADVANCED

0RGLI\ &KHFN 3URSHUWLHV


1. Open Text Check Properties dialog, General tab 2. Uncheck View only the active properties 3. In the Expect row, select "NotFound" from Value list 4. Click the box to the left of Expect

34

Note that in this example, the test should pass if the error text is NOT found.

4-34 LoadRunner for the Web 7.0

6XPPDU\
Determine the visual cues you will check to verify each business process Add text and image checks during recording Make sure that Enable verification checks is checked in the Run-Time Settings, Preferences tab before running the Vuser LoadRunner compares expected information to actual information obtained during the run The check status is always PASS or FAIL

35

Verification Checkpoints 4-35

4-36 LoadRunner for the Web 7.0

Planning Specification (continued):


Book a Flight
USER ACTIONS
1 Invoke the Web browser, type http://localhost/MercuryWebTours/ for the URL address and press Enter. Type the name in the User Name box. Type the password in the Password box.

EXPECTED RESULTS
The Mercury Tours home page appears. The members login name appears in the Member name box. The members password appears as a string of asterisks in the Password box. The Mercury Tours FLIGHT FINDER page appears. The Find Flight page appears with the following flight information fields: - Type - Passengers - Departing From - On - Arriving In - Returning - Service Class - Airline The SELECT FLIGHT page appears and returns all values of available flights. The BOOK A FLIGHT page appears. - First Name - Last Name - Number

2 3

4 5

Click the Sign-In button. Type the following data in the indicated fields on the FLIGHT FINDER page.

Click the CONTINUE button.

7 8

Select the first available flight and click the CONTINUE button. Type the following data in the indicated fields on the BOOK A FLIGHT page.

Verification Checkpoints 4-37

USER ACTIONS
9 Click the SECURE PURCHASE button.

EXPECTED RESULTS
The FLIGHT CONFIRMATION page appears. It contains confirmation of the reserved flight, and the flight and customer details.

10

Verify that the FLIGHT CONFIRMATION page appears, and that the page contains the text Your itinerary has been booked!. Verify the flight number. Flight details appear in the FLIGHT CONFIRMATION page.

11

4-38 LoadRunner for the Web 7.0

Exercises

In this lab, you will create a Vuser to book a flight. During recording you will add the checks necessary to verify the business process. Continuation of the Planning Specification is provided as your reference for input data. Why is it recommended to add verification checks to your Vusers? ________________________________________________________________________ ________________________________________________________________________

Exercise A: Add Verification Checkpoints to a Vuser

Begin Recording a Book Flight Vuser


1. Create a new Web Vuser in VuGen. 2. Rename Action1 to BookFlight. 3. Start recording into BookFlight. If the following URL is not already present in the URL box, then type it in:
http://localhost/servlets/com.mercurytours.servlet. WelcomeServlet

Leave Record the application startup checked, and click OK. 4. Sign in to the Mercury Tours Web site as jojo with the password bean. 5. Rename the com.mercurytours.servlet.SignonServlet step to FindFlight. Please refer to Lesson 2 if you need help completing this step.

Verification Checkpoints 4-39

6. Enter the flight details to search for available flights. Accept the defaults for all fields in the FLIGHT FINDER page except those shown in the table below.

FIELD Departing From Arriving In


7. Click CONTINUE.

VALUE San Francisco New York

8. Rename the com.mercurytours.servlet.ReservationServlet step to SelectFlight. 9. Accept the first available flight for both directions of the round trip. Click the CONTINUE button on the SELECT FLIGHT page. 10. Rename the com.mercurytours.servlet.PurchaseServlet step to PurchaseFlight.

Verify Text
1. Add a Start Transaction step called purchase_flight. If you need help with this step, please refer to Lesson 3. 2. Enter the passenger and credit card information in The BOOK A FLIGHT page. Use data from the following table.

FIELD First Name Last Name Number

VALUE Josephine Frisbee 123456789

3. Click SECURE PURCHASE.

4-40 LoadRunner for the Web 7.0

4. Rename the com.mercurytours.servlet.PurchaseServlet2 step to ConfirmFlight. 5. End the purchase_flight transaction with status LR_AUTO. Was the flight confirmation page returned from the Web server? ________________________________________________________________________ What other visual cues indicate that the reservation was created successfully? ________________________________________________________________________ 6. Create a check to find the text Your itinerary has been booked. Highlight the text Your itinerary has been booked in the browser (omit the exclamation point). Click the Insert Text Check button on the Record floating toolbar. Was the text check added? How do you know? ________________________________________________________________________ 7. Rename the Text Check to VerifyItinerary. In VuGen, right-click the Text Check step and select Properties from the pop-up menu. The Text Check Properties dialog box opens. Make sure that the text you wanted to check appears in the Search for box. Click the General tab. Replace Text Check with VerifyItinerary in the Step Name box. Click OK to close the Text Check Properties dialog.

Verify an Image
1. Find the flight confirmation image file name. In the browser, right-click the words FLIGHT CONFIRMATION on the FLIGHT CONFIRMATION page. Select Save Picture As from the pop-up menu. The name of the image file is displayed in the File name field of the Save Picture dialog.

Verification Checkpoints 4-41

What is the name of the flight confirmation image? Write the file name (including the file extension) in the space below.

img src = _______________________________________________________________


2. Copy the file name to the Windows clipboard. If the file name is not yet selected, select it, then press Ctrl+C. 3. Close the Save Picture dialog without saving. Click Cancel. 4. Add an image check to verify that the flight confirmation image appears. In the VuGen window, right-click the End Transaction step in the icon tree. Select Insert After from the pop-up menu. The Add Step dialog box opens. Expand the Web Checks category. Select Image Check, and click OK. The Image Check Properties dialog opens. Check the Image server file name (SRC attribute) check box. Paste the file name into the file name box by pressing Ctrl+V, then add the .gif extension. 5. Rename the web_image_check to VerifyFlightConfirmPage. Click the General tab in the Image Check Properties dialog box. Replace web_image_check in the Step Name box with VerifyFlightConfirmPage. Click OK to close the Image Check Properties dialog box. Was the image check added to the icon tree? ________________________________________________________________________ Why do you think you were asked to put the image check after the End Transaction step, rather than after the ConfirmFlight step? ________________________________________________________________________ ________________________________________________________________________ 6. In the browser, click SIGN-OFF and wait for the SIGN-ON page to appear.

4-42 LoadRunner for the Web 7.0

7. Stop recording, then save the script as: \web_project\Vusers\Lab4vuser1

Verify Correct Execution


1. Enable verification checks in the Run-Time Settings. Click the Run-Time Settings toolbar button. Check Verification checks in the Preferences tab. Click OK to save the changes. 2. Run Lab4vuser1. Click OK to accept the default results directory result1. 3. Review the test results. Click the Iteration 1 icon in the Test Results window. Each step in the script is represented on the Test Iteration 1 Summary page. Did the Vuser execute successfully? ________________________________________________________________________ How does the Iteration 1 Summary show that the checks passed? How would it show a check failure? ________________________________________________________________________ ________________________________________________________________________ 4. Compare the text on the Iteration 1 Summary page with the text on the Image Check page and the Web Find page. Are the key words from the Iteration Summary page also present on the checkpoint pages? ________________________________________________________________________ 5. Close the Test Results window, the Run-Time Viewer, and Lab4vuser1.

Verification Checkpoints 4-43

Review Questions
Validate your understanding of this lesson by answering the following questions: 1. What is a good reason to verify functionality under load with checkpoints? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 2. How do you determine which visual cues to verify during load testing? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________

4-44 LoadRunner for the Web 7.0

Data Parameterization

Data Parameterization 5-1

2EMHFWLYHV
In this lesson you will learn: What parameters are and how they work How parameterization can help to solve some playback problems How to parameterize input fields

5-2 LoadRunner for the Web 7.0

DEFINITION

.H\ 7HUPV 8VHG LQ 7KLV &RXUVH

3DUDPHWHU
A parameter is a placeholder which replaces a recorded value in a Vuser script. At run time, a value from an external source is substituted for the parameter.

Data Parameterization 5-3

3DUDPHWHUL]H ,QSXW 'DWD


Vuser
start transaction send XRunner {MIproduct} receive web page end transaction page checkpoint

During a run, VuGen replaces each parameter with a value from a data file or another external source, and inputs it to the Web application
4

5-4 LoadRunner for the Web 7.0

$ERXW 3DUDPHWHUL]DWLRQ
Parameterization lets you substitute many values for one recorded value You may parameterize input data and checkpoints Parameterization can help to solve problems affecting load testing

Data Parameterization 5-5

2EMHFWLYHV RI 3DUDPHWHUL]DWLRQ
Solve certain problems that may occur during playback: Date constraints make recorded date invalid Unique constraints prevent reusing recorded data Data caching response times are inaccurate real user activity is not emulated servers are not exercised

5-6 LoadRunner for the Web 7.0

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

1.1 Get system usage information 1.2 Document business process properties 1.3 Determine which fields to parameterize 1.4 Establish which data to use
7

Data Parameterization 5-7

 'HWHUPLQH :KLFK )LHOGV WR 3DUDPHWHUL]H


Which fields require a current date? Which fields require unique values? Which fields exercise the database server?

Part of the planning process involves determining the fields that you need to parameterize before you begin creating the Vusers.

5-8 LoadRunner for the Web 7.0

'DWH &RQVWUDLQW
PROBLEM

Business process works only for the current date Vuser works only on the date it was recorded
SOLUTION

Parameterize the input date Use a Date Type parameter to make the Vuser work for any current date

Data Parameterization 5-9

EXAMPLE

'DWH &RQVWUDLQW

Reserve seat on Flight 876 June 30, 2001 Today is July 1, 2001. You must enter a valid date.
Web server Internet

10

A date that is hard-coded in the Vuser during recording may no longer be valid when that date has passed. Parameterizing the date allows Vuser execution to succeed by replacing the hard-coded date.

5-10 LoadRunner for the Web 7.0

8QLTXH 'DWD &RQVWUDLQW


PROBLEM

Each product in inventory requires a unique ID number Once its in the system, a product ID number cannot be added again for a different product How to measure the performance of the process which creates a new product?
SOLUTION

Parameterize the product ID number field After running, delete the test ID numbers from the system so the Vuser can be run again
11

Data Parameterization 5-11

EXAMPLE

8QLTXH 'DWD &RQVWUDLQW

Add product ID 36901. Product ID 36901 is in use. Please choose another product ID.
Web server Internet

12

A field that uses unique data is constrained because the business process will not allow reuse of the data after it has been added to the system and processed. In the example shown above, the first run failed because the script tried to reuse the recorded product ID.

5-12 LoadRunner for the Web 7.0

'DWD ,V &DFKHG
PROBLEM

Vusers all use the same data Data caching makes load test response times shorter than when real users load the system
SOLUTION

Parameterize input data to force the system to get data from a database

13

Data Parameterization 5-13

EXAMPLE

'DWD ,V &DFKHG

Repeat Request11 request Data from cache database


Internet

&$&+(
Web server

Database

14

Data gets relocated in the servers cache when it is reused for each Vuser execution. As a result, server activity is not emulated during playback. While Vuser execution is successful, it will not produce test results meaningful for load testing because the server is not exercised. Using different data better emulates server activity and exercises the system. That improves the chances for meaningful load test results.

5-14 LoadRunner for the Web 7.0

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

1.1 Get system usage information 1.2 Document business process properties 1.3 Determine which fields to parameterize 1.4 Establish which data to use
15

Data Parameterization 5-15

 (VWDEOLVK :KLFK 'DWD WR 8VH


Extract master data from database Create valid transactional data predict according to type of data obtain from a functional expert
10/16/2002

TRUE

SMITH, WM.

$230.59

16

5-16 LoadRunner for the Web 7.0

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

2.1 Record User Actions 2.2 Add LoadRunner transactions 2.3 Add verification checks 2.4 Parameterize Input Data 2.5 Correlate reused data 2.6 Verify correct execution
17

Data Parameterization 5-17

PROCESS

+RZ WR 3DUDPHWHUL]H ,QSXW


1. Determine which fields to parameterize 2. Replace recorded values with parameters 3. Decide which parameter type to use 4. Choose the data access method and the number of iterations 5. Run the Vuser and analyze the results to verify correct execution

18

5-18 LoadRunner for the Web 7.0

3DUDPHWHU 7\SHV
Each type replaces a parameter with: Date/Time current date and/or time File data from a text file Group Name name of Vuser Group (see Scenarios lesson) Iteration Number current iteration number Load Generator Name name of the machine on which the Vuser is running (see Scenarios lesson) Random Number from a user-defined range of numbers Unique Number from user-defined start number and block size User Defined Function data generated by a function from an external DLL Vuser ID ID assigned to the Vuser by the Controller during a scenario run (see Scenarios lesson)
For information about parameter types not discussed in this course, please consult your LoadRunner documentation
19

Data Parameterization 5-19

PARAMETERIZE INPUT DATA

2SHQ WKH 6WHS 3URSHUWLHV


1. Identify the field to parameterize (from the Planning Specification) 2. Right-click the step which inputs data to the field 3. Select "Properties"

VUSER DESIGN SPECIFICATION


Field MIproduct query Data search_button Astra SiteTest LoadRunner TestDirector WinRunner XRunner

20

5-20 LoadRunner for the Web 7.0

PARAMETERIZE INPUT DATA

&UHDWH D )LOH 7\SH 3DUDPHWHU


1. Click Parameter button next to the recorded value 2. Enter a parameter name (or select from the list) 3. Select a Parameter type from the list

VUSER DESIGN SPECIFICATION


Field MIproduct query Data search_button Astra SiteTest LoadRunner TestDirector WinRunner XRunner

21

A data file is a text file that holds the name of the parameter you defined and the data you will use to replace the parameter with during the run.

Data Parameterization 5-21

PARAMETERIZE INPUT DATA

2SHQ WKH 3DUDPHWHU 3URSHUWLHV


1. Click the Properties button 2. Click the Create button and confirm a new file

22

5-22 LoadRunner for the Web 7.0

PARAMETERIZE INPUT DATA

2SHQ WKH 'DWD )LOH


Parameter.dat file is added to Vuser folder Click Edit button to open the new data file in Windows Notepad

FILE NAME

23

LoadRunner uses the parameter name with the extension .dat as the suggested name for a new data file. You may use any name you like.

Data Parameterization 5-23

PARAMETERIZE INPUT DATA

$GG 'DWD WR WKH )LOH


Enter new data in the Notepad window Press Enter after typing each data item (including the last item) Close Notepad and save the changes
VUSER DESIGN SPECIFICATION
Field MIproduct query Data search_button Astra SiteTest TestDirector LoadRunner WinRunner XRunner

PARAMETER NAME DATA

24

5-24 LoadRunner for the Web 7.0

PARAMETERIZE INPUT DATA

)LOH 'DWD $SSHDUV LQ 3DUDPHWHU 3URSHUWLHV


In the Parameter Properties dialog, data from the file appears in table form Multiple columns for different parameters are allowed in the same data file

25

Data Parameterization 5-25

6HOHFW WKH 'DWD $FFHVV 0HWKRG

Select next row tells LoadRunner in what order to use data from the file

Sequential Random Unique Same line as {parameter}

26

If the access method for parameter1 is random, for example, the tester can specify Same line as parameter1 as the access method for parameter2. In this way, data dependencies can be preserved.

5-26 LoadRunner for the Web 7.0

EXAMPLE

6HTXHQWLDO 5HSODFHPHQW 0HWKRG


Each Vuser uses the same row of data for each iteration Row 1 is used for iteration 1, Row 2 for iteration 2, etc.

6HTXHQWLDO
Vuser 1 Vuser 2 Vuser 3 Iteration 1 Iteration 2 Iteration 3

aaa bbb ccc

aaa bbb ccc

aaa bbb ccc


27

VuGen reads one row of data per iteration beginning with the first row. In a load test scenario, it is likely that many Vusers will run the same script. With the sequential access method, each Vuser uses the 1st data row for iteration 1, row 2 for iteration 2, etc.

Data Parameterization 5-27

EXAMPLE

5DQGRP 5HSODFHPHQW 0HWKRG


Rows are selected randomly by LoadRunner at run time Uniqueness is not guaranteed

5DQGRP
Vuser 1 Vuser 2 Vuser 3 Iteration 1 Iteration 2 Iteration 3

ddd fff ggg

aaa ccc bbb

eee eee bbb


28

The data row is chosen randomly for each iteration. Some data may be reused. The more iterations and Vusers you run, the more likely it is that data will be reused.

5-28 LoadRunner for the Web 7.0

EXAMPLE

8QLTXH 5HSODFHPHQW 0HWKRG


Each Vuser has a block of rows for its exclusive use LoadRunner expert must ensure uniqueness of data in the table

8QLTXH
Vuser 1 Vuser 2 Vuser 3 Iteration 1 Iteration 2 Iteration 3

aaa bbb ccc

ddd eee fff

ggg hhh iii


29

The data file is separated into blocks of rows; each block is assigned to only one Vuser per run. VuGen reads one row of data per iteration beginning with the first row of the block assigned to each Vuser. In this example, the Unique replacement method shows data blocks assigned in Vuser order. In fact, data blocks are assigned in the order that Vusers are initialized. That may or may not be the same as Vuser ID order.

Data Parameterization 5-29

EXAMPLE

3DUDPHWHUL]DWLRQ6FULSW 9LHZ
BEFORE PARAMETERIZATION

30

5-30 LoadRunner for the Web 7.0

EXAMPLE

3DUDPHWHUL]DWLRQ6FULSW 9LHZ
AFTER PARAMETERIZATION

NOTE: Tree View shows no differences

31

Data Parameterization 5-31

PARAMETERIZE INPUT DATA

&UHDWH D 'DWH 7\SH 3DUDPHWHU


Choose "Date/Time" from the Parameter type list Choose Date/Time format from Parameter Properties
32

5-32 LoadRunner for the Web 7.0

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

2.1 Record User Actions 2.2 Add LoadRunner transactions 2.3 Add verification checks 2.4 Parameterize Input Data 2.5 Correlate reused data 2.6 Verify correct execution
33

Data Parameterization 5-33

VERIFY CORRECT EXECUTION

5XQ7LPH 6HWWLQJV ,WHUDWLRQV


To test all data using the Sequential access method, Number of Iterations should equal the number of rows in the data file

34

The number of iterations assigned to a given business process should be based on the expected throughput for that process. The throughput (the number of processes occurring in a certain time period) should be extracted from a Transaction Profile (developed during the planning phase).

5-34 LoadRunner for the Web 7.0

VERIFY CORRECT EXECUTION

5XQ7LPH 6HWWLQJV /RJ


To see parameter data in the Execution Log, select Extended log and Parameter substitution in the Run-Time Settings Disable logging before load testing
35

In order to view the parameters and their values in the output logs after playback, the options shown above must be set.

Data Parameterization 5-35

VERIFY CORRECT EXECUTION

([HFXWLRQ /RJ
Iteration 1

36

The Execution Log lists parameters and their values for each iteration during Vuser playback.

5-36 LoadRunner for the Web 7.0

VERIFY CORRECT EXECUTION

([HFXWLRQ /RJ
Iteration 2

37

Data Parameterization 5-37

VERIFY CORRECT EXECUTION

7HVW 5HVXOWV :LQGRZ

Sometimes, parameter data may be displayed on the result page for the step that used the data

38

5-38 LoadRunner for the Web 7.0

&KHFNLQJ '\QDPLF 9LVXDO &XHV

Visual Cue may be:


paulb sathya jojo eric franz

How to check

?
39

depending on the input data

A dynamic visual cue is a value used as input data which is obtained from a parameter in the Vuser. How can you check for these values that change from one iteration to the next?

Data Parameterization 5-39

&KHFNLQJ D 9LVXDO &XH *HQHUDWHG E\ D 3DUDPHWHU


1. Add a text check to a parameterized step 2. Click the ABC button 3. Select the steps parameter from the list and click OK LoadRunner will now check for the value of the parameter during each iteration

40

You can assign a text check to look for values that exist in a data file. This is an effective way to verify the appearance of a parameterized value.

5-40 LoadRunner for the Web 7.0

6XPPDU\
Parameterize fields in order to: solve unique data constraints solve date constraints exercise the server(s) Determine what input data to use: from the database with the help of a Functional Expert Control Vuser execution from the Run-Time Settings extended log, parameter substitution number of iterations

41

Dont parameterize a field unless you have a good reason to do so.

Data Parameterization 5-41

Data Parameterization 5-42

Planning Specification (continued):


Create New User Account USER ACTIONS
1 2 Click the REGISTER button. In the REGISTER page, type the information for creating a new user. Fields in red may not be left blank.

EXPECTED RESULTS
The REGISTER page appears. Customer information is displayed in the fields: - First Name - Last Name - Phone - E-mail - Address - City - State - Postal Code - Country - User Name - Password - Confirm Password The new user is added into the database and the Mercury Tours REGISTER page appears with confirmation.

Click the Submit button.

Data Parameterization 5-43

Display Itinerary USER ACTIONS


1 Invoke the Web browser, type http://localhost/servlets/com.mercurytours .servlet.WelcomeServlet for the URL address, and click the Sign-In button. Type a valid user name in the User Name box. Type a valid password in the Password box.

EXPECTED RESULTS
The Mercury Tours home page appears.

2 3

The typed characters are displayed in the User Name box. The users password appears as a series of asterisks in the Password box. A query is sent to the database to match an existing value for registered user name and password. If a match is found, the Mercury Tours FLIGHT FINDER page appears. A Query is sent to the database to search for all flights reserved for the logged in user name. The ITINENARY page appears and displays all values returned by the database in response to the query.

Click the Sign-In button.

After the FLIGHT FINDER page appears, click the ITINERARY button.

5-44 LoadRunner for the Web 7.0

Exercises

In these exercises, you will determine which fields to parameterize, then add parameters to your Vuser.

Exercise A: Create Vuser to Sign Up New User

Setup
1. Create a new Web Vuser in VuGen.

Tree Pane

Actions Pane
2. Rename Action1 to RegisterNewUser. Right-click Action1 in the Actions pane and select Rename Action from the pop-up menu. The Action1 label opens for editing. Overwrite Action1 with RegisterNewUser and press Enter. 3. Start recording into the action RegisterNewUser. If the following URL is not already present in the URL box, then type it in:
http://localhost/servlets/com.mercurytours.servlet. WelcomeServlet

Leave Record the application startup checked, and click OK.

Data Parameterization 5-45

Record
1. Register with the Mercury Tours Web site. Click the REGISTER link in the Mercury Tours home page. The REGISTER page appears. 2. Rename the Register step to NewUserSignup. 3. Complete the new account information in the browser. Enter values from the table for the fields shown. Leave blank any fields not shown in the table.

FIELD First Name Last Name Country UserName Password Confirm Password

VALUE Steve Salvador United States sal chevy chevy

4. Finish registering the new user. Click SUBMIT. 5. Rename the com.mercurytours.servlet.RegisterServlet step to NewUserInfo. Was the sign up successful? What indicates that you have successfully created a new user account with Mercury Tours? ________________________________________________________________________ ________________________________________________________________________ 6. Insert a checkpoint to verify that a new user account was created. Rename the checkpoint VerifyNewAccount. If you need help completing this step, please refer to Lesson 4.

5-46 LoadRunner for the Web 7.0

7. Navigate to the Mercury Tours welcome page. Click the sign-in link in the Thank you message. Wait for the SIGN-ON page to appear. 8. Sign in to Mercury tours using the new user name and password. Were you able to sign in with new username and password? How can you tell? ________________________________________________________________________ 9. Rename the . . . SignonServlet step to FindFlight. 10. Insert a checkpoint called VerifySign-in. 11. Stop recording. 12. Save the Vuser as: \web_project\Vusers\Lab5vuser1 In the VuGen icon tree, what action does the sign-in link step represent? ________________________________________________________________________

Verify Correct Execution


1. Run Lab5vuser1 and accept result1 as the results directory. 2. Review the test results in the Test Results window. What was the result of the Vuser execution? ________________________________________________________________________ Which step in the execution tree failed? ________________________________________________________________________

Data Parameterization 5-47

NOTE: If your Test Results showed no failed step, do the following: 1. Select Start > Programs > Mercury Tours > Stop Server. 2. In Notepad, open the file: ...\MercuryTours\Apache Group\Apache\AdminParams.ini 3. Edit the useJavaScript line. Set: useJavaScript = on 4. Save the modified file and close Notepad. 5. Restart the Apache Server. 6. Rerun Lab5vuser1. What information appears in the Details column of the VerifyNewAccount page of the Test Results? ________________________________________________________________________ ________________________________________________________________________ 3. Compare Test Results information with the Execution Log. What error message was displayed in the Execution Log? ________________________________________________________________________ ________________________________________________________________________ What was written on the line preceding the error message in the Execution Log? ________________________________________________________________________ ________________________________________________________________________ What step preceded VerifyNewAccount in the Test Results window? ________________________________________________________________________ 4. In Test Results, click the Web Submit Form: NewUserInfo step.

5-48 LoadRunner for the Web 7.0

Was there an error message displayed on the captured page for the Web Submit Form: NewUserInfo step? If yes, what was the message? ________________________________________________________________________ ________________________________________________________________________ How could you solve the problem revealed by the error message on the captured Web Submit Form: NewUserInfo page? ________________________________________________________________________ ________________________________________________________________________ 5. Close the Test Results window and the Run-Time Viewer.

Exercise B: Parameterize Fields with Unique Data Constraints


What is an input field with a unique data constraint? ________________________________________________________________________ ________________________________________________________________________ In the RegisterNewUser action, which fields do you think are likely to have unique data constraints? ________________________________________________________________________

Parameterize an Input Field


1. Save Lab5vuser1 as Lab5vuser2. In the icon tree, which step contains the new user information? ________________________________________________________________________

Data Parameterization 5-49

2. Open the properties for the step that contains the new user information. Right-click the step NewUserInfo in the VuGen icon tree. Select Properties from the pop-up menu. The Submit Form Step Properties dialog opens with the Data tab displayed. From the table in the Data tab, write the field name and the value for each field with unique data constraints.

FIELD

VALUE

3. Parameterize the userName field. Click the ABC button on the same row as the userName value sal. The Select or Create Parameter dialog opens. Type username in the Parameter name box. Accept the default Parameter type File, and click Properties. The Parameter Properties dialog box opens.

Create Data File and Add Data


What is the suggested data file name in the File path box? ________________________________________________________________________ 1. Create the data file. Click the Create button. Click OK to dismiss the confirmation message box. 2. Replace the first entry in the data file for the username parameter. Click the Edit button. Notepad opens, displaying the data file username.dat. In Notepad, replace sal with elvis.

5-50 LoadRunner for the Web 7.0

Why should you replace sal in the data file? ________________________________________________________________________ 3. Add the remaining user names from the following table to username.dat. Press Enter after each data item, including the last one.

USER NAME
elvis fred carl

4. Save the changes, and close Notepad. What is the value of Select next row in the Parameter Properties dialog? Based on this value, in what order would you expect VuGen to use the data in username.dat? ________________________________________________________________________ ________________________________________________________________________ 5. Click Close to close the Parameter Properties dialog box. 6. Click OK to close the Select or Create Parameter dialog box. What happened to the value sal that was in the userName field in the Submit Form Step Properties dialog? ________________________________________________________________________

Parameterize Another Field


1. Parameterize the password field using password for the Parameter Name. 2. Open the Parameter Properties for password.

Data Parameterization 5-51

What is the suggested data file name in the File path box? ________________________________________________________________________ 3. Create a data file for password and open it for editing. 4. Replace chevy with shoes in the data file password.dat. Follow the same procedure you used to create a file and add data for username. 5. Add the remaining passwords from the table to the data file password.dat.

PASSWORD
shoes wilma seti

6. Close Notepad and save the changes to password.dat. 7. Ensure that dependent values are matched. Pick Same line as username from the Select next row list. 8. Close the Parameter Properties dialog and the Select or Create Parameter dialog when you have finished.

Parameterize a Field Using Existing Parameter


Refer to the Submit Form Step Properties dialog. Which field uses the same data as the password field? ________________________________________________________________________ 1. Parameterize the confirmPassword field using an existing parameter. Click the ABC icon on the confirmPassword row. Click the down-arrow to open the Parameter name list in the Select or Create Parameter dialog box. Select password from the Parameter name list and click OK.

5-52 LoadRunner for the Web 7.0

Was the parameter password assigned to the field confirmPassword? ________________________________________________________________________ 2. Parameterize firstName and lastName. Use data from the table.

firstName Elvis Fred Carl

lastName Presley Flintstone Sagan

3. Return to the VuGen main window. Click OK to close the Submit Form Step Properties dialog.

Verify Correct Execution


1. Change the Run-Time Settings to run the Vuser 3 times, to show parameter values in the Execution Log, and to verify checkpoints. Make sure that the settings agree with those in the following table. Do not change other settings that are not in the table. Click OK to save any changes.

TAB Pacing Log Preferences

SETTINGS Set Number of Iterations to 3 Check Extended log and Parameter substitution. Check Verification checks

2. Save, then run Lab5vuser2, accepting the default results directory. 3. Review the execution results.

Data Parameterization 5-53

Did the Vuser iterate successfully? What were the results of each iteration in the Test Results window? ________________________________________________________________________ ________________________________________________________________________ Was a new user name created for each iteration? (HINT: Look at the captured NewUserInfo page for each iteration.) ________________________________________________________________________ 4. Review the Execution Log. Did the Execution Log list the parameters you created and the values for each parameter during each iteration? _______________________________________________________________________ 5. Close the Run-Time Viewer and the Test Results window.

Exercise C: Parameterize to Avoid Server Caching

Setup
1. Open \web_project\Vusers\Lab4vuser1. NOTE: If you were not able to complete the exercise that created Lab4vuser1, open \web_project\Solutions\_Lab4vuser1 instead. 2. Save the Vuser as: \web_project\Vusers\Lab5vuser3 3. Parameterize the userName and password fields for the FindFlight step, then close the Submit Data Step Properties dialog. DO NOT ADD THE DATA YET. Follow the same procedure you used to parameterize these fields in the previous exercise, then close Submit Form Step Properties without adding any data.

5-54 LoadRunner for the Web 7.0

Use One Data File for 2 Parameters


In the previous exercise you created separate data files for each parameter. In this section you will create one data file that works for two parameters. 1. Open the Parameter List dialog box. Click the Open parameter list toolbar button, or select Vuser > Parameter List. 2. Create a data file called sign-in.dat. Select username from the list in the left pane of the dialog box. In the File path box, overwrite username.dat with sign-in.dat. Click the Create button. A data column, username, with one row of data, jojo, appears in the frame below the File path box. 3. Associate the password parameter with sign-in.dat. Select password from the list in the left pane of the dialog box. Click the down-arrow button at the right end of the File path box and select signin.dat from the list. 4. Add a second column to sign-in.dat for the passwords. Click the Add Col. button. The Add New Column dialog box opens with password already entered in the Column name box. Click OK. A second column called password is added to sign-in.dat. The first data row contains the value bean. 5. Check the column associations. When you select a parameter from the left pane, the value in the By number box should change. Make sure that username is associated with column 1, and password with column 2 of sign-in.dat.

Data Parameterization 5-55

6. Add more data for both parameters to sign-in.dat. Click the Edit button. Notepad opens sign-in.dat showing the column headings username,password on line 1 and the first row of data jojo,bean on line 2. Starting on line 3, add each username and password (separated by a comma) from the table to a new line of sign-in.dat. Do not add a space after the comma. Press Enter after each line (including the last line). Close Notepad and save the changes when you have finished.

USER NAME
elvis fred carl

PASSWORD
shoes wilma seti

7. Ensure that dependent values are matched. Highlight password in the parameter list, and pick Same line as username from the Select next row list. 8. Close the Parameter List dialog box and save the Vuser.

Verify Correct Execution


1. Verify and configure the Run-Time Settings. Verify that the settings agree with those in the following table. Change any setting that does not agree with the table. Do not change other settings that are not in the table. Click OK to save any changes.

TAB Pacing Log Preferences

SETTINGS Set Number of Iterations to 4 Select Extended log Check Parameter substitution Check Verification checks

2. Run Lab5vuser3, accept the default results directory, and click OK.

5-56 LoadRunner for the Web 7.0

3. Review the test results. Did the Vuser iterate successfully 4 times? ________________________________________________________________________ Did a different Vuser sign in each iteration? ________________________________________________________________________ 4. Close the Run-Time Viewer and the Test Results window after you have finished reviewing the results.

Exercise D: Parameterize a Text Check


In this exercise you will use the Lab5vuser3 script again. You will add a text check to the already parameterized username and password fields. In what situation would you want to parameterize a text check? ________________________________________________________________________ ________________________________________________________________________ 1. Open Lab5vuser3 and save it as Lab5vuser4. NOTE: If you were unable to complete Lab5vuser3 successfully, you can use
\web_project\solutions\_Lab5vuser3.

2. Parameterize the creditnumber field in the ConfirmFlight step. Use cardnumber for the Parameter name.

Data Parameterization 5-57

3. Add more card numbers from the table to the data file cardnumber.dat.

CARD NUMBER
2345678 13579 24680

4. Ensure that dependent values are matched. Pick Same line as username from the Select next row list. 5. Close all open dialogs when you have finished. 6. Add a text check to the parameterized ConfirmFlight step. Right-click the ConfirmFlight step in the icon tree. Select Insert After from the pop-up menu. The Add Step dialog box opens. Expand Web Checks, select Text Check, and click OK. The Text Check Properties dialog box opens. 7. Set the text check to find the cardnumber value. Click the ABC icon at the right of the Search for box. The Select or Create Parameter dialog box opens. Click the down-arrow at the right of the Parameter name box. Select cardnumber from the list, and click OK to close the dialog. 8. Rename the text check from web_find to VerifyCardNumber. Click the General tab. Replace web_find with VerifyCardNumber in the Step Name box. Click OK to save the changes and to close the Text Check Properties dialog. 9. Save, then run Lab5vuser4. Accept the default results directory and click OK. Did the cardnumber text check pass for each iteration? ________________________________________________________________________

5-58 LoadRunner for the Web 7.0

10. Close the Test Results window, the Run-Time Viewer, and Lab5vuser4 when you have finished.

Exercise E (Optional): Database Issues


1. Open, then run Lab5vuser2 again. What were the results of the run? ________________________________________________________________________ Why did the run fail each time? ________________________________________________________________________ ________________________________________________________________________ One way to avoid the problem encountered in this exercise is to create unique data for every script run. What is a better way to avoid the problem? ________________________________________________________________________ 2. Close the Test Results window, the Run-Time Viewer, and all open Vusers.

Data Parameterization 5-59

Review Questions
Validate your understanding of this lesson by answering the following questions: 1. Why do you need to parameterize fields in your Vuser scripts? ________________________________________________________________________ ________________________________________________________________________ 2. List the reasons why parameterization is necessary when load testing the Web server and the database server. ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 3. Who is the person on the project team who can give you valid data necessary for Vusers with parameterized fields? ________________________________________________________________________ 4. How can data caching have a negative effect load testing results? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________

5-60 LoadRunner for the Web 7.0

Part 2: Web Scenarios & Analysis

Manual Scenarios

Manual Scenarios 6-1

2EMHFWLYHV
In this lesson, you will learn: The elements that make up a LoadRunner scenario The different types of scenarios How to create and run a manual scenario How to use LoadRunner analysis tools to locate trouble spots in the application under test How to adjust Run-Time Settings to help achieve your load test goals

6-2 LoadRunner for the Web 7.0

Introduction to Scenarios

Manual Scenarios 6-3

DEFINITION

.H\ 7HUPV 8VHG LQ 7KLV &RXUVH

/RDG5XQQHU 6FHQDULR
An environment which describes all the elements to be used and the conditions under which you want to test your system.

6-4 LoadRunner for the Web 7.0

EXAMPLES

6FHQDULR (OHPHQWV
GOAL VUSER SCRIPT Vuser Script MONITORS

start transaction send URL1 receive web page end transaction image checkpoint

Response time not to exceed 7 seconds

Hits/sec Pages/sec HTTP response/sec

RUN-TIME SETTINGS LOAD GENERATOR

Disable logging Disable think times Enable checks

Manual Scenarios 6-5

7KH /RDG5XQQHU &RQWUROOHU


Controller organizes & manages scenario elements
Before scenario execution creates scenario starts scenario During scenario execution runs many Vusers simultaneously controls each Vuser (initialize, run, pause, stop) displays execution status of each Vuser displays messages from each Vuser monitors server and network resources After scenario execution collects and organizes performance data launches the Analysis tools
6

6-6 LoadRunner for the Web 7.0

EXAMPLES

:KDW ,V D /RDG *HQHUDWRU"


Vusers create the load Load generators are computers which run the Vusers
T8@I6SDP

8yyr

LOAD GENERATOR
T8@I6SDP!

Wr Drr

Xri rr

Many arrangements are possible

Xri rr 8yyr Drr

Wr

LOAD GENERATORS

Wr

Manual Scenarios 6-7

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

See flowchart on next slide

6-8 LoadRunner for the Web 7.0

&UHDWH 6FHQDULR 2YHUYLHZ


MANUAL select script add group* add vusers edit schedule* select load generators set rendezvous policy* select monitor options* select monitors* select run-time settings Select scenario type GOAL select script edit goal

*OPTIONAL

Manual Scenarios 6-9

CREATE SCENARIOOVERVIEW

6HOHFW 6FHQDULR 7\SH


Choose one of these types when you start a new scenario: Manual GoalOriented

10

6-10 LoadRunner for the Web 7.0

CREATE SCENARIOOVERVIEW

0DQXDO YV *RDO2ULHQWHG


Manual main purpose is to learn how many Vusers can run concurrently gives you manual control over how many Vusers run and at what times Goal-Oriented goal may be throughput, response time, or number of concurrent Vusers LoadRunner manages Vusers automatically

11

Manual Scenarios 6-11

CREATE SCENARIOOVERVIEW

$GG 9XVHU 6FULSW V


Options: Select one or more items from Available Scripts list Browse for more scripts Find script in a TestDirector* project Record a new script

*TestDirector is Mercury Interactives integrated test management tool

12

6-12 LoadRunner for the Web 7.0

Manual Scenarios

Manual Scenarios 6-13

CREATE MANUAL SCENARIO

$GG *URXSV

Click Add Group to open the Add Group dialog Select a script Edit the Group Name Change the number of Vusers
14

6-14 LoadRunner for the Web 7.0

CREATE MANUAL SCENARIO

(GLW *URXS ,QIRUPDWLRQ

Select a script row and click Details. Edit Group Name, Vuser Quantity, Load Generator Check the script Type Click More to see Vusers, Files, & Rendezvous
15

You can include different types of Vusers in a scenario so that different business processes are run within the same scenario. One way to accomplish that is to set up a group for each Vuser script you want to include in the scenario. For example, you could add Create order, Update order and Ship order groups to a scenario called Order Processing, to emulate real user Web site activity. The advantage to this type of scenario implementation is that you can control the number of processes through the system. If you want to scale up the number of Create Order transactions by 20%, then you just run more of those Vusers in the scenario.

Manual Scenarios 6-15

(GLW 6FKHGXOH

RSWLRQDO

Click Edit Schedule to open Schedule Builder

16

6-16 LoadRunner for the Web 7.0

EDIT SCHEDULE

6FKHGXOH %XLOGHU5DPS 8S 7DE

RAMP UP TAB

Schedule by Scenario or by Group Control Vuser ramp up load all Vusers at once specify how many to load and how often

17

Manual Scenarios 6-17

EDIT SCHEDULE

6FKHGXOH %XLOGHU 'XUDWLRQ 7DE

Control scenario duration Run until all Vusers finish Run for a certain length of time

DURATION TAB

18

6-18 LoadRunner for the Web 7.0

CREATE MANUAL SCENARIO

$GG

&RQILJXUH /RDG *HQHUDWRU V


1. Add load generators for the scenario 2. Select load generator for each group

19

Manual Scenarios 6-19

CREATE MANUAL SCENARIO

'HILQH 5HQGH]YRXV 3ROLF\

RSWLRQDO

Rendezvous settings are accessible only for scripts which already include a rendezvous Open from menu: Scenario > Rendezvous

When to release Vusers

Enable/ disable Vusers

Maximum time Vusers wait to be released

Enable/ disable rendezvous

20

6-20 LoadRunner for the Web 7.0

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

4.1 Set Monitoring Options 4.2 Select & Configure Monitors 4.3 Choose Run-Time Settings 4.4 Run

21

Manual Scenarios 6-21

RUN SCENARIOOVERVIEW

$ERXW 5XQQLQJ 6FHQDULRV


When scenario starts running, Vuser groups are assigned to their load generators and execute their scripts LoadRunner records duration of defined transactions performs any rendezvous in the scripts collects error and notification messages generated by Vusers

22

6-22 LoadRunner for the Web 7.0

RUN MANUAL SCENARIO

5XQ 7DE

Scenario status

Vuser groups

Select monitors from list

Add monitors and watch them in real time Watch scenario progress in real time
23

Manual Scenarios 6-23

RUN MANUAL SCENARIO

6HW 0RQLWRULQJ 2SWLRQV


In the Monitors tab: Check Enable Transaction Monitor Select Send errors to the output window

24

6-24 LoadRunner for the Web 7.0

RUN MANUAL SCENARIO

6HOHFW 0RQLWRUV

RSWLRQDO

Drag item from list to a graph window Double-click a graph window to enlarge it

25

LoadRunner offers monitoring tools which provide means to track how the system is coping with load. For example, LoadRunners Server Resource Monitor not only gives you access to all the Windows NT counters used by the NT Performance Monitor, but also saves its measurements in the results database. That enables the LoadRunner Analysis window to display graphs of the NT counters.

Manual Scenarios 6-25

&RQILJXUH 0RQLWRUV
For monitors from these categories: Do this: 1. Right-click a monitor pane

Database Server 2. Select "Add MeasureResource ment(s)" from pop-up menu Firewalls 3. Select machines and Network Delay resources to monitor from Streaming Media the dialog System Resource Web Application Server Web Server Resource
127(6qvvhvrvvyrtrhrrvrqpsvtrurrv

26

6-26 LoadRunner for the Web 7.0

&RQILJXUH 0RQLWRUV
1. Right-click a monitor pane 2. Select "Add Measurement(s)" from pop-up menu

27

Manual Scenarios 6-27

&RQILJXUH 0RQLWRU1HWZRUN 'HOD\


3. Select the machines to monitor from the dialogs

29

6-28 LoadRunner for the Web 7.0

&RQWUROOLQJ 9XVHUV
Vusers opens Vusers dialog Initialize initializes selected Vusers
Select group

Run buttons run selected Vusers Start Scenario runs all Vusers

Filter Vusers by status

30

Initializing a Vuser group distributes the Vusers in the group to their designated load generators so that they are ready to execute their script(s). By initializing all of the Vusers in a group before running them, you can ensure that they all begin executing the scenario at the same time.

Manual Scenarios 6-29

&RQWUROOLQJ 9XVHUV
Details opens the Vuser Information dialog

31

6-30 LoadRunner for the Web 7.0

6FHQDULR ([HFXWLRQ 3URFHVV


Objective 4.1 Verify that Vusers run concurrently Purpose Verify that parameterized data works under concurrent usage # of Vusers 3-5

32

Manual Scenarios 6-31

4.1 VERIFY THAT VUSERS RUN CONCURRENTLY

5XQWLPH 6HWWLQJV/RJ
Use logs to help debug a scenario Select Extended log Check Parameter substitution Vuser output will be blank unless logging is enabled
33

Run-Time Settings are saved with the test in VuGen but can be overridden with changes in the Controller.
s s

Disable logging is the default in the Controller Standard log is the default in VuGen

6-32 LoadRunner for the Web 7.0

9XVHU 2XWSXW /RJ


LoadRunner produces log information for each Vuser when logging is enabled Can be included in log: error messages parameter substitution transaction statuses verification statuses Open the Output Logs for the Vusers which had errors Vuser number

34

Manual Scenarios 6-33

6FHQDULR ([HFXWLRQ 3URFHVV


Objective 4.1 Verify that Vusers run concurrently Purpose Verify that parameterized data works under concurrent usage # of Vusers 3-5

4.2 Isolate Top Time transactions

Isolate transactions that have performance problems irrespective of load

20%

35

6-34 LoadRunner for the Web 7.0

DEFINITION

.H\ 7HUPV 8VHG LQ 7KLV &RXUVH

7RS 7LPH 7UDQVDFWLRQ


A LoadRunner transaction which requires significantly longer to complete than other transactions,* irrespective of load.

* In this definition, "other transactions" excludes those which measure an entire business process.

36

Manual Scenarios 6-35

4.2 ISOLATE TOP TIME TRANSACTIONS

5XQWLPH 6HWWLQJV7KLQN 7LPH


Select Ignore Think times might make it more difficult to find top time transactions

37

6-36 LoadRunner for the Web 7.0

4.2 ISOLATE TOP TIME TRANSACTIONS

5XQWLPH 6HWWLQJV*HQHUDO
Check Define each step as a transaction Automatically measures each step Makes it easier to find top-time transactions

38

Run Vusers as a thread unless your operating system does not support multi-threading (e.g., Windows 95). Use Automatic Transactions for each step if response times are too slow. Measuring each step might help to locate bottlenecks.

NOTE: At the testers option, VuGen can add the action name and line number to the name of each automatic transaction for a step. Toggle that option on and off in the Preferences tab of the Run-Time Settings dialog.

Manual Scenarios 6-37

4.2 ISOLATE TOP TIME TRANSACTIONS

7UDQVDFWLRQ 5HVSRQVH 7LPH

Top time transactions

Transactions measuring entire business processes can be filtered out

39

6-38 LoadRunner for the Web 7.0

6FHQDULR ([HFXWLRQ 3URFHVV


Objective 4.1 Verify that Vusers run concurrently Purpose Verify that parameterized data works under concurrent usage # of Vusers 3-5

4.2 Isolate Top Time transactions

Isolate transactions that have performance problems irrespective of load Verify that the system functions under the expected load

20%

4.3 Run full load test

100%

40

Manual Scenarios 6-39

4.3 RUN FULL LOAD TEST

5XQWLPH 6HWWLQJV/RJ
Select Disable logging Logging: Consumes resources Not needed after script is debugged

41

6-40 LoadRunner for the Web 7.0

4.3 RUN FULL LOAD TEST

5XQ7LPH 6HWWLQJV7KLQN 7LPH


Ignore think time to achieve greater throughput Replay think time to emulate real users (but you might want to limit them)

42

s s

Replay think time as recorded is the default in the Controller Ignore think time is the default in VuGen

Manual Scenarios 6-41

4.3 RUN FULL LOAD TEST

5XQWLPH 6HWWLQJV3UHIHUHQFHV
Enable Verification checks to verify functionality under load

43

6-42 LoadRunner for the Web 7.0

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

5.1 Check Analysis Summary 5.2 Open Appropriate Graphs

44

Manual Scenarios 6-43

4.3 RUN FULL LOAD TEST

&KHFN $QDO\VLV 6XPPDU\


The 1st page you see after a run includes: total transactions passed / failed specific transactions passed / failed Click a link to go to the associated graph Automatic AND userdefined transactions appear in the Analysis Summary and graphs
45

6-44 LoadRunner for the Web 7.0

2SHQ D 1HZ *UDSK

46

Manual Scenarios 6-45

+LWV +773 5HTXHVWV SHU 6HFRQG

47

6-46 LoadRunner for the Web 7.0

6FHQDULR ([HFXWLRQ 3URFHVV


Objective 4.1 Verify Vusers run concurrently Purpose Verify parameterized data works under concurrent usage # of Vusers 3-5

4.2 Isolate Top Time transactions 4.3 Run full load test

Isolate transactions that have performance problems irrespective of load Verify that the system functions under the expected load Verify the scalability of the system by running more than 100% load

20%

100%

4.4 Run "overdrive test"

100% +

48

Manual Scenarios 6-47

4.4 RUN OVERDRIVE TEST

7HVW 6FDODELOLW\ RI 6\VWHP


Determine whether your system is scalable for increased load Determine the limit of load that can be handled before more resources are required Use the same run-time settings and analysis tools as for a full load test Use cross result graphs to compare scenario runs for different loads

49

6-48 LoadRunner for the Web 7.0

&URVV 5HVXOW *UDSKV


Compare the same scenario before and after system tuning Compare heavier load with lighter load to see how performance was affected

50

Manual Scenarios 6-49

&URVV 5HVXOW *UDSKV


R E S P O N S E h i g h e r

heavier load heavier load lighter load

l T o I w M e E r

lighter load

51

6-50 LoadRunner for the Web 7.0

&URVV 5HVXOW *UDSKV

Each circled pair is same transaction under different loads Heavier load is the right member of each pair

52

Manual Scenarios 6-51

&URVV 5HVXOW *UDSKV

Heavier load is clustered at the high end

lower - RESPONSE TIME - higher

53

6-52 LoadRunner for the Web 7.0

&URVV 5HVXOW *UDSKV

FlightPurchase:25vusers

FlightPurchase:30vusers

Compare transactions per second for lighter vs. heavier load


54

Manual Scenarios 6-53

6XPPDU\
The Controller manages the scenario elements A load generator is a machine on which Vusers run Scenarios may be manual or goal-oriented Some monitors require that you add measurements to them in order to generate data Merge graphs to see how different scenario elements affect each other

55

6-54 LoadRunner for the Web 7.0

Exercises

Exercise A: Create and Run a Manual Scenario

Setup
1. Write down the network name of your computer. Write your network computer name: ______________________________________ To get your network computer name:
s

Windows NTRight-click the Network desktop icon and select Properties from the pop-up menu. The machine name appears in the Properties dialog. Windows 2000Right-click the MyComputer desktop icon and select Properties from the pop-up. Click the Network Identification tab to see the name. If you cannot get your network computer name that way, use localhost instead.

2. Start the Windows Task Manager program. Right-click the Windows task bar and select Task Manager. 3. Make sure the Apache Web Server is running.

Start
1. Invoke the Controller and maximize it. From the Windows Start menu, select Controller from the LoadRunner program group. 2. Create a new manual scenario. If the New Scenario dialog did not appear automatically after you invoked the Controller, select File > New or click the Create a new scenario button to open it. In the Select Scenario Type frame select Manual Scenario.

Manual Scenarios 6-55

3. Add the Lab5vuser4 script to the scenario. Select Lab5vuser4 from the Available Scripts list and click the Add button. If Lab5vuser4 is not in the list, click Browse and navigate to \web_project\Vusers to find it. (If you did not complete the exercise that created Lab5vuser4, select \web_project\solutions\_Lab5vuser4 instead. Click OK. The Controller Design tab opens, displaying the Scenario Schedule and Scenario Groups panes. NOTE: In this exercise we wont schedule the scenarios. In a real load testing situation, you might want to use the Schedule Builder to achieve your test objectives. 4. Verify the script Type. Click the Details button. The Group Information dialog opens. What is the script Type? ________________________________________________________________________ 5. Rename the group to Lab6. Overwrite the text in the Group Name box with Lab6. 6. Increase the number of Vusers to 25. In the Vuser Quantity box, overwrite the default 10 with 25. Click OK to close the Group Information dialog.

Add and Configure Load Generator


1. Add a Load Generator to the scenario. Click the Generators button. The Load Generators dialog box opens. Click the Add button. The Add Load Generator dialog box opens. In the Name box, type the machine name you wrote down in the Setup section of Exercise A. In the Platform list box select Windows and click OK. 2. Connect to the Load Generator. Select the machine that you just added and click the Connect button. Make sure that the load generator Status changes to Ready, then click Close.

6-56 LoadRunner for the Web 7.0

3. Assign the Load Generator to the Lab6 group. Click the cell in row 1 of the Load Generators column (the current value of that cell should be localhost). Open the list and select the load generator that you just connected to.

Adjust Settings and Options


1. Select the Run-time Settings. Click the Run-Time Settings button. Verify that the Run-Time Settings agree with those in the following table. Change any setting that does not agree with the table. If there is no row in the table for a setting, leave it as is.

TAB Pacing Log Think Time

SETTINGS Enter 4 in Number of Iterations edit box. Select Extended log. Check Parameter substitution. Select Replay think time. Select As recorded. Check Limit think time to and enter 3 in the seconds box. Check Verification checks. Uncheck File and line in automatic transaction names. Uncheck Continue on error. Select Run Vuser as a thread. (Win 2000 or NT only)* Check Define each action as a transaction. Check Define each step as a transaction.

Preferences General

* Vusers running as threads use fewer system resources than when running as processes. Do not check if running Win 95 or Win 98. 2. Click OK to save any changes and close the Run-Time Settings dialog. 3. Save all messages. Select Tools > Options. The Options dialog box opens. Click the Output tab and verify that Save all messages is selected. Click OK to close the Options dialog box.

Manual Scenarios 6-57

Why do you want to save all messages? ________________________________________________________________________ 4. Save the scenario as: \web_project\Scenarios\Lab6_manual.lrs

Add and Configure Monitors


1. Add the Throughput Web Resources monitor. Click the Run tab at the bottom of the Controllers main window. In the list of graphs (just below the Scenario Groups grid) click the + next to Web Resource Graphs to expand the graph tree. Select Throughput and drag it into a pane of the graph view area. 2. Add the default measurements for the Windows Resources monitor. If the Windows Resources Monitor is not already visible, expand System Resource Graphs, select Windows Resources, and drag it to one of the graph panes. Right-click the Windows Resources graph and select Add Measurement(s) from the pop-up menu. The Windows Resources dialog opens. Click the Add button in the Monitored Server Machines frame. The Add Machine dialog opens. Type the Load Generators name in the Name edit box. Choose the correct version of Windows from the Platform list, then click OK to close the Add Machine dialog. In the Resource Measurements on: frame you will see the default measurements for this monitor. Click OK to close the Windows Resources dialog and start the monitor. 3. Familiarize yourself with the monitor information. Double-click the Windows Resources graph pane to enlarge it. Notice that each measurement appears on a color-coded row in the bottom pane of VuGens main window. Each row corresponds to a line in the graph of the same color. Selecting a row highlights the corresponding line in the graph, and vice versa.

6-58 LoadRunner for the Web 7.0

Who would you consult for advice on which Windows NT counters to set? ________________________________________________________________________ What is the benefit of having the Windows Resources Monitor? ________________________________________________________________________ 4. Add the Apache Web Server Resource monitor. Double-click the Windows Resources graph to reduce it and to bring the other graph panes back into view. Select Apache from the Web Server Resource Graphs and drag it into the graph view area. 5. Add the load generator to the Apache Monitor. Right-click the Apache graph pane and select "Add Measurement(s)" from the pop-up menu. The Apache dialog opens. Click the Add button in the Monitored Server Machines frame. Type the Load Generators name in the Name box in the Add Machine dialog. Choose the correct version of Windows from the Platform list. Click OK to close the Add Machine dialog. 6. Add measurements to the Apache Monitor. Click the Add button in the Resource Measurements on: frame. The Apache - Add Measurements dialog opens. Select an item from Available Measurements. Type /server-status?auto in the URL box if its not already there. Click OK to add the item. Repeat this step until all 5 measurements have been added. Click OK to close the Apache dialog and start the monitor.

Manual Scenarios 6-59

Preliminary Runs
1. Specify the result file: \web_project\Results\Lab6_2vusers. Select Results > Results Settings. The Set Results Directory dialog box opens. Type Lab6_2vusers in the Results name box. If \web_project\Results is not the default directory, then click Browse and select it. Click OK to close the Set Results Directory dialog box. 2. Open the Vusers window. In the Run tab, click the Vusers button. The Vusers dialog box opens. 3. Run 2 Vusers to see if you can. Select 2 rows in the Vusers window and click the Run button. Wait for the Vusers statuses to change to Done. 4. If both Vusers finished the run without an error, reset the Vusers to Down status. In the Run tab click the Reset button. All Vusers statuses should change to Down. If the run produced any errors, consult the instructor to correct the problem. 5. Run 5 Vusers and set the Results directory to \web_project\Results
\Lab6_5vusers.

Select Results > Results Settings. 6. Check Vuser output for anomalies. Right-click any row in the Vuser window and select Show Vuser Log from the pop-up menu. The Vuser output windows open. Scan the text for iteration numbers, parameter substitutions, and verification statuses.
s s s s s

Iterations should be clearly defined. Parameter substitutions should show different values for each iteration. Web_find statements should say successful. Transactions should show a Pass status. The word Error should not appear.

6-60 LoadRunner for the Web 7.0

If you see no errors or other problems, close all 5 Vuser output windows (they are stacked on top of each other) and proceed to the next step. Otherwise, consult the instructor about how to proceed.

TIP

If you prefer, you can open the log in Notepad so that you can use Notepads Search feature. The files are \web_project\results\Lab6_5vusers\Lab6_1.log for Vuser 1, Lab6_2.log for Vuser 2, etc.

Find Top Time Transactions


1. Click the Analyze Results toolbar button and wait for the Analysis Summary to appear. 2. Display the Transaction Response Time - Average graph. Click the Transaction Response Time - Average tab. If that tab does not appear in your Analysis window, click the Add Graph toolbar button to open the Open a New Graph dialog. Expand the Transactions category and select Transaction Response Time - Average from the list. Click the Open Graph button, then close the dialog after the graph appears. Which transaction had the highest average response time? (HINT: Click a line in the graph to highlight the corresponding row in the grid below.) ________________________________________________________________________ 3. Filter out the BookFlight_Transaction from the graph. Uncheck the box next to BookFlight_Transaction in the grid. Why should you remove BookFlight_Transaction from the graph when looking for top time transactions? ________________________________________________________________________ ________________________________________________________________________

Manual Scenarios 6-61

Does the graph show any spikes now? If yes, which transaction(s) caused the spikes? ________________________________________________________________________ 4. Save the Analysis session as: \web_project\Results\Lab6_5vusers
\res1.lra

5. Close the LoadRunner Analysis window.

Exercise B: Load Testing

Run Full Load Test


NOTE: The graphs and questions in this section are intended to be suggestive, not prescriptive. As you become more familiar with LoadRunners analysis tools and with load testing, you may find other tools and questions useful as well. NOTE: During this exercise, you should check the Windows Task Manager occasionally to make sure that your machine does not run out of resources. If it does, stop the scenario and scale down the number of Vusers that you run to a number that does not consume all of the computers resources. 1. Verify that Results > Auto Load Analysis is selected.

TIP

LoadRunner can automatically create a results database and display the Analysis window. If Auto Analysis is not enabled, you can select Results > Analyze Results from the menu to perform those actions after a scenario has finished running. 2. Set the results directory to Lab6_20vusers. 3. Disable logging in the Run-Time Settings. 4. Reset the Vusers.

6-62 LoadRunner for the Web 7.0

5. Initialize 20 Vusers. In the Vusers window, highlight the first 20 Vusers and click the Initialize button on the Controllers toolbar. Wait for the Vusers Statuses to change to Ready. 6. Run the Vusers and watch the Apache monitor. Click the Run button in the Vusers window (or on the Controllers toolbar). The Vusers Statuses should change to Running. Click the Close button to close the Vuser dialog box. Double-click the Apache monitor to enlarge it. Make sure that data is appearing on it. If not, there may be a problem with your httpd.conf file. NOTE: If data does not appear on your Apache monitor graph, 1. Stop the scenario run. 2. Run the Stop Server program in the Mercury Tours program group. 3. In Notepad, open the file: \MercuryTours\Apache Group\Apache\Conf
\httpd.conf

4. Find the following line:


#LoadModule status_module modules mod_status.so

5. Delete the # character. 6. Delete # from the line: #ExtendedStatus On 7. Also delete the # character from these lines:
#<Location /server-status> #SetHandler server-status #</Location> [the first line where this occurs after SetHandler server-status]

8. Save the changes and close Notepad. 9. Restart the Apache server.

Analyze Results
1. Check the Transaction Summary. When LoadRunner has finished processing the results data, it displays the Analysis Summary. Look at the Transaction Summary. How many passed and failed transactions does the Transaction Summary show? What percentage of all transactions failed? ________________________________________________________________________

Manual Scenarios 6-63

2. Open the Apache graph (from the Web Server Resources category). 3. Compare Busy Servers and Idle Servers in the Apache graph. Hold down the Shift key, then, in the grid below the Apache graph, click the rows #Busy Servers (Apache) and #Idle Servers (Apache). What do you notice about the Busy and Idle Servers lines in the Apache graph? ________________________________________________________________________ 4. Display the Transaction Response Time - Average graph. 5. Filter out the action transaction. In the grid below the graph, uncheck BookFlight_Transaction. What do you notice about the graph now? ________________________________________________________________________ 6. Save the session and close the Analysis window when you are finished. Save the session as: \web_project\Results\Lab6_20vusers\res1 NOTE: If you were conducting a real load test on your system, at this point you would analyze the test results and report your findings to the system experts. They should then tune the system to optimize it for 100% load. We wont be tuning systems in this course so we continue with the next scenario.

Run Overdrive Test


What is a reason to scale the load from 20 to 25 Vusers? ________________________________________________________________________ ________________________________________________________________________ 1. Specify the result file: \web_project\Results\Lab6_25vusers

6-64 LoadRunner for the Web 7.0

2. Reset the Vusers. 3. Initialize and run 25 Vusers, and wait for them to finish.

Compare Full Load and Overdrive Results


1. Create cross result graphs. In the Analysis window, select File > Cross with Result. The Cross Result dialog opens with Lab6_25vusers.lrr already in the list. Click the Add button. The Open Result File for New Analysis Session dialog opens. Navigate to \web_project\Results\Lab6_20vusers, select the file Lab6_20vusers.lrr, and click Open. Click OK to close the Cross Result dialog. LoadRunner creates a new database. Click No if you see a message asking if you want to open the default graphs. 2. Open the Transaction Response Time - Average graph. 3. Filter the transactions of the Transaction Response Time - Average graph. In the grid below the graph, uncheck the boxes for all transactions except the ones in the table below. Fill in the average transaction response times.

AVERAGE TRANS. RESPONSE TIMES TRANSACTION ConfirmFlight FindFlight PurchaseFlight (automatic) purchase_flight (manual) SelectFlight 20VUSERS.LRR 25VUSERS.LRR

Manual Scenarios 6-65

How much did the average transaction response time vary as more Vusers were added? ________________________________________________________________________ 4. Open the Throughput graph from the Web Resources category. How much did the average throughput decline as more Vusers were added? ________________________________________________________________________ Overall, do you think that the difference between 25 and 20 Vusers was small enough that you would feel confident allowing the higher load on your system? ________________________________________________________________________ 5. When you have finished analyzing the results, save the analysis session as Lab6_cross20+25. 6. Close the LoadRunner Analysis window and the scenario Lab6_manual.lrs.

6-66 LoadRunner for the Web 7.0

Review Questions
Test your understanding of this lesson by answering the following questions: 1. Why is it a good practice to run one Vuser the first time, and more than one Vuser the next time? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 2. Why do the transaction measurements not matter when testing multiple Vusers to make sure they can run concurrently without errors? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________

Manual Scenarios 6-67

6-68 LoadRunner for the Web 7.0

Goal-Oriented Scenarios

Goal-Oriented Scenarios 7-1

2EMHFWLYHV
In this lesson, you will learn: How to choose a scenario goal based on planning How to create and run a goal-oriented scenario Learn to perform more in-depth analysis

7-2 LoadRunner for the Web 7.0

*RDO2ULHQWHG $XWRPDWLF 6FHQDULRV


ELEMENTS Goal Vuser Scripts Load Generators Rendezvous (optional) Monitor options Monitors Run-Time Settings

GOAL AUTO select script edit goal select load generators set rendezvous policy* select monitor options* select monitors* select run-time settings

*OPTIONAL

Goal-Oriented Scenarios 7-3

CREATE GOAL-ORIENTED SCENARIO

$GG 9XVHU 6FULSW


Select GoalOriented Scenario Select one or more Vuser scripts

7-4 LoadRunner for the Web 7.0

CREATE GOAL-ORIENTED SCENARIO

6HOHFW 6FHQDULR *RDO


Choose one of these goals when you start a new goal-oriented scenario: Response time Throughput hits/second transactions/ second Number of concurrently running Vusers
5

Goal-Oriented Scenarios 7-5

SELECT SCENARIO GOAL

*RDO 5HVSRQVH 7LPH


Response time tests how many Vusers can run without exceeding a specified response time Measures response time of LoadRunner transactions Set minimum and maximum number of Vusers to run LoadRunner runs scenario until max. defined # of Vusers have run response time goal was exceeded before max. # of Vusers were run

7-6 LoadRunner for the Web 7.0

SELECT SCENARIO GOAL

*RDOV 7KURXJKSXW
Choose one: 1. Hits/second available to Web Vusers only measures HTTP requests per second 2. Transactions/second select min. and max. number of Vusers to run LoadRunner runs scenario until goal is reached max. defined # of Vusers have run & goal was not reached throughput did not increase when additional Vusers were run

Goal-Oriented Scenarios 7-7

SELECT SCENARIO GOAL

*RDO 5XQQLQJ 9XVHUV


Running Vusers tests how many Vusers can run concurrently LoadRunner runs scenario until all Vusers run all iterations of their scripts no more Vusers can run

7-8 LoadRunner for the Web 7.0

REVIEW

FROM PLANNING: GET SYSTEM USAGE INFORMATION

7DVN 'LVWULEXWLRQ 'LDJUDP


Business Processes
Create new account Search for title View shopping cart Purchase book Night 40 30

Hours to be emulated
Day50

100 5000 1600 500

50 1500 500 200

50 1000 300 170

25 500 150 140

Night

2000 700

Administrative Processes
*Invoice processing *System backup
12 am

50 1
2

50 1
4

50

50

10

12 pm

10

12

*Not a Web task

ONLINE BOOKSTORE (typical work day)


9

Goal-Oriented Scenarios 7-9

EXAMPLE

3ODQQLQJ%DVHG *RDO 7UDQVDFWLRQ 5HVSRQVH 7LPH


Based on the task distribution diagram "Typical Work Day," you could define the following goal: Select a transaction to measure an entire business process (e.g., "Search for title") Set response time to 5 seconds (or whatever your system experts think is reasonable) Set min. and max. number of Vusers to run Run the scenario and keep adding Vusers until response time exceeds 5 seconds Then you know how many users your system can handle before performance becomes unacceptable
10

7-10 LoadRunner for the Web 7.0

EXAMPLE

3ODQQLQJ%DVHG *RDO 7UDQVDFWLRQV 3HU 6HFRQG


Based on the task distribution diagram "Typical Work Day," you could define the following goal: Select a transaction to measure an important business process step (e.g., the "Save" step for "Purchase book") Set transactions per second to 5 (or whatever your database administrator thinks is reasonable) Set min. and max. number of Vusers to run Run scenario to see if goal is reasonable given the expected number of users

11

Goal-Oriented Scenarios 7-11

CREATE GOAL-ORIENTED SCENARIO

(GLW 6FHQDULR *RDO6FHQDULR 6HWWLQJV

Check Receive notification if you want to see this message


12

7-12 LoadRunner for the Web 7.0

CREATE GOAL-ORIENTED SCENARIO

(GLW 6FHQDULR *RDO/RDG %HKDYLRU

You must choose a Transaction Name if Goal Type is "Transaction Response Time" or "Transactions per Second"

The Step up period cannot be less than 1 min. 30 secs.

13

Goal-Oriented Scenarios 7-13

CREATE GOAL-ORIENTED SCENARIO

&RQILJXUH /RDG *HQHUDWRUV


1. Click a cell in the Load Generators column. 2. Select a load generator from the list. 3. Click in % of Target cell to change default value.

Assign a "percent of target" to each load generator

NOTE: Adding load generators was covered in the previous lesson

14

7-14 LoadRunner for the Web 7.0

REVIEW

RUN GOAL-ORIENTED SCENARIO

6HOHFW DQG &RQILJXUH 0RQLWRUV


Select monitors which support your testing goal

What is enabled on the Monitor Menu depends on which monitor is selected below
15

Goal-Oriented Scenarios 7-15

RUN GOAL-ORIENTED SCENARIO

6HOHFW 5XQ7LPH 6HWWLQJV


Configure browser and bandwidth settings to test different types of real users

NOTE: When IP Spoofing, always use maximum bandwidth

16

NOTE: If you want to set the bandwidth to emulate modem speed (Browser Emulation tab), you should also select Run Vuser as a process in the General tab. Modem speed emulation does not work when Vusers are run as threads.

7-16 LoadRunner for the Web 7.0

(QDEOH :HE 3DJH %UHDNGRZQ


In Web Page Breakdown tab of Options dialog: Check Enable Web Page Breakdown Set percentage of Vusers to a small number so as not to impact response times

17

Goal-Oriented Scenarios 7-17

:HE 3DJH %UHDNGRZQ

One page takes far longer than the others

18

7-18 LoadRunner for the Web 7.0

*HW 1DPH RI 6ORZ 3DJH

1. Hold pointer over graph line to see component name 2. Select page from list

19

Goal-Oriented Scenarios 7-19

=RRP LQ RQ 6ORZ 3DJH


Download Time Breakdown

20

7-20 LoadRunner for the Web 7.0

&RPSRQHQW %UHDNGRZQ 2YHU 7LPH

21

Goal-Oriented Scenarios 7-21

:HE 6HUYHU 5HVRXUFHV

This is the same data that appeared on the live Apache monitor
22

7-22 LoadRunner for the Web 7.0

1HWZRUN 'HOD\ *UDSKV


See the delay between "hops"

23

Goal-Oriented Scenarios 7-23

1HWZRUN 'HOD\ *UDSKV


See the delay between "hops" Zoom in on a segment

24

7-24 LoadRunner for the Web 7.0

$ERXW 0HUJHG *UDSKV


Number of transactions This graph is filtered to show only the transaction named in the goal definition

Response time

Y-axis scales are different for each of the 2 merged graphs

X-axis is the common axis for both graphs


25

Goal-Oriented Scenarios 7-25

0HUJLQJ *UDSKV
View > Merge Graphs

26

7-26 LoadRunner for the Web 7.0

0HUJHG *UDSK

Running Vusers

Transaction Response Time + Running Vusers

27

Be aware that merged graphs may not always use the same scale. The second column of the grid, Scale, shows you what scale is being used for each line in the current graph. If there are differences, they will show up there.

Goal-Oriented Scenarios 7-27

)LOWHU &XUUHQW *UDSK

Selection examples: A few transactions A range of response times Part of a scenario Group by different fields Criteria can be: = (equal to) < > (not equal to)
28

7-28 LoadRunner for the Web 7.0

*OREDO )LOWHU
More filter conditions than single graph filters Criteria can be "=" or "< >"

29

Goal-Oriented Scenarios 7-29

7UDQVDFWLRQV *UDSK
TRANSACTION RESPONSE TIME - DISTRIBUTION

Transaction key

30

7-30 LoadRunner for the Web 7.0

)LOWHUHG 7UDQVDFWLRQV *UDSK


Use a filter to remove clutter from a graph
Same graph as on previous slide with all but 3 transactions filtered out

31

Goal-Oriented Scenarios 7-31

)LQGLQJ D 7UDQVDFWLRQ

Select a row to highlight the associated graph

32

7-32 LoadRunner for the Web 7.0

'ULOO 'RZQ 2SWLRQV


Right-click on a bar in the graph Select "Drill Down" to open dialog box Select a Transaction Select a Group By field Repeat if desired

34

Goal-Oriented Scenarios 7-33

$IWHU 'ULOOLQJ 'RZQ

35

7-34 LoadRunner for the Web 7.0

&RPSDUH /RDG *HQHUDWRUV

Right-click graph line Select "Drill Down" from pop-up Select "Host Name" from Group By
36

One reason you might want to compare load generators is if one is on the LAN inside the firewall and the other is remote. LoadRunner lets you test on both sides of the firewall.

Goal-Oriented Scenarios 7-35

$QDO\]LQJ 5HVXOWV 8VLQJ 0XOWLSOH /RDG *HQHUDWRUV


Collating results from multiple load generators can be slow and might take a long time

37

7-36 LoadRunner for the Web 7.0

6XPPDU\
The LoadRunner Controller helps you to: create scenarios run the Vusers collect performance data Scenarios consist of generators, scripts, Vusers, monitors, run-time settings, and results folders Follow the LoadRunner Scenario execution process Initialize Vusers before running them Analyze a load test depending on the objective

38

Goal-Oriented Scenarios 7-37

7-38 LoadRunner for the Web 7.0

Exercises

Exercise A: Create and Run a Goal-Oriented Scenario


In this exercise you will create a goal-oriented scenario with the existing Vuser,
\web_project\Vusers\Lab5vuser4.

The scenario goal is learn how the servers perform when there are more than 25 hits per second on the site.

Setup.
1. Create a new goal-oriented scenario with Lab5vuser4. Create a new scenario in the LoadRunner Controller. Select Goal-Oriented Scenario for the Scenario type. Select the script Lab5vuser4 and add it to the scenario. Click OK to close the New Scenario dialog and display the Design tab. 2. Name the Goal. Click the Edit Scenario Goal button. The Edit Scenario Goal dialog opens. Click the Rename button. The New Goal Profile dialog opens. Type Hits per Second 25 in the Name box and click OK. On what factors will you base your decisions for hits per second, minimum and maximum Vusers? ________________________________________________________________________ 3. Define the goal. Under Define Scenario Goal select Hits per Second from the Goal Type list. Type 25 in the Reach goal of edit box. Type 10 in the Using a minimum of box and 25 in the and a maximum of box. In the Run Time frame change Run for to 1 minute. Select the Stop scenario and save results radio button in the Scenario Settings tab. Click the Load Behavior tab and select the Automatic button. Click OK to save the changes and close the Edit Scenario Goal window.

Goal-Oriented Scenarios 7-39

4. Rename the group Lab7-goal. Click in the first row of the Script Name column, overwrite "Lab5vuser4" with Lab7-goal and press Enter. NOTE: The Details button opens the Script Information dialog for a goal scenario. This is unlike a manual scenario where it opens the Group Information dialog, allowing you to rename the group within. 5. Add the load generator to the scenario and connect to it. If you need help with this step, please refer to the Manual Scenarios lesson. 6. Assign the load generator to the Lab7 group. 7. Select the Run-time Settings. In the Design tab click the Run-Time Settings button. Verify that the Run-Time Settings agree with those in the following table. Change any setting that does not agree with its corresponding line in the table. If there is no line in the table for a particular setting, leave it as is.

TAB Pacing Log Think Time Preferences General

SETTINGS Enter 4 in Number of Iterations edit box. Select Disable logging Check Ignore think time. Check Verification checks Uncheck Continue on error. Select Run Vuser as a thread. (Win 2000 or NT only) Check Define each action as a transaction. Check Define each step as a transaction.

8. Specify the result file: \web_project\Results\Lab7_25hits-sec

7-40 LoadRunner for the Web 7.0

Add and Configure Monitors


Which monitor should you select to watch progress towards the scenario goal? ________________________________________________________________________ 1. Add the Hits per Second monitor. (Skip this step if hits per second is already present in one of the graph panes.) 2. Add the Apache Web Server Resource monitor with all 5 measurements. If you need help with this step, please refer to Lesson 6. 3. Add the Windows Resources Monitor. (Skip this step if Windows Resources is already present.) If you need help with this step, please refer to Lesson 6. 4. Save the scenario as \web_project\Scenarios\Lab7_goal.lrs,

Run Scenario and Verify that Goal was Reached.


1. Run the Scenario. Click the Start Scenario button or select Scenario > Start. Did the scenario achieve your hits per second goal? How do you know? ________________________________________________________________________ 2. Compare transaction response times with hits per second. Click the Transaction Response Time - Average tab to display the graph. Select View > Merge Graphs to open the Merge Graphs dialog box. In the Merge Graphs dialog select "Hits per Second" from the Select graph to merge with list. If Overlay is not selected for Select type of merge, select it. Click OK.

Goal-Oriented Scenarios 7-41

3. Highlight hits per second in the graph. In the grid below the graph click the "Hits" row. Notice that the left y-axis shows average response time (for the transactions), and the right y-axis shows the number of hits per second. Analyze the graph to see if you can determine how transaction response times were affected by the number of hits. ________________________________________________________________________ 4. Close all open windows after you finish analyzing the run results. 5. Click yes if you see a message asking you to save the current Analysis session. Save it as: \web_project\results\Lab7_25hits-sec\res1

(Optional) Increase Goal and Run Again


1. If your Lab7 scenario reached its goal when running fewer than 25 Vusers, increase the number of hits per second in the goal definition and run the scenario again.

7-42 LoadRunner for the Web 7.0

Review Questions
Test your understanding of this lesson by answering the following questions: 1. What Run-Time Settings can you use to help emulate real users? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 2. Why run more Vusers than your anticipated peak load? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________

Goal-Oriented Scenarios 7-43

7-44 LoadRunner for the Web 7.0

Part 3: Data Correlation

Manual Correlation

Manual Correlation 8-1

2EMHFWLYHV
In this lesson, you will learn: Problems caused by recorded dynamic values How to parameterize and correlate dynamic, unpredictable values manually, using LoadRunner script functions

8-2 LoadRunner for the Web 7.0

5HXVH 6\VWHP&UHDWHG '\QDPLF 'DWD


PROBLEM

The system outputs data needed later for input, such as System generated session ids URLs that change each time you access the Web page Fields (sometimes hidden) recorded during a form submission The data is only good for the current session
SOLUTION

Correlate the data Capture output value from one step Use captured value as input to another step
3

Manual Correlation 8-3

DEFINITION

.H\ 7HUPV 8VHG LQ 7KLV &RXUVH

&RUUHODWHG 'DWD
Correlated data is data which is sent to the client from the server, and later sent back to the server by the client.

8-4 LoadRunner for the Web 7.0

EXAMPLE

5HXVH 6\VWHP &UHDWHG 'DWD ,Q WKH 6DPH 6HVVLRQ


2

Send me a list [Session ID = Login 12345 (hidden)]


Web server Internet

Welcome [Session ID = 12345 (hidden)]

Dynamic data is correlated automatically by the client application (running in the browser) while recording a script
5

Manual Correlation 8-5

EXAMPLE

5HXVH 6\VWHP &UHDWHG 'DWD ,Q D /DWHU 6HVVLRQ


2

Send me a list [Session ID = Login (hidden)] 12345


Web server Internet

Vuser

Welcome [Session ID = 23456 (hidden)]

Reusing recorded dynamic data will cause errors when you replay the script Recorded dynamic data must be recorrelated using parameters
6

The cause of this Vuser execution problem is that the dynamic value returned from the server was recorded and, therefore, was part of the Vuser script. When the script is played back, the Vuser attempts to reuse the recorded value, while the server is expecting another value, assigned for the current playback session.

8-6 LoadRunner for the Web 7.0

&RUUHODWLQJ 'DWD ZLWK 9X*HQ


There are several ways to correlate data in VuGen: Manual correlation (covered in this lesson) Automatic correlation after recording (covered later) Automatic correlation during recording (covered later)

Manual Correlation 8-7

EXAMPLE

$ 9XVHU 6HDUFKHV IRU 6XSSRUW

URL=http://support.merc-int.com web_add_cookie index.jsp Support Intro kbBrowse.jsp kbBrowse2.jsp kbBrowse3.jsp

Invokes Mercury Interactive Support home page

Puts info on PC Submits login form Clicks a link Gets new page after selecting Product LoadRunner Clicks Retrieve after selecting Sort By Date Clicks Log Out button 8

8-8 LoadRunner for the Web 7.0

PROBLEM

$ 6WHS )DLOHG 'XULQJ 3OD\EDFN

Q: Why did the step creation fail? 1. Make a note of which step failed. 2. Look at the results of the previous step.
9

Manual Correlation 8-9

PROBLEM

&KHFN WKH 3UHYLRXV 6WHS

A: Step creation failed because the session timed out. Q: Why did the session time out? Lets see if the Execution Log can tell us.
10

8-10 LoadRunner for the Web 7.0

PROBLEM

([HFXWLRQ /RJ 5HYHDOV 3UREOHP

A: Immediately above the error, the Execution Log shows that a session ID was redirected to a timeout page. There must be a problem with the session ID in the script. Q: What do we know about session IDs? A: Session IDs are dynamic. They work for only one session. Servers generate a new ID for every session.
11

Manual Correlation 8-11

CAUSE

$ '\QDPLF 9DOXH :DV 5HFRUGHG


Double-click the red "Error" line in the Execution Log. VuGen puts the cursor on the script line that was executing when the error occurred. The session ID is hard-coded in the script. It worked for the recording session, but it wont work for any playback session.

Q: What is the solution?

12

8-12 LoadRunner for the Web 7.0

SOLUTION

&RUUHODWH WKH '\QDPLF 9DOXH LQ WKH 9XVHU 6FULSW


1. Determine the value to capture 2. Find the right and left text boundaries of the value to capture 3. Find which occurrence of the text boundaries should be used 4. Add a web_reg_save_param function to the script, above the step which requests the page with the value to capture 5. Add the parameter name, left boundary, right boundary, and occurrence to the function 6. Parameterize the dynamic value in the script every time it occurs 7. Verify correct execution

13

Manual Correlation 8-13

MANUAL CORRELATION

 'HWHUPLQH WKH 9DOXH WR &DSWXUH


1.1 Create 2 identical Vusers 1.2 Compare the 2 scripts

14

8-14 LoadRunner for the Web 7.0

DETERMINE THE VALUE TO CAPTURE

 &UHDWH 7ZR ,GHQWLFDO 9XVHUV


Re-record the Vuser with exactly the same steps If the dynamic value you need to capture is
dependent on an input data value, then change only that value independent of any input data, then re-record with exactly the same data

Q: Is the session ID in our example dependent on any user input data? A: No.
15

In order to determine which values are dynamic but get hard-coded into the script during recording, create two Vusers with the same action steps and input data. The idea is to compare the contents of two nearly identical scripts to see if any values changed.

Manual Correlation 8-15

DETERMINE THE VALUE TO CAPTURE

 &RPSDUH WKH 6FULSWV


Select Tools > Compare with Vuser to open the Open Test dialog Select the current Vusers twin from the dialog VuGen compares the Vuser currently visible with the Vuser you select
16

Tools > Compare with Vuser runs a utility program called WDiff.exe. You can run this program even when VuGen is not running. It is found in the \bin folder of LoadRunner.

8-16 LoadRunner for the Web 7.0

COMPARE THE SCRIPTS

:'LII +LJKOLJKWV WKH 'LIIHUHQFHV

web_add_cookie("BV_IDS=ialllegddfhbemfcfkmcfeedhi.0: @@@@1345195498.0999297950@@@@", "Name=x", "Value=35", ENDITEM, 2 "Name=y", "Value=8", ENDITEM,

web_add_cookie("BV_IDS=eallldfiieebemfcfkmcfeedhi.0: @@@@1920023721.0999189073@@@@", "Name=x", "Value=29", ENDITEM, "Name=y", "Value=13", ENDITEM,

"URL= . . . ?BV_SessionID=@@@@2089996444.0999297996@@@@&",

3 " URL= . . . ?BV_SessionID=@@@@0046855696.0999189747@@@@&", 17

This is the step that failed

This is how WDiff compares the files. It goes through each line of the script and highlights the lines where differences occur. In this example, WDiff noted three lines in each script that have mismatches.

Manual Correlation 8-17

1. DETERMINE THE VALUE TO CAPTURE

3DUDPHWHUL]H 9DOXH V 5HXVHG LQ WKH 6FULSW


This value changes every session It was not reused by the script
1

web_add_cookie("BV_IDS=.@@@@1345195498.0999297950@@@@", "Name=x", "Value=35", ENDITEM, "Name=y", "Value=8",ENDITEM, URL=?BV_SessionID=@@@@2089996444.0999297996@@@@& These values represent the screen locations of mouse clicks They were not reused by the script Think times, if recorded, also are not reused This value changes every session It was reused by the script This is the step that failed
18 3 2

8-18 LoadRunner for the Web 7.0

 )LQG WKH 7H[W %RXQGDULHV


Copy the dynamic value (in this case, the "BV_SessionID") from the first Vuser in WDiff to Notepad using Ctrl+Ins (Ctrl+C wont work)

19

Manual Correlation 8-19

2. FIND THE TEXT BOUNDARIES

)LQG WKH +70/ 3DJH

In the Execution Log, double-click the line causing the error The pointer jumps to corresponding step in the icon tree and opens that HTML page

20

8-20 LoadRunner for the Web 7.0

2. FIND THE TEXT BOUNDARIES

)LQG %RXQGDULHV LQ +70/ 9LHZ


In HTML View: 1. Open the Find dialog (Ctrl+F). 2. Paste value copied from WDiff into Find What box. 3. Click Find.
RIGHT BOUNDARY LEFT BOUNDARY

21

The left boundary is the text immediately to the left of the dynamic value you want to capture. The right boundary is the text immediately to the right of the dynamic value.

Note: In LoadRunners Script View, certain characters (such as the double quotation marks) have special functions. When you want to include such a character as part of boundary text, you must precede that character with a backslash. In script functions, the backslash is used as a control character to indicate that the character which follows is meant to be processed as text. For example:
s s

abc\"" indicates the boundary abc". abc\\ indicates the boundary abc\.

Manual Correlation 8-21

2. FIND THE TEXT BOUNDARIES

/HIW %RXQGDU\ 6KRXOG EH 8QLTXH


LB should be as nearly unique as possible In this example, "BV_SessionID=" is a good choice RB should not appear in string to be captured "&" is OK to use for RB in this example

RIGHT BOUNDARY

LEFT BOUNDARY

22

8-22 LoadRunner for the Web 7.0

2. FIND THE TEXT BOUNDARIES

)LQG %RXQGDULHV LQ 5HFRUGLQJ /RJ


VuGen puts lines breaks in the Recording Log that are not in the HTML

23

Manual Correlation 8-23

2. FIND THE TEXT BOUNDARIES

)LQG %RXQGDULHV LQ 5HFRUGLQJ /RJ

Find doesnt work when text spans a line break

FOUND

NOT FOUND

24

8-24 LoadRunner for the Web 7.0

3. FIND WHICH OCCURRENCE TO CAPTURE

)LQG 2FFXUUHQFH LQ ([HFXWLRQ /RJ


This works only when Data returned from server was checked in Log RunTime Settings before playback
25

The boundaries of the dynamic value could occur more than once on the page. If they do, the value within those boundaries might not be the same in each instance. One of the difficulties about manual correlation is that you not only must find the left and right boundaries, but you must also make sure that you find the occurrence of those boundaries that contains the value you need to correlate.

Manual Correlation 8-25

3. FIND WHICH OCCURRENCE TO CAPTURE

3OD\ %DFN ZLWK 6HUYHU 'DWD 2Q


In Run-Time Settings, Log tab: Select Extended log Check Data returned by server If these were not selected before your last playback, select them and play back the Vuser again
26

8-26 LoadRunner for the Web 7.0

4. ADD FUNCTION TO SCRIPT

ZHEBUHJBVDYHBSDUDP 
web_reg_save_param ("param_name", "<List of Attributes>", LAST); ATTRIBUTES NOTFOUND* ERROR (default) or EMPTY LB Left boundary: string enclosing left side of captured value RB Right boundary: string enclosing right side of captured value RELFRAMEID* Hierarchy level of the HTML page relative to the requested URL SEARCH* Scope: Headers, Body, or ALL (default) ORD* Ordinal: occurrence number of the match (default=1)

*optional

27

Manual Correlation 8-27

4. ADD FUNCTION TO SCRIPT

ZHEBUHJBVDYHBSDUDP 
Create a parameter by adding the following statement to the Vuser script:
Indicates "no more attributes"

web_reg_save_param ("param_name","LB=","RB=","ORD=",LAST);
User-defined parameter name Occurrence*

These strings can be found in VuGens Recording Log, in the source HTML of the page where the dynamic value resides, and in the Execution Log when Extended Log was selected and Data returned by Server was checked.

*optional

28

ORD, the occurrence attribute, is optional. If you omit it, the default value is 1. NOTE: Executing web_reg_save_param always succeeds (return code = 0), with the parameter being assigned the value "" (NULL). (This can be verified from the Execution Log.) If, and only if, the function is on the correct line, with the correct boundaries, will it capture the dynamic value.

8-28 LoadRunner for the Web 7.0

$GG )XQFWLRQ WR 6FULSW %HIRUH 9DOXH ,V 5HTXHVWHG


4.1 Add web_reg_save_param () before the step that gets the page with a dynamic value.
URL=http://support.merc-int.com web_add_cookie index.jsp Support Intro kbBrowse.jsp kbBrowse2.jsp kbBrowse3.jsp Invokes Mercury Interactive Support home page

Puts info on PC Submits login form Clicks a link

This is the step that gets the dynamic value This is the step that uses the dynamic value

Gets new page after selecting Product LoadRunner Clicks Retrieve after selecting Sort By Date Clicks Log Out button

Q: What if you dont know which step requests the page which contains the dynamic value?

29

Why should the web_reg_save_param statement be added before the step that sends for the page with the dynamic value? During playback, when VuGen executes the web_reg_save_param statement, three things occur: 1. VuGen creates the parameter specified in the first argument. 2. When the next step is executed, VuGen searches the HTML source of that page for the text specified by the left and right boundary arguments in the statement. 3. When the value is found, VuGen places it into the defined parameter. Thereafter, whenever VuGen encounters a reference to the parameter name later in the script, it will plug in the value stored there.

Manual Correlation 8-29

+RZ WR 3ODFH WKH 6DYH )XQFWLRQ


A: If youre not sure which step gets the value, use the following procedure to place the function correctly. 1. In the Execution Log, find the correct occurrence of the left boundary. 2. Double-click that line in the Execution Log to jump to the corresponding line in either the Script View or the Tree View. 3. Insert a new step: web_reg_save_param() 4. Enter the parameter name and attributes you want, click OK. 5. VuGen inserts the function into the correct spot.

30

8-30 LoadRunner for the Web 7.0

 $GG )XQFWLRQ $UJXPHQWV


web_reg_save_param ("param_name","LB=","RB=","ORD=",LAST);

Name the parameter Copy the boundary text from the HTML Add the instance ("ORD") from the Execution Log

31

Manual Correlation 8-31

 3DUDPHWHUL]H WKH 9DOXH V LQ WKH 6FULSW


Add braces to the parameter name Click Replace All

32

1. Select Edit > Replace from the menu. The Search and Replace dialog opens. 2. Paste or type the original recorded value in the Find What box. 3. Type the parameter name in the Replace With box. The parameter name:
s s

must be the same as the name defined in the web_reg_save_param statement must be enclosed within braces { }*

4. Press the Find Next button. 5. When LoadRunner finds the value, press the Replace All button.

* Braces are VuGens default parameter enclosure characters. The user may change this character from the Parameterization tab of the General Options dialog box. (Select Tools > General Options.)

8-32 LoadRunner for the Web 7.0

 3DUDPHWHUL]H WKH 9DOXH LQ WKH 6FULSW

33

Manual Correlation 8-33

+RZ ,W :RUNV
web_reg_save_param

specifies "sessID" to store the dynamic value

34

8-34 LoadRunner for the Web 7.0

+RZ ,W :RUNV

This step used to have the recorded, hardcoded value When script is played back, VuGen substitutes the captured value for "sessID"

35

A parameter acts like a placeholder or a variable.


s s

A parameter replaces a literal value in the script. VuGen substitutes a captured, dynamic value for the parameter at run time.

Manual Correlation 8-35

7. VERIFY CORRECT EXECUTION

5XQ7LPH 6HWWLQJV/RJ
Select Extended log, and check Parameter substitution

36

If you dont check these settings, you wont be able to tell for certain whether the process worked.

8-36 LoadRunner for the Web 7.0

7. VERIFY CORRECT EXECUTION

&KHFN 7HVW 5HVXOWV


Repeat the procedure if necessary In this example, it was necessary to save 2 dynamic values

37

Manual Correlation 8-37

7. VERIFY CORRECT EXECUTION

&KHFN ([HFXWLRQ /RJ

These are the captured dynamic values


Line # in script

38

8-38 LoadRunner for the Web 7.0

7. VERIFY CORRECT EXECUTION

&KHFN ([HFXWLRQ /RJ

These show the replacement of parameters with captured data later in the script
39

Manual Correlation 8-39

DEFINITION

.H\ 7HUPV 8VHG LQ 7KLV &RXUVH

'DWD 'HSHQGHQF\
Data which is valid only when used with certain other data.
In the login process, for example, the password is dependent on the username. When the username changes, the password must also change or the login wont work.

40

8-40 LoadRunner for the Web 7.0

'DWD 'HSHQGHQW )LHOGV


PROBLEM

You want to test your shopping application with several different merchandise items After parameterizing the item name, the application works for the recorded item and fails for all others
SOLUTION

Find and parameterize the dependent data as well as the name of the merchandise item

41

Manual Correlation 8-41

9XVHU 5HSOD\ )DLOV

If all iterations fail except the one which used the recorded value, that usually indicates a data dependent value hardcoded in your script

42

8-42 LoadRunner for the Web 7.0

VUSER REPLAY FAILS

,GHQWLI\LQJ WKH 3UREOHP

TEST STATUS

ITEM DESCRIPTION

SkiJacket SkiPants Goggles Gloves

Original Recorded Value Additional values from a data file after parameterizing the item description
43

Manual Correlation 8-43

VUSER REPLAY FAILS

,GHQWLI\LQJ WKH 3UREOHP


Using procedures taught in this lesson, you would find that the Item Number changed whenever a different Item Description was selected (i.e., the Item Number is dependent on the Item Description)
TEST STATUS ITEM DESCRIPTION ITEM NUMBER

SkiJacket SkiPants Goggles Gloves

1000123 1000124 1000125 1000126


44

8-44 LoadRunner for the Web 7.0

REVIEW

DETERMINE THE VALUE TO CAPTURE

 &UHDWH 7ZR ,GHQWLFDO 9XVHUV


Re-record the Vuser with exactly the same steps If the dynamic value you need to capture is
dependent on an input data value, then change only that value independent of any input data, then re-record with exactly the same data

Q: Is the Item Number in our example dependent on any user input data? A: Yes. It is dependent on the Item Description.
45

Manual Correlation 8-45

SOLUTION

&RUUHODWH 'HSHQGHQW 9DOXH V


The solution is the same as that shown previously for the SessionID, except that, when recording the 2nd Vuser you would change the Item Description
TEST STATUS ITEM DESCRIPTION

SkiJacket SkiPants Goggles Gloves Record using one of these values


46

8-46 LoadRunner for the Web 7.0

6XPPDU\
To find and correlate a dynamic value manually: Determine the value to capture Find the left and right boundaries of the value Find the occurrence you need to capture Add a web_reg_save_param statement before the step that requests a page with a dynamic value Parameterize the all occurrences of the dynamic value in the script Verify correct execution Repeat the procedure if necessary
47

Manual Correlation 8-47

8-48 LoadRunner for the Web 7.0

Exercises

Exercise A: Create Vuser to Book a New Flight

Setup and Sign-in


1. Create a new Web Vuser in VuGen. 2. Make sure that the following Recording Options are set. Dont change any other options if they are not in the table.

TAB Recording Correlation Advanced

RECORDING OPTION HTML-based script Enable correlation system-wide all

VALUE selected unchecked unchecked

3. Make sure that the following General Options are set in the Correlation tab. Dont change any other options if they are not in the table Select Tools > General Options.

GENERAL OPTION, CORRELATION TAB Save correlation information during replay Show Scan for correlations pop-up after replay of Vuser Show only differences that appear in script Enable Scripting and Java applets on Snapshots viewer Download images on Snapshots viewer Scan for differences . . . snapshots using: HTML comparison
4. Start recording with Mercury Tours into Action1. Leave Record the application startup checked.

VALUE checked unchecked checked unchecked checked selected

Manual Correlation 8-49

5. Sign in to the Mercury Tours Web site as jojo with the password bean.

Record a Flight Reservation


1. Enter the flight information to the FLIGHT FINDER page. Accept the defaults for all input fields except as noted in the table below.

FIELD Departing From Arriving In

VALUE San Francisco New York

2. Click the CONTINUE button. 3. Accept the first departing flight in the list. By default, the first available flight is selected for each direction when the SELECT FLIGHT page appears. 4. Select the last (4th) return flight in the list. 5. Click the CONTINUE button on the SELECT FLIGHT page. 6. Purchase the selected flight. Enter the passenger and credit card information in the BOOK A FLIGHT page. Use data from the following table.

FIELD First Name Last Name Number

VALUE Joseph Frisbee 987654321

7. Click the SECURE PURCHASE button on the BOOK A FLIGHT page. 8. Insert a checkpoint to verify that the Flight Confirmation page appeared.

8-50 LoadRunner for the Web 7.0

Sign-off and Parameterize the Cities


1. In the browser, click SIGN-OFF and wait for the SIGN-ON page to appear. 2. In VuGen, stop recording. 3. Save the Vuser as: \web_project\Vusers\Lab8original 4. Save the Vuser again as: \web_project\Vusers\Lab8vuser1

TIP

When editing Vusers, it is recommended to keep an original copy of the script. Save your script with a different name before making changes to it. Which step includes the input steps for the fly from and fly to cities? ________________________________________________________________________ 5. Parameterize the fromPort and toPort fields as type file, sequential. Select the ReservationServlet step. Use Depart as the Parameter Name for fromPort field. Use Return as the Parameter Name for toPort field. Put the values from the table below into one data file. If you need help completing this step, please refer to lesson 5.

DEPART San Francisco Seattle Sydney Zurich

RETURN New York Frankfurt London Acapulco

Manual Correlation 8-51

Verify Correct Execution


1. Set the Vuser to iterate 4 times and to show parameter values and server data in the Execution Log. Verify that the settings agree with those in the following table. Change any setting that does not agree with the table, then click OK. Dont change any settings that are not in the table.

TAB Pacing Log

SETTINGS Set Number of Iterations to 4 Select Extended log Check Parameter substitution Check Data returned by server Check Verification checks

Preferences

2. Save, then run Lab8vuser1. Accept the default results directory result1. Click OK.

TIP

Click the Recording Log tab to speed up playback. 3. Review the execution results. Did the Vuser iterate 4 times? ________________________________________________________________________ In the Test Results, did any iteration fail? If yes, which iterations failed? ________________________________________________________________________ What was the name of the first step where an iteration failed? ________________________________________________________________________

8-52 LoadRunner for the Web 7.0

Based on the lesson presented, why do you think iterations 2, 3, and 4 failed while iteration 1 passed? ________________________________________________________________________ ________________________________________________________________________

Exercise B: Recreate Vuser and Compare with Original


Exercise objective: Find the dynamic data to capture.

Setup and Login


1. Create a new Web Vuser in VuGen. 2. Start recording with Mercury Tours into Action1. Leave Record the application startup checked. 3. Sign in to the Mercury Tours Web site as jojo with the password bean.

Record Flight Reservation


Use the same steps as in Exercise A to record another Vuser, changing only one data element in the process. 1. Enter the flight information from the FLIGHT FINDER page. Accept the defaults for all input fields except as noted in the table below. Note that only the Departing From value is different from that used to record Lab8vuser1.

FIELD Departing From Arriving In

VALUE Seattle New York

Manual Correlation 8-53

Why do you think that only one data value should be changed for the 2nd recording? ________________________________________________________________________ ________________________________________________________________________ 2. Click the CONTINUE button. 3. Select the first departing flight in the list and the last (4th) return flight. 4. Click the CONTINUE button on the SELECT FLIGHT page. 5. Purchase the selected flight. Enter the passenger and credit card information in The BOOK A FLIGHT page. Use data from the following table.

FIELD First Name Last Name Number

VALUE Joseph Frisbee 987654321

6. Click the SECURE PURCHASE button on the BOOK A FLIGHT page. The FLIGHT CONFIRMATION page appears. 7. Insert a checkpoint to verify that the Flight Confirmation page appeared. 8. Click SIGN-OFF and wait for the SIGN-ON page to appear. 9. In VuGen, stop recording. 10. Save the Vuser script as: \web_project\Vusers\Lab8vuser2

8-54 LoadRunner for the Web 7.0

Compare the Two Vusers


1. Invoke the WDiff utility. Make sure that Action1.c is highlighted in the Action list (not vuser_init or vuser_end). Select Tools > Compare with Vuser. The Open Test dialog box appears. Select Lab8vuser1 and click Open. WDiff opens with Lab8vuser2\Action1.c and Lab8vuser1\Action1.c displayed side-by-side. Lines which are different in the two files are highlighted. What differences did you find between the two files at the step that failed? ________________________________________________________________________ ________________________________________________________________________ Which difference(s) should be captured for playback? Give a reason for your answer. ________________________________________________________________________ ________________________________________________________________________ Why should you copy the outFlight AND inFlight values when only the outFlight input value changed from Lab8vuser1 to Lab8vuser2? ________________________________________________________________________ ________________________________________________________________________ 2. Copy the difference(s) to be captured in the Web Submit Form . . . PurchaseServlet step from Lab8vuser1 in WDiff to Notepad. Open Notepad. Use Ctrl+Insert to copy from WDiff. NOTE: Ctrl+C doesnt work here. Then use Ctrl+V to paste into Notepad.

Manual Correlation 8-55

Exercise C: Fix the Vuser Script


Exercise objective: Capture and use the dynamic data in a Vuser script.

Find Boundaries and Occurrence of Dynamic Data


The example in the graphic shows how data in the script corresponds to objects on the Web page. In this application, flight numbers are unique and change when the airline or depart time changes. Also, prices vary with the flight. Therefore, capturing only the airline name or the time is not enough.

"$" is a data delimiter

partial line of script

"Value=Blue Skies Airlines$200$244$5:03 pm$"


1) 2) 3) 4)

1) Airline 2) Flight # 3) Cost 4) Time

In the example shown in the graphic, what part of the string is dynamic and should be captured? ________________________________________________________________________ 1. In VuGen, display Lab8vuser1, and open the Script View. Which step submits the flight details? Which step causes the server to send the page with the flight details form? ________________________________________________________________________ ________________________________________________________________________

8-56 LoadRunner for the Web 7.0

2. Find the first line in the Execution Log which shows an error. Put the cursor anywhere in the Execution Log. Press Ctrl+Home to go to the top of the log. Press Ctrl+F to open the Find dialog. Type Error in the Find What box. Check Match Case. Click the Find button. What is the error message in the Execution Log? ________________________________________________________________________ ________________________________________________________________________ What is the message on the previous line of the log? ________________________________________________________________________ ________________________________________________________________________ The error message indicates that the web_submit_form . . . PurchaseServlet step tried to send the flight data to the server and was unsuccessful. The BOOK A FLIGHT page was received from the server in response to the previous (successful) step. That form contains the flight details for all available choices at that point in the process. What is the name of the step immediately preceding the PurchaseServlet step? ________________________________________________________________________ 3. Find the dynamic value in the HTML. Switch to Tree View and click the HTML View tab. Highlight the ReservationServlet step in the Tree View. Put the cursor at the top of the HTML page in the Snapshot of Recording pane. Press Ctrl+F. The Find dialog opens. Copy the first dynamic value to be replaced from Notepad. Paste the value to be captured to the Find What box using Ctrl+V. Click the Find button.

Manual Correlation 8-57

Would value= be a good left boundary? Give a reason for your answer. ________________________________________________________________________ ________________________________________________________________________ What is the left boundary? ________________________________________________________________________ What is the right boundary? ________________________________________________________________________ 4. Copy the left boundary of the dynamic value from the HTML. Select the boundary text you want to copy. The left boundary should be as nearly unique as possible. Right-click the selection and pick Copy Selection from the pop-up menu. NOTE: Ctrl+C doesnt work here. 5. Paste the left boundary text into Notepad. How will you determine the correct occurrence of the left boundary? ________________________________________________________________________ ________________________________________________________________________ 6. Find the correct occurrence of the left boundary in the Execution Log. Use Ctrl+Home to put the cursor at the top of the Execution Log. Press Ctrl+F to open the Find dialog. Type or paste the left boundary text into the Find What box. Move the Notepad window so that you can read the dynamic value from it while looking at the Execution log. Click Find. Compare the value following the left boundary with the value in Notepad. If they are the same, you have found the correct occurrence. If not, press Find again and compare. Continue this process until you find the correct occurrence.

8-58 LoadRunner for the Web 7.0

Insert the Function in the Vuser


1. In the Execution Log, double-click the line containing the correct occurrence of the left boundary. The pointer jumps to the corresponding line in the Script View. Which line did the cursor jump to? ________________________________________________________________________ 2. Open the Add Step dialog box. Right-click the current step in the icon tree and select "Insert Before" from the pop-up menu. The Add Step dialog opens. 3. Open the Save Data to a Parameter dialog box. Expand the Services category in the Add Step dialog box and select web_reg_save_param. The Save Data to a Parameter dialog opens. 4. Enter the Parameter Name, the LB, the RB, and the Instance, then click OK. Choose a descriptive name for the parameter, for example, outFlight_data. VuGen inserts the function at the correct spot in the script, immediately above the . . .ReservationServlet step.

Replace Recorded Values with Parameter


1. Switch to Script View. 2. Put the cursor at the top of the script, then select Edit > Replace. The Search and Replace dialog opens. 3. Enter the dynamic value in the Find What box. 4. Enter the parameter name (enclosed in braces) in the Replace With box. 5. Click Replace All, then close Search and Replace. 6. Save the modified Lab8vuser1 as Lab8vuser3.

Manual Correlation 8-59

7. Repeat the entire procedure for the inFlight data. 1. If you have not already done so, find the boundaries and the correct occurrence for the inFlight data. 2. Add another web_reg_save_param function to capture the inFlight data. 3. In Script View, replace the occurrence(s) of that data with the parameter. (The procedure for doing all this began at Step 3 in the section "Find Boundaries and occurrence of Dynamic Data" and ended at Step 5 of this section, "Replace Recorded Values with Parameter." )

Verify Correct Execution


1. Close the Run-Time Viewer and the Test Results window if they are still open. 2. Save, then run Lab8vuser3. How can you verify that Lab8vuser3 captured the values correctly? ________________________________________________________________________ What flight numbers and ticket prices did Lab8vuser3 insert?
ITERATION

outFlight_data

inFlight_data

1 2 3 4
3. Close WDiff, Notepad, the Test Results window, the Run-Time Viewer, and all Vusers.

8-60 LoadRunner for the Web 7.0

Review: Manual Correlation


Test your understanding of this lesson by answering the following questions: 1. How can parameterizing a recorded Vuser script expose data dependencies? ________________________________________________________________________ ________________________________________________________________________ 2. What usually indicates that your Vuser script has dynamic data which is dependent on your parameterized fields? ________________________________________________________________________ ________________________________________________________________________ 3. What technique should you use to find dynamic dependent data caused by parameterization? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________

Manual Correlation 8-61

8-62 LoadRunner for the Web 7.0

Automatic Correlation After Recording

Automatic Correlation After Recording 9-1

2EMHFWLYH
In this lesson, you will learn how to correlate data automatically after recording

9-2 LoadRunner for the Web 7.0

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

2.1 Record User Actions 2.2 Add LoadRunner transactions 2.3 Add verification checks 2.4 Parameterize Input Data 2.5 Correlate reused data 2.6 Verify correct execution
3

Automatic Correlation After Recording 9-3

$ERXW $XWRPDWLF &RUUHODWLRQ $IWHU 5HFRUGLQJ


To work correctly, automatic correlation requires at least one playback Web pages captured during playback are needed to compare to Web pages captured during recording After playback, use the Scan for Correlations tool

9-4 LoadRunner for the Web 7.0

PROCESS

+RZ WR &RUUHODWH $XWRPDWLFDOO\ $IWHU 5HFRUGLQJ


1. Enable saving of replay correlation information 2. Play back the script in VuGen 3. Select the most recent replay results 4. Perform the scan 5. Correlate 6. Verify correct execution

Automatic Correlation After Recording 9-5

 (QDEOH &RUUHODWLRQ
In the Correlation tab of General Options: 1. Check Save correlation information during replay 2. Check Show Scan for correlations popup after replay of Vuser

Open the General Options dialog box by selecting Tools > General Options. Save correlation information during replay means to capture the Web pages returned by the server when you play back the recorded script. That must be done so that VuGen has something to compare to the Web pages captured during recording. If you dont check this option, LoadRunner will have nothing to compare with the Web pages captured during recording, and therefore will be unable to correlate data. Checking Show scan for correlations popup is optional because there are other ways to start a scan after playback:
s s s

click the Scan toolbar button select Vuser > Scan press Ctrl + F8

9-6 LoadRunner for the Web 7.0

 3OD\ %DFN 6FULSW LQ 9X*HQ


Enable Generate report and Display report If Test Results show failure, correlation may be needed at the failing step

Automatic Correlation After Recording 9-7

 6HOHFW 0RVW 5HFHQW 5HVXOWV

If Vuser ran only once, skip this step 3.1 Click Select Test Results button 3.2 Select most recent result file
8

If the Vuser has been run more than once, and changes were made to the Vuser, scanning previous result files might yield incorrect results. NOTE: Ignore the Iteration 0 folder.

9-8 LoadRunner for the Web 7.0

 3HUIRUP $XWRPDWLF 6FDQ


Click Yes in "Scan for correlation" popup

Or, if the popup was not enabled: click the Scan toolbar button select Vuser > Scan press Ctrl+F8
9

Automatic Correlation After Recording 9-9

 &RUUHODWH
VuGen lists the scan results in the Correlation Results tab Click Correlate All to see if VuGen can accomplish the correlation

The rightmost column, Count, indicates the number of occurrences of that difference between the recorded snapshots.

10

9-10 LoadRunner for the Web 7.0

$IWHU &RUUHODWLRQ

LR web functions added to script

Correlation succeeded

Correlation Results tab


11

Automatic Correlation After Recording 9-11

$IWHU &RUUHODWLRQ6FULSW 9LHZ


2 values captured with web_reg_save_param

2 parameters substituted for recorded values

12

9-12 LoadRunner for the Web 7.0

/RDG5XQQHU ([SHUW :RUNIORZ =RRPLQJ ,Q


Phase 1
Plan Load Test

Phase 2
Create Web Virtual Users

Phase 3
Create Scenarios

Phase 4 Run Scenarios

Phase 5 Analyze System Under Load Tune System Based on Analysis

2.1 Record User Actions 2.2 Add LoadRunner transactions 2.3 Add verification checks 2.4 Parameterize Input Data 2.5 Correlate reused data 2.6 Verify correct execution
13

Automatic Correlation After Recording 9-13

 9HULI\ &RUUHFW ([HFXWLRQ

Check the Test Results window

14

9-14 LoadRunner for the Web 7.0

6XPPDU\
Automatic correlation after recording: requires that Save correlation information during replay be enabled in the Correlation tab of the General Options dialog requires at least one playback of the script is accomplished using the Scan for Correlations tool and the buttons in the Correlation tab adds the same web_reg_save_param function used for manual correlation

15

Automatic Correlation After Recording 9-15

9-16 LoadRunner for the Web 7.0

Planning Specification (continued):


Book a Flight
USER ACTIONS
1 Invoke the Web browser, type http://localhost/MercuryWebTours/ for the URL address and press Enter. Type the name in the User Name box. Type the password in the Password box.

EXPECTED RESULTS
The Mercury Tours home page appears. The members login name appears in the Member name box. The members password appears as a string of asterisks in the Password box. The Mercury Tours FLIGHT FINDER page appears. The Find Flight page appears with the following flight information fields: - Type - Passengers - Departing From - On - Arriving In - Returning - Service Class - Airline The SELECT FLIGHT page appears and returns all values of available flights. The BOOK A FLIGHT page appears. - First Name - Last Name - Number

2 3

4 5

Click the Sign-In button. Type the following data in the indicated fields on the FLIGHT FINDER page.

Click the CONTINUE button.

7 8

Select the first available flight and click the CONTINUE button. Type the following data in the indicated fields on the BOOK A FLIGHT page.

Automatic Correlation After Recording 9-17

USER ACTIONS
9 Click the SECURE PURCHASE button.

EXPECTED RESULTS
The FLIGHT CONFIRMATION page appears. It contains confirmation of the reserved flight, and the flight and customer details.

10

Verify that the FLIGHT CONFIRMATION page appears, and that the page contains the text Your itinerary has been booked!. Verify the flight number. Flight details appear in the FLIGHT CONFIRMATION page.

11

9-18 LoadRunner for the Web 7.0

Exercises

Run Vuser
1. Open Lab8vuser1 and save it as Lab9vuser1. NOTE: If you did not complete Lab8vuser1 successfully, you can use \web_project\solutions\_Lab8vuser1. 2. Make sure that the following General Options are set in the Correlation tab. Dont change any other options if they are not in the table Select Tools > General Options.

GENERAL OPTION, CORRELATION TAB Save correlation information during replay Show Scan for correlations pop-up after replay of Vuser Show only differences that appear in script Enable Scripting and Java applets on Snapshots viewer Download images on Snapshots viewer Scan for differences . . . snapshots using: HTML comparison

VALUE checked unchecked checked unchecked checked selected

3. Make sure that the Run-Time Settings conform to those in the following table:

TAB Pacing Log

SETTING set Iteration count to 4 select Extended log check Parameter substitution uncheck Data returned by server check Verification checks

Preferences

4. Run the Vuser script, then examine the Test Results.

Automatic Correlation After Recording 9-19

Did the Vuser script play back successfully? ________________________________________________________________________ Did the first iteration use the same fromPort and toPort as when you first recorded? Did the first iteration succeed? ________________________________________________________________________ Which iterations failed? What does this usually indicate? ________________________________________________________________________ Which step failed in the iterations that failed? ________________________________________________________________________ What was the error message displayed on the page for that step in Test Results? ________________________________________________________________________ 5. Close the Test Results window and the Run-Time Viewer.

Fix Vuser with Automatic Correlation


Which iteration will you choose for comparison with the recorded ReservationServlet step? ________________________________________________________________________ 1. Open the results for the last iteration. Click the Select Test Result button in the Page View, Snapshot of Recording pane. The Select Test Result dialog opens. Select the last iteration of the last result in the list and click OK. The recorded results for that iteration are displayed in the Snapshot of Result pane. NOTE: If you dont see the Select Test Result button, select View > Snapshot from VuGens main menu. (Do not select View > Test Results.)

9-20 LoadRunner for the Web 7.0

2. Compare the recorded and replay text. Click the Scan for Correlations button in the VuGen toolbar. What differences between the recorded and replayed text did the Correlation Results tab display? ________________________________________________________________________ 3. Correlate the differences. Click the Correlate All button in the Correlation Results tab. Click Yes to the confirmation message. Was the correlation successful? How could you tell? ________________________________________________________________________ What changes did automatic correlation make to the script? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 4. Save the script as Lab9vuser2. 5. Run Lab9vuser2. Accept the default results directory and click OK. Did all 4 iterations pass this time? ________________________________________________________________________ 6. Close the Test Results window and Lab9vuser2.

Automatic Correlation After Recording 9-21

Review Questions
Validate your understanding of this lesson by answering the following questions: 1. Why do you need at least one playback for automatic correlation after recording to work properly? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 2. Under what conditions will you choose to use automatic correlation during recording? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________

9-22 LoadRunner for the Web 7.0

Automatic Correlation During Recording

Automatic Correlation During Recording 10-1

10

2EMHFWLYHV
In this lesson, you will learn how to: correlate data automatically during recording define your own rules for automatic correlation

10-2 LoadRunner for the Web 7.0

10

:KHQ WR &RUUHODWH 'XULQJ 5HFRUGLQJ


Correlate during recording when: The Web application server is on the Recording Options list of known server types The session has a known context You can determine rules for correlation

Known context refers to the behavior of the Web application server. It means that the rules for correlating dynamic data are known for a specific server. For example, LoadRunner knows that for a BroadVision server, a session ID follows the string BV_SessionID=@@@@ and precedes @@@@. If you are familiar with a Web application server that is not one for which LoadRunner has built-in rules, LoadRunner provides a means for you to create the rules to automate the data correlation process for that server. Those means are discussed later in this lesson.

Automatic Correlation During Recording 10-3

10

$ERXW $XWRPDWLF &RUUHODWLRQ 'XULQJ 5HFRUGLQJ


LoadRunner can correlate dynamic data within known application environments Correlation during recording is accomplished using the Correlation Recording Options Set correlation options before you record a script If VuGen finds server-generated data that is used again in the recorded action, VuGen automatically correlates it (or prompts the user)

10-4 LoadRunner for the Web 7.0

10

3URFHGXUH WR $XWRPDWH &RUUHODWLRQ 'XULQJ 5HFRUGLQJ


1. Set correlation recording options 2. Record 3. Verify correct execution

Automatic Correlation During Recording 10-5

10

1. SET CORRELATION RECORDING OPTIONS

(QDEOH &RUUHODWLRQ
1.1 Open the Recording Options dialog, Correlation tab 1.2 Check Enable correlation system-wide to enable all other options 1.3 Check Auto-detect specific web servers to enable the Required server types list and the When detected, do this options

Currently, the Auto Detect option works for the following application server types:
s s s s s s s

AribaBuyer BlueMartini BroadVision InterStage MySap NetDynamics SilverJRunner

10-6 LoadRunner for the Web 7.0

10

1. SET CORRELATION RECORDING OPTIONS

8VLQJ $XWR'HWHFW
1.4 Check a When detected, do this option Checking Issue online message allows user to decide whether to correlate case-bycase and disables the other options Selecting Perform offline actions and checking Correlate in script automates completely without user intervention
7

If you want correlation to happen automatically and behind the scenes, check Correlate in script. No user intervention during recording is required with this option. If you want to decide whether to correlate on a case-by-case basis, check Issue online message. Create rule(s) only is used for known contexts.

Automatic Correlation During Recording 10-7

10

AUTOMATIC CORRELATION DURING RECORDING

 5HFRUG

2.1 Start recording If Issue online message was checked, the Correlation Warning dialog may appear during recording 2.2 Check a What to do now option: Create rule(s) Correlate in script

You can also create rules and change the level of automation from the Correlation Warning dialog box during recording.

10-8 LoadRunner for the Web 7.0

10

3. VERIFY CORRECT EXECUTION

6HW *HQHUDO 2SWLRQV


Before replaying the script, open the General Options dialog and make sure that: Display tab Generate report... and Display report... are checked Correlation tab Save correlation information during replay is checked

Do this step every time you change a script before using it to test your application.

Automatic Correlation During Recording 10-9

10

3. VERIFY CORRECT EXECUTION

7UHH 9LHZ

VuGen adds web_reg_save_param() to the recording where appropriate

No correlation

Correlated

NOTE: This is the same script used in Lesson 8

10

10-10 LoadRunner for the Web 7.0

10

3. VERIFY CORRECT EXECUTION

6FULSW 9LHZ
NO CORRELATION CORRELATED

Left boundary, right boundary, & occurrence appear in the script view

NOTE: This is the same script used in Lesson 8

11

Automatic Correlation During Recording 10-11

10

3. VERIFY CORRECT EXECUTION

7HVW 5HVXOWV

No correlation

Correlated

NOTE: This is the same script used in Lesson 8

12

10-12 LoadRunner for the Web 7.0

10

AUTOMATIC CORRELATION DURING RECORDING

&UHDWLQJ D 5XOH 
1. Click Define Rules
The Correlation Rules dialog opens

2. Click Add Rule


<New Rule 1> is added to the Rules list user may edit the rule name

13

Automatic Correlation During Recording 10-13

10

AUTOMATIC CORRELATION DURING RECORDING

&UHDWLQJ D 5XOH 
3. Select an Action (type of rule)
Parameterize token in link/form action text user defines boundaries alternate right boundary (optional) instance (optional) Parameterize value extracted from cookie value is extracted from cookie text looks for cookie text in links/form and actions/form fields no boundaries needed Parameterize form field value enter or select field name to parameterize
14

10-14 LoadRunner for the Web 7.0

10

AUTOMATIC CORRELATION DURING RECORDING

&UHDWLQJ D 5XOH 
Right of (boundary) Left of (boundary) OR (alternate right boundary) Instance Match Case Reverse Search Parameter Prefix Always create new parameter

4. Select other options as needed

15

Add right and left boundaries - for the left boundary you may specify End of String or Newline Character in addition to User-defined Text. You may also specify an alternate right boundary. Instance - specify which occurrence of the search text to parameterize Match case - makes the search for boundaries case sensitive Reverse search - look for left boundary from end of the string backwards Parameter prefix - prevent overwriting existing user parameters; easier to recognize the parameter in your script; standardize parameter names Always create new parameter - create a new parameter for this rule even if the value replaced the parameter has not changed from the previous instance. This option should be set if the Web server assigns the token a different value for each page. For example, NetDynamics servers may change the session ID from page to page to minimize fraud.

Automatic Correlation During Recording 10-15

10

AUTOMATIC CORRELATION DURING RECORDING

&UHDWLQJ D 5XOH 
5. Test the rule
A. Click Test B. Enter text in the Source string for substitution box C. Click Test If substitution occurred: The parameterized source text appears in the Substitution Result box A list of the rules applied appears in the Applied Rules box The parameters created and their substituted values are colorcoded in both windows
16

10-16 LoadRunner for the Web 7.0

10

6XPPDU\
Correlate dynamic values during recording when: web application server can be automatically detected session has a known context you can determine rules for correlation Correlation during recording is accomplished using Correlation Recording Options

17

Automatic Correlation During Recording 10-17

10

10-18 LoadRunner for the Web 7.0

Part 4: Advanced Topics

Custom Output Messages

Custom Output Messages 11-1

11

2EMHFWLYHV
In this lesson, you will learn how to: Determine why a Vuser failed Add logic and decision-making to a Vuser script Enhance Vuser output logs Send parameter values to output logs Use the Continue on error run-time setting

11-2 LoadRunner for the Web 7.0Advanced

11

:KDW &DQ WKH 9XVHU 7HOO <RX"


Enhance Vuser Output Logs Return code of the Check statement Value of an input parameter Error message Transaction status

Custom Output Messages 11-3

11

REVIEW

.H\ 7HUPV 8VHG LQ 7KLV &RXUVH

)XQFWLRQDO 7HVWLQJ 8QGHU /RDG


Confirms that all business processes complete properly while the server handles concurrent usage.

11-4 LoadRunner for the Web 7.0Advanced

11

REVIEW

7\SHV RI &KHFNV
Check Text Example usage Did a search engine return expected matches?

Image

Did the news site display the picture?

Custom Output Messages 11-5

11

REVIEW

9HULI\ WKDW %XVLQHVV 3URFHVV :RUNV &RUUHFWO\


...
Action1.c(15):Transaction Login started.

OUTPUT LOG

...
Action1.c(46):Transaction Login ended with Pass status (Duration: 1.7090). Action1.c(47):The test step: "Submit Form: reservation.pl" succeeded. Action1.c(54):Transaction InsertSalesOrder started. Action1.c(55):Starting Step - "Submit Form: SalesOrder". Action1.c(57)Transaction DB_InsertOrder started.

...
Action1.c(65):Transaction DB_InsertOrder ended with Pass status (Duration: 3.6320). Action1.c(66):The test step: "Submit Form: reservation.pl" succeeded. Action1.c(68):ERROR: Text Check : VerifyOrderNumber - Failed : Expected "1234", but found "" Starting iteration 2. [MsgId: MMSG-15970] Action1.c(13):Starting Step - "URL: Order Entry Module". Action1.c(15):Transaction Login started.

...

By examining the output log, the LoadRunner Expert can see that the correct order number was not sent back from the Web server.

11-6 LoadRunner for the Web 7.0Advanced

11

:KDW 'R <RX :DQW 7R .QRZ"


Why did the check fail (in greater detail)? What was the input data for that iteration? What dynamic values were captured during that iteration?

Action1.c(15):ERROR: Text Check: VerifyOrderNumber - Failed : Expected "1234", but found ""

Custom Output Messages 11-7

11

(QKDQFH 9XVHU 2XWSXW /RJV


1. Capture the return code of the Check statement.

You can make the output log more informative by modifying the Vuser script with LoadRunner functions and variables.

11-8 LoadRunner for the Web 7.0Advanced

11

&KHFN 6WDWHPHQWV 5HWXUQ D 9DOXH


Check Status LR_PASS

LR_PASS

web _find web _image_check

;
LR_FAIL

LR_PASS equals 0 LR_FAIL equals 1

Custom Output Messages 11-9

11

 &DSWXUH 5HWXUQ &RGH RI WKH &KHFN 6WDWHPHQW


1.1 Declare an integer variable to capture the return code of the check 1.2 Assign the result of the check statement to the variable

int rc; . . . . rc = web_find ("Verify_Order_Number", "RightOf=Order No.:,", "LeftOf=, has been processed", "what=1234", LAST);

10

The declaration statement may go either inside or outside the brackets of Action1(). In this example, the variable rc (return code) is defined as an integer. This is done because LR_PASS and LR_FAIL are integer values. On playback, the return code is stored in rc where it can be accessed by the script and your code.

11-10 LoadRunner for the Web 7.0Advanced

11

(QKDQFH 9XVHU 2XWSXW /RJV


1. Capture the return code of the Check statement. 2. Compare the return code to LR_FAIL.

11

Custom Output Messages 11-11

11

 &RPSDUH 5HWXUQ &RGH WR /5B)$,/


rc = web_find ("Verify_Order_Number", "RightOf=Order No.:,", "LeftOf=, has been processed", "what=1234", LAST); if (rc == LR_FAIL)

NOTE: Comparisons require "==", and assignments require "=".


12

Create a condition to check whether the value of the return code (rc) matches an LR_FAIL status. Follow C programming syntax when editing the Vuser script.

11-12 LoadRunner for the Web 7.0Advanced

11

(QKDQFH 9XVHU 2XWSXW /RJV


1. Capture the return code of the Check statement. 2. Compare the return code to LR_FAIL. 3. If return code == LR_FAIL, send a problem description to the output log.

13

Custom Output Messages 11-13

11

 ,I UF /5B)$,/ 6HQG 3UREOHP 'HVFULSWLRQ WR 2XWSXW /RJ


Use lr_error_message ("string");

A formatted string, which is the message to be sent to the Output window You may use the standard formatting conventions which are available for printf in C

14

The lr_error_message statement takes a formatted string and sends it to the Vuser output log. The first character of the format argument is always a percent sign (%). The last character of format is a letter code that determines the type of formatting. One or more format modifiers can appear between the first and last character of the format argument (see below). The possible letter codes are as follows: c d e f g o s x % Prints a character from its decimal ASCII code. Prints the decimal integer portion of a number. Converts input to scientific notation. Pads with zeros to the right of the decimal point. Prints a decimal value while suppressing non-significant zeros. Prints the octal value of the integer portion of a number. Prints an unmodified string. Prints the hexadecimal value of the integer portion of a number. Prints a literal percent sign (%).

11-14 LoadRunner for the Web 7.0Advanced

11

 ,I UF /5B)$,/ 6HQG 3UREOHP 'HVFULSWLRQ WR 2XWSXW /RJ


lr_error_message ("Order Number was not sent from server." ); lr_error_message ("Check that Vendor was correct." );

OrderClerk.c(3):ERROR: Order Number was not sent from server. OrderClerk.c(4):ERROR: Check that Vendor was correct.

15

Add the lr_error_message statement describing the error in the condition that checks for the FAIL status of the return code. You can also use the statement lr_set_debug_message to toggle output logging on and off. Using this function may be preferable to changing logging in the Run-Time Settings dialog, because you can turn it on for a single step if you want. The syntax is:
lr_set_debug_message(type, ON|OFF);
s s

type may be either extended or brief. ON = 1; OFF = 0.

Custom Output Messages 11-15

11

 ,I UF /5B)$,/ 6HQG 3UREOHP 'HVFULSWLRQ WR 2XWSXW /RJ


rc = web_find ("Verify_Order_Number", "RightOf=Order No.:,", "LeftOf=, has been processed", "what=1234", LAST); if (rc == LR_FAIL) { lr_error_message ("Order Number not sent from server." ); lr_error_message ("Check that Vendor was correct." );

16

11-16 LoadRunner for the Web 7.0Advanced

11

(QKDQFH 9XVHU 2XWSXW /RJV


1. Capture the return code of the Check statement. 2. Compare the return code to LR_FAIL. 3. If return code == LR_FAIL, send a problem description to the output log. 4. Transform input parameters to output messages.

17

Custom Output Messages 11-17

11

 7UDQVIRUP ,QSXW 3DUDPHWHUV ,QWR 2XWSXW 0HVVDJHV


Use lr_eval_string ( "{parameter name}");

Name of parameter whose value you want to retrieve This function returns a string representation of the value of a specified parameter

18

11-18 LoadRunner for the Web 7.0Advanced

11

 7UDQVIRUP ,QSXW 3DUDPHWHUV ,QWR 2XWSXW 0HVVDJHV


lr_error_message ("Vendor: %s", lr_eval_string("{Vendor}" ) ); lr_error_message ("Material No.: %s", lr_eval_string("{Material_Nm}" ) );

OrderClerk.c(5):ERROR: Vendor: 7832 OrderClerk.c(6):ERROR: Material No.: ST-34922

19

In this example, %s indicates that the format of the parameter is string. Note that, by default, a parameter in a Vuser script is enclosed by { }. However, the character that encloses a parameter can be changed by the user. The lr_eval_string returns the data in the data file as a string, which can then be printed out to the output log via the lr_error_message statement.

Custom Output Messages 11-19

11

 7UDQVIRUP ,QSXW 3DUDPHWHUV ,QWR 2XWSXW 0HVVDJHV


if (rc == LR_FAIL) { lr_error_message ("Order Number not sent from server." ); lr_error_message ("Check that Vendor was correct." ); lr_error_message ("Vendor: %s", lr_eval_string("{Vendor}" ) ); lr_error_message ("Material No.: %s", lr_eval_string("{Material_Nm}"));

20

11-20 LoadRunner for the Web 7.0Advanced

11

(QKDQFH 9XVHU 2XWSXW /RJV


1. Capture the return code of the Check statement. 2. Compare the return code to LR_FAIL. 3. If return code == LR_FAIL, send a problem description to the output log. 4. Transform input parameters to output messages. 5. Stop execution of the Vuser.

21

Custom Output Messages 11-21

11

 6WRS ([HFXWLRQ RI WKH 9XVHU


Use return (value);

A numeric code which specifies how VuGen will stop execution (0) (-1) Stops the current iteration Stops the Vuser entirely

22

The body of a Vuser is actually a C function called Action1 by default. As noted in the Action Files lesson, that function can be renamed by the user. As in C, the return statement returns a value and stops the function execution which ultimately stops the Vusers iteration.

11-22 LoadRunner for the Web 7.0Advanced

11

:KLFK 0HWKRG RI 6WRSSLQJ WKH 9XVHU 6KRXOG , 8VH"

Use return(0); if the Vuser can recover from the failure by starting the next iteration and using different data

The Vendor number doesnt work with the warehouse number, so the business process will fail

Use return(-1); if the error is fatal, such that the Vuser cannot continue to run

Web sites default page could not load

23

Custom Output Messages 11-23

11

 6WRS ([HFXWLRQ RI WKH 9XVHU


if (rc == LR_FAIL) { lr_error_message ("Order Number not sent from server." ); lr_error_message ("Check that Vendor was correct." ); lr_error_message ("Vendor: %s", lr_eval_string("{Vendor}" ) ); lr_error_message ("Material No.: %s", lr_eval_string("{Material_Nm}")); return(0); }

24

11-24 LoadRunner for the Web 7.0Advanced

11

(QKDQFH 9XVHU 2XWSXW /RJV


1. Capture the return code of the Check statement. 2. Compare the return code to LR_FAIL. 3. If return code == LR_FAIL, send a problem description to the output log. 4. Transform input parameters to output messages. 5. Stop execution of the Vuser. 6. Enable the run-time setting: Continue on error.

25

Custom Output Messages 11-25

11

&RQWLQXH 2Q (UURU
By default, VuGen and Controller stop an iteration when an error occurs Continue on error allows the Vuser to execute succeeding statements (if possible) Also allows you to program logic into your Vuser optional business process navigation re-submit a form

26

11-26 LoadRunner for the Web 7.0Advanced

11

 (QDEOH &RQWLQXH RQ (UURU


If Continue on error is not set, LoadRunner stops an iteration the moment a check fails In that case, any output message statements are not executed, because they follow the failed check
27

Custom Output Messages 11-27

11

 (QDEOH &RQWLQXH RQ HUURU


E x e c u t i o n

rc = web_find ("Verify_Order_Number", "RightOf=Order No.:,", "LeftOf=, has been processed", "what=1234", LAST);

STOP

if (rc == LR_FAIL) { lr_error_message ("Order Number ... lr_error_message ("Check that ... lr_error_message ("Vendor: %s", lr_error_message ("Material No.: %s", return(0); }

E x e c u t i o n

28

If Continue on error is disabled in this example, the if statement would not be executed. The iteration would stop the moment the web_find function failed. If Continue on error is enabled and an error occurs, an error message is sent to the output log and the Vuser continues running, if possible. As a rule, Continue on error should be disabled. This setting should be made decisively. If the Vuser were composed of context sensitive statements, during playback the execution would continue after an error but the Vuser would no longer be emulating a real user. In that case the test results would be skewed.

11-28 LoadRunner for the Web 7.0Advanced

11

WARNING

8VH &DXWLRQ ZLWK &RQWLQXH RQ HUURU

RULE OF THUMB

Enable Continue on error only when making output logs more informative or adding logic to the Vuser. Otherwise, undesired results may occur.

29

Custom Output Messages 11-29

11

3XWWLQJ LW $OO 7RJHWKHU


int rc; ....... ....... rc = web_find ("Verify_Order_Number", "RightOf=Order No.:,", "LeftOf=, has been processed", "what=1234", LAST); if (rc == LR_FAIL) { lr_error_message ("Order Number not sent from server." ); lr_error_message ("Check that Vendor was correct." ); lr_error_message ("Vendor: %s", lr_eval_string("{Vendor}" ) ); lr_error_message ("Material No.: %s", lr_eval_string("{Material_Nm}")); return(0); }
30

Because the Vuser script is a C program, you can add any C function to it or use any C constructs (e.g., for-loop, while-loop, etc.). LoadRunner Experts might want to add more logic to the Vuser to control multiple page navigation, or to add a loop that re-submits a form when the server is busy.

11-30 LoadRunner for the Web 7.0Advanced

11

6XPPDU\
Troubleshoot failed Vusers Determine the reason a Vuser failed Capture check statement return codes Add logic and decision-making to the Vuser script Enhance Vuser output logs
insert problem description based on return code insert parameter values

Use the Continue on error run-time setting

31

Custom Output Messages 11-31

11

11-32 LoadRunner for the Web 7.0Advanced

11

Exercises

Exercise A: Returning an Informative Error Message


Exercise objective: To create a Vuser able to return a more informative error message if it fails to submit a flight reservation request successfully.

Record Vuser to Book a Flight


Record a Vuser script that signs in, purchases a flight, and verifies that the reservation request was successful. 1. Create a new Web Vuser in VuGen, and begin recording. 2. Sign in to the demo Web site. 3. Click the CONTINUE button on the FLIGHT FINDER page. 4. Click the CONTINUE button on the SELECT FLIGHT page. 5. Type in a name and card number on the BOOK A FLIGHT page, then click SECURE PURCHASE. 6. Insert a text checkpoint to verify the text Your itinerary has been booked on the FLIGHT CONFIRMATION page. 7. Click SIGN-OFF. 8. Stop recording. 9. Save the Vuser as: \web_project\Vusers\Lab11original

Custom Output Messages 11-33

11

Edit the Vuser Script


1. Save the script again as: Lab11vuser1 2. Switch to Script View to see the Vuser script as text. Which statement verifies that the flight reservation request was successful? ________________________________________________________________________ To make output logs more informative, for what type of statement would you want to monitor the return code? Why? ________________________________________________________________________ ________________________________________________________________________ How can you capture the return code? ________________________________________________________________________ ________________________________________________________________________ Where in your Vuser script do you need to initialize your return code variable? What is the data type of the return code variable? ________________________________________________________________________ ________________________________________________________________________ 3. Initialize rc as the variable to capture your return code. 4. Assign the return code of the web_find statement to rc. What return code value indicates that the check failed? What return code value indicates that the check succeeded? ________________________________________________________________________

11-34 LoadRunner for the Web 7.0Advanced

11

What condition should you use to decide whether you need to return an output message? ________________________________________________________________________ What statement can you use to send a message to the Execution Log? ________________________________________________________________________ What value should you return to stop an iteration? ________________________________________________________________________ 5. Insert logic to send a message and stop the iteration if the check fails. If the web_find fails, your script should return the following error message:
Business Process error. Flight was not purchased.

After returning the message, the code should stop the current iteration. 6. Run the modified script to verify correct execution.

Break here for class discussion.

Custom Output Messages 11-35

11

Reconfigure the Server Options


1. Open the demo Web server in your browser. (Dont record this.) 2. Sign in as admin with password mercury. 3. Reconfigure the server options. On the MERCURY TOURS ADMINISTRATION page, check the box next to Database Error. Click the SUBMIT button. 4. Close the browser after the Sign-in page reappears.

Verify Correct Execution


1. Make sure that the Run-Time Settings conform to those in the following table:

TAB Pacing Preferences General

SETTING set Iteration count to 2 Check Verification checks select Continue on error

Why is it necessary to select Continue on error in the Run-Time Settings? ________________________________________________________________________ 2. Play back the Vuser script. 3. Review the Test Results. Did the first iteration pass? How many iterations did VuGen run? ________________________________________________________________________

11-36 LoadRunner for the Web 7.0Advanced

11

When an iteration failed, what page was returned instead of the FLIGHT CONFIRMATION page? ________________________________________________________________________ The Web server returned an error page in response to which submit statement? ________________________________________________________________________ ________________________________________________________________________ What line in the Execution Log was returned by your error message statement? ________________________________________________________________________ 4. When you have finished examining the results, close the Test Results window, the Run-Time Viewer, and the Vuser.

5. Reset the demo Web server to its default state. Sign in as admin with password mercury. Make sure that all boxes are unchecked, then click SUBMIT.

Custom Output Messages 11-37

11

Review: Custom Output Messages


Test your understanding of this lesson by answering the following questions: 1. For what purpose should you select Continue on error? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 2. When would you want to stop an iteration? When would you want to stop a Vuser? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 3. If your Vuser script had two parameters, DepartCity and ArrivalCity, how could you have the Vuser script return an error message which included the city names? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________

11-38 LoadRunner for the Web 7.0Advanced

Understanding Record and Playback

Understanding Record and Playback 12-1

12

2EMHFWLYHV
In this lesson, you will learn: VuGens mechanism of recording The difference between URL and HTML recording and replay Advantages and disadvantages of URL and HTML recordings How to make use of multiple actions within one Vuser

12-2 LoadRunner for the Web 7.0Advanced

12

HTML and URL Recording Modes

Understanding Record and Playback 12-3

12

REVIEW

9X*HQ 5HFRUGLQJ 0RGHV


There are two ways to record: HTML (browser/context sensitive) URL (HTTP/analog) Set the recording mode in Recording Options before you start recording

12-4 LoadRunner for the Web 7.0Advanced

12

+RZ 9X*HQ 5HFRUGV +773 5HTXHVWV


1. VuGen launches the browser with a web_url request to capture the HTTP requests that are sent. 2. VuGen stores the page returned by the server in the Record Proxy cache.

Understanding Record and Playback 12-5

12

VUGEN RECORDING PROCESS

%URZVHU /DXQFKHG DQG 3UR[LHV 6HW


1. VuGen launches the browser with a web_url request to capture the HTTP requests that are sent.

Record Proxy

Native Proxy

:(% 6(59(5

1999 Microsoft Corporation. All rights reserved.

http://www.hotmail.com

During recording, VuGen traps all HTTP traffic by using its own record proxy. When you begin recording in VuGen, you must specify the root URL of the Web site under test. VuGen then:
s s

launches the browser on the desktop. sets the browsers proxy settings to the VuGen record proxy, so the browser will send all HTTP requests to the record proxy during recording. sets the record proxy settings of the original/native proxy so that the HTTP request can be forwarded from the record proxy to the native proxy server.

After this process is complete, when the browser requests the root page to be sent from the server, the HTTP request goes through the record proxy for recording. Responses also pass through the record proxy for display in the browser. Note: If there isnt a native proxy server, the record proxy will just send all HTTP requests to the Web server.

12-6 LoadRunner for the Web 7.0Advanced

12

VUGEN RECORDING PROCESS

5HWXUQHG 3DJH 6WRUHG LQ &DFKH


2. VuGen stores the page returned by the server in the Record Proxy cache.
R E GI STE R ED U S ER S Login Name Password Enter
Frames No Frames My Default

VISITORS

IN FO

cache

Record Proxy

Native Proxy

:(% 6(59(5

1999 Microsoft Corporation. All rights reserved.

http://www.hotmail.com

Once an HTTP request is sent to the server, the resulting page that is sent back for display is also saved in the record proxy cache. VuGen will always save the last page sent from the server in its cache. The following slides discuss why VuGen does that.

Understanding Record and Playback 12-7

12

+70/ YV 85/ 


web_submit_form("start", ITEMDATA, "name=user", "value=steve", ENDITEM, "name=password", "value=dude", ENDITEM, LAST);

HTML

URL

web_submit_data("start", "Action=login.asp", "Method=POST", ITEMDATA, "name=user", "value=steve", ENDITEM, "name=password", "value=dude", ENDITEM, "name=sessionID", "value=15379", ENDITEM, LAST);
8

Comparing the two statements, notice that the web_submit_data statement recorded the Action object, the request method and the hidden data field. This ensures that on playback, web_submit_data sends all items embedded in the statement to the server, and the server retrieves the necessary information to send the resulting page. How does the web_submit_form play back such that the Web server knows the necessary information to send the resulting page?

12-8 LoadRunner for the Web 7.0Advanced

12

+70/ YV 85/ 


HTML Statement Some necessary information not included in new request VuGen searches cache for result of last request If cached information matches new request, VuGen records web_submit_form URL Statement Contains all information necessary to complete new request Memory is not searched VuGen records web_submit_data

Understanding Record and Playback 12-9

12

+70/ 6WDWHPHQWV
Statements that can be executed only within the context of the last request
STATEMENT Page produced by last HTTP Request It MUST be present for Context Sensitive statements to play back CACHED DATA

web _submit_form

Action Method Hidden Data Action (name of link) Action (name of image)

web _link

web _image

10

Because web_submit_form relies on the result of the last request to be in memory, it must succeed the appropriate step or it wont play back correctly. This means that it is a context sensitive statement. It must be replayed in the context of the result of the last statement.

12-10 LoadRunner for the Web 7.0Advanced

12

HOW DOES VUGEN PLAY BACK STATEMENTS?

85/ ([DPSOH ZHEBXUO

web_url("www.hotmail.com", "URL=http://www.hotmail.com/", 1 HTTP Request "TargetFrame=_TOP", LAST); web_submit_form("start", ITEMDATA, "name=user", "value=steve", ENDITEM, "name=password", "value=dude", ENDITEM, LAST);

:(% 6(59(5

... <Form Action=login.asp Method="POST"> <input name=user value=""> <input name=password value=""> <input name=sessionID value=15380> </Form> ...

2
Result of HTTP Request

11

Playback begins with the web_url statement: 1. The web_url statement sends a request to the Web server. web_url is an analog statement. Therefore, the URL was hard-coded during recording, and that recorded URL was sent to the server during playback. 2. The Web server processes the request and sends an HTML page back to VuGen. VuGen caches the returned pages source HTML. Notice that the session ID returned by the server during the first playback (15380) was different than the session ID that was recorded (15379). The recording and the playback each took place during different Web server sessions.

Understanding Record and Playback 12-11

12

HOW DOES VUGEN PLAY BACK STATEMENTS?

+70/ ([DPSOH ZHEBVXEPLWBIRUP


web_submit_form("start", ITEMDATA, "name=user", "value=steve", ENDITEM, "name=password", "value=dude", ENDITEM, LAST); Action? login.asp POST login.asp HTTP/1.1 3 user=steve password=dude sessionID=15380

1 Method?
Hidden data?

2 POST
sessionID=15380

:(% 6(59(5

4
NEW PAGE REPLACES OLD PAGE Result of HTTP Request

12

Playback continues with the context sensitive web_submit_form statement: 1. VuGen first checks the cache for the values needed by the web_submit_form statement: action, method and hidden data. 2. The values are in the cache, so VuGen retrieves them. In this example the action, method and hidden data values were login.asp, POST, and sessionID = 15380 respectively. 3. VuGen sends the web_submit_form statement with the retrieved values to the server. 4. The server processes this request and returns the next page, which is then cached in turn. The playback of the context sensitive statement was successful even though the sessionID was dynamic, because the data were not hardcoded.

12-12 LoadRunner for the Web 7.0Advanced

12

HOW DOES VUGEN PLAY BACK STATEMENTS?

85/ ([DPSOH ZHEBVXEPLWBGDWD


web_submit_data("start", "Action=login.asp", "Method=POST", ITEMDATA, "name=user", "value=steve", ENDITEM, "name=password", "value=dude", ENDITEM, "name=sessionID", "value=15379", ENDITEM, LAST); cache is not searched POST login.asp HTTP/1.1

1 user=steve

password=dude sessionID=15379

:(% 6(59(5

2
ERROR! Session IDs do not match! Result of HTTP Request

13

What if the second statement played back had been analog rather than context sensitive? In that case, it would have been web_submit_data rather than web_submit_form. Also, the action, method, and hidden data would have been hard-coded in the script. 1. The originally recorded action, method, and hidden data values are sent back to the server (in this example, login.asp, POST, and sessionID= 15379). Because the web_submit_data statement had all the information needed to make the request, VuGen did not query the cache for the values. The hidden value for sessionID, 15379, that was originally recorded was sent to the server regardless of the value just returned by the server for this new session. 2. The server returns an error page to the browser (and to VuGens cache). During playback the server expected sessionID=15380 (not 15379), because this was a new server session, with an id that was different than the one when the recording took place. In this case playback was not successful.

Understanding Record and Playback 12-13

12

%HQHILWV RI +70/ 5HFRUGLQJ


REDUCES NEED TO CAPTURE DYNAMIC VALUES Action tag values and hidden data are NOT hard coded They are retrieved from memory during playback If they are dynamic, the Vuser still runs Script is as big as business processone step per page

14

12-14 LoadRunner for the Web 7.0Advanced

12

'LVDGYDQWDJHV RI +70/ UHFRUGLQJ


SCRIPTS ARE LESS SCALABLE Memory (cache) is searched during playback Requires more memory Requires more CPU power

15

Understanding Record and Playback 12-15

12

%HQHILWV RI 85/ 5HFRUGLQJ


FLEXIBILITY AND SCALABILITY Scripts are about more scalable than HTML scripts Support for Java Applets and ActiveX objects on the page Ability to replay on Unix

16

12-16 LoadRunner for the Web 7.0Advanced

12

'LVDGYDQWDJHV RI 85/ 5HFRUGLQJ


MORE CORRELATION REQUIRED Scripts require more correlation (nothing is retrieved from cache) Context-sensitive checks wont work (parser is disabled)* Scripts are large (all images and frames are recorded as separate step

* Use web_reg_save_param to search for specific text

17

Understanding Record and Playback 12-17

12

Multiple Action Files in a Vuser

12-18 LoadRunner for the Web 7.0Advanced

12

0XOWLSOH $FWLRQ )LOHV LQ 2QH 9XVHU


Reasons to put multiple action files into one Vuser: Emulate real users from User Profile Record application login and logout separately from other user actions Iterate some action files more frequently than others ("weighting")

19

Understanding Record and Playback 12-19

12

,WHUDWH 6RPH $FWLRQV 6HSDUDWHO\


1

Do Login once Login


Select item 1 & put in shopping cart. Select item 2 & put in shopping cart.

Internet

Web server

Do all 3 tasks in 1 Vuser

Checkout Do checkout once


3

Select item & put in cart many times

20

12-20 LoadRunner for the Web 7.0Advanced

12

9XVHU 6FULSW 0RGHO


Login
(recording optional)

User Actions
(Business Processes)

Logout
(recording optional)

Action1.c, Action2.c, etc.


vuser_init.c
(e.g., Select item & put in shopping basket, Checkout)

vuser_end.c

This section may be iterated (repeated) during one test run

21

Understanding Record and Playback 12-21

12

0XOWLSOH $FWLRQ )LOHV LQ 2QH 9XVHU


Record Login in vuser_init Record shopping cart actions in Action1 Record Checkout in Action2 Record Logout in vuser_end

22

12-22 LoadRunner for the Web 7.0Advanced

12

0XOWLSOH $FWLRQ )LOHV LQ 2QH 9XVHU

1. Start recording 2. Select action file 3. Record actions 4. Repeat steps 2 and 3 as necessary 5. Stop recording

23

Understanding Record and Playback 12-23

12

$FWLRQ )LOH :HLJKWLQJ 6HTXHQWLDO $FFHVV 0HWKRG


1. Open Run-Time Settings, Pacing tab. 2. Right-click "Run," and select "Properties." 3. Select "Sequential" from Run logic list and click OK. 4. Right-click "Run" again, and select "Insert Actions." 5. Double-click an action file.
24

12-24 LoadRunner for the Web 7.0Advanced

12

$FWLRQ )LOH :HLJKWLQJ 5DQGRP $FFHVV 0HWKRG


1. In Run-Time Settings Pacing tab, right-click "Run," and select "Properties." 2. Select "Random" from Run logic list and click OK.

25

The default Random percents is equal percentages for each action. In the above example, that is 50% for each of the two.

Understanding Record and Playback 12-25

12

$FWLRQ )LOH :HLJKWLQJ 5DQGRP $FFHVV 0HWKRG


3. Right-click 1st action file and select "Properties." 4. Type a percent and click OK. 5. Repeat for other action files. Total for all action files must be 100%. 6. Set Iteration count appropriately.
This Vuser needs at least 3 iterations to make accurate weighting more probable

26

In practice, you should iterate a Vuser many more than the minimum number of times to ensure that accurate weighting is accomplished.

12-26 LoadRunner for the Web 7.0Advanced

12

6XPPDU\
Data in an HTTP request may be hidden and dynamic In HTML recording mode VuGen stores pages returned by the server in its cache HTML statements retrieve data from cache if data is dynamic, Vuser still replays less need to capture dynamic values HTTP statements contain all necessary information more scalable more work required to make scripts replay Multiple action files in a Vuser may emulate real users better allow action file "weighting"
27

NOTE: If VuGen crashes during recording: 1. Go to your browsers LAN settings. 2. Make sure that Use a proxy server is either unchecked or set to the right port. If Use a proxy server is checked and set to a local port, you wont be able to connect to the internet!

Understanding Record and Playback 12-27

12

12-28 LoadRunner for the Web 7.0Advanced

12

Review Questions

Multiple Actions in One Vuser


1. What are the benefits of creating multiple actions within a Vuser? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________

Different Types of Data


2. Why do Web developers use hidden data when creating interactive Web sites? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________

HTTP Requests
3. What information is typically sent in an HTTP request? ________________________________________________________________________ ________________________________________________________________________

Understanding Record and Playback 12-29

12

4. What are the different ways a Web developer can create an HTTP request? ________________________________________________________________________ ________________________________________________________________________ 5. During recording, what is saved in the record proxy cache? ________________________________________________________________________ ________________________________________________________________________ 6. VuGen can parse HTML in memory. True or False? ________________________________________________________________________

Recording Process
7. When does VuGen record a web_submit_data instead of a web_submit_form? Why? (Be as specific as possible.) ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________

12-30 LoadRunner for the Web 7.0Advanced

12

Playback Process
8. During the playback of a web_submit_form, where do the values of the action, method, and hidden fields come from? ________________________________________________________________________

9. Provide a definition of a context sensitive statement. Be specific. ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ 10. What is the benefit of context sensitive statements in a Vuser? ________________________________________________________________________ ________________________________________________________________________

Understanding Record and Playback 12-31

12

12-32 LoadRunner for the Web 7.0Advanced

IP Spoofing

IP Spoofing 13-1

13

2EMHFWLYHV
In this lesson, you will learn: How load balancing systems function How routing tables and load balancing systems use IP addresses The importance of IP spoofing to load testing How to implement IP spoofing in LoadRunner

13-2 LoadRunner for the Web 7.0Advanced

13

IP-Specific Load Balancing Systems

IP Spoofing 13-3

13

7KH 5RXWLQJ RI :HE &OLHQW 5HTXHVWV ,V ,3UHODWHG


Databases

Internet users

Application servers Routers Web server

255.7.144.1

203.33.0.253

Load balancing system

121.10.199.25

A load balancing system may distribute requests to application servers and backend databases according to the client IP address
4

Some systems employ load balancing configurations to maximize overall speed and efficiency. Such systems typically use the IP address of the originating client to distribute a request.

13-4 LoadRunner for the Web 7.0Advanced

13

+RZ $UH ,3 $GGUHVVHV 8VHG E\ 5RXWLQJ 7DEOHV"


Routing tables identify a packets next step by looking up the destination IP address

Every IP packet is forwarded by hubs, routers, and Web servers by means of a routing table.

IP Spoofing 13-5

13

5RXWLQJ 7DEOHV 8VH 'HVWLQDWLRQ $GGUHVV WR )LQG D 3DFNHW


V 1H[W 6WHS
This packet from 25.20.255.200 needs to get to 101.101.101.1. Where should I send it next? 25.20.255.200 Client 7.77.77.7

ROUTER 7.77.77.7 Routing Table To 33.33.33.33! 101.101.101.1 Web server Destination 44.4.4.44 95.96.97.9 101.101.101.1 80.8.80.88 212.1.21.212 56.5.65.6 Next step 33.33.33.33 9.1.91.191 33.33.33.33 9.1.91.191 2.2.2.222 2.2.2.222

2.2.2.222 Routers

33.33.33.33

Routers, like hubs and Web servers, know where to send a packet of information by referencing the final destination in its internal routing table and retrieving the IP address of the packets next step.

13-6 LoadRunner for the Web 7.0Advanced

13

:HE 6HUYHUV 8VH WKH &OLHQW


V ,3 $GGUHVV WR 5HWXUQ 5HVXOWV
Databases

Application servers Routers 7.77.77.7 25.20.255.200 Client 101.101.101.1 33.33.33.33 To 33.33.33.33! This packet is a response to a request from 25.20.255.200. Where should I send it next? Web server

2.2.2.222

WEB SERVER 101.101.101.1 Routing Table Destination 25.20.255.200 95.96.97.9 12.10.251.210 8.18.90.89 21.16.21.212 56.117.65.6 Next stop 33.33.33.33 9.1.91.191 53.53.55.5 9.1.91.191 98.2.2. 22 2.2.98.7 7

155.1.1.55

The results of a Web query must be forwarded by the Web server back to the querys originator. The clients IP address is indexed in the Web servers routing table. In the example above, the client at 25.20.255.200 sent a request to the Web server (101.101.101.1), and the request was passed along to the appropriate application and database servers. Their results were sent back to the Web server, which looked up the originating clients IP address, 25.20.255,200, in its routing table. Here the Web server found that packets to that client should be sent to router 33.33.33.33.

IP Spoofing 13-7

13

+RZ $UH ,3 $GGUHVVHV 8VHG E\ /RDG %DODQFLQJ 6\VWHPV"


Load balancing systems specify a backend server based on the IP address which sent the request

Load balancing systems also use the client IP address to direct queries.

13-8 LoadRunner for the Web 7.0Advanced

13

/RDG %DODQFLQJ 6\VWHPV 5HO\ RQ WKH ,3 $GGUHVV RI WKH &OLHQW


Databases Application servers Routers Web server

Virtual users with IP Spoofer 103.14.255.200

200.37.66.9 Requests from 200.37.66.9 go to Database Server 1 Load balancing system Requests from 103.14.255.200 go to Database Server 2

144.100.105.88

Requests from 144.100.105.88 go to Database Server 3 9

Each request is sorted by IP address to a backend destination. In this example, requests from the three browsers were distributed to three different database servers based on their IP addresses.

IP Spoofing 13-9

13

9LUWXDO 8VHUV *HQHUDOO\ 5HVLGH DW D 6LQJOH ,3 $GGUHVV


Databases Application servers Virtual users Routers Web server

200.37.66.9 200.37.66.9 200.37.66.9 200.37.66.9

Load balancing system

Virtual users at one IP address create unrealistic load on routers, application servers, and backend databases
10

If, during load testing, all requests appear to be originating from a single IP address (or a narrow range of IP numbers) the load may not be distributed realistically through various parts of the system.

13-10 LoadRunner for the Web 7.0Advanced

13

EXAMPLES

8QEDODQFHG /RDG 0RGHOLQJ &DXVHV 8QFHUWDLQ 7HVW 5HVXOWV

Virtual users may fail unrealistically

11

An unbalanced load test may invalidate some, if not all, of the test results.

IP Spoofing 13-11

13

Implementing IP Spoofing with LoadRunner

13-12 LoadRunner for the Web 7.0Advanced

13

,3 6SRRILQJ ,VVXHV
Do I need IP spoofing? Yes, if your system uses IPdependent load balancing

13

The IP Spoofer feature of LoadRunner is unnecessary when testing systems without IP-dependent load balancing.

IP Spoofing 13-13

13

,3 6SRRILQJ ,VVXHV
Do I need IP spoofing? Yes, if your system uses IPdependent load balancing

How do I implement IP spoofing?

Run the IP Wizard on each Vuser load generator Enable the IP Spoofer from the Controllers main menu Disable modem emulation in the Run-Time Settings
14

Because the IP Wizard configures a host machine to employ multiple IP addresses, the wizard must be run on every Vuser host machine.

13-14 LoadRunner for the Web 7.0Advanced

13

7KH ,3 :L]DUG
Invoke IP Wizard from the LoadRunner program group IP Wizard Step 1 - Select "New Settings" IP Wizard Step 2 - Enter IP address of Web server

TIP This step is necessary for automatic updating of the Web servers routing table
15

By inputting the Web servers IP address, the IP Wizard can compare this address with the client IP addresses. If they do not reside on the same network, updates to the routing table are required. If the Web servers IP address is not entered, the servers routing table must be manually updated by executing scripts named at the end of the wizard. In practice, it is simpler to enter the servers IP address at this point.

IP Spoofing 13-15

13

7KH ,3 :L]DUG
Invoke the IP Wizard from the LoadRunner program group IP Wizard Step 1 Select "New Settings" IP Wizard Step 2 Enter IP address of Web server

IP Wizard Step 3 Add IP addresses that will load balance your system

16

Clicking the Add button allows the user to enter IP addresses to be spoofed during scenario execution. Confirm address validity with the network administrator.

13-16 LoadRunner for the Web 7.0Advanced

13

$GG ,QWUDQHW/$1 $GGUHVVHV


Class C Example

199 . 199 . 199 . 0 netid hostid


3 bytes define the network; 1 byte defines up to 256 client nodes. Class B Example

199 . 199 . 0 . 0 netid hostid Enter a range of IP addresses representing nodes on a LAN 199 . 199 . 1 . 0 199 . 199 . 1 . 1 199 . 199 . 1 . 2 199 . 199 . 1 . 3
TIP Your network administrator can provide valid IP addresses for your network 2 bytes define network; 2 bytes define client nodes. Class A Example

199 . 0 . 0 . 0 netid hostid


1 byte defines the network; 3 bytes define client nodes.
17

If testing an intranet or a small LAN system, enter a range of numbers to represent users on this closed system. Select Class A, B, or C according to the numbering convention used on the network.

IP Spoofing 13-17

13

$GG ,QWHUQHW $GGUHVVHV


Internet testing

Enter individual IP addresses to represent Internet clients


44 . 233 . 10 . 66 199 . 137 . 108 . 141 230 . 5 . 36 . 175 88 . 17 . 166 . 205

18

To simulate usage from many parts of the Internet, select the Dont use any of these option and enter several completely unique IP addresses. Consult the network administrator responsible for the load balancing system to learn which IP addresses can be used to create a balanced load across the entire system.

13-18 LoadRunner for the Web 7.0Advanced

13

7KH ,3 :L]DUG
Invoke the IP Wizard from the LoadRunner program group IP Wizard Step 1 Select "New Settings" IP Wizard Step 2 Enter IP address of Web server IP Wizard Step 3 Add addresses that will load balance your system

IP Wizard Summary Check Reboot now to update routing tables. This ensures that the Web server remembers paths to virtual clients.
19

To ensure an automatic update of the Web servers routing table, check the appropriate box at the end of the wizard.

IP Spoofing 13-19

13

,PSOHPHQWLQJ WKH ,3 6SRRIHU


Select Enable IP Spoofer from the Controllers Scenario menu

20

After the Web server has been rebooted, open the Controller and enable the IP Spoofer from the Scenario menu.

13-20 LoadRunner for the Web 7.0Advanced

13

,PSOHPHQWLQJ WKH ,3 6SRRIHU


Make sure that Bandwidth is set to maximum in Run-Time Settings

21

IP Spoofing 13-21

13

,3 6SRRILQJ 5HVXOWV LQ :HOO'LVWULEXWHG /RDG 0RGHOLQJ


Databases Application servers Routers Web server

Virtual users with IP Spoofer

200.37.66.9 144.100.105.88 191.230.1.0 103.14.255.200

Load balancing system

Virtual users from many "spoofed" IP addresses create realistic load on entire multi-tiered system
22

During load testing with the IP Spoofer enabled, requests seem to originate from a spectrum of client addresses. Consequently, the entire system is realistically tested.

13-22 LoadRunner for the Web 7.0Advanced

13

6XPPDU\
IP addresses Used by routing tables to determine an IP packets path Used by load balancing systems to divide a load among several backend servers IP spoofing Emulates real-world network traffic Associates each Vuser with a different IP address Is configured by running the IP Wizard Must be configured separately on every Vuser load generator
23

IP Spoofing 13-23

13

13-24 LoadRunner for the Web 7.0Advanced

Appendix: Answers to Questions

This appendix contains answers to all of the exercise questions and the review questions at the end of each exercise.

Appendix: Answers to Questions A-1

1 - Review: Planning an Effective Load Test


1. What are some of the ways you could have obtained the information shown in the Task Distribution Diagrams?
s s

consult experienced users, managers, system experts, and Web developers get statistics from the system

2. How does the information in a Task Distribution Diagram help you to build a Transaction Mix? It shows you where the peak loads occur and what transactions occur during that time. 3. What information is gathered in the Transaction Mix that is not displayed in the Task Distribution Diagram? Business risk (should the business process fail), database usage, and Web server activity. 4. Where would you get the additional information (not in the Task Distribution Diagram) which appears in the Transaction Mix?
s s s

database usage from database administrators risk to business enterprise from managers Web usage from the server experts

5. What criteria would you use to select Web transactions for load testing?
s s s

processes with high throughput processes which create heavy database activity processes which present a high risk to the company if they should fail

A-2 LoadRunner for the Web 7.0

2 - Actions

Exercise A: Create a Web Vuser


Was the site under test invoked successfully by VuGen? Yes. Why is it necessary for VuGen to invoke the browser? In order to capture the communication between the browser and the server for correct playback, VuGen must launch the browser. In VuGen, what is it that indicates that the login was recorded? A step called com.mercurytours.servlet.SignonServlet was added to the icon tree. Was the Flight Confirmation page received from the Web server? Yes. Was the Vuser added to the framework? Yes. In light of the information gathered from the Transaction Mix, why is BookFlight considered a key business process to automate for load testing? BookFlight showed heavy database usage and high business risk. In the Test Results window, what indicates that the Vuser run passed? The Results Summary page shows Passed in its Results column, and a green check mark appears next to the Test Summary icon in the tree pane.

Appendix: Answers to Questions A-3

Was an image of the Flight Confirmation page captured by the Test Results? Yes. What are the file name and extension of the file that displays the test results? Results.qtp To what do the messages in the Execution Log refer? The Execution Log messages refer to the Vusers communication with the server.

Review: Actions
1. For what purpose are Vusers created? Vusers are created to: 1. emulate real users 2. apply load to the system 2. What tools does VuGen provide to help you analyze Vuser run results? 1. Execution Log 2. Run-Time Viewer 3. Test Results window. 4. HTML View 5. Snapshot Results window

A-4 LoadRunner for the Web 7.0

3 - LoadRunner Transactions

Exercise A: Add a Transaction During Recording


Based on the lesson presented and the planning specification, why would you want to add a LoadRunner transaction for the Display Itinerary process? You would want to measure the performance of the server(s) when the query for a flight itinerary is sent to the database. How many flight reservations are listed in the itinerary? 2. In the Execution Log, how long did the display_itinerary transaction take in seconds? It should be less than one second unless you have an old machine. The exact time will vary depending on your hardware, your network, and whether or not the Run-Time Viewer was displayed during playback.

Exercise B: Add a Transaction After Recording


How long did the sign-in transaction take in seconds? It should be less than one second unless you have an old machine. The exact time will vary depending on your hardware, your network, and whether or not the Run-Time Viewer was displayed during playback.

Appendix: Answers to Questions A-5

Review: LoadRunner Transactions


1. What is the purpose of a LoadRunner transaction? To measure one or more steps/user actions of a business process. 2. What is the purpose of measuring a business process from start to end? To compare total transaction time with measurements on specific steps in the business process. This will aid in finding areas causing bottlenecks. 3. What is the easiest way to get measurements for each step of a recorded script? For an entire action? In the Automatic Transactions frame of the General tab in the Run-Time Settings dialog, check:
s s

Define each action as a transaction Define each step as a transaction

A-6 LoadRunner for the Web 7.0

4 - Exercises: Verification Checkpoints


Why is it recommended to add verification checks to your Vusers? You would want to verify, using LoadRunner, that the business process is functioning as expected under load.

Exercise A: Add Verification Checkpoints to a Vuser


Was the flight confirmation page returned from the Web server? Yes. What other visual cues indicate that the reservation was created successfully? The message Your itinerary was booked! appeared on the Flight Confirmation page. Was the text check added? How do you know? Yes. In VuGen an icon was added to the tree. What is the name of the flight confirmation image? Write the file name (including the file extension) in the space below. mast_confirmation.gif Was the image check added to the icon tree? Yes. Why do you think you were asked to put the image check after the End Transaction step, rather than after the ConfirmFlight step? If it is included within the transaction, then the execution time of the checkpoint is added to the execution time of the step the transaction is supposed to measure, thus making the results inaccurate.

Appendix: Answers to Questions A-7

Did the Vuser execute successfully? Yes. How does the Iteration 1 Summary show that the checks passed? How would it show a check failure? Green text and words such as succeeded and successful in the Details column of the checkpoint row. Red text would indicate a verification failure. Are the key words from the Iteration Summary page also present on the checkpoint pages? Yes.

Review: Verification Checkpoints


1. What is a good reason to verify functionality under load with checkpoints? Its possible that a heavy load could cause a server to return errors rather than correct information. 2. How do you determine which visual cues to verify during load testing? Consult a Functional Expert or use your judgment as to what visual cue provides evidence that the business process is working as expected.

A-8 LoadRunner for the Web 7.0

5 - Data Parameterization

Exercise A: Create Vuser to Sign Up New User


Was the sign up successful? What indicates that you have successfully created a new user account with Mercury Tours? Yes. The Mercury Tours REGISTER page confirms the new account has been accepted and displays the new user name. Were you able to sign in with the new username and password? How can you tell? Yes. The FLIGHT FINDER page appeared. In the VuGen icon tree, what action does the sign-in link step represent? It represents the user clicking the sign-in text in the Thank you message. What was the result of the Vuser execution? Vuser execution failed. Which step in the execution tree failed? The VerifyNewAccount checkpoint step failed. What information appears in the Details column of the VerifyNewAccount page of the Test Results? Step failed. 0 occurrences of Thank you for registering found. (Assuming that you used a text check to verify Thank you for registering.)

Appendix: Answers to Questions A-9

What error message was displayed in the Execution Log? VerifyNewAccount failed. 0 occurrences of Thank you for registering found. (Assuming that you used a text check to verify Thank you for registering.) What was written on the line preceding the error message in the Execution Log? web_submit_form was successful What step preceded VerifyNewAccount in the Test Results window? Web Submit Form: NewUserInfo Was there an error message displayed on the captured page for the Web Submit Form: NewUserInfo step? If yes, what was the message? Yes. The user name has already been used, please enter a new name. How could you solve the problem revealed by the error message on the captured Web Submit Form: NewUserInfo page? Parameterize userName, password, and confirmPassword, and put unused data into the data file for these parameters.

Exercise B: Parameterize Fields with Unique Data Constraints


What is an input field with a unique data constraint? A field with unique constraints prohibits the insertion of data values which already exist in the database for that field. The field accepts each data value once and only once. Once a value is inserted for that field, it cannot be inserted again. In the RegisterNewUser action, which fields do you think are likely to have unique data constraints? userName, password, and confirmPassword.

A-10 LoadRunner for the Web 7.0

In the icon tree, which step contains the new user information? NewUserInfo From the table in the Data tab, list the field name and the value for each field with unique data constraints.

FIELD userName password passwordConfirm

VALUE sal chevy chevy

What is the suggested data file name in the File path box? username.dat Why should you replace sal in the data file? Because sal has already been used in the unique field. What is the value of Select next row in the Parameter Properties dialog? Based on this value, in what order would you expect VuGen to use the data in username.dat? Sequential. VuGen will use the first data row for iteration 1 of the Vuser, data row 2 for iteration 2, etc. What happened to the value sal that was in the userName field in the Submit Form Step Properties dialog? It was replaced by the parameter {username}. What is the suggested data file name in the File path box? password.dat

Appendix: Answers to Questions A-11

Refer to the Submit Form Step Properties dialog. Which field uses the same data as the password field? confirmPassword. Was the parameter password assigned to the field confirmPassword? Yes. Did the Vuser iterate successfully? What were the results of each iteration in the Test Results window? Yes. The result was Passed for each iteration. Was a new user name created for each iteration? Yes. Did the Execution Log list the parameters you created and the values for each parameter during each iteration? Yes.

Exercise C: Parameterize to Avoid Server Caching


Did the Vuser iterate successfully 4 times? Yes. Did a different Vuser sign in each iteration? Yes.

A-12 LoadRunner for the Web 7.0

Exercise D: Parameterize a Text Check


In what situation would you want to parameterize a text check? Parameterize a text check in instances when the value to be checked changes with each iteration, and is referenced from an input value or a parameter. Did the cardnumber text check pass for each iteration? Yes.

Exercise E (Optional): Database Issues


What were the results of the run? All 3 iterations failed. Why did the run fail each time? The database allows a user/password combination to be created only once. One way to avoid the problem encountered in this exercise is to create unique data for every script run. What is a better way to avoid the problem? Refresh the database between runs.

Appendix: Answers to Questions A-13

Review: Data Parameterization


1. Why do you need to parameterize fields in your Vuser scripts?
s s

to ensure successful playback by addressing problems of unique or date constraints to exercise the server and avoid caching by using different data for each iteration

2. List the reasons why parameterization is necessary when load testing the Web server and the database server. Parameterization allows you to use different data for each iteration of your Vusers, emulating real user load. Emulating real user load will provide more meaningful results for analysis of your load test. 3. Who is the person on the project team who can give you valid data necessary for Vusers with parameterized fields? The Functional User. The functional user is any person knowledgeable about the application under test. This person might be a developer, an in-house trainer, or an end-user. 4. How can data caching have a negative effect on load testing results? When data is cached in the servers memory, the server does not need to fetch it from the database during playback. Then, test results do not reflect the same performance they would if real users were loading the system with different data.

A-14 LoadRunner for the Web 7.0

6 - Manual Scenarios

Exercise A: Create and Run a Manual Scenario


What is the script Type? QTWeb Why do you want to save all messages? So they may be examined after the test run in Vuser output windows. Who would you consult for advice on which Windows NT counters to set? The IT person in charge of the server(s). What is the benefit of having the Windows Resources Monitor? You can keep monitoring the Load Generators system resource usages in realtime and locate any bottleneck on a particular machine. Which transaction had the highest average response time? BookFlight_Transaction. Why should you remove BookFlight_Transaction from the graph when looking for top time transactions? Because BookFlight_Transaction measures the entire action. Top time transactions measure only a step or a group of steps. Does the graph show any spikes now? If yes, which transaction(s) caused the spikes? com.mercurytours.servlet.WelcomeServlet. That is the first step of the script, the one that sends the URL and causes the server to return the home page.

Appendix: Answers to Questions A-15

Exercise B: Load Testing


How many passed and failed transactions does the Transaction Summary show? What percentage of all transactions failed? All, or nearly all, transactions should pass. What do you notice about the Busy and Idle Servers lines in the Apache graph? Each line is the inverse or complement of the other. What do you notice about the graph now? You might notice that several different transactions show spikes. What is a reason to scale the load from 20 to 25 Vusers? To isolate hardware and software that might limit scalability. How much did the transaction response time vary as more Vusers were added? In most cases, average response time was significantly higher for 25 Vusers than for 20 Vusers. How much did the average throughput decline as more Vusers were added? Very little, if any. Overall, do you think that the difference between 25 and 20 Vusers was small enough that you would feel confident allowing the higher load on your system? Yes.

A-16 LoadRunner for the Web 7.0

Review: Manual Scenarios


1. Why is it a good practice to run just a few Vusers the first time? Theres no point running a load test if there is a problem running the scenario with just a few Vusers. 2. Why do the transaction measurements not matter when testing multiple Vusers to make sure they can run concurrently without errors? Because you are not conducting a load test of the system. You are only verifying that the scenario will run with more than one Vuser.

Appendix: Answers to Questions A-17

7 - Goal-Oriented Scenarios

Exercise A: Create a Goal-Oriented Scenario


On what factors will you base your decisions for hits per second, minimum and maximum Vusers? Based on Task Distribution. Which monitor should you select to watch progress towards the scenario goal? Hits per second. Did the scenario achieve your hits per second goal? How do you know? Yes. 1) The Scenario Status (in the Run tab) showed 25+ hits/second. 2) The Controller automatically stopped the run, and there were no errors. Analyze the graph to see if you can determine how transaction response times were affected by the number of hits. Response time appeared to increase and decrease in tandem with the number of hits per second.

Review: Goal Scenarios


1. What Run-Time Settings can you use to help emulate real users? (1) Check Replay think time in the Think Time tab. (2) Bandwidth Settings in the Browser Emulation tab. 2. Why run more Vusers than your anticipated peak load? To find out how scalable your system is.

A-18 LoadRunner for the Web 7.0

8 - Manual Correlation

Exercise A: Create Vuser to Book a New Flight


Which step includes the input steps for the fly from and fly to cities? web_submit_form(....Reservation.Servlet) Did the Vuser iterate 4 times? Yes. In the Test Results, did any iteration fail? If yes, which iterations failed? Iterations 2, 3, and 4 failed. What was the name of the first step where an iteration failed? The failed step was: web_submit_form(...Purchase.Servlet) Based on the lesson presented, why do you think iterations 2, 3, and 4 failed while iteration 1 passed? That usually indicates dependent data in the script.

Exercise B: Recreate Vuser and Compare with Original


Why do you think that only one data value should be changed for the 2nd recording? To learn whether that value has any data dependent on it. What differences did you find between the two files at the step that failed? login.x, login.y, fromPort, toPort, findFlights.x, findFlights.y, outFlight, inFlight, reserveFlights.x, reserveFlights.y, buyFlights.x, and buyFlights.y.

Appendix: Answers to Questions A-19

Which difference(s) should be captured for playback? Give a reason for your answer. Only the values for outFlight and inFlight because (1) they appeared in the failed step, PurchaseServlet, and (2) the other differences in that step, reserveFlights.x and reserveFlights.y, were mouse click values which not reused in the script. The mouse click values in the other steps dont matter; they were not reused either. Why should you copy the outFlight AND inFlight values when only the outFlight input value changed from Lab8vuser1 to Lab8vuser2? Because both values changed in Lab8vuser2. Both values must be dependent on the cities selected.

Exercise C: Fix the Vuser Script


In the example shown in the graphic, what part of the string is dynamic and should be captured? This answer is for the example only: Blue Skies Airlines$200$244$5:03 pm$ This is not the value you should look for Which step submits the flight details? Which step causes the server to send the page with the flight details form? PurchaseServlet, ReservationServlet What is the error message in the Execution Log? Requested form not found What is the message on the previous line of the log? web_submit_form was successful What is the name of the step immediately preceding the PurchaseServlet step? web_submit_form . . . ReservationServlet

A-20 LoadRunner for the Web 7.0

Would value= be a good left boundary? Give a reason for your answer. No, because value= is repeated many times throughout the script, often in places having nothing to do with dynamic values. What is the left boundary? outFlight value= What is the right boundary? $> How will you determine the correct occurrence of the left boundary? Repeat the find for the left boundary in the Execution Log until the dynamic value following the boundary matches the one you copied from WDiff to Notepad. Which line did the cursor jump to? web_submit_form(....Reservation.Servlet) How can you verify that Lab8vuser3 captured the values correctly? 1st, check the Test Results to see that there were no failures during the run. 2nd, check the Execution Log to see what values were used for parameter substitution. What flight numbers and ticket prices did Lab8vuser3 insert?
ITERATION

OUT_DATA
Blue Skies Airlines$630$270$5:03 pm$ Blue Skies Airlines$720$478$5:03 pm$ Blue Skies Airlines$800$1330$5:03 pm$ Blue Skies Airlines$910$706$5:03 pm$

IN_DATA
Unified Airlines$363$303$18:53 pm$ Unified Airlines$273$557$18:56 pm$ Unified Airlines$83$1403$18:59 pm$ Unified Airlines$193$761$18:02 pm$

1 2 3 4

Appendix: Answers to Questions A-21

Review: Lesson 8-Manual Correlation


1. How can parameterizing a recorded Vuser script expose data dependencies? If two fields are data dependent and either of them is parameterized, then using unsynchronized data in either field will break the script. 2. What usually indicates that your Vuser script has dynamic data which is dependent on your parameterized fields? If all iterations fail except for the one which used the recorded data values. 3. What technique should you use to find dynamic dependent data caused by parameterization? 1. Record with different data (for a parameterized field). 2. Use WDiff to compare the two recordings.

A-22 LoadRunner for the Web 7.0

9 - Automatic Correlation After Recording


Did the Vuser script play back successfully? No. Did the first iteration use the same fromPort and toPort as when you first recorded? Did the first iteration succeed? Yes. Yes. Which iterations failed? What does this usually indicate? Iterations 2, 3, and 4. It usually indicates dependent values hard-coded in the script. Which step failed in the iterations that failed? Web Submit Form: . . . PurchaseServlet What was the error message displayed on the page for that step in Test Results? Step creation failed. Which iteration will you choose for comparison with the recorded ReservationServlet step? Iteration 2, 3, or 4. What differences between the recorded and replayed text did the Correlation Results tab display? Correlation Results displayed the differences for the outFlight and the inFlight dynamic values, which includes the airline, flight number, price, and time. Was the correlation successful? How could you tell? Yes. A green check mark appeared at the left end of both lines in the Correlation tab.

Appendix: Answers to Questions A-23

What changes did automatic correlation make to the script? Correlation added 4 lines to the script, above the . . .ReservationServlet step: (1) a comment, beginning: //WCSPARAM WCSParam_Diff1Studio.... (2) a web_reg_save_param statement to save the outFlight information (3) another comment, similar to the first one (4) web_reg_save_param statement to save the inFlight information In addition, it replaced the 2 dynamic values in the PurchaseServlet step with 2 parameter names: {WCSParam_Diff1} and {WCSParam_Diff2} Did all 4 iterations pass this time? Yes.

Review: Automatic Correlation After Recording


1. Why do you need at least one playback for automatic correlation after recording to work properly? The VuGen requires something to compare to the recorded information. The only place it can get it is from information captured during a playback.

A-24 LoadRunner for the Web 7.0

11 - Custom Output Messages


Which statement verifies that the flight reservation request was successful? web_find(. . .VerifyFlightConfirm) To make output logs more informative, for what type of statement would you want to monitor the return code? Why? The statement that verifies the business process, in this case, the web_find(. . .) statement. Monitoring that statement should help to identify any problems the Vuser has with a particular set of data. How can you capture the return code? Assign the result of web_find to a variable, e.g., rc = web_find(...); Where in your Vuser script do you need to initialize your return code variable? What is the data type of the return code variable? At the top of the script, right after the #include statement. int (for integer) What return code value indicates that the check failed? What return code value indicates that the check succeeded? LR_FAIL. LR_PASS. What condition should you use to decide whether you need to return an output message? if (rc == LR_FAIL) What statement can you use to send a message to the Execution Log? lr_error_message

Appendix: Answers to Questions A-25

What value should you return to stop an iteration? return (0); Why is it necessary to select Continue on error in the Run-Time Settings? So that the if statement will be executed. Otherwise, VuGen would stop the iteration immediately after the web_find failed. Did the first iteration pass? How many iterations did VuGen run? Yes. 2. When an iteration failed, what page was returned instead of the FLIGHT CONFIRMATION page? The YOU ENCOUNTERED AN ERROR page. The Web server returned an error page in response to which submit statement? Web Submit Form: . . . PurchaseServlet2 What line in the Execution Log was returned by your error message statement? It should have returned:
Business Process error. Flight was not purchased.

Review: Custom Output Messages


1. For what purpose should you select Continue on error? Set it only when you want VuGen to execute some code you have added to send more information to the Execution Log, to branch according to the value of a return code, etc.

A-26 LoadRunner for the Web 7.0

2. When would you want to stop an iteration? When would you want to stop a Vuser?
s s

Stop an iteration if the Vuser can recover by beginning a new iteration. Stop a Vuser if the Vuser cannot continue to run correctly.

3. If your Vuser script had two parameters, DepartCity and ArrivalCity, how could you have the Vuser script return an error message which included the city names?
lr_error_message(The flight from %s to %s was not booked, (lr_eval_string({DepartCity}), lr_eval_string({ArrivalCity}));

Appendix: Answers to Questions A-27

12 - Understanding Record and Playback Review Questions

Multiple Actions in One Vuser


1. What are the benefits of creating multiple actions within a Vuser? They allow you to perform different business processes in one Vuser to represent a real user who does the same thing. They let you build Vusers that emulate real users defined in the User Profile. They also allow you to record the login and logoff separately from the business process actions and thus avoid iteration.

Different Types of Data


2. Why do Web developers use hidden data when creating interactive Web sites? Developers use hidden data fields to maintain a preferred state during the users Web session. Web sites might behave differently, send different pages, or change access privileges according to the data values in hidden fields. For example, a hidden field might identify a user as a preferred customer. Preferred customers might be entitled to special offers not displayed to non-preferred customers.

HTTP Requests
3. What information is typically sent in an HTTP request? The version of HTTP, the objects which are either to be sent back or to handle data, the method of the request (e.g., POST), server type and version, content length, etc. 4. What are the different ways a Web developer can create an HTTP request? The properties of an HTTP request can be set via HTML, JavaScript, Java Applets, ActiveX controls, or any third-party program.

A-28 LoadRunner for the Web 7.0

5. During recording, what is saved in the record proxy cache? The HTML page returned from the server as a result of the previous HTTP request. 6. VuGen can parse HTML in memory. True or False? True.

Recording Process
7. When does VuGen record a web_submit_data instead of a web_submit_form? Why? (Be as specific as possible) A web_submit_data is recorded when VuGen cannot match the action, method, data fields, and/or hidden data values with the page that is stored in the record proxy cache. Comparison failures are typically caused by something other than HTML setting the properties of the HTTP request. Because VuGen can parse only HTML, it cannot find all the properties of the HTTP request in memory. This results in the hard-coding of all the request information in a web_submit_data statement.

Playback Process
8. During the playback of a web_submit_form, where do the values of the action, method, and hidden fields come from? During playback, the result of the last request is saved in memory. The values are retrieved from VuGens memory.

Appendix: Answers to Questions A-29

9. Provide a definition of a context sensitive statement. Be specific. Context sensitive statements are statements which can be executed only within the context of the last request. Because much of the HTTP request data is retrieved from memory, the context sensitive statements must be executed immediately after the correct, previous request. For example, web_submit_form relies on the result of the last request, so the page produced by that request must be in computer memory when web_submit_form is executed. 10. What is the benefit of context sensitive statements in a Vuser? Because much of the HTTP request data is retrieved from memory, less hardcoded data is recorded. As a result, the necessity for capturing and parameterizing hard-coded, dynamic data is reduced.

A-30 LoadRunner for the Web 7.0

Appendix: Test Specifications

This appendix collects all the test specifications that appear in various lessons throughout the book.

Appendix: Test Specifications B-1

B-2 LoadRunner for the Web 7.0

Overview
Your company, Mercury Tours, is a medium-sized travel and tours company. As part of its campaign to increase sales, Mercury Tours plans to expand its travel and tours business into e-commerce. An external Web site has been built to serve its customers via the Internet. The system has been built, customized and configured. It is stable. Everything works for one user. Now load testing can begin. As the LoadRunner Expert, it is your responsibility to use LoadRunners VuGen and Controller to create the required load on the system. In addition to creating the required load, you will also use LoadRunners analysis tools to assess the results. In the following pages, we will present information about the system to be load tested in the form of a Planning Specification. The Planning Spec. is intended to represent the sort of documentation you would have to put together yourself if it were a real life situation. After each lesson, a portion of the Planning Spec. will be followed by some exercises. You will need the information contained in the Planning Spec. to do the exercises.

Appendix: Test Specifications B-3

Planning Specification

Flight Application Web Site Usage

TASK DISTRIBUTION FOR NORMAL BUSINESS DAY


3am 6 am 13 system backup 12 9 am 15 12pm 3 pm 6pm 25 22 19 9pm 17 12

30 17 search for flights 16

15 30 display itinerary

11 12 11 delete reservation 16 18 14 book a flight 12 18 30 19

11

15 11 register new user account 46 29 112 82

11

TOTAL

13

23 31

76

28

Source: Mercury Tours MIS Dept.

B-4 LoadRunner for the Web 7.0

TASK DISTRIBUTION FOR PRE-HOLIDAY TRAVEL


3am 6 am 24 system backup 9 am 20 30 12pm 3 pm 6pm 70 70 36 9pm 50 24 12

50 40 30 search for flights 30 4

20 50 display itinerary 2

8 2 delete reservation 40 36 24

16

30 24 book a flight 30

20 40 16 20 register new user account 96 208 158 120

TOTAL

24

70

144 40

Source: Mercury Tours MIS Dept.

Appendix: Test Specifications B-5

Transaction Mix
Business Process Name Search for flight Display itinerary Book a flight Delete flight reservation Create new user account Normal Day Peak Thruput 25 30 PreHoliday Peak Thruput 70 50

System Usage

DB Usage heavy heavy

Risk

business process processed from the client side, generates server activity business process processed from the client side, query for existing flight reservations generates server activity generates activity in the database server, returns server output to confirm business process completion generates activity in the database server, returns server output to confirm business process completion adds new member to the customer database, user may proceed to member login

low med

30

40

heavy

high

12

low

low

15

40

low

high

B-6 LoadRunner for the Web 7.0

Selected Transactions to Automate


Mercury Tours has determined the three key business processes for load testing.

BUSINESS TRANSACTION
Display Itinerary Book a flight Create New User Account

NORMAL LOAD
30 30 15

PEAK LOAD
50 40 40

Appendix: Test Specifications B-7

B-8 LoadRunner for the Web 7.0

Planning Specification (continued):


Display Itinerary
USER ACTIONS
1 Invoke the Web browser, type http://localhost/servlets/com.mercurytours .servlet.WelcomeServlet for the URL address, and press the Enter button. Type a valid user name in the User Name box. Type a valid password in the Password box.

EXPECTED RESULTS
The Mercury Tours home page appears.

2 3

The typed characters are displayed in the User Name box. The users password appears as a series of asterisks in the Password box. A query is sent to the database to match an existing value for registered user name and password. If a match is found, the Mercury Tours FLIGHT FINDER page appears. A Query is sent to the database to search for all flights reserved for the logged in user name. The ITINENARY page appears and displays all values returned by the database in response to the query.

Click the Sign-In button.

After the FLIGHT FINDER page appears, click the ITINERARY button.

Appendix: Test Specifications B-9

Planning Specification (continued):


Create New User Account
USER ACTIONS
1 2 Click the REGISTER button. In the REGISTER page, type the information for creating a new user. Fields in red may not be left blank.

EXPECTED RESULTS
The REGISTER page appears. Customer information is displayed in the fields: - First Name - Last Name - Phone - E-mail - Address - City - State - Postal Code - Country - User Name - Password - Confirm Password The new user is added into the database and the Mercury Tours REGISTER page appears with confirmation.

Click the Submit button.

B-10 LoadRunner for the Web 7.0

Planning Specification (continued):


Book a Flight
USER ACTIONS
1 Invoke the Web browser, type http://localhost/MercuryWebTours/ for the URL address and press Enter. Type the name in the User Name box. Type the password in the Password box.

EXPECTED RESULTS
The Mercury Tours home page appears. The members login name appears in the Member name box. The members password appears as a string of asterisks in the Password box. The Mercury Tours FLIGHT FINDER page appears. The Find Flight page appears with the following flight information fields: - Type - Passengers - Departing From - On - Arriving In - Returning - Service Class - Airline The SELECT FLIGHT page appears and returns all values of available flights. The BOOK A FLIGHT page appears. - First Name - Last Name - Number

2 3

4 5

Click the Sign-In button. Type the following data in the indicated fields on the FLIGHT FINDER page.

Click the CONTINUE button.

7 8

Select the first available flight and click the CONTINUE button. Type the following data in the indicated fields on the BOOK A FLIGHT page.

Appendix: Test Specifications B-11

USER ACTIONS
9 Click the SECURE PURCHASE button.

EXPECTED RESULTS
The FLIGHT CONFIRMATION page appears. It contains confirmation of the reserved flight, and the flight and customer details.

10

Verify that the FLIGHT CONFIRMATION page appears, and that the page contains the text Your itinerary has been booked!. Verify the flight number. Flight details appear in the FLIGHT CONFIRMATION page.

11

B-12 LoadRunner for the Web 7.0

Appendix: Scaling the Web

This appendix contains technical notes about hardware and operating system requirements and configuration for large scale load testing.

Appendix: Scaling the Web C-1

Scaling the Web: Large Scale Load Testing with LoadRunner

Highly active and large scale Web systems require load test simulations of thousands of virtual users in order to accurately quantify the performance of the test system prior to deployment. Unfortunately, large numbers of simulated users require more hardware, raising the cost for load testing large systems. Thus, a cost-effective test bed that supports large numbers of users is important for both scalability and manageability. This article delineates important decision and configuration issues in designing a cost-effective test bed for hosting 1,000 to 100,000 Web Virtual Users (running in Analog mode). Perhaps the most important first step is deciding whether to use Unix or PC. Contrary to the general propensity to use Unix, PC Windows systems are more scalable given LoadRunners architecture. This is largely because PC Virtual Users are thread-based, and Unix Virtual Users are process-based. Table A shows the resource requirements for Unix and Windows for Web Vusers that submit HTTP requests and contain reasonable levels of think-time between HTML pages (e.g., 5-15 seconds of random think-time).

Web Vusers Windows NT/2000 Unix

100 Vusers 23 MB 400 MB

1,000 Vusers 230 MB 4 GB

10,000 Vusers 2.3 GB 40 GB

50,000 Vusers 23 GB 400 GB

Table A: RAM requirements for Analog Web Vusers under Unix and Windows

Based on the above resource requirements, the Windows NT/2000 platform would be ideal for hosting large numbers of Vusers for less cost. However a single instance of Windows NT/2000 can support only 1,500 to 2,000 Virtual Users due to limited handle resources (i.e., threads, files, sockets, etc.) per OS session. In order to circumvent this limitation Windows should be equipped with Terminal Sessions.
s

Windows 2000 w/ Microsoft Terminal Server (MTS) - MTS comes with Windows 2000 Server; however, licenses from Microsoft must to be purchased. Windows NT 4.0 w/ Citrix Server - Citrix Server is a separate package that

C-2 LoadRunner for the Web 7.0

must be purchased and installed on top of Windows NT 4.0 Servers. Table B shows the number of Vusers that can run on a single server hosting different numbers of terminal sessions. Note that an extra terminal session is required (although not used) as an idiosyncrasy of LoadRunners Agent communication protocol.

Terminal Sessions Web Vusers

2 1,500

3 3,000

4 4,500

5 6,000

6 7,500

7 9,000

Table B: Vusers on a single server* with multiple terminal sessions

*Values are based on a 4-CPU 500 MHz Xeon Server running Windows 2000 Terminal Server

Although more Terminal Sessions should theoretically yield more Web Vuser hosting, Windows NT and Windows 2000 impose a Kernel-level limit of ~10,000 on the number of threads that each server can host. Thus each PC can host roughly 9,000 Web Vusers (since background processes and other tasks may consume the remaining thread resources). Based on the nature of the scripts (e.g., downloading images concurrently, etc.), each Vuser consumes roughly 1-4 TCP/IP connection ports. Windows NT/2000 has a default of 5,000 transient ports that can be used for TCP/IP connection. Luckily, this default is configurable, and must be increased when attempting to run more than 3,000 virtual users. The following registry entries should be updated and the system rebooted to allow a large number of connections (and Vusers) on a single PC server. KEY: HKLM\System\CurrentControlSet\Services\TcpIp\Parameters\MaxUserPort [This DWORD key may not exist in your system. In that case, you should create it.] VALUE: 65534 KEY: HKLM\System\CurrentControlSet\Control\Session Manager\Sub Systems\Windows VALUE: [Set second value to] 4096

Appendix: Scaling the Web C-3

Finally, but most importantly, a network that is capable of supporting the traffic of thousands of users is essential in generating true load. Based on empirical data, each load driver station (PC) should have a dedicated 200 Mbps connection to the target server (via a bridge) when running thousands of Virtual Users. Collisions and network latency should be minimized in order to generate more load against the server. The following formula provides a good estimate of the number of requests that a fully utilized network can generate: # of HTTP Requests per second (hps) = Bandwidth (bps) / ((Request + Response) * 8) (bph) Example: A typical HTML page is 18 KB, thus Request + Response data size is roughly 18.5 KB. A 100 Mbps network can produce a maximum of ( 100,000,000 / 151,552 ) = ~660 HTTP requests per second (assuming an infinitely fast server and client). Realistically, only ~90% of this value is actually attainable (e.g., 600 hps). This figure is important in determining the maximum number of Vusers that are allowed to run on a given station without running into network bandwidth constraints. Once a server is fully configured for the optimal number of Vusers, it can be mirrored to launch an equivalent number of Virtual Users across multiple stations. Table C shows how many load drivers are needed to run a desired number of Virtual Users (assuming 7,500 Vusers per station).

# Web Vusers # Windows 2000 4-CPU, 3GB RAM Servers

1,000 1

5,000 1

10,000 2

20,000 3

50,000 7

100,000 14

Table C: Number of servers required to run desired number of virtual users

C-4 LoadRunner for the Web 7.0

Training Evaluation Form

COURSE: LoadRunner 7 for the Web DATE:__________________________ INSTRUCTOR: ___________________

NAME: ____________________________________ COMPANY:_________________________________ YOUR DEPARTMENT: ________________________ TELEPHONE #: ______________________________

1. How would you rate the quality of the instructors presentation? Please circle only one rating for each category:
Excellent Stated objectives clearly Displayed knowledge of subject Encouraged expression of opinions/ideas Understood and responded to questions Showed enthusiasm Spoke understandably (clarity, volume, speed) 8 8 8 8 8 8 7 7 7 7 7 7 6 6 6 6 6 6 Good 5 5 5 5 5 5 Average 4 4 4 4 4 4 3 3 3 3 3 3 2 2 2 2 2 2 Poor 1 1 1 1 1 1

Additional comments/suggestions about the instructors presentation skills.


_________________________________________________________________________________________________ _________________________________________________________________________________________________ _________________________________________________________________________________________________

2. How would you rate the quality of the course materials (slides and student workbook)? Please circle only one rating for each category.
Excellent Overall effectiveness Logical organization Supported the course objectives Comprehensive Layout / visual clarity 8 8 8 8 8 7 7 7 7 7 6 6 6 6 6 Good 5 5 5 5 5 Average 4 4 4 4 4 3 3 3 3 3 2 2 2 2 2 Poor 1 1 1 1 1

Additional comments/suggestions about the course materials. Please list three specific suggestions.
1. _______________________________________________________________________________________________ 2. _______________________________________________________________________________________________ 3. _______________________________________________________________________________________________

(PLEASE TURN OVER)

3. Did you find any of the exercises or review questions difficult? If so, specify which topics could have been explained more clearly.
_________________________________________________________________________________________________ _________________________________________________________________________________________________

4. Is there any topic that you feel should have been presented in more depth? If so, please specify.
_________________________________________________________________________________________________ _________________________________________________________________________________________________

5. What were the most important skills, concepts, or ideas you learned in these courses?
1. ________________________________________________________________________________________________ 2. ________________________________________________________________________________________________ 3. ________________________________________________________________________________________________

6. Were your needs and objectives met? Why or why not?


_________________________________________________________________________________________________ _________________________________________________________________________________________________

7. Would you recommend our products to others? Why or why not?


_________________________________________________________________________________________________ _________________________________________________________________________________________________

8. Would you act as reference to other customers?

Yes

No (If not, please explain)

_________________________________________________________________________________________________ _________________________________________________________________________________________________

9. Are you interested in any other Mercury Interactive products? If so, which one(s)?
__________________________________________________________________________________________________

10. How would you rate the course administration? (for public classes only) Please circle only one rating for each category:
Excellent Registration procedures Classroom Course equipment (computers, projector, etc.) Food 8 8 8 8 7 7 7 7 6 6 6 6 Good 5 5 5 5 Average 4 4 4 4 3 3 3 3 2 2 2 2 Poor 1 1 1 1 N/A __ __ __ __

Additional comments/suggestions about the course administration:


_________________________________________________________________________________________________ _________________________________________________________________________________________________

LR7WEB-04

Vous aimerez peut-être aussi