Académique Documents
Professionnel Documents
Culture Documents
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
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
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
6 7
Manual Scenarios ................................................................................6-1 Exercises ....................................................................................... 6-55 Goal-Oriented Scenarios ......................................................................7-1 Exercises ....................................................................................... 7-39
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
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
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
Products
and
Services
Web C/S - Databases
LoadRunner TestDirector WinRunner WinRunner WebTest LoadRunner TestDirector Astra QuickTest Astra LoadTest
3
*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
Introduction xv
Creating and running load test scenarios, and analyzing their results
Advanced Topics
Introduction xvii
10
Introduction xix
DEFINITION
/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
EXAMPLE
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?
12
Introduction xxi
EXAMPLE
Load test
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
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
The limitations of manual testing make it difficult to achieve meaningful load test results.
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
Web server
Database server
LoadRunner provides you with tools that address the issues of manual testing.
Introduction xxv
DEFINITION
17
18
Introduction xxvii
19
LoadRunner Controller
LoadRunner Analysis
20
These are the LoadRunner tools you will work with to implement load testing for the Web.
Introduction xxix
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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.
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
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
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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.
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
DEFINITION
%XVLQHVV 3URFHVV
A business process is a set of user actions performed with an application to accomplish a business task.
EXAMPLE
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
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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
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.
NOTE: The diagrams and profiles in the following illustrations must be created by the user.
EXAMPLE
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
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.
EXAMPLE
Night
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
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).
EXAMPLE
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
High Low
Mod. High
High
Selection criteria:
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.
EXAMPLE
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
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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
14
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.
EXAMPLE
16
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
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 Specification
15 30 display itinerary
11
11
TOTAL
13
23 31
76
28
20 50 display itinerary 2
8 2 delete reservation 40 36 24
16
30 24 book a flight 30
TOTAL
24
70
144 40
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
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
BUSINESS TRANSACTION
Display Itinerary Book a Flight Create New User Account
NORMAL LOAD
30 30 15
PEAK LOAD
50 40 40
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? ________________________________________________________________________ ________________________________________________________________________
5. What criteria would you use to select Web transactions for load testing? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________
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
$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
ENHANCE
$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
VuGen
send URL1 receive web page
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
CREATE A VUSER
Insert measuring transactions Insert verification checkpoints Parameterize input data Correlate reused data
Recording 2-7
CREATE A VUSER
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.
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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
$FWLRQ
A recorded business process or series of steps that, when played back, emulates a real user performing the same steps.
10
$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)
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
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
9X*HQ :LQGRZ
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
15
VuGen is the integrated development environment that allows you to record user actions, modify and play back Vusers.
Recording 2-15
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.
17
Recording 2-17
18
Scalabilityscripts are more scalable than HTML scripts because they require fewer resources
19
Recording 2-19
20
21
Recording 2-21
22
23
Recording 2-23
25
The logon and logoff may be recorded inside the action if you wish.
Recording 2-25
26
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
28
,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
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"
32
5HQDPLQJ DQ $FWLRQ
To enhance Test Tree readability: 1. Click action name 2. Type new name 3. Press Enter
33
Actions 2-33
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.
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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
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.
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
38
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
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.
Vuser
result1
Results.qtp
41
the entire test run each iteration of the run each step of each iteration
Recording 2-41
42
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
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.
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
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
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.
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.
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.
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.
Recording 2-51
Was the Flight Confirmation page received from the Web server? ________________________________________________________________________ 8. Rename the . . . PurchaseServlet2 step to ConfirmFlight.
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.
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
LoadRunner Transactions
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
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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
DEFINITION
/RDG5XQQHU 7UDQVDFWLRQ
An end-to-end (browser-to backend-to browser) measurement of one or more user actions within an action file.
$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
EXAMPLE
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.
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
BEST PRACTICE
'XULQJ 5HFRUGLQJ
BEST PRACTICE
'XULQJ 5HFRUGLQJ
3. Complete the user actions for the process to be measured 4. Click the End Transaction toolbar button
10
11
$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
13
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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
15
Deselect Prompt for results directory in Display tab of General Options dialog box if you would rather have that as the default.
16
EXAMPLE
Transaction Name
$XWRPDWLF 7UDQVDFWLRQV
Measure performance of every test step automatically Compare individual steps to each other to an entire business process
18
$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.
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
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.
After the FLIGHT FINDER page appears, click the ITINERARY button.
Exercises
LoadRunner transaction steps can be added to a script during recording and after recording. These exercises show you how to do both.
Leave Record the application startup checked, and click OK. 4. Sign in to the Mercury Tours Web site as jojo using the password bean.
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
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? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________
Verification Checkpoints
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
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.
DEFINITION
The appearance of expected visual cues indicates that the server can send the proper pages back and that the load is being properly handled.
DEFINITION
&KHFNSRLQW
A checkpoint is a step in a Vuser script which verifies whether a visual cue appeared as expected.
REVIEW
$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
10
11
12
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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
&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.
,PDJH &KHFN
Check
Image
Example usage
Did the Web page display the correct image?
15
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.
17
BEST PRACTICE
BEST PRACTICE
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.
BEST PRACTICE
BEST PRACTICE
21
The image file name pasted into the check properties becomes the expected result of the check.
BEST PRACTICE
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.
BEST PRACTICE
23
7H[W &KHFN
Check
Text
Example usage
Did the business process complete successfully?
24
BEST PRACTICE
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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
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.
PASSED EXAMPLE
30
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
32
ADVANCED
Q: So, how do you make NOT finding the text a PASS condition, and finding the text a FAIL condition?
33
ADVANCED
34
Note that in this example, the test should pass if the error text is NOT found.
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
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.
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.
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
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? ________________________________________________________________________ ________________________________________________________________________
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.
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.
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.
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.
What is the name of the flight confirmation image? Write the file name (including the file extension) in the space below.
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? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________
Data Parameterization
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
DEFINITION
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.
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
$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
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
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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
Part of the planning process involves determining the fields that you need to parameterize before you begin creating the Vusers.
'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
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.
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
EXAMPLE
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.
'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
EXAMPLE
'DWD ,V &DFKHG
&$&+(
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.
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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
TRUE
SMITH, WM.
$230.59
16
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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
PROCESS
18
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
20
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.
22
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.
24
25
Select next row tells LoadRunner in what order to use data from the file
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.
EXAMPLE
6HTXHQWLDO
Vuser 1 Vuser 2 Vuser 3 Iteration 1 Iteration 2 Iteration 3
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.
EXAMPLE
5DQGRP
Vuser 1 Vuser 2 Vuser 3 Iteration 1 Iteration 2 Iteration 3
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.
EXAMPLE
8QLTXH
Vuser 1 Vuser 2 Vuser 3 Iteration 1 Iteration 2 Iteration 3
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.
EXAMPLE
3DUDPHWHUL]DWLRQ6FULSW 9LHZ
BEFORE PARAMETERIZATION
30
EXAMPLE
3DUDPHWHUL]DWLRQ6FULSW 9LHZ
AFTER PARAMETERIZATION
31
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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
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).
In order to view the parameters and their values in the output logs after playback, the options shown above must be set.
([HFXWLRQ /RJ
Iteration 1
36
The Execution Log lists parameters and their values for each iteration during Vuser playback.
([HFXWLRQ /RJ
Iteration 2
37
Sometimes, parameter data may be displayed on the result page for the step that used the data
38
How to check
?
39
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?
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.
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
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.
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.
After the FLIGHT FINDER page appears, click the ITINERARY button.
Exercises
In these exercises, you will determine which fields to parameterize, then add parameters to your Vuser.
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
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
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.
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? ________________________________________________________________________
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.
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.
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.
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? ________________________________________________________________________
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.
Was the parameter password assigned to the field confirmPassword? ________________________________________________________________________ 2. Parameterize firstName and lastName. Use data from the table.
3. Return to the VuGen main window. Click OK to close the Submit Form Step Properties dialog.
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.
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.
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.
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.
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.
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.
2. Parameterize the creditnumber field in the ConfirmFlight step. Use cardnumber for the Parameter name.
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? ________________________________________________________________________
10. Close the Test Results window, the Run-Time Viewer, and Lab5vuser4 when you have finished.
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? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________
Manual Scenarios
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
Introduction to Scenarios
DEFINITION
/RDG5XQQHU 6FHQDULR
An environment which describes all the elements to be used and the conditions under which you want to test your system.
EXAMPLES
6FHQDULR (OHPHQWV
GOAL VUSER SCRIPT Vuser Script MONITORS
start transaction send URL1 receive web page end transaction image checkpoint
EXAMPLES
8yyr
LOAD GENERATOR
T8@I6SDP!
Wr Drr
Xri rr
Wr
LOAD GENERATORS
Wr
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
*OPTIONAL
CREATE SCENARIOOVERVIEW
10
CREATE SCENARIOOVERVIEW
11
CREATE SCENARIOOVERVIEW
12
Manual Scenarios
$GG *URXSV
Click Add Group to open the Add Group dialog Select a script Edit the Group Name Change the number of Vusers
14
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.
(GLW 6FKHGXOH
RSWLRQDO
16
EDIT SCHEDULE
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
EDIT SCHEDULE
Control scenario duration Run until all Vusers finish Run for a certain length of time
DURATION TAB
18
$GG
19
RSWLRQDO
Rendezvous settings are accessible only for scripts which already include a rendezvous Open from menu: Scenario > Rendezvous
20
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
4.1 Set Monitoring Options 4.2 Select & Configure Monitors 4.3 Choose Run-Time Settings 4.4 Run
21
RUN SCENARIOOVERVIEW
22
5XQ 7DE
Scenario status
Vuser groups
Add monitors and watch them in real time Watch scenario progress in real time
23
24
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.
&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
&RQILJXUH 0RQLWRUV
1. Right-click a monitor pane 2. Select "Add Measurement(s)" from pop-up menu
27
29
&RQWUROOLQJ 9XVHUV
Vusers opens Vusers dialog Initialize initializes selected Vusers
Select group
Run buttons run selected Vusers Start Scenario runs all Vusers
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.
&RQWUROOLQJ 9XVHUV
Details opens the Vuser Information dialog
31
32
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
34
20%
35
DEFINITION
* In this definition, "other transactions" excludes those which measure an entire business process.
36
37
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.
39
Isolate transactions that have performance problems irrespective of load Verify that the system functions under the expected load
20%
100%
40
5XQWLPH 6HWWLQJV/RJ
Select Disable logging Logging: Consumes resources Not needed after script is debugged
41
42
s s
Replay think time as recorded is the default in the Controller Ignore think time is the default in VuGen
5XQWLPH 6HWWLQJV3UHIHUHQFHV
Enable Verification checks to verify functionality under load
43
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
44
46
47
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%
100% +
48
49
50
l T o I w M e E r
lighter load
51
Each circled pair is same transaction under different loads Heavier load is the right member of each pair
52
53
FlightPurchase:25vusers
FlightPurchase:30vusers
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
Exercises
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.
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.
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.
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.
Why do you want to save all messages? ________________________________________________________________________ 4. Save the scenario as: \web_project\Scenarios\Lab6_manual.lrs
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.
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.
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.
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
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.
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
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? ________________________________________________________________________
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.
2. Reset the Vusers. 3. Initialize and run 25 Vusers, and wait for them to finish.
AVERAGE TRANS. RESPONSE TIMES TRANSACTION ConfirmFlight FindFlight PurchaseFlight (automatic) purchase_flight (manual) SelectFlight 20VUSERS.LRR 25VUSERS.LRR
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.
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? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________
Goal-Oriented Scenarios
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
GOAL AUTO select script edit goal select load generators set rendezvous policy* select monitor options* select monitors* select run-time settings
*OPTIONAL
*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
REVIEW
Hours to be emulated
Day50
Night
2000 700
Administrative Processes
*Invoice processing *System backup
12 am
50 1
2
50 1
4
50
50
10
12 pm
10
12
EXAMPLE
EXAMPLE
11
You must choose a Transaction Name if Goal Type is "Transaction Response Time" or "Transactions per Second"
13
14
REVIEW
What is enabled on the Monitor Menu depends on which monitor is selected below
15
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.
17
18
1. Hold pointer over graph line to see component name 2. Select page from list
19
20
21
This is the same data that appeared on the live Apache monitor
22
23
24
Response time
0HUJLQJ *UDSKV
View > Merge Graphs
26
0HUJHG *UDSK
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.
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
*OREDO )LOWHU
More filter conditions than single graph filters Criteria can be "=" or "< >"
29
7UDQVDFWLRQV *UDSK
TRANSACTION RESPONSE TIME - DISTRIBUTION
Transaction key
30
31
)LQGLQJ D 7UDQVDFWLRQ
32
34
35
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.
37
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
Exercises
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.
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.
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.
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
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? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________
Manual Correlation
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
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
DEFINITION
&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.
EXAMPLE
Dynamic data is correlated automatically by the client application (running in the browser) while recording a script
5
EXAMPLE
Vuser
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.
EXAMPLE
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
PROBLEM
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
PROBLEM
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
PROBLEM
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
CAUSE
12
SOLUTION
13
MANUAL CORRELATION
14
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.
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.
"URL= . . . ?BV_SessionID=@@@@2089996444.0999297996@@@@&",
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.
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
19
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
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\.
RIGHT BOUNDARY
LEFT BOUNDARY
22
23
FOUND
NOT FOUND
24
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.
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
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.
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.
30
Name the parameter Copy the boundary text from the HTML Add the instance ("ORD") from the Execution Log
31
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.)
33
+RZ ,W :RUNV
web_reg_save_param
34
+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 replaces a literal value in the script. VuGen substitutes a captured, dynamic value for the parameter at run time.
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.
37
38
These show the replacement of parameters with captured data later in the script
39
DEFINITION
'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
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
If all iterations fail except the one which used the recorded value, that usually indicates a data dependent value hardcoded in your script
42
TEST STATUS
ITEM DESCRIPTION
Original Recorded Value Additional values from a data file after parameterizing the item description
43
REVIEW
Q: Is the Item Number in our example dependent on any user input data? A: Yes. It is dependent on the Item Description.
45
SOLUTION
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
Exercises
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.
5. Sign in to the Mercury Tours Web site as jojo with the password bean.
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.
7. Click the SECURE PURCHASE button on the BOOK A FLIGHT page. 8. Insert a checkpoint to verify that the Flight Confirmation page appeared.
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.
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? ________________________________________________________________________
Based on the lesson presented, why do you think iterations 2, 3, and 4 failed while iteration 1 passed? ________________________________________________________________________ ________________________________________________________________________
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.
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
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? ________________________________________________________________________ ________________________________________________________________________
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.
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.
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." )
outFlight_data
inFlight_data
1 2 3 4
3. Close WDiff, Notepad, the Test Results window, the Run-Time Viewer, and all Vusers.
2EMHFWLYH
In this lesson, you will learn how to correlate data automatically after recording
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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
PROCESS
(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
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.
Or, if the popup was not enabled: click the Scan toolbar button select Vuser > Scan press Ctrl+F8
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
$IWHU &RUUHODWLRQ
Correlation succeeded
12
Phase 2
Create Web Virtual Users
Phase 3
Create Scenarios
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
14
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
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.
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.
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
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
3. Make sure that the Run-Time Settings conform to those in the following table:
SETTING set Iteration count to 4 select Extended log check Parameter substitution uncheck Data returned by server check Verification checks
Preferences
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.
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.
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? ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________
10
2EMHFWLYHV
In this lesson, you will learn how to: correlate data automatically during recording define your own rules for automatic correlation
10
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.
10
10
10
(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
10
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.
10
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
Do this step every time you change a script before using it to test your application.
10
7UHH 9LHZ
No correlation
Correlated
10
10
6FULSW 9LHZ
NO CORRELATION CORRELATED
Left boundary, right boundary, & occurrence appear in the script view
11
10
7HVW 5HVXOWV
No correlation
Correlated
12
10
&UHDWLQJ D 5XOH
1. Click Define Rules
The Correlation Rules dialog opens
13
10
&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
&UHDWLQJ D 5XOH
Right of (boundary) Left of (boundary) OR (alternate right boundary) Instance Match Case Reverse Search Parameter Prefix Always create new parameter
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.
10
&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
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
10
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
11
REVIEW
11
REVIEW
7\SHV RI &KHFNV
Check Text Example usage Did a search engine return expected matches?
Image
11
REVIEW
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
Action1.c(15):ERROR: Text Check: VerifyOrderNumber - Failed : Expected "1234", but found ""
11
You can make the output log more informative by modifying the Vuser script with LoadRunner functions and variables.
11
LR_PASS
;
LR_FAIL
11
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
11
11
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
13
11
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
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
11
16
11
17
11
Name of parameter whose value you want to retrieve This function returns a string representation of the value of a specified parameter
18
11
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.
11
20
11
21
11
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
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
23
11
24
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
11
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
WARNING
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
11
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
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
31
11
11
Exercises
11
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.
11
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
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.
11
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
12
REVIEW
12
12
Record Proxy
Native Proxy
:(% 6(59(5
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
VISITORS
IN FO
cache
Record Proxy
Native Proxy
:(% 6(59(5
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.
12
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
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
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.
12
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
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.
12
14
12
15
12
16
12
17
12
12
19
12
Internet
Web server
20
12
User Actions
(Business Processes)
Logout
(recording optional)
vuser_end.c
21
12
22
12
1. Start recording 2. Select action file 3. Record actions 4. Repeat steps 2 and 3 as necessary 5. Stop recording
23
12
12
25
The default Random percents is equal percentages for each action. In the above example, that is 50% for each of the two.
12
26
In practice, you should iterate a Vuser many more than the minimum number of times to ensure that accurate weighting is accomplished.
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!
12
12
Review Questions
HTTP Requests
3. What information is typically sent in an HTTP request? ________________________________________________________________________ ________________________________________________________________________
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
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? ________________________________________________________________________ ________________________________________________________________________
12
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
IP Spoofing 13-3
13
Internet users
255.7.144.1
203.33.0.253
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
Every IP packet is forwarded by hubs, routers, and Web servers by means of a routing table.
IP Spoofing 13-5
13
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
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
Load balancing systems also use the client IP address to direct queries.
13
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
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
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
EXAMPLES
11
An unbalanced load test may invalidate some, if not all, of the test results.
IP Spoofing 13-11
13
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
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
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
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
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
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
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
20
After the Web server has been rebooted, open the Controller and enable the IP Spoofer from the Scenario menu.
13
21
IP Spoofing 13-21
13
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
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
This appendix contains answers to all of the exercise questions and the review questions at the end of each exercise.
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
2 - Actions
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
3 - LoadRunner Transactions
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.
5 - Data Parameterization
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.
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.
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
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.
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.
6 - Manual Scenarios
7 - Goal-Oriented Scenarios
8 - Manual Correlation
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.
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
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.
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.
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}));
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.
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.
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.
This appendix collects all the test specifications that appear in various lessons throughout the book.
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 Specification
15 30 display itinerary
11
11
TOTAL
13
23 31
76
28
20 50 display itinerary 2
8 2 delete reservation 40 36 24
16
30 24 book a flight 30
TOTAL
24
70
144 40
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
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
BUSINESS TRANSACTION
Display Itinerary Book a flight Create New User Account
NORMAL LOAD
30 30 15
PEAK LOAD
50 40 40
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.
After the FLIGHT FINDER page appears, click the ITINERARY button.
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.
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.
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.
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
This appendix contains technical notes about hardware and operating system requirements and configuration for large scale load testing.
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).
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
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.
2 1,500
3 3,000
4 4,500
5 6,000
6 7,500
7 9,000
*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
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).
1,000 1
5,000 1
10,000 2
20,000 3
50,000 7
100,000 14
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
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. _______________________________________________________________________________________________
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. ________________________________________________________________________________________________
Yes
_________________________________________________________________________________________________ _________________________________________________________________________________________________
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 __ __ __ __
LR7WEB-04