106
Load Runner Introduction and Architecture LoadRunner is an industry-leading performance and load testing product by Hewlett-Packard (since it acquired Mercury Interactive in November 2006) for examining system behavior and performance, while generating actual load. LoadRunner can emulate hundreds or thousands of concurrent users to put the application through the rigors of real- life user loads, while collecting information from key infrastructure components (Web servers, database servers etc). The results can then be analyzed in detail, to explore the reasons for particular behavior. Consider the client-side application for an automated teller machine (ATM). Although each client is connected to a server, in total there may be hundreds of ATMs open to the public. There may be some peak times — such as 10 a.m. Monday, the start of the work week — during which the load is much higher than normal. In order to test such situations, it is not practical to have a testbed of hundreds of ATMs. So, given an ATM simulator and a computer system with LoadRunner, one can simulate a large number of users accessing the server simultaneously. Once activities have been defined, they are repeatable. After debugging a problem in the application, managers can check whether the problem persists by reproducing the same situation, with the same type of user interaction. HP LoadRunner is an automated performance and test automation product from Hewlett-Packard for examining system behaviour and performance, while generating actual load. HP acquired LoadRunner as part of its acquisition of Mercury Interactive in November 2006.HP LoadRunner can simulate thousands of concurrent users to put the application through the rigors of real-life user loads, while collecting information from key infrastructure components (Web servers, database servers etc.)The results can then be analyzed in detail, to explore the reasons for particular behavior. LoadRunner supports various application protocols; Flex AMF, Citrix ICA, Remote Desktop Protocol (RDP), ERP/CRM (e.g. SAP, Oracle eBusiness, Siebel and PeopleSoft), Databases, Mail Clients, Web Services, AJAX TruClient (with V.11.0). LOADRUNNER COMPONENTS

Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Embed Size (px)

Citation preview

Page 1: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Load Runner Introduction and ArchitectureLoadRunner is an industry-leading performance and load testing product by Hewlett-Packard (since it acquired Mercury Interactive in November 2006) for examining system behavior and performance, while generating actual load.LoadRunner can emulate hundreds or thousands of concurrent users to put the application through the rigors of real-life user loads, while collecting information from key infrastructure components (Web servers, database servers etc). The results can then be analyzed in detail, to explore the reasons for particular behavior.

Consider the client-side application for an automated teller machine (ATM). Although each client is connected to a server, in total there may be hundreds of ATMs open to the public. There may be some peak times — such as 10 a.m. Monday, the start of the work week — during which the load is much higher than normal. In order to test such situations, it is not practical to have a testbed of hundreds of ATMs. So, given an ATM simulator and a computer system with LoadRunner, one can simulate a large number of users accessing the server simultaneously. Once activities have been defined, they are repeatable. After debugging a problem in the application, managers can check whether the problem persists by reproducing the same situation, with the same type of user interaction.

HP LoadRunner is an automated performance and test automation product from Hewlett-Packard for examining system behaviour and performance, while generating actual load. HP acquired LoadRunner as part of its acquisition of Mercury Interactive in November 2006.HP LoadRunner can simulate thousands of concurrent users to put the application through the rigors of real-life user loads, while collecting information from key infrastructure components(Web servers, database servers etc.)The results can then be analyzed in detail, to explore the reasons for particular behavior.

LoadRunner supports various application protocols; Flex AMF, Citrix ICA, Remote Desktop Protocol (RDP), ERP/CRM (e.g. SAP, Oracle eBusiness, Siebel and PeopleSoft), Databases, Mail Clients, Web Services, AJAX TruClient (with V.11.0).

LOADRUNNER COMPONENTS

Page 2: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Loadrunner has mainly three components.

VuGen (Virtual user generator)

Controller (License based component)

Analysis

apart from these components there are other components like LoadRunner Agent process.

Vugen: The purpose of Vugen is to create scripts for single user and do the required enhancements to the script in a such a way that it can be run for multiple users.

Controller:The purpose of Controller is to Run the load test and monitor the servers during load test execution. In loadrunner language is to create scenarios and the run the loadrunner controller scenario. Generally Controller installed in a client environment machine which will be configured with loadrunner license for defined number of users. Performance engineers to connect to this machine to run the load test. If the client has multiple projects and multiple performance engineer resources, client may setup multiple controller with multiple licenses.Analysis:Analysis will be used to Analyze the results and create graphs and reports to present the performance test report to stake holders.

Page 3: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

File Extensions:

VuGen : .USR is the file extension.Controller : .lrs is the file extension. - -> .lrr Analysis : .lra is the file extension

Loadrunner environment:Number of machines required in loadrunner test environment. In general you can use one machine by installing all the components one box. 1 Machine: Controller, Vugen, Anaylysis and Loadrunner agent process. The disadvantage is we may not able to run bigger load test. Multiple Machine: Controller1 - 1 Machine - 1000 user license Load generators - 3 Machines Controller2 - 1 Machine - 3000 user license Load generators - 3 Machines Controller4 - 1 Machine - 2000 user license Load generators - 3 Machines Architecture of LoadRunner:

How load runner works?Suppose you want to test a bank server that serves many automatic teller machines (ATMs).

The ATMs provide a full range of banking services to the bank's customers--such as withdrawing and depositing cash.

To test the bank server using LoadRunner, you create a scenario. The scenario defines the actions that are performed

on the server during the load test. During the scenario that loads and monitors the bank server, you want to:

1. emulate conditions of controlled load on the server

2. emulate conditions of maximum load on the server

Page 4: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

3. measure server performance under load

4. check where performance delays occur: network or client delays, CPU performance, I/O delays, database

locking, or other issues at the server monitor the network and server resources under load

All about web_url and web_link in LoadRunnerPoints to note with web_url and web_link:

web_url is not a context sensitive function while web_link is a context sensitive function. Context sensitive functions describe your actions in terms of GUI objects (such as windows, lists, and buttons). Check HTML vs URL recording mode. If web_url statement occurs before a context sensitive statement like web_link, it should hit the server, otherwise your script will get error’ed out. While recording, if you switch between the actions, the first statement recorded in a given action will never be a context sensitive statement. The first argument of a web_link, web_url, web_image or in general web_* does n

ot affect the script replay. For example: if your web_link statements were recorded asOn executing the above script

you won’t find the actual text of the parameter {Welcome to Learn LoadRunner} instead you will find {Welcome

to Learn LoadRunner} itself in the execution log. However to show the correlated/parameterized data you can

uselr_eval_string to evaluate the parameter

Types of VUsersLoadRunner has various types of Vusers. Each type is designed to handle different aspects of today's client/server architectures.

You can use the Vuser types in any combination in a scenario in order to create a comprehensive client/server test. The following Vuser types are available:

The Vuser types are divided into the following categories: All Protocols: a list of all supported protocols in alphabetical order.

1. Application Deployment Solution: For the Citrix protocol.

2. Client/Server: For DB2 CLI, DNS, MS SQL, ODBC, Oracle (2-tier), Sybase

3. Ctlib, Sybase Dblib, and Windows Sockets protocols.

4. Custom: For C templates, Visual Basic templates, Java templates,

5. Javascript and VBscript type scripts.

6. Distributed Components: For COM/DCOM, Corba-Java, and Rmi -Java protocols.

7. E-business: For FTP, LDAP, Palm, Web (HTTP/HTML), Web Services, and the dual Web/Winsocket protocols.

8. Enterprise Java Beans: For EJB Testing and Rmi-Java protocols.

9. ERP/CRM: For Baan, Oracle NCA, Peoplesoft-Tuxedo, Peoplesoft 8,

10. SAPGUI, SAP-Web, and Siebel (Siebel-DB2CLI, Siebel-MSSQL, Siebel-Web, and Siebel-Oracle) protocols.

11. Legacy: For Terminal Emulation (RTE).

12. Mailing Services: Internet Messaging (IMAP), MS Exchange (MAPI), POP3, and SMTP.

13. Middleware: Jacada and Tuxedo (6, 7) protocols.

14. Streaming: For MediaPlayer and RealPlayer protocols.

15. Wireless: For i-Mode, VoiceXML, and WAP protocols.

Page 5: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Unlike a WinRunner workstation which emulates a single user's use of a client, LoadRunner can emulate thousands of Virtual Users.

Load generators are controlled by VuGen scripts which issue non-GUI API calls using the same protocols as the client under test. But WinRunner GUI Vusersemulate keystrokes, mouse clicks, and other User Interface actions on the client being tested Only one GUI user can run from a machine unless LoadRunner Terminal Services Manager manages remote machines with Terminal Server Agent enabled and logged into a Terminal Services Client session.During run-time, threaded vusers share a common memory pool. So threading supports more Vusers per load generator.

The Status of Vusers on all load generators start from "Running", then go to "Ready" after going through the init section of the script. Vusers are "Finished" in pass or failed end status. Vusers are automatically "Stopped" when the Load Generator is overloaded.

No additional license is needed to monitor standard web (HTTP) servers (Apache, IIS, and Netscape).

To use Web Services Monitors for SOAP and XML, a separate license is needed, and vUsers require the Web Services add-in installed with Feature Pack (FP1)

Why LoadRunner? What are the uses of Load RunnerWhy load runner:

LoadRunner reduces the personnel requirements by replacing human users with virtual users or Vusers. These Vusers emulate the behavior of real users-- operating real applications.

Because numerous Vusers can run on a single computer, LoadRunner reduces the hardware requirements.

The LoadRunner Controller allows you to easily and effectively control all the Vusers--from a single point of control.

LoadRunner automatically records the performance of the client/server system during a test. You can choosefrom a wide variety of graphs and reports how you want to view the performance data.

LoadRunner checks where performance delays occur: network or client delays, CPU performance, I/O delays, database locking, or other issues at the database server. LoadRunner monitors the network and server resources to help you improve performance.

Because LoadRunner tests are fully automated, you can easily repeat them as often as you need.

Uses Of LoadRunner:

Using LoadRunner, you divide your client/server performance testing requirements into scenarios.

A scenario defines the events that occur during each testing session. Thus, for example, a scenario defines and controls the number of users to emulate, the actions that they perform, and the machines on which they run their emulations.

In the scenario, LoadRunner replaces human users with virtual users or Vusers. When you run a scenario, Vusers emulate the actions of human users--submitting input to the server. While a workstation accommodates only a single human user, many Vusers can run concurrently on a single workstation. In fact, a scenario can contain tens, hundreds, or even thousands of Vusers.

To emulate conditions of heavy user load, you create a large number of Vusers that perform a series of tasks. For example, you can observe how a server behaves when one hundred Vusers simultaneously withdraw cash from the bank ATMs. To accomplish this, you create 100 Vusers, and each Vuser:

enters an account number into an ATM

enters the amount of cash to withdraw

withdraws cash from the account

checks the balance of the account

repeats the process numerous times

Page 6: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

What is performance testing?

Software performance testing is a means of quality assurance (QA). It involves testing software applications toensure they will perform well under their expected workload.

Features and Functionality supported by a software system is not the only concern. A software application’s performance like its response time, do matter. The goal of performance testing is not to find bugs but to eliminate performance bottlenecks

The focus of Performance testing is checking a software programs

Speed – Determines whether the application responds quickly

Scalability – Determines maximum user load the software application can handle.

Stability – Determines if the application is stable under varying loads

Why do performance testing?Performance testing is done to provide stakeholders with information about their application regarding speed, stability, and scalability. More importantly, performance testing uncovers what needs to be improved before the product goes to market. Without performance testing, software is likely to suffer from issues such as: running slow while several users use it simultaneously, inconsistencies across different operating systems and poor usability.

Performance testing will determine whether or not their software meets speed, scalability, and stability requirements under expected workloads’. Applications sent to market with poor performance metrics due to nonexistent or poor performance testing are likely to gain a bad reputation and fail to meet expected sales goals. Also, mission critical applications like space launch programs or life saving medical equipments should be performance tested to ensure that they run for a long period oftime without deviations.

Types of performance testing?Load testing: Load testing is conducted to verify that your application can meet your desired performance objectives; these performance objectives are often specified in a service level agreement (SLA). A load test enables youto measure response times, throughput rates, and resource-utilization levels, and to identify your application’s breaking point, assuming that the breaking point occurs below the peak load condition.Purpose :To verify application behavior under normal and peak load conditions.Stress testing – involves testing an application under extreme workloads to see how it handles high traffic or data processing .The objective is to identify breaking point of an applicationPurpose: To determine or validate an application’s behavior when it is pushed beyond normal or peak load conditions.Endurance tests – is done to make sure the software can handle the expected load over a long period of time.Spike testing – tests the software’s reaction to sudden large spikes in the load generated by users.

Page 7: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Volume testing – Under Volume Testing large no. of. Data is populated in database and the overall software system’s behavior is monitored. The objective is to check software application’s performance under varying database volumes.

Scalability testing – The objective of scalability testing is to determine the software application’s effectiveness in “scaling up” to support an increase in user load. It helps plan capacity addition to your software system.Capacity testing: Capacity testing is conducted in conjunction with capacity planning, which you use to plan for future growth, such as an increased user base or increased volume of data. For example, to accommodate future loads, you need to know how many additional resources (such as processor capacity, memory usage, disk capacity, or network bandwidth) are necessary to support future usage levels. Capacity testing helps you to identify a scaling strategy in order to determine whether you should scale up or scale out. Purpose:To determine how many users and/or transactions a given system will support and still meet performance goals.

Volume TestingVolume test shall check if there are any problems when running the system under test with realistic amounts of data, or evenmaximum or more. Volume test is necessary as ordinary function testing normally does not use large amounts of data, ratherthe opposite.

A special task is to check out real maximum amounts of data which are possible in extreme situations, for example on days with extremely large amounts of processing to be done (new year, campaigns, tax deadlines, disasters, etc.) Typical problemsare full or nearly full disks, databases, files, buffers, counters which may lead to overflow. Maximal data amounts in communications may also be a concern.

Part of the test is to run the system over a certain time with a lot of data. This is in order to check what happens to temporarybuffers and to timeouts due to long times for access. One variant of this test is using especially low volumes, such as empty databases or files, empty mails, no links etc. Some programs cannot handle this either.

One last variant is measuring how much space is needed by a program. This is important if a program is sharing resources with other ones. All programs taken together must not use more resources than available.

So we can summarize Volume Testing as follows:

Objective:

Find problems with max. amounts of data.System performance or usability often degrades when large amounts ofdata must be searched, ordered etc.

Test Procedure:

The system is run with maximum amounts of data.Internal tables, databases, files, disks etc. are loaded with a maximum of data.Maximal length of external input.Important functions where data volume may lead to trouble.Result wanted:

No problems, no significant performance degradation, and no lost data.Considerations:

Data generation may need analysis of a usage profile and may not be trivial. (Same as in stress testing.)Copy of production data or random generation.Use data generation or extraction tools.Data variation is important!Memory fragmentation important!Examples:

Online system: Input fast, but not necessarily fastest possible, from different input channels. This is done for some time in order to check if temporary buffers tend to overflow or fill up, if execution time goes down. Use a blend of create, update, read and delete operations.

Database system: The data base should be very large. Every object occurs with maximum number of instances. Batch jobs are run with large numbers of transactions, for example where something must be done for ALL objects in the data base. Complex searches with sorting through many tables. Many or all objects linked to other objects, and to the maximum number of such objects. Large or largest possible numbers on sum fields.

Performance Testing Process

Page 8: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

The methodology adopted for performance testing can vary widely but the objective for performance tests remain the same. It can help demonstrate that your software system meets certain pre-defined performance criteria. Or it can help compare performance of two software systems. It can also help identify parts of your software system which degrade its performance.

Below is a generic performance testing process

Identify your testing environment – Know your physical test environment, production environment and what testing tools are available. Understand details of the hardware, software and network configurations used during testing before you begin the testing process. It will help testers create more efficient tests. It will also help identify possible challenges that testers may encounter during the performance testing procedures.

Identify the performance acceptance criteria – This includes goals and constraints for throughput, response times and resource allocation. It is also necessary to identify project success criteria outside of these goals and constraints. Testers should be empowered to set performance criteria and goals because often the project specifications will not include a wide enough variety of performance benchmarks. Sometimes there may be none at all. When possible finding a similar application to compare to is a good way to set performance goals.

Plan & design performance tests – Determine how usage is likely to vary amongst end users and identify key scenarios to test for all possible use cases. It is necessary to simulate a variety of end users, plan performance test dataand outline what metrics will be gathered. Configuring the test environment – Prepare the testing environment before execution. Also, arrange tools and other resources.

Implement test design – Create the performance tests according to your test design.

Run the tests – Execute and monitor the tests.

Analyze, tune and retest – Consolidate, analyze and share test results. Then fine tune and test again to see if there is an improvement or decrease in performance. Since improvements generally grow smaller with each retest, stop when bottlenecking is caused by the CPU. Then you may have the consider option of increasing CPU power. Proof of Concept-POCA proof of concept (POC) is a demonstration whose purpose is to verify that certain concepts or theories have the potential for real-world application. POC is therefore a prototype that is designed to determine feasibility, but does not represent deliverables. Proof of concept is also referred to as proof of principle.

A proof of concept (POC) or a proof of principle is a realization of a certain method or idea to demonstrate its feasibility,or a demonstration in principle, whose purpose is to verify that some concept or theory has the potential of being used. A proof of concept is usually small and may or may not be complete.

Requirement Gathering for Performance test ProjectHere are the Ideal Requirements to be included while developing a Performance test plan.

• Deadlines available to complete performance testing, including the scheduled deployment date.• Whether to use internal or external resources to perform the tests. This will largely depend on time scales and in-house expertise (or lack thereof).• Test environment design agreed upon. Remember that the test environment should be as close an approximation of the liveenvironment as you can achieve and will require longer to create than you estimate.• Ensuring that a code freeze applies to the test environment within each testing cycle.• Ensuring that the test environment will not be affected by other user activity. Nobody else should be using the test environment while performance test execution is taking place; otherwise, there is a danger that the test execution and resultsmay be compromised.• All performance targets identified and agreed to by appropriate business stakeholders. This means consensus from all involved and interested parties on the performance targets for the application. • The key application transactions identified, documented, and ready to script. Remember how vital it is to have correctly

Page 9: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

identified the key transactions to script. Otherwise, your performance testing is in danger of becoming a wasted exercise.• Which parts of transactions (such as login or time spent on a search) should be monitored separately. This will be used in Step 3 for “checkpointing.”• Identify the input, target, and runtime data requirements for the transactions that you select. This critical consideration ensures that the transactions you script run correctly and that the target database is realistically populated in terms of size and content. Data is critical to performance testing. Make sure that you can create enough test data of the correct type withinthe time frames of your testing project. You may need to look at some form of automated data management, and don’t forget to consider data security and confidentiality.• Performance tests identified in terms of number, type, transaction content, and virtual user deployment. You should also have decided on the think time, pacing, and injection profile for each test transaction deployment.• Identify and document server, application server, and network KPIs. Remember that you must monitor the application landscape as comprehensively as possible to ensure that you have the necessary information available to identify and resolve any problems that occur.• Identify the deliverables from the performance test in terms of a report on the test’s outcome versus the agreed performance targets. It’s a good practice to produce a document template that can be used for this purpose.• A procedure is defined for submission of performance defects discovered during testing cycles to the development or application vendor. This is an important consideration that is often overlooked. What happens if, despite your best efforts, you find major application, related problems? You need to build contingency into your test plan to accommodate this possibility. There may also be the added complexity of involving offshore resources in the defect submission process. If your plan is to carry out the performance testing in-house then you will also need to address the following points, relating to the testing team.

If there are no requirements, how will you write your test plan?If there are no requirements we try to gather as much details as possible from:

Business Analysts Developers (If accessible) Previous Version documentation (if any)

Stake holders (If accessible)

Prototypes

Performance Test Plan example:

-functionality of application

e.g. Login functionality

user should be able to login into application with valid username and password.if user enters invalid username/password ,

application has to give an error message

Page 10: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

-non-functional requirements

-performance requirements

-Performance of application

e.g. how much time the user took to login into application

50 concurrent users login, time < 100 sec

100 concurrent users login, time < 200 sec

Types of test:

-load test:

-testing an application with requested no. of users. The main objective is to check whether application can sustain

the no. of users with the time frame.

50 concurrent users login, time < 100 sec

100 concurrent users login, time < 200 sec

no. of users (vs) response time

-stress test:

-testing an application with requested no. of users over a time period. The main objective is to check

stability/reliability of application

-Capacity test:

-to check max. user load. How many users the application can sustain.

ramp up scenario

Components in loadrunner:

-virtual user generator

-Create ONE virtual user (vUser: simulation of real user)

-record script

-enhancements:

-parametrization:

-test with more data sets

-check points

-to verify expected result

-correlation(regular expressions)

-to handle dynamic objects

-controller

-controller

-how many such users you need e.g. 50

-design load test scenario

-manual scenario

-no. of users (vs) response time

-no. of users is defined

-goal oriented scenario

-define a goal

- 20 hits per sec

- 10 transactions per sec-run test scenario-monitor test scenario-generate dynamic graphs-analysis-prepare load test reports-send it to project stake holders

Important aspects of Performance test project

Page 11: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Important aspects of a Performance test projectFor a performance testing project to be successful, both the approach to testing performance and the testing itself must be relevant to the context of the project. Without an understanding of the project context, performance testing is bound to focuson only those items that the performance tester or test team assumes to be important, as opposed to those that truly are important, frequently leading to wasted time, frustration, and conflicts.

The project context is nothing more than those things that are, or may become, relevant to achieving project success. This may include, but is not limited to:

The overall vision or intent of the project

Performance testing objectives

Performance success criteria

The development life cycle

The project schedule

The project budget

Available tools and environments set of the

The skill performance tester and the team

The priority of detected performance concerns

The business impact of deploying an application that performs poorly

Some examples of items that may be relevant to the performance-testing effort in your project context include: Project vision: Before beginning performance testing, ensure that you understand the current project vision. The project vision is the foundation for determining what performance testing is necessary and valuable. Revisit the vision regularly, as it has the potential to change as well. Purpose of the system: Understand the purpose of the application or system you are testing. This will help you identify the highest-priority performance characteristics on which you should focus your testing. You will need to know the system’s intent, the actual hardware and software architecture deployed, and the characteristics of the typical end user. Customer or user expectations. Keep customer or user expectations in mind when planning performance testing. Remember that customer or user satisfaction is based on expectations, not simply compliance with explicitly stated requirements. Business drivers: Understand the business drivers – such as business needs or opportunities – that are constrained to some degree by budget, schedule, and/or resources. It is important to meet your business requirements on time and within the available budget. Reasons for testing performance. Understand the reasons for conducting performance testing very early in the project. Failing to do so might lead to ineffective performance testing. These reasons often go beyond a list of performance acceptance criteria and are bound to change or shift priority as the project progresses, so revisit them regularly as you and your team learn more about the application, its performance, and the customer or user. Value that performance testing brings to the project. Understand the value that performance testing is expected to bring to the project by translating the project- and business-level objectives into specific, identifiable, and manageable performance testing activities. Coordinate and prioritize these activities to determine which performance testing activities are likely to addvalue. Project management and staffing:Understand the team’s organization, operation, and communication techniques in order to conduct performance testing effectively. Process. Understand your team’s process and interpret how that process applies to performance testing. If the team’s processdocumentation does not address performance testing directly, extrapolate the document to include performance testing to the best of your ability, and then get the revised document approved by the project manager and/or process engineer. Compliance criteria: Understand the regulatory requirements related to your project. Obtain compliance documents to ensure that you have the specific language and context of any statement related to testing, as this information is critical to determining compliance tests and ensuring a compliant product. Also understand that the nature of performance testing makes it virtually impossible to follow the same processes that have been developed for functional testing. Project schedule: Be aware of the project start and end dates, the hardware and environment availability dates, the flow ofbuilds and releases, and any checkpoints and milestones in the project schedule.

Page 12: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Test Strategy Vs Test PlanningTest Strategy:

A Test Strategy document is a high level document and normally developed by project manager. This document defines “Testing Approach” to achieve testing objectives. The Test Strategy is normally derived from the Business Requirement Specification document(BRS).

The Test Stategy document is a static document meaning that it is not updated too often. It sets the standards for testing processes and activities and other documents such as the Test Plan draws its contents from those standards set in the Test Strategy Document.Some companies include the “Test Approach” or “Strategy” inside the Test Plan, which is fine and it is usually the case for small projects. However, for larger projects, there is one Test Strategy document and different number of Test Plans for each phase or level of testing.

Components of the Test Strategy document : Scope and Objectives

Business issues

Roles and responsibilities

Communication and status reporting

Test deliverability

Industry standards to follow

Test automation and tools

Testing measurements and metrices

Risks and mitigation

Defect reporting and tracking

Change and configuration management

Page 13: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Training plan

Test Plan:

The Test Plan document on the other hand, is derived from the Product Description, Software Requirement Specification(SRS), or Use Case Documents.

The Test Plan document is usually prepared by the Test Lead or Test Manager and the focus of the document is to describe what to test, how to test, when to test and who will do what test.It is not uncommon to have one Master Test Plan which is a common document for the test phases and each test phase have their own Test Plan documents.

There is much debate, as to whether the Test Plan document should also be a static document like the Test Strategy document mentioned above or should it be updated every often to reflect changes according to the direction of the project and activities.

My own personal view is that when a testing phase starts and the Test Manager is “controlling” the activities, the test plan should be updated to reflect any deviation from the original plan. After all, Planning and Control are continuous activities in the formal test process.

Components of the Test Strategy document : Test Plan id

Introduction

Test items

Features to be tested

Features not to be tested

Test techniques

Testing tasks

Suspension criteria

Features pass or fail criteria

Test environment (Entry criteria, Exit criteria)

Test delivarables

Staff and training needs

Responsibilities

Schedule

This is a standard approach to prepare test plan and test strategy documents, but things can vary company-to-company

Mitigation of Performance Testing ImpedimentsAn impediment is anything that prevents people from doing their job. Here are some impediments that performance testing teams have encountered.

A. Unavailability of subject matter / technical experts such as developers and operations staff.

B. Unavailability of applications to test due to delays or defects in the functionality of the system under test.

C. Lack of Connectivity/access to resources due to network security ports being available or other network blockage.

D. The script recorder fails to recognize applications (due to non-standard security apparatus or other complexity in the

application).

E. Not enough Test Data to cover unique conditions necessary during runs that usually go several hours.

F. Delays in obtaining or having enough software licenses and hardware in the performance environment testing.

Page 14: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

G. Lack of correspondence between versions of applications in performance versus in active development.

H. Managers not familiar with the implications of ad-hoc approaches to performance testing.

Fight Or Flight? Proactive or Reactive?

Some call the list above "issues" which an organization may theoretically face.

Issues become "risks" when they already impact a project.

A proactive management style at a particular organization sees value in investing up-front to ensure that desired

outcomes occur rather than "fight fires" which occur without preparation.

A reactive management style at a particular organization believes in "conserving resources" by not dedicating resources to

situations that may never occur, and addressing risks when they become actual reality.

Subject Matter Expertise

The Impediment

Knowledge about a system and how it works are usually not readily available to those outside the development team.

What documents written are often one or more versions behind what is under development.

Requirements and definitions are necessary to separate whether a particular behavior is intended or is a deviation from

that requirement.

Even if load testers have access to up-to-the-minute wiki entries, load testers usually are not free to interact as a peer of

developers.

Load testers are usually not considered a part of the development team or even the development process, so are therefore

perceived as an intrusion to developers.

To many developers, Performance testers are a nuisence who waste time poking around a system that is "already perfect"

or "one we already know that is slow".

What can reactive load testers do?

Work among developers and easedrop on their conversations (like those studying animals in the wild).

What can proactive load testers do?

Up-front, an executive formally establishes expectations for communication and coordination between developers and

load testers.

Ideally, load testers participate in the development process from the moment a development team is formed so that they

are socially bonded with the developers.

Recognizing that developers are under tight deadlines, the load test team member defines exactly what is needed from

the developer and when it is needed.

Page 15: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

This requires up-front analysis of the development organization:

o the components of the application

o which developers work on which component

o contact information for each developer

o existing documents available and who wrote each document

o comments in blogs written by each developer

An executive assigns a "point person" within the development organization who can provide this information.

Assignments for each developer needs to originate from the development manager under whom a developer works for.

When one asks/demands something without the authority to do so, that person would over time be perceived as a

nuisence.

No one can serve two masters. For you will hate one and love the other; you will be devoted to one and despise the

other.

A business analyst who is familiar with the application's intended behavior makes a video recording of the application

using a utility such as Camtasia from ToolSmith. A recording has the advtange of capturing the timing as well as the steps.

The U.S. military developed the web-based CAVNET system to collaborate on innovations to improvise around impediments

found in the found.

Availability of applications

The Impediment

Parts of an applications under active development become inacessible while developers are in the middle of working on

them.

The application may not have been built successfully. There are many root causes for bad builds:

o Specification of what goes into each build are not accurate or complete.

o Resources intended to go into a particular build are not made available.

o An incorrect version of a component is built with newer incompatible components.

o Build scripts and processes do not recognize these potential errors, leading to build errors.

o Inadequate verification of build completeness.

What can reactive load testers do?

Frequent (nightly) builds may enable testers more opportunities than losing perhaps weeks wait for the next good build.

Testers switch to another project/application when one application cannot be tested.

What can proactive load testers do?

Use a separate test environment that is updated from the development system only when parts of the application become

Page 16: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

stable enough to test.

Have a separate test environment for each version so that work on a prior version can occur when a build is not successful

on one particular environment.

Develop a "smoke test" suite to ensure that applications are testable.

Coordinate testing schedules with what is being changed by developers.

Analyze the root causes of why builds are not successful, and track progress on elminating those causes over time.

Connectivity/access to resources

The Impediment

Workers may not be able to reach the application because of network (remote VPN) connectivity or security access.

What can reactive load testers do?

Work near the physical machine.

Grant unrestricted access to those working on the system.

What can proactive load testers do?

Analyze the access for each functionality required by each role.

Pre-schedule when those who grant access are available to the project.

Script Recorder Recognition

The Impediment

Load test script creation software such as LoadRunner work by listening and capturing what goes across the wire and

display those conversations as script code which may be modified by humans.

Such recording mechanisms are designed to recognize only standard protocols going through the wire.

Standard recording mechanisms will not recognize custom communications, especially within applications using

advanced security mechanisms.

Standard recording mechanisms also have difficulty recognizing complex use of Javascript or CSS syntax in SAP portal

code.

What can reactive load testers do?

Skip (de-scope) portions which cannot be easily recognized.

What can proactive load testers do?

To ensure that utility applications (such as LoadRunner) can be installed, install them before locking down the system.

Define the pattern install them before locking down the system.

Page 17: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Test Data

The Impediment

Applications often only allow a certain combination of values to be accepted. An example of this is only specific postal zip

codes being valid within a certain US state.

Using the same value repeatedly during load testing does not create a realistic emulation of actual behavior because most

modern systems cache data in memory, which is 100 times faster than retrieving data from a hard drive.

This discussion also includes role permissions having a different impact on the system. For example, the screen of an

administrator or manager would have more options. The more options, the more resources it takes just to display the screen

as well as to edit input fields.

A wide variation in data values forces databases to take time to scan through files. Specifying an index used to retrieve

data is the most common approach to make applications more efficient.

Growth in the data volume handled by a system can render indexing schemes inefficient at the new level of data.

What can reactive load testers do?

Use a single role for all testing.

Qualify results from each test with the amount of data used to conduct each test.

Use trial-and-error approachs to finding combinations of values which meet field validation rules.

Examine application source code to determine the rules.

Analyze existing logs to define the distribution of function invocations during test runs.

What can proactive load testers do?

Project the likely growth of the application in terms of impact to the number of rows in each key data variable. This

information is then used to define the growth in row in each table.

Define procedures for growing the database size, using randomized data values in names.

Test Environment

The Impediment

Creating a separate enviornment for load testing can be expensive for a large complex system.

In order to avoid overloading the production network, the load testing enviornment is often setup so no communication

is possible to the rest of the network. This makes it difficult to deploy resources into the environment and then retrieve run

result files from the environment.

A closed environment requires its own set of utility services such as DNS, authentication (LDAP), time sychronization,

etc.

Page 18: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

What can reactive load testers do?

Change network firewalls temporarily while using the development environment for load testing (when developers do not

use it).

Use the production fail-over environment temporarily and hope that it is not needed during the test.

What can proactive load testers do?

Build up a production environment and use it for load testing before it is used in actual production.

Correspondance Between Versions

The Impediment

Defects found in the version running on the perftest environment may not be reproducible by developers in the

development/unit test environments running a different (more recent) version.

Developers may have moved on to a different version, different projects, or even different employers.

What can reactive load testers do?

Rerun short load tests on development servers. If the server is shared, the productivity of developers would be affected.

What can proactive load testers do?

Before testing, freeze the total state of the application in a full back-up so that the exact state of the system can be

restored, even after changes are tried to diagnose or fix the application on the system where it's found.

Run load tests with trace logs information. This would not duplicate how the system is actually run in production mode.

Ad-hoc Approaches

The Impediment

Most established professional fields (such as accounting and medicine) have laws, regulations, and defined industry

practices which give legitimacy to certain approaches. People are trained to follow them. The consequences of certain

courses of action are known.

But the profession of performance and load testing has not matured to that point.

The closest industry document, ITIL, is not yet universally adopted. And ITIL does not clarify the work of performance

testing in much detail.

Consequently, each individual involved with load testing is likely to have his/her own opinions about what actions should

be taken.

This makes rational exploration of the implications of specific courses of action a conflict-ridden and thus time-

consuming and expensive endeavor.

What can reactive load testers do?

Allocate time for planning before starting actual work until concurrance on the project plan is achieved among the

Page 19: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

stakeholders.

Revise project completion estimates or scope as new information becomes available.

What can proactive load testers do?

Before the project gets away, agree on the rationale for elements of the project plan and who will do what when

(commitments of tasks and deliverables). This is difficult for those who are not accustomed to being accountable, and

requests for it would result in withdrawl or other defensive behavior.

Identify alternative approaches and analyze them before managers come up with it themselves.

Up-front, identify how to contact each stakeholder and keep them updated at least weekly, and immediately if decisions

impact what they are actively working on.

If a new manager is inserted in the project after it starts, review the project plan and rationale for its elements.

Case Studies – Identifying Performance-testing ObjectivesCase Study 1 Scenario

A 40-year-old financial services company with 3,000 employees is implementing its annual Enterprise Resource Planning (ERP) software upgrade, including new production hardware. The last upgrade resulted in disappointing performance and many months of tuning during production.

Performance Objectives

The performance-testing effort was based on the following overall performance objectives: Ensure that the new production hardware is no slower than the previous release. Determine configuration settings for the new production hardware. Tune customizations.

Performance Budget/Constraints

The following budget limitations constrained the performance-testing effort: No server should have sustained processor utilization above 80 percent under any anticipated load. (Threshold) No single requested report is permitted to lock more than 20 MB of RAM and 15-percent processor utilization on the Data Cube Server. No combination of requested reports is permitted to lock more than 100 MB of RAM and 50-percent processor utilization onthe Data Cube Server at one time.

Performance-Testing Objectives

The following priority objectives focused the performance testing: Verify that there is no performance degradation over the previous release. Verify the ideal configuration for the application in terms of response time, throughput, and resource utilization.Resolve existing performance inadequacy with the Data Cube Server.

Questions1. The following questions helped to determine relevant testing objectives:

2. What is the reason for deciding to test performance?

3. In terms of performance, what issues concern you most in relation to the upgrade?

4. Why are you concerned about the Data Cube Server?

Case Study 2Scenario

Page 20: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

A financial institution with 4,000 users distributed among the central headquarters and several branch offices is experiencing performance problems with business applications that deal with loan processing.Six major business operations have been affected by problems related to slowness as well as high resource consumption and error rates identified by the company’s IT group. The consumption issue is due to high processor usage in the database, while the errors are related to database queries with exceptions.

Performance Objectives The performance-testing effort was based on the following overall performance objectives:

The system must support all users in the central headquarters and branch offices who use the system during peak business hours.

The system must meet backup duration requirements for the minimal possible timeframe.

Database queries should be optimal, resulting in processor utilization no higher than 50-75 percent during normal and peak business activities.

Performance Budget/Constraints

The following budget limitations constrained the performance-testing effort: No server should have sustained processor utilization above 75 percent under any anticipated load (normal and

peak) when users in headquarters and branch offices are using the system. (Threshold)

When system backups are being performed, the response times of business operations should not exceed 8 percent,or the response times experienced when no backup is being done.

Response times for all business operations during normal and peak load should not exceed 6 seconds.

No error rates are allowable during transaction activity in the database that may result in the loss of user-submitted loan applications.

Performance-Testing Objectives

The following priority objectives focused the performance testing: Help to optimize the loan-processing applications to ensure that the system meets stated business requirements.

Test for 100-percent coverage of the entire six business processes affected by the loan-manufacturing applications.

Target database queries that were confirmed to be extremely sub-optimal, with improper hints and nested sub-query hashing.

Help to remove superfluous database queries in order to minimize transactional cost.

Tests should monitor for relevant component metrics: end-user response time, error rate, database transactions per second, and overall processor, memory, network, and disk status for the database server.

Questions1. The following questions helped to determine relevant testing objectives:

2. What is the reason for deciding to test performance?

3. In terms of performance, what issues concern you most in relation to the queries that may be causing processor bottlenecks and transactional errors?

4. What business cases related to the queries might be causing processor and transactional errors?

5. What database backup operations might affect performance during business operations?

6. What are the timeframes for back-up procedures that might affect business operations, and what are the most critical scenarios involved in the time frame?

7. How many users are there and where are they located (headquarters, branch offices) during times of critical business operations?

These questions helped performance testers identify the most important concerns in order to help prioritize testing efforts. The questions also helped determine what information to include in conversations and reports.

Case Study 3ScenarioA Web site is responsible for conducting online surveys with 2 million users in a one-hour timeframe. The site infrastructure was built with wide area network (WAN) links all over the world. The site administrators want to test the site’s performance to ensure that it can sustain 2 million user visits in one hour.

Performance Objectives

Page 21: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

The performance-testing effort was based on the following overall performance objectives: The Web site is able to support a peak load of 2million user visits in a one-hour timeframe. Survey submissions should not be compromised due to application errors.

Performance Budget/Constraints

The following budget limitations constrained the performance-testing effort: No server can have sustained processor utilization above 75 percent under any anticipated load (normal and peak) during submission of surveys (2 million at peak load). Response times for all survey submissions must not exceed 8 seconds during normal and peak loads. No survey submissions can be lost due to application errors.

Performance-Testing Objectives

The following priority objectives focused the performance testing: Simulate one user transaction scripted with 2 million total virtual users in one hour distributed among two

datacenters, with 1 million active users at each data center.

Simulate the peak load of 2 million user visits in a one-hour period.

Test for 100-percent coverage of all survey types.

Monitor for relevant component metrics: end-user response time, error rate, database transactions per second, andoverall processor, memory, network and disk status for the database server.

Test the error rate to determine the reliability metrics of the survey system.

Test by using firewall and load-balancing configurations.

Questions

1. The following questions helped to determine relevant testing objectives:

2. What is the reason for deciding to test performance?

3. In terms of performance, what issues concern you most in relation to survey submissions that might cause data loss or user abandonment due to slow response time?

4. What types of submissions need to be simulated for surveys related to business requirements?

5. Where are the users located geographically when submitting the surveys?

How did you plan the Load? What are the Criteria?Load test is planned to decide the number of users, what kind of machines we are going to use and from where they are run. It is based on 2 important documents, Task Distribution Diagram and Transaction profile. Task Distribution Diagram gives us the information on number of users for a particular transaction and the time of the load. The peak usage and off-usage aredecided from this Diagram. Transaction profile gives us the information about the transactions name and their priority levelswith regard to the scenario we are deciding.

Performance Testing Estimation PreparationIt depends of which estimation techniue you are using...if it is WBS then you will have to break all the performance testing activities in smaller parts then using your prior experience you can estimate no of days for each activities. Also take some time for each activity in spare so that you can get time in case of any environmental or deploymental delay or issue. Incase of WBS following activities can be considered:

A. Planning 1. Understanding of application 2. Identifing of NFR 3. Finilazing the workload model 4. setup of test environment and tools& monitors 5. Preperation of Test plan

B. Preperation

Page 22: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

1. Creation & validation of Test scripts 2. Creation of Test Data 3. Creation of business scenarios 4. Getting approval

C. Execution 1.Run a dummy test 2. Baseline test 3. Upgrade or tune the environment (if needed) 4. baseline test2 5. final performance run 6. Analysis 7. Final performance run2 8. Benchmarking etc..

D. Reporting 1. Creation of performance test report 2. Review with seniors or peers 3. Update the report 4. Publish the final report. 5. Getting signoff

PACING Calculation

Pacing Calculation :

D = Duration of the test(test window/time frame)

B = Baseline time(total time taken by 1 Vu to complete 1 whole iteration)

T = Total amount of Think time in the script

I = Expected/Target iteration

R = Residual time of the test window.

R = ( D - (T + B)*I)

P = Pacing interval

Dividing the residual time by target iteration gives pacing interval

Hence:

P = R/I

D is pacing time.(T + B)*I represents the duration of a scenarioand P is the waiting time before the next scenario

Calculating Pacing Time/Think Time to achieve 50 TPS with an average response time of 0.5 seconds with total of 100 Users

Let us start with calculating total number of transactions in an hour.1 sec = 50 trnx3600 sec = xx = 3600 * 50 = 180000 trnx/hour by 100 Users

Page 23: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

We have total number of users given as 100. Let us see how to calculate how many transactions each user will perform.Total Number of Users = 100Each User will perform 180000/100=1800 transactions/hour

Since, every transaction is taking on an average 0.5 seconds, let us see how much time is required to complete the each user transactions.To complete 1800 trnx it will take 1800*0.5 = 15 minutes

So now, let us see how much think-time is required to complete the required number transactions per User in an hour.1800 transactions will complete in 15 minuteshence, 45 minutes of thinktime is required in between 1800 transactions (i.e. 45*60 = 2700 seconds of thinktime required in between 1800 transactions (per user))2700 seconds = 1800 trnxx = 1 trnxx = 1.5 seconds think time need to include

Let us see how much time is required to complete each iteration.Total time required to complete each Iteration = x + 0.5 seconds= 1.5 + 0.5= 2 seconds

Verification: Let us verify if our above calculation is correct.Total time = 1800 * 2= 3600 seconds= 1 Hr

So, Each User will perform 1800 transactions where we will provide 2 seconds for each Iteration to complete.

Random Virtual User Pacing in LoadRunner:I guess there's always a first time. I had never used LoadRunner's random virtual user (VU) pacing earlier, but am working on a project that will need to use this feature for the first time. And as I thought about it a little more, I may start using it more frequently now. Here's how it happened

This is one of the rare projects that provided me with excellent documentation - not only system documentationlike the system specs, API Guides etc but also performance requirements like actual production volume reports and capacity models that estimated the projected volumes.

The capacity models estimated the maximum transaction load by hour as well as by minute (max TPM). What I needed to do was take maximum hourly load, divide it by 60 to get a per minute transactional load and use this as the average TPM. The idea was to vary the VU pacing so that over the whole duration of test, average load stays at this Average TPM but it also reaches the Max TPM randomly.

For example, if the maximum hourly transaction rate is 720 requests and maximum TPM is 20, the average TPM will be 720/60 = 12 and I will need to vary the pacing so that the load varies between 4TPM and 20TPM and averages to around 12TPM.

The Calculation:To vary the transactional load, I knew I had to vary the VU Pacing randomly. Taking above example, I had to achieve 12TPM and I knew the transactions were taking around 1-2 seconds to complete. So I could have the

Page 24: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

pacing of around 120 seconds if I needed to generate a fixed load of 12TPM with a 5 second Ramp-up and 24 users.

Script TPM Number of VUs

Pacing (sec)

Ramp Up

Script 1 12 24 120 1 VU/5sec

So now to vary the TPM to x with the same 24 virtual users, I will need to have a pacing of 24*60/x. I got this from an old-fashioned logic which goes in my head this way:24 users with a pacing of 60 seconds generate a TPM of 2424 users with a pacing of 120 seconds generate a TPM of 24 * 60/12024 users with a pacing of x seconds generate a TPM of 24 * 60/x

So using above formula, to vary the load from 20 to 4TPM I will need to vary the VU pacing from 72 to 360. So now we have:

Script TPM Number

of VUs

Pacing

(sec)

Ramp

Up

Script 1 4 to 20 24 Random

(72 to

360)

1

VU/5sec

Page 25: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Of course, there's a caveat. The range of 72 to 360 seconds has an arithmetic mean of 216. 120 is actually the harmonic mean of the 2 numbers. So the actual variation in TPM will depend on the distribution of random numbers that LoadRunner generates within the given range. If it generates the numbers with a uniform distribution around the arithmetic mean of the range, then we have a problem.

I ran a quick test to find this out. I created an LR script and used the rand() function to generate 1000 numbers between the range with the assumption that LR uses a similar function to generate the random pacing values.

int i;srand(time(NULL));for (i=0;i<1000 br="" i="">lr_output_message("%d\n", rand() % 289 + 72);}

And of course, the average came out close to the arithmetic mean of 72 and 360, which is 216.

So with the assumption that the function used by LoadRunner for generating random pacing values generates numbers that are uniformly distributed around the arithmetic mean of the range, we'll need to modify the rangeof pacing values so that the arithmetic mean of the range gives us the arithmetic mean of the TPM that we want...phew. What it means is that the above pacing values need to be modified from 72 to 360 (arithmetic mean = 216) to 72 to 168 (arithmetic mean = 120). However, this gives us the TPM range of 20 to 8.6 TPM with a harmonic mean of 12TPM.

But I'll live with it. I would rather have the average load stay around 12TPM. So here are the new values. Note the asterisk on TPM. I need to mention in the test plan that the actual TPM will vary from 8.6 to 20TPM with an average of 12TPM.

Script TPM* Number of

VUs

Pacing (sec) Ramp

Up

Script 1 4 to 20 24 Random (72 to 168) 1

VU/5sec

Vuser Calculation In LoadRunnerHow to calculate number of virtual users (VUsers) for load/stress testing? What should be the concurrent virtual users to load?

What should be the peak load?

25, 100, 500, 1000. We cannot give number of VUsers blindly which will not return intuitive result for analysis.

The main purpose of VUsers is to simulate the live environment. It is very tricky but easy to obtain number of VUsers required for the load/stress testing. Universal formula to calculate the arriving rate to the system is Little’s Law.

N = Z * (R + T)

where

N – number of VUsers,Z – Transactions per Second (TPS)R – Response Time in secondsT – Think Time in seconds

If you get the following data from the stakeholders i.e. TPS, Response Time and Think Time, number of VUsers can be calculated easily.

Page 26: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

E.g. TPS is 100, R is 3 sec and T is 2 sec then N will be

N = 100 * (3+2)= 100 * 5= 500 Peak load will be 500 VUsers.

General Guidelines for ScriptingThese are the general guidelines to be followed while creating LoadRunner scripts for performance testing:

Load testing is intended for assessing the behavior of the application when multiple users are accessing the application. Hence the purpose of testing and performance requirements should be clearly defined before start of creation of scripts. Thisincludes figuring out the various business processes, transactions that are widely used by end users, the business critical transactions and transactions that include pages, which will take large amount of time for load testing.Do not create one script for each transaction or functionality. Group the transactions into multiple sets (different actions) and create minimum number of scripts covering all the transactions. During actual test, the actions, which are not required for that specific test, can be removed from the running list of actions.Give meaningful names for scripts, transactions and actions in the scripts. Do not leave the default names for actions.Create separate actions for Login to the application and Log out of the application and keep them in ‘vuser_init’ and ‘vuser_end’ sections.In the beginning of the script, provide a brief description regarding the script flow. Add appropriate comments for all transactions and major steps.Insert rendezvous statements when a particular page is to be tested when multiple users are simultaneously accessing it.If a portion of script is to be executed multiple times in each iteration, include this portion in a ‘for’ loop and indicate through a parameter for how many times this portion is to run rather than putting it in a block (in ‘Pacing’ tab of runtime settings) and specifying how many times to run.By doing this the behavior of script can be better controlled by changing the value in a data file rather than every time going and changing runtime settings.Add ‘lr_vuser_status_message’ functions at appropriate places with information such as which iteration is being executed. These types of message functions are very useful to find out status of vusers and how the testing is going on.

LoadRunner VuGen scripting - How to automatically download file from server and save it to local disk?LoadRunner records file transferring from server and does not record file saving.

What to do, if you have to save transferred file to local disk?Continue reading, and you will get the solution :)

You can download file from a server with the web_url function.See an example:

Image downloading: web_url("logo.gif", "URL=http://www.google.com/intl/en_ALL/images/logo.gif", "Resource=1", "RecContentType=image/gif", "Snapshot=t1.inf", LAST);

This code downloads Google's logo image:

Page 27: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

To save this image as file to local disk, we have to perform these steps: Capture image from server's response Save captured data to local disk

How to capture image from server's response?

Use web_reg_save_param function with the following boundaries - "LB=\r\n\r\n", "RB=". These boundaries allows to capture the whole data from a body of server's response. Function will look like:web_reg_save_param("prmLogoImage", "LB=\r\n\r\n", "RB=", LAST);

This function should be placed before web_url function. After execution, prmLogoImage parameter will contain GIF-file.

I will clarify briefly the meaning of boundaries - "LB=\r\n\r\n" and "RB=".Please, read the basic concepts of HTTP protocol, read Request message section:

HTTP response consists of the following: Headers, such as HTTP/1.1 200 OK or Content-Length: 3473 An empty line A message body, containg text of requested page or file

So, Header and Message body should be separated by empty line.First CRLF (that is, a carriage return (CR = "\r") followed by a line feed (LF = "\n")) ends last header, and second CRLF ( = "\r\n") creates empty line. All data, followed by second CRLF, are treated as message body.To summarize - "LB=\r\n\r\n" says "start capturing from the beginning of message body", empty right boundary "RB=" says"capture data till the end of message".

Open LoadRunner and enable logging of data, returned by server:

Then execute script containing initial web_url function, and open Replay log:

Page 28: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

As you see, Replay log contains "\r\n\r\n" at the end of server's response.Also, pay attention, that server returns the length of file to be downloaded (Content-Length: 8558).

Save captured data to local diskSaving captured binary data (in our case, GIF file) requires additional step - we have to determine the length (= size) of captured data.

Tips: The simplest way - strlen function - is not correct. Imagine, that that captured data contains embedded NULL characters ('\0'):"123\0qwe"The real size of captured data = 7 bytes ('1', '2', '3', '\0', 'q', 'w', 'e').But strlen function will return value 3, because it counts bytes before the first NULL character ('\0').

To calculate size of captured data use lr_eval_string_ext function:lr_eval_string_ext ("{prmLogoImage}", strlen("{prmLogoImage}") /* = 14*/, &szBuf, &nLength, 0, 0,-1);

lr_eval_string_ext function copies captured data into szBuf array and places a size of captured data into nLength variable. That's easy, I hope :) If not, Help will help :)

Tips: There is another way to get known the size of file to be downloaded. Remember, that server returned the length of file (Content-Length: 8558). So, you can extract this value using Correlation.

And the last action is to save binary data from szBuf array into a local file. I used standard fwrite function from C programming language:fwrite(szBuf, len, 1, hFile);

Well, please see the whole source code:

Click the block to expand the source code: int WriteDataToFile(char *szFileName, const char *szBuf, int len) { int hFile;

hFile = fopen(szFileName,"wb"); .....

Execute the source code, and you will see, that new file will be created and saved automatically - "C:\LogoImage.gif". And this is what we needed - Google's logo image.

VuGen does not launch any applications while recording

Turn off Data Execution Prevention in WindowsIf this problem occurs with every application that it tries to launch, make sure Data Execution Prevention is turned off. To find Data Execution Prevention:

1. Right-click on My Computer, and choosing Properties.2. Select the Advanced tab, and click on Performance, then Settings.

Page 29: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

3. Select the Data Execution Prevention tab, and make sure the first option is selected which is “Turn on DEP for essential Windows programs and services only.

Difference between HTML, URL and GUI Mode RecordingHTML Mode:

Default and recommended recording mode.

Records HTML action in the context of the current Web page so that all we see on a web page will be recorded in a single function which makes it easier to read.

Advantage of this mode is that it generates a script that is intuitive to the reader in terms of what is the form requesting (in a form of entire web page).

Best for browser applications.

URL Mode:Instructs VuGen to record all requests and resources from the server. It automatically records every HTTP resource as URL steps.

Generates a script that has all known resources downloaded for your viewing which works good with non-HTML applications such as applets and non-browser applications (e.g. Win32 executables).

Having everything together creates another problem of overwhelming low-level information and making the script unintuitive. Difficult to read.

When there are unrecognizable requests made to the server in Web (HTTP/HTML) protocol, they are recorded as web_custom_request. However, in URL-mode, this can be selected to allow recording to default to web_custom_request.

GUI Mode:Introduced with Web (Click & Script) protocol.GUI-mode option instructs VuGen to record all editable fields in an object or non-browser applications. What it does is to detect the fields that have been edited and generate the scripts accordingly.Concept similar to functional testing when objects are detected at theGUI-level. When reading the script, it allows easier reading as the script is based on the GUI presented to the real user. Easier to read in context of the object.Best for applets and non-browser applications.

Converting a String from HTML to URL format in LRI need to correlate a string in LR script which is in below formatu4yxAKJcJkcHw7ou%2BagbvBykfJqrjFlgu4QHZw%2FAY1w5eBs0j2cPwaC%2Bo7KQfbYHvZsat

But using web_Reg_save_param() function I could only capture in this formatu4yxAKJcJkcHw7ou+agbvBykfJqrjFlgu4QHZw/AY1w5eBs0j2cPwaC+o7KQfbYHv

The issue is the captured string has "+" spaces inbetween. I have to convert the "+" to something like "%2B"basically from HTML format to URL format.

After correlation. I used web_convert_param() function to convert it to URL. passed it to a parameter and used that parameter to replace the hardcoded string

Please see below picture:

Page 30: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Turning off scripting errors - "MESSAGE FROM WEBPAGE" IN LOAD RUNNERYou may find you get pop-up messages in some WebbIE applications and more generally in Internet Explorer that tell you about scripting errors on the web page. Generally, unless you are a web developer, you just don't care about these messages and don't want them to appear. Turning them off won't hurt the operation of any program, so here is how to turn off scripting error messages in Internet Explorer. These messages say things like "Errors on this webpage might cause it to work incorrectly."

The first thing to try is turning off these messages in Internet Explorer:Open Internet ExplorerOpen the Tools menu (Alt and T)Select the Internet Options item (O key)The Internet Options dialog has many tabs. You need the Advanced tab. Press Control and Tab until you get to the Advanced Tab (that's six presses for Internet Explorer 8)You should now be in a list, starting with Accessibility as the first item in Internet Explorer 8. This has the scripting options you want to change.Cursor down to "Disable script debugging (Internet Explorer)" and press Space until it is on.Cursor down to "Disable script debugging (Other)" and press Space until it is on.Cursor down to "Display a notification about every script error" and press Space until it is off.Press the Return key to close the Internet Options dialog. You should now have turned off the scripting errors.

Page 31: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Not worked? Here are some other things you can try:Update Internet Explorer. You should be on the latest Internet Explorer, it's safer and better. You can get it from Windows Update. Start Internet Explorer, Alt and T for the Tools menu, then cursor down to Windows Update.Change your antivirus program. These cause no end of trouble.Set your Internet Explorer Security settings to Default. You do this again in the Internet Explorer Tools menu, Internet Options, Security tab, and click Default Level.Delete your Internet Explorer temporary files and cookies and history. Internet Options, General tab. This will mean you'll have to re-enter your username and password in places where you've saved it, so make sure you know them all before you trythis.

CHECK POINTS--LoadRunner web_reg_find function - How to verify web page content?When you perform load testing, you have to be fully confident, that your application works correctly. It may be very usefull tocheck UI of application - is it shown correctly or not.

This verification can be performed with 2 ways: Using LoadRunner content verification with web_reg_find function Running LoadRunner GUI Vusers (QTP or WR scripts) The present LoadRunner tutorial describes content verifications with web_reg_find function. I will explain and show a usageofweb_reg_find function, its attributes and result.To get additional information about the seconds approach (running LoadRunner GUI Vusers), please read the article How toexecute QTP script from LoadRunner?How to add LoadRunner content verification?Let's start with LoadRunner demo Web application - Web Tours.I will show how to check that a greeting 'Welcome to the Web Tours site' is shown on a start page:

Page 32: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

I've recorded a simple script on Web Tour applicati

on - it just opens a start page, logs in, and logs out:

After that: open the script in Tree View (with menu 'View/Tree View') select initial step ('Url: WebTours')

Page 33: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

select the text I would like to check on the page and

right mouse click: Use default seetings in 'Find Text' dialog:

Then open your LoadRunner script in Script View (menu 'View/Script View') and you will see that web_reg_find function has been just added before the first function:

web_reg_find("Text=Welcome to the Web Tours site", "Search=Body", LAST); web_url("WebTours", "URL=...", ...

Note:web_reg_find function has been added before the page opening function (web_url)!This is because LoadRunner web_reg_find function does not search for text on a page, it just registers a search request for a text string on an HTML page.

This is very important and I would like to pay your attention - web_reg_find function should be placed before the function, which loads a page. Description of web_reg_find function attributesThe simplest web_reg_find function can look like:

web_reg_find("Text=Welcome to the Web Tours site", LAST);

Page 34: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

This form means 'register a request to search for a "Welcome to the Web Tours site" text on a next Web page retrieved from aserver.

Attribute 'Text=' contains a text, that should be searched.If the check fails, the error is reported after the next action function executes:

Attribute 'Search=' defines the scope of the search: Body (default value) means to search in a body of server's response and its resources Headers means to search within a pages headers Noresource means to search in a body of HTML page retrived from server and do not searhc in its resources Example:Please, see a server response:

The following web_reg_find function checksthat server's name is 'Xitami':

web_reg_find("Text=Server: Xitami", "Search=Headers", LAST);

The next important attribute of web_reg_find function is 'SaveCount='. Use it to save a number of matches that were found.

Let me show an example on this attribute and you will understand it.Imagine, that we have to get a number of 'A Coach class ticket for :' text on Itinerary page:

Page 35: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

The following code: uses web_reg_find function with "SaveCount=" attribute (3rd line) before the Itinerary page loads then loads Itinerary page (6th line) extracts number of matches (8th line) and compares it to an expected value (9th line):

int nFound;

web_reg_find("Text=A Coach class ticket for :", "SaveCount=TextPresent_Count", LAST);

// open Itinerary page web_image("Itinerary Button", "Alt=Itinerary Button", LAST);

nFound = atoi(lr_eval_string("{TextPresent_Count}")); if (nFound == 11) lr_output_message("Correct number of 'Coach class ticket' text: %d", nFound); else { lr_error_message("Incorrect number of 'Coach class ticket' text: %d", nFound); return 0; }

If you have additional info on 8th line:

nFound = atoi(lr_eval_string("{TextPresent_Count}")); please, read my article How to perform basic operations on LoadRunner parameters?

All previous examples generated errors when text was not present on a page. What about the case, when should check that a web page doesnot containa specific text, say 'Exception occurred'? For that we can use 'Fail=' attribute.

Possibles values: NotFound (default value) means to generate error if the text is not found on a page Found means to generate error if the text is found on a page For example, the following web_reg_find function

web_reg_find("Text=Error occurred","Search=Body", "Fail=Found", LAST); will fail only if a web page contains "Error occurred" text.If this text is not shown on a page, then function finishes successfully.

Tip: use this approach to verify that your application work correctly under heavy load. 'Find Text' dialog for web_reg_find functionYou can generate all content verifications manually or with 'Find Text' dialog.I would recommend using of 'Find Text' dialog for LoadRunner beginners.

For example, there is an analogous 'Find Text' dialog options for previous web_reg_find function example (with 'Error occurred'):

Page 36: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

As for me, I prefer writing web_reg_find function and its attributes manually. Other important info on web_reg_find functionI understand, that the present article is not comprehensive :)

web_reg_save_param(); (detailed description)This function registers a request to save dynamic data information to a parameter.

Syntax for C language:

int web_reg_save_param( const char *ParamName, <List of Attributes>, LAST );

Syntax for Java language:

int object.reg_save_param( String ParamName, String[] attributeList );

The web_reg_save_param function is a Service function used for correlating HTML statements in Web scripts..

Object :An expression evaluating to an object of type WebApi. Usually web for Java and Visual Basic. See also Function and Constant Prefixes.

ParamName : A null–terminated string indicating the name of the parameter to create.

List of Attribute : Attribute value strings (e.g., "Search=all") are not case–sensitive.

LAST :A marker that indicates the end of the argument list.

Note: (Service functions : Service Functions perform customization tasks, like setting of proxies, authorization information, user–defined headers and so forth. These functions do not make any change in the Web application context.

Many of the service functions specify run–time settings for a script. A setting that is set with a service function always overrides the corresponding setting set with the Run–time settings dialog box.)

General Informationweb_reg_save_param is a registration type function. It registers a request to find and save a text string within the server response. The operation is performed only after executing the next action function, such as web_url.

web_reg_save_param is only recorded when correlation during recording is enabled (see VuGen's Recording Options). VuGen must be in either URL–based recording mode, or in HTML–based recording mode with the A script containing explicit URLs only option checked (see VuGen's Recording Options).

Page 37: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

This function registers a request to retrieve dynamic information from the downloaded page, and save it to a parameter. For correlation, enclose the parameter in braces (e.g., "{param1}") in ensuing function calls which use the dynamic data. The request registered byweb_reg_save_param looks for the characters between (but not including) the specified boundaries and saves the information that begins at the byte after the left boundary and ends at the byte before the right boundary.

If you expect leading and trailing spaces around the string and you do not want them in the parameter, add a space at the end of the left boundary, and at the beginning of the right boundary. For example, if the Web page contains the string, "Where and when do you want to travel?", the call:

web_reg_save_param("When_Txt", "LB=Where and ", "RB= do",LAST );

Wth a space after "and" and before "do", will result in "when" as the value of When_Txt. However,

web_reg_save_param("When_Txt", "LB=Where and", "RB=do",LAST );

without the spaces, will result in a value of " when ".

Embedded boundary characters are not supported. web_reg_save_param results in a simple search for the next occurrence after the most recent left boundary. For example, if you have defined the left boundary as the character `{` and the right boundary as the character `}', then with the following buffer c is saved:

{a{b{c}

The left and right boundaries have been located. Since embedded boundaries are not supported, the `}' is matched to the most recent `{` appearing just before the c. The ORD attribute is 1. There is only one matching instance.

The web_reg_save_param function also supports array type parameters. When you specify ORD=All, all the occurrences of the match are saved in an array. Each element of the array is represented by the ParamName_index. In the following example, the parameter name is A:

web_reg_save_param("A", "LB/ic=", "Ord=All", LAST );

The first match is saved as A_1, the second match is saved as A_2, and so forth. You can retrieve the total number of matchesby using the following term: ParamName_count. For example, to retrieve the total number of matches saved to the parameter array, use:

TotalNumberOfMatches=atoi(lr_eval_string("{A_count}"));

This function is supported for all Web scripts, and for WAP scripts running in HTTP or Wireless Session Protocol (WSP) replay mode.

List of AttributesConvert: The possible values are:HTML_TO_URL: convert HTML–encoded data to a URL–encoded data formatHTML_TO_TEXT: convert HTML–encoded data to plain text formatThis attribute is optional. IgnoreRedirections: If "IgnoreRedirections=Yes" is specified and the server response is redirection information (HTTP status code 300-303, 307), the response is not searched. Instead, after receiving a redirection response, the GET request is sent to the redirected location and the search is performed on the response from that location.This attribute is optional. The default is "IgnoreRedirections=No".

LB: The left boundary of the parameter or the dynamic data. If you do not specify an LB value, it uses all of the characters from the beginning of the data as a boundary. Boundary parameters are case–sensitive and do not support regular expressions. To further customize the search text, use one or more text flags. This attribute is required. See the Boundary Arguments section.

NOTFOUND: The handling option when a boundary is not found and an empty string is generated."Notfound=error", the default value, causes an error to be raised when a boundary is not found."Notfound=warning" ("Notfound=empty" in earlier versions), does not issue an error. If the boundary is not found, it sets the parameter count to 0, and continues executing the script. The "warning" option is ideal if you want to see if the string was found, but you do not want the script to fail.Note: If Continue on Error is enabled for the script, then even when NOTFOUND is set to "error", the script continues when the boundary is not found, but an error message is written to the Extended log file.This attribute is optional.

ORD: Indicates the ordinal position or instance of the match. The default instance is 1. If you specify "All," it saves the

Page 38: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

parameter values in an array. This attribute is optional.Note: The use of Instance instead of ORD is supported for backward compatibility, but deprecated. RB: The right boundary of the parameter or the dynamic data. If you do not specify an RB value, it uses all of the characters until the end of the data as a boundary. Boundary parameters are case–sensitive and do not support regular expressions. To further customize the search text, use one or more text flags. This attribute is required. See the Boundary Arguments section.

RelFrameID: The hierarchy level of the HTML page relative to the requested URL. The possible values are ALL or a number. Click RelFrameID Attribute for a detailed description. This attribute is optional.Note: RelFrameID is not supported in GUI level scripts.

SaveLen: The length of a sub–string of the found value, from the specified offset, to save to the parameter. This attribute is optional. The default is –1, indicating to save to the end of the string. SaveOffset: The offset of a sub–string of the found value, to save to the parameter. The offset value must be non–negative. The default is 0. This attribute is optional.

Search: The scope of the search—where to search for the delimited data. The possible values are Headers (Search only the headers), Body (search only body data, not headers), Noresource (search only the HTML body, excluding all headers and resources), or ALL (search body , headers, and resources). The default value is ALL. This attribute is optional.

RelFrameID Attribute in web_reg_save_param()The RelFrameID attribute represents the frame ID of the current HTML page relative to the requested URL. RelFrameID is not supported in GUI level scripts.

In Web scripts, a Relative Frame ID is specified as a dot-delimited sequence of decimal integers also known as qualifiers. You can specify a maximum of seven qualifiers, each qualifier ranging from 1 to 15. Zero is not a valid qualifier for a Relative Frame ID. The first qualifier is always 1, implying the first HTML page that is referenced (as a frame) by the requested URL. The next qualifier denotes the index of the next requested page.

The following section shows a sample hierarchy:

1. the requested URL2. the first HTML page referenced as a frame by the requested URL3. the second HTML page referenced as a frame by the requested URL4. the first HTML page referenced by the 1.2 page.

The following gui delines apply to Relative Frame IDs: Relative Frame IDs are ordered. The lowest possible Relative Frame ID of an HTML page is 1. This is significant when there is an ordinal match on multiple pages. VuGen uses the lowest ID. (see guidelines below)The IDs are seven values separated with a point. Do not pass leading zeros, but do keep in mind that they are implicit and affect the order.

Argument Implicit Value Lowest to Highest

1 0.0.0.0.0.0.1

1.1 0.0.0.0.0.1.1

1.2 0.0.0.0.0.1.2

1.1.1 0.0.0.0.1.1.1

To see all Relative Frame IDs in the log, select Extended log - Advanced trace in the Log Run-Time settings.

All non-HTML pages (e.g. resources) have a Relative Frame ID of zero Therefore, they cannot be explicitly referred to by a Relative Frame ID argument.

If RelFrameID is not specified, or RelFrameID=ALL, VuGen searches all pages (including non-HTML pages) for the

Page 39: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

requested string. If the page is non-HTML, VuGen issues a warning indicating that the string was found in a resource rather than in an HTML page. If RelFrameID is specified, VuGen does not search non-HTML pages.

Specific Relative Frame ID (not RelFrameID=ALL) and Ordinal: When you specify a Relative Frame ID or if the Frame ID is retrieved by default, occurrences (ordinals) are counted within the headers and/or body of a single page, not across pages. The only exception is that a redirection of a page is considered as a continuation of that page. A redirected-to page has the same Relative Frame ID as its redirected-from page.

Specific Ordinal (not Ord=ALL): When VuGen finds a match for the specified ordinal (occurrence) on more than one page, itsaves the value from the page with the lowest Relative Frame ID. If ordinal matches are found in one or more non-HTML pages, the value saved by web_reg_save_param, web_create_html_param and web_create_html_param_ex is the value from the last match it encountered. This value may differ between runs, depending on the order in which the data arrived from the server. Ord=ALL: When you specify Ord=ALL for parameter named <param_name>, all the matches within the specified or defaulted Relative Frame ID (including non-HTML pages) are saved into parameters named < param_name >_<occ>", where "<occ>" begins at 1. < param_name >_count is set to a null-terminated string representing the total number of matches.

When no match is found, "<param_name >_count" is 0. In the following example, web_reg_save_param saves the first occurrence (e.g., "HTML") into "Tags_1", the second (e.g., "HEAD") into Tags_2, and so forth.

web_reg_save_param("Tags", "LB=<", "RB=>", "Ord=ALL", LAST)

Note: It is not recommended to refer directly to a specific occurrence (e.g., "Tags_9" or "Tags_21"). The order of occurrences may not be constant between runs, so that referring directly to a specific occurrence may yield a different value for each run. There may also be other ambiguous cases. Instead of referring to a specific occurrence, loop through the returned values to locate the value in which you are interested.

Use Ord=ALL to search all saved values, not specific occurrences. RelFrameID=ALL: Instructs VuGen to scan all frames (including non-HTML pages). When you explicitly set RelFrameID=ALL, you cannot specify an ordinal; the setting is automatically "Ord=ALL" . This is because occurrences (ordinals) are counted in the order in which they are encountered. Since frames and resources are downloaded in an unpredictable order, the order of the occurrence is unpredictable and may be different from run to run. Defaults :If the RelFrameID attribute is not specified (or cannot be specified, as in web_create_html_param and web_create_html_param_ex), the default is RelFrameID=ALL.

How can we update the length of the Parameter ? Web_Set_Max_Html_param_Len ().Default session id length – 256 CharactersTo update length of the parameterWeb_set_max_html_length (“1024“) function is used to set the maximum length to the parameter to update the length of the parameter

HTTP Response Messages(HTTP CODES)

400 Bad RequestOfficially: The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat therequest without modifications.

When / Why: The request in the script may be badly formatted. The best thing to do is check if the request has any parameters that you have edited, of so check them by debugging.

HTTP 401 UnauthorisedOfficially: The request requires user authentication. The response MUST include a WWW-Authenticate header field (section 14.47) containing a challenge applicable to the requested resource. The client MAY repeat the request with a suitableAuthorization header field (section 14.8). If the request already included Authorization credentials, then the 401 response

Page 40: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

indicates that authorization has been refused for those credentials. If the 401 response contains the same challenge as the prior response, and the user agent has already attempted authentication at least once, then the user SHOULD be presented the entity that was given in the response, since that entity might include relevant diagnostic information. HTTP access authentication is explained in "HTTP Authentication: Basic and Digest Access Authentication"

When / Why: Typically when load testing many users are generated from the same machine. In a Microsoft example the browser can use the current Windows logon credentials as credentials for the web site using NTLM. Therefore if the login is different as does not have the same authorisation as the original login (from the recording phase) during the execution the server may deny access with 401.In the script you should use:SetAuthentication(UserNameVariable,PasswordVariable,DomainVariable);

HTTP 403 ForbiddenOfficially: The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. If the server does not wish to make this information available to the client, the status code 404 (Not Found) can be used instead.

When / Why: If you do not see the error when manually browsing but do see it when running a script check that the script is recent. If there has been aconfiguration change on the server you may see this message: For example if if at one time a server hosted the site and now no longer does so and can't or won't provide a redirection to the new location it may send a HTTP 403 back rather than a more meaningful message.Check that authentication is correctly set up in the script - see HTTP 401.Also check that the browser you are simulating is allowed as a security policy can ban certain types of traffic from a server.

HTTP 404 Not FoundWhen / Why: You may find that when interacted with manually the web site does not appear to throw any HTTP 404 messages.When running a load test script you then may see 404's in the response codes. This can be because the object (probably a page component) that the tool requested does not exist on the server - it may be a .gif or a .js java script or similar that is referenced by the page yet does not exist on the server. In a browser this would simply appear as an empty image place holder in the case of an image for example, or in the case of a java script you may even see nothing if the java script is redundant. As the tool specifically requests the object (as the browser does) it will of course log the 404 message if the object cannot be found.

HTTP 407 Proxy Authentication RequiredOfficially: This code is similar to 401 (Unauthorized), but indicates that the client must first authenticate itself with the proxy. The proxy MUST return a Proxy-Authenticate header field (section 14.33) containing a challenge applicable to the proxy for the requested resource. The client MAY repeat the request with a suitable Proxy-Authorization header field (section 14.34). HTTP access authentication is explained in "HTTP Authentication: Basic and Digest Access Authentication"

When / Why: The script was probably captured with the browser already pointing to a proxy server set (see browser network settings). See the information on HTTP 401 for reasons why this might happen.Typically it's best to avoid running a load test through a proxy server, especially if production load will not be routed throughthat proxy server. Ways to avoid the proxy server are to remove the part of the script that states use of the proxy server (ofteninternal applications are available even while bypassing the proxy server), if that doesn't work - move the injection point to a location in the network where the proxy server can be bypassed (perhaps the same VLAN as the web server).

HTTP 500 Internal Server ErrorOfficially: The server encountered an unexpected condition which prevented it from fulfilling the request.

When / Why: You'll often see this after an HTTP POST statement and it usually means that the post statement has not been formed correctly.There can be a number of reasons for this including the request being badly formed by the tool - or at least not formed as expected by the server. More typically it's because the POSTed form values are incorrect due to incorrect correlation / parameterisation of form variables.For example: In a .Net application a very large __VIEWSTATE value is passed between the browser and server with each POST, this is a way to maintain state and puts the onus on state ownership on the browser rather than the server. This can

Page 41: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

have performance issues which I won't go into here. If this value is not parameterised correctly in the script (there can be more than one __VIEWSTATE) then the server can be confused (sent erroneous requests) and respond with a 500 Internal Server Error.A 500 error usually originates from the application server part of the infrastructure.It's not just .Net parameters that can cause this. Items such as badly formed dates, incorrectly formatted fields and badly formatted strings (consider replaced spaces with + characters) and so on can all cause HTTP 500 errors.

HTTP 503 Service UnavailableOfficially: The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response.

When / Why: Typically this will be due to the allowed number of concurrent connections on the server and is usually down to a configuration or license setting. For example IIS running on a non server version of Windows is limited to 10 concurrent connections - after this point it will deliver a 503 message. There is a temptation in load testing to overload the application under test, so it's worth revisiting your non functional requirements - will the production server ever see this number of concurrent connections?

HTTP Response Messages

HTTP servers respond to client requests in the form of a response message. This message contains a status line, response headers, and meta-information about the resource (information about the resource itself, not about the information that is contained in the resource).

Each HTTP status line contains the HTTP version number, a status code, and a description. For example, "HTTP/1.0 200 OK" is a typical status line returned in a response message from an HTTP server.

The following table contains status codes and their meanings.

LoadRunner unique file name with web_save_timestamp_param functionEarlier, I shown two ways how to create unique file names in LoadRunner:

How to get unique file name in LoadRunner :Generating unique file name using LoadRunner parameter

Today I'm going to show the simplest way. And I would like to thank Charlie for his comment.

He suggested to use web_save_timestamp_param function.

web_save_timestamp_param function saves the current timestamp to LoadRunner parameter. Timestamp is the number of milliseconds since midnight January 1st, 1970 (also known as Unix Epoch).

This is how web_save_timestamp_param works:web_save_timestamp_param("TimeStamp", LAST);lr_output_message("Timestamp: %s", lr_eval_string("{TimeStamp}"));

And the result is:

Page 42: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

As I explained in this loadRunner tutorial about unique file names in LoadRunner, we have to get unique ids per virtual users with lr_whoamiLoadRunner function.

So, the final LoadRunner script is:char szFileName[256];int vuserid, scid;char *groupid;

lr_whoami(&vuserid, &groupid, &scid); web_save_timestamp_param("TimeStamp", LAST);

sprintf(szFileName, "%s_%d_%d_%s", lr_eval_string("{TimeStamp}"), vuserid, scid, groupid);

lr_output_message("File name: %s", szFileName);

And its result is from LoadRunner Controller:

So, you can add a required file

Page 43: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

extension (txt, pdf, etc) and get a unique file name. It will work for any number of concurrent virtual users in LoadRunner Controller.

How to get LoadRunner iteration number - using globalvariable?How to determine the current iteration number? The first way is to use LoadRunner parameter od 'Iteration Number' type.The second way is to use a LoadRunner global variable.I will explain this approach now. Also, you will see how to define and use global variables.

Define a global variableYou can add a new variable definition into vuser_init section of LoadRunner script:

Then we will add a variable incrementation and usage into Action section of LoadRunner script. For example, like this:

Please, note that LoadRunner does not require using of "extern" keyword.

And last step is to open LoadRunner Run-time Settings and to set the desired total iteration count. In my example I set it to 3:

Page 44: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

That's all! Let's start our script and see Log-file:

As you can see, nIterationNumber variable changes its values with every new iteration.

Tip: do not forget to increment its value, for example with ++ operator.

Both proposed approaches (with LoadRunner parameter and with a global variable) are simple enough. Use any you like andtrack your LoadRunner iterations thoroughly :)

Function to write current system Time

Page 45: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

This main use of this functions to return the current system time at any givenpoint of time while load runner script is running.This functiona can be used toreport transaction times , script starti time and end time.

long get_secs_since_midnight(void){

char * curr_hr; /* pointer to a parameter with current clock hr */char * curr_min; /* pointer to a parameter with current clock min*/char * curr_sec; /* pointer to a parameter with current clock sec */long current_time, /* current number of seconds since midnight */hr_secs, /* current hour converted to secs */min_secs, /* current minutes converted to secs */secs_secs; /* current number of seconds*/curr_hr = lr_eval_string("{current_hr}>");curr_min = lr_eval_string("{current_min}");curr_sec = lr_eval_string("{current_sec}");hr_secs = (atoi(curr_hr)) * 60 * 60;min_secs = (atoi(curr_min)) * 60;secs_secs = atoi(curr_sec);

current_time = hr_secs + min_secs + secs_secs;return(current_time);

}

Then these two lines are enough for getting current time.

lr_save_datetime("Today is %H %M %S", DATE_NOW, "curr_time");lr_output_message(lr_eval_string("{curr_time}"));

Printing the current log options to the output log (even if logging is disabled) in load runner// Prints the current log options to the output log (even if logging is disabled)// Example: xyz_print_log_options(lr_get_debug_message());void xyz_print_log_options(unsigned int log_options_to_print) { char buf[(4 * 8) + 1]; // sizeof(unsigned int) is always 4 bytes in LoadRunner. unsigned int original_log_options = lr_get_debug_message(); xyz_clear_log_options(); xyz_set_log_options(LR_MSG_CLASS_BRIEF_LOG); // Print the bit pattern for the current log options. itoa(log_options_to_print, buf, 2); lr_output_message("Log options bit pattern: %032.32s", buf); lr_output_message("Log options selected:"); if (log_options_to_print == 0) { lr_output_message("* Disabled (LR_MSG_CLASS_DISABLE_LOG)"); } else { if (log_options_to_print & LR_MSG_CLASS_JIT_LOG_ON_ERROR) { lr_output_message("* Send messages only when an error occurs (LR_MSG_CLASS_JIT_LOG_ON_ERROR)"); } else { lr_output_message("* Always send messages"); } if (log_options_to_print & LR_MSG_CLASS_BRIEF_LOG) { lr_output_message("* Log messages at the detail level of \"Standard log\" (LR_MSG_CLASS_BRIEF_LOG)"); } if (log_options_to_print & LR_MSG_CLASS_EXTENDED_LOG) { lr_output_message("* Log messages at the detail level of \"Extended log\" (LR_MSG_CLASS_EXTENDED_LOG)"); }

Page 46: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

if (log_options_to_print & LR_MSG_CLASS_PARAMETERS) { lr_output_message("* Parameter substitution (LR_MSG_CLASS_PARAMETERS)"); } if (log_options_to_print & LR_MSG_CLASS_RESULT_DATA) { lr_output_message("* Data returned by server (LR_MSG_CLASS_RESULT_DATA)"); } if (log_options_to_print & LR_MSG_CLASS_FULL_TRACE) { lr_output_message("* Advanced trace (LR_MSG_CLASS_FULL_TRACE)"); } } xyz_clear_log_options(); xyz_set_log_options(original_log_options); return;}/*Output looks like this:globals.h(26): Log options bit pattern: 00000000000000000000001000011110globals.h(28): Log options selected:globals.h(35): * Send messages only when an error occurs (LR_MSG_CLASS_JIT_LOG_ON_ERROR)globals.h(45): * Log messages at the detail level of "Extended log" (LR_MSG_CLASS_EXTENDED_LOG)globals.h(49): * Parameter substitution (LR_MSG_CLASS_PARAMETERS)globals.h(53): * Data returned by server (LR_MSG_CLASS_RESULT_DATA)globals.h(57): * Advanced trace (LR_MSG_CLASS_FULL_TRACE)*/

Save Dynamic Parameter value in Text File using load runner scriptingI have a value which dynamic for each iteration. I have captured that value using web_reg_save_param(correlation) function. Please any enahncement in the script is most welcome….Action_Main_URL(){char MainID; int i; char Length[100]; long file; char * filename = “c:\\Session.txt”;

if ((file = fopen(filename, “a+” )) == NULL) { lr_output_message(“Unable to create %s”, filename); return -1; }

web_reg_save_param( “Cor_Session_Id”, “LB= value=’”, “RB=’”, “Ord=6″, “IgnoreRedirections=Yes”, “Search=Body”, “RelFrameId=1″, LAST );web_url(“Workplace”,”URL=http://server/Workplace”,”Resource=0″,”RecContentType=text/html”,”Referer=”,”Snapshot=t1.inf”,”Mode=HTML”,LAST);lr_start_transaction(“TS_Main_URL_Login”);

Page 47: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

web_reg_find(“Text=Record Search and Check-In”, “SaveCount=Value_Count”,LAST);web_submit_data(“WcmSignIn.jsp”,”Action=http://server/Workplace/WcmSignIn.jsp?eventTarget=signInModule&eventName=SignIn”,”Method=POST”,”RecContentType=text/html”,”Referer=http://server/Workplace/WcmSignIn.jsp?targetUrl=WcmDefault.jsp&targetBase=http%3A%2F%2Fserver%2FWorkplace&sessionId={Cor_Session_Id}&originIp=10.x.x.x&originPort=”,”Snapshot=t2.inf”,”Mode=HTML”,ITEMDATA,”Name=targetBase”, “Value=http://server/Workplace”, ENDITEM,”Name=originPort”, “Value=”, ENDITEM,”Name=targetUrl”, “Value=Default.jsp”, ENDITEM,”Name=encodedSessionId”, “Value=null”, ENDITEM,”Name=originIp”, “Value=10.x.x.x”, ENDITEM,”Name=sessionId”, “Value={Cor_Session_Id}”, ENDITEM,”Name=browserTime1″, “Value=Sat Jan 1 05 EST 2011″, ENDITEM,”Name=browserTime2″, “Value=Wed Jun 15 05 EDT 2011″, ENDITEM,”Name=browserOffset1″, “Value=300″, ENDITEM,”Name=browserOffset2″, “Value=240″, ENDITEM,”Name=clientTimeZone”, “Value=”, ENDITEM,”Name=appId”, “Value=Workplace”, ENDITEM,”Name=userId”, “Value=userid”, ENDITEM,”Name=password”, “Value=password”, ENDITEM,EXTRARES,”Url=images/web/common/Banner.jpg”, “Referer=http://server/Workplace/HomePage.jsp?mode=reset”, ENDITEM,LAST);if (atoi(lr_eval_string(“{Value_Count}”)) > 0){lr_output_message(“Page found successfully.”);}else{lr_error_message(“Page is not found.”);lr_exit( LR_EXIT_MAIN_ITERATION_AND_CONTINUE,LR_FAIL );return(0);}

lr_end_transaction(“TS_Main_URL_Login”,LR_AUTO);sprintf(Length,”\n%s,”,lr_eval_string(“{Cor_Session_Id}”)); i = fwrite(&Length,sizeof(Length), 1, file); if ( i > 0) lr_output_message(“Successfully wrote %d record”, i ); fclose(file);return 0;}

Functions in load Runner

Functions:-

1,

In the following example, lr_error_message sends a message to the LoadRunner output window or Application Managementagent log file if the login fails. lr_abort is then invoked to abort the script.

2.

The following example uses abs to convert the integers 23 and -11 to their absolute values:

int m = 23, n = -11;

Page 48: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

lr_output_message ("absolute value of %d = %d", m, abs(m));

lr_output_message ("absolute value of %d = %d", n, abs(n));

3

In the following example, the web_add_cookie function adds a cookie with the name "client_id" to the list of cookies available to the script.

web_add_cookie ("client_id=China127B; path=/; expires=Wednesday, 09–Nov–2001 23:12:40 GMT; domain=www.cnn.com");

4

The following example gets the time as a time_t structure and converts it to a tm structure, gmt, in Coordinated Universal Time.asctime then takes gmt and converts it to a string.

5

The following example converts the initial portion of the string, s, to a float.

double atof (const char *string); /* Explicit declaration */

vuser_init() {

float x; char *s = "7.2339 by these hilts or I am a villain else";

x = atof(s); /* The %.2f formatting string limits the output to 2 decimal places */ lr_output_message("%.2f", x);

return 0;}

Output:vuser_init.c(11): 7.23

6

The following example converts the initial portion of the string, s, to an integer.

int i;

char * s = "7 dollars";

i = atoi(s);

lr_output_message ("Price $%d", i);

Output:vuser_init.c(7): Price $7

7

Function Name

Description

Page 49: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

abs Gets the absolute value of an integer.

asctime Converts time from a structure to a string.

atof Converts a string to a floating point value.

atoi Converts a string to an integer value.

atol Converts a string to a long integer value.

calloc Allocates an array and initializes all elements to zero.

chdir Changes the current directory to the given path.

chdrive Switches to another drive.

cos Computes the cosine of an angle in radians.

ctime Converts the calendar time to local time.

fclose Closes a file.

feof Checks if the end of file has occurred on a stream.

ferror Checks if any error has occurred during file I/0.

fgetc Gets a character from a stream.

fgets Reads a string from a file.

floor Gets the largest integral value that is less than x.

fopen Opens a file for buffered I/0.

fprintf Writes formatted output to a file.

fputc Writes a character to a stream.

Page 50: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

fread Reads unformatted data from a stream into a buffer.

free Frees a block of memory.

fscanf Reads formatted input from a stream.

fseek Sets the current position in a file to a new location.

ftime Prints time information to a structure.

fwrite Write unformatted data from a buffer to a stream.

getcwd Returns the name of the current working directory.

getdrive Returns the name of the current drive.

getenv Gets the definition of an environment variable.

gmtime Converts the calendar time into Coordinated Universal Time (UTC).

isalpha Checks if a string is a letter.

isdigit Checks if a string is a decimal digit.

itoa Converts an integer to a string. Windows only.

localtime Converts the calendar time into local time.

malloc Allocates a block of memory.

memchr Searches for a character in a buffer.

memcmp Compares two buffers.

memcpy Copies n characters from one buffer into another.

memmove Moves a number of bytes from one buffer to another.

Page 51: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

memset Sets n bytes of a buffer to a given character.

mkdir Creates a directory using the given path name.

putenv Inserts a new definition into an environment table.

rand Gets a random integer between 0 and RAND_MAX.

realloc Reallocates (adjusts the size of) a block of memory.

remove Deletes the specified file.

rewind Rewinds a file.

rmdir Deletes the specified directory.

sin Computes the sine of an angle in radians.

sprintf Writes formatted output to a string.

sqrt Computes the square root of x.

sscanf Reads formatted input from a string.

strcat Concatenates two strings.

strchr Returns the pointer to the first occurrence of a character in a string.

strcmp Compares two strings to determine the alphabetic order.

strcpy Copies one string to another.

strdup Duplicates a string.

stricmp Performs a case-insensitive comparison of two strings.

strlen Returns the length of a string.

Page 52: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

strlwr Converts a string to lower case.

strncat Concatenates n characters from one string to another.

strncmp Compares the first n characters of two strings.

strncpy Copies the first n characters of one string to another.

strnicmp Performs a case-insensitive comparison of n strings.

strrchr Finds the last occurrence of a character in a string.

strset Fills a string with a specific character.

strspn Returns the length of the leading characters in a string that are contained in a specified string.

strstr Returns the first occurrence of one string in another.

strtok Returns a token from a string delimited by specified characters.

strtol Converts a string to a long integer using a given radix.

strupr Converts a string to upper case.

system Executes an operating system command.

time Returns the current calendar time.

tolower Converts a string to lowercase.

toupper Converts a string to uppercase.

8.

In the following example, lr_error_message sends a message to the LoadRunner output window or Application Management agent log file if login fails:

int status = web_url("Login", "URL=https://secure.computing.com//login.asp?user={username}&session={ssid}", "RecContentType=text/html", LAST);

Page 53: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

if (status == LR_FAIL) {

lr_error_message("Error: %s", "Unable to login to secure computing"); return -1;}

9

The lr_eval_string function returns the input string after evaluating any embedded parameters. If string argument contains only a parameter, the function returns the current value of the parameter.

10.

In the following example, lr.eval_int returns the value of parameter ID_num.

// Create the parameter

lr.save_int(12,"ID_num");

// Output the parameter value

lr.message(" Track Stock : " + lr.eval_int("<ID_num>") );

Example 2 - ParameterizationIn the following example, lr.eval_int substitutes the parameter string STID with appropriate values for each iteration.

lr.message( "Stock Trader ID Number is " + lr.eval_int("<STID>") );

11.

C Constants Object Oriented Constants

Behavior

LR_EXIT_VUSER lr.EXIT_VUSER Exit without any condition, and go directlyto end action

LR_EXIT_ACTION_AND_CONTINUE

lr.EXIT_ACTION_AND_CONTINUE

Stop current action, and go to the next action.

LR_EXIT_MAIN_ITERATION_AND_CONTINUE

lr.EXIT_MAIN_ITERATION_AND_CONTINUE

Stop current global script run iteration, and go to the next iteration.

LR_EXIT_ITERATION_AND_CONTINUE

lr.EXIT_ITERATION_AND_CONTINUE

Stop current iteration, and go to the next iteration.

If called from within a block iteration, only the block iteration will be exited, and not the global iteration.

Page 54: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

LR_EXIT_VUSER_AFTER_ITERATION

lr.EXIT_VUSER_AFTER_ITERATION

Run until the end of the current iteration and then exit.

LR_EXIT_VUSER_AFTER_ACTION

lr.EXIT_VUSER_AFTER_ACTION

Run until the end of the current action and then exit.

12.

13

Example: feof

The following example, for Windows platforms, opens a file and reads it into a buffer until feof returns true, indicating the end of the file.

To run the example, copy the file readme.txt from the installation's dat directory to the c drive, or copy another file and change the value of filename.

14.

The following example, for Windows platforms, opens a file and reads it into a buffer. ferror checks for errors on the read file stream.

15

The following example, for Windows platforms, opens a file using fopen, reads it into a buffer, and then closes it.

To run the example, copy the file readme.txt from the installation's dat directory to the c drive, or copy another file and change the value of filename.

int count, total = 0;

char buffer[1000];

long file_stream;

char * filename = "c:\\readme.txt";

// Open the file with read access

if ((file_stream = fopen(filename, "r")) == NULL) {

lr_error_message ("Cannot open %s", filename);

return -1;

}

// Read until end of file

while (!feof(file_stream)) {

// Read 1000 bytes while maintaining a running count

count = fread(buffer, sizeof(char), 1000, file_stream);

lr_output_message ("%3d read", count);

Page 55: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

// Check for file I/O errors

if (ferror(file_stream)) {

lr_output_message ("Error reading file %s", filename);

break;

}

total += count; // Add up actual bytes read

}

// Display final total

lr_output_message ("Total number of bytes read = %d", total );

// Close the file stream

if (fclose(file_stream))

lr_error_message ("Error closing file %s", filename);

Output:Action.c(19): 1000 bytes readAction.c(19): 1000 bytes read...Action.c(19): 1000 bytes read Action.c(20): 977 readAction.c(34): Total number of bytes read = 69977

16.

The following example opens a log file and writes the id number and group name of the Virtual User to it using fprintf.

#ifdef unix

char * filename = "/tmp/logfile.txt";

#else

char * filename = "c:\\logfile.txt";

#endif

long file;

int id;

char * groupname;

// Create a new file

if ((file = fopen(filename, "w+" )) == NULL) {

lr_output_message("Unable to create %s", filename);

return -1;

}

Page 56: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

// Write the Vuser id and group to the log file

lr_whoami(&id, &groupname, NULL);

fprintf(file, "log file of virtual user id: %d group: %s\n", id, groupname);

fclose(file);

Written to log file:log file of virtual user id: -1 group: None

17.

The following example uses free to de-allocate a buffer of length 1024.

18.

The following example, for Windows platforms, opens a file and reads it into a buffer. If file errors occur during the process, goto is used to escape the enclosing loop to code which prints an error message and exits the function.

int count, total = 0;

char buffer[1000];

long file_stream;

char * filename = "c:\\xyzpqi.txt";

// Open the file with read access

if ((file_stream = fopen(filename, "r")) == NULL)

goto file_error;

// Read until end of file

19.

In the following example, lr_log_message sends a message to the log file if the connection to the server fails.

char* abort="aborting...";

...

if (init() < 0) {

lr_log_message ("login failed: %s", abort);}

return(0);

}

20.

In the following example, lr_message sends a message if the connection to the server fails.

char* abort="aborting...";

...

if (init() < 0) {

Page 57: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

lr_message ("login failed: %s", abort);}

return(0);

}

21,

In the following example, ID is a parameter defined in the Parameter list. The lr_next_row function advances to the next row in theID.dat file.

lr_message( "Connect to Stock Trader ID Number %s",

lr_eval_string("{ID}") );

lr_next_row("ID.dat");

lr_message( "Connect to Stock Trader ID Number %s",

lr_eval_string("{ID}") );

The output window shows:

Connect to Stock Trader ID Number 2347

Connect to Stock Trader ID Number 2348

22.

In this example, an Iteration Number type parameter called "iteration" was defined in VuGen. The lr_output_message function sends a message to the Load Runner Controller or the Application Mangement Admin Center indicating the current iteration number.

lr_output_message ( "We are on iteration #%s", lr_eval_string ( "{iteration}" ) );

23.

In the following example, the lr_rendezvous function sets the Meeting rendezvous point. When all users that belong to theMeeting rendezvous arrive at the rendezvous point, they perform do_transaction simultaneously.

lr_rendezvous("Meeting"); do_transaction(); /* application dependent transaction */

24. In the following example, lr.save_data assigns a series of values to the ID parameter. This parameter is then used in an output message.

// Example array of arbitrary bytes.

byte [] b_arr = new byte[]{(byte)0x12,(byte)0x2,(byte)0x1,(byte)0x3};

// Save the array into parameter ID

lr.save_data(b_arr,"ID");

// Save the contents of the array parameter to another array

byte [] output_arr = lr.eval_data("<ID>");

lr.output_message("This is the value of the first output byte: "

+ Byte.toString(output_arr[0]));

Page 58: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

25

In the following example, lr_load_dll is used so that a standard Windows message box can be displayed during script replay:

lr_load_dll("user32.dll");

MessageBoxA(NULL, "This is the message body", "message_caption", 0);

26.

In the following example, lr_log_message sends a message to the log file if the connection to the server fails.

char* abort="aborting...";

...

if (init() < 0) {

lr_log_message ("login failed: %s", abort);}

return(0);

}

In the next example, an Iteration Number type parameter called "iteration" was defined in VuGen. The lr_log_message function sends a message to the LoadRunner Controller or Application Management Admin Center indicating the current iteration number.

lr_log_message ( "We are on iteration #%s", lr_eval_string ( "{iteration}" ) );

27.

In the following example, lr_message sends a message if the connection to the server fails.

char* abort="aborting...";

...

if (init() < 0) {

lr_message ("login failed: %s", abort);}

return(0);

}

28.

In this example, an Iteration Number type parameter called "iteration" was defined in VuGen. The lr_output_message function sends a message to the Load Runner Controller or the Application Mangement Admin Center indicating the current iteration number.

lr_output_message ( "We are on iteration #%s", lr_eval_string ( "{iteration}" ) );

29.

In the following example, lr_save_datetime is used to retrieve tomorrow's date.

lr_save_datetime("Tomorrow is %B %d %Y", DATE_NOW + ONE_DAY, "next");

Page 59: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

lr_output_message(lr_eval_string("{next}"));

30.

In the following example, lr_save_int assigns the string representation of the value of variable num times 2 to parameter param1.

int num;

num = 5;

lr_save_int(num * 2, "param1");

The value of param1 is now "10".

31.

In this example, the lr_set_debug_message function enables the full trace option just before a call to lrd_fetch, which the user needs to debug because it has been giving unexpected results.

The second invocation of lr_set_debug_message resets the debug level to what it was formerly, by turning off (LR_SWITCH_OFF) the Extended message level.

32.

In the following segment, lr_start_timer and lr_end_timer are used to calculate the time spent on checks. This is then subtracted from the time spent on transaction "sampleTrans" with lr_wasted_time.

double time_elapsed, duration, waste;

merc_timer_handle_t timer;

lr_start_transaction("sampleTrans");

web_url("index.htm",

"URL=http://localhost/index.htm",

"TargetFrame=",

"Resource=0",

"RecContentType=text/html",

"Referer=",

"Snapshot=t1.inf",

"Mode=HTML",

LAST);

timer = lr_start_timer();

/* Do some checks the duration of which

is not to be included in the transaction. */

Page 60: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

web_image_check("ImgCheck1",

"src=index_files/image002.jpg",

LAST);

web_image_check("ImgCheck2",

"src=index_files/planets.gif",

LAST);

// How long did the tests take in seconds.

time_elapsed = lr_end_timer(timer);

// Convert to millisecond.s

waste = time_elapsed * 1000;

/* Remove the time the checks took from

the transaction. */

lr_wasted_time(waste);

lr_end_transaction("sampleTrans", LR_AUTO);

In the following segment, lr_think_time instructs the script to pause for 10 seconds after accessing a link and submitting aform.

In the following example, a user data point is defined that checks the CPU every second and records the result.

for (i=0;i<100;i++) {

measure_cpu ( ); cpu_val=cpu_check();

lr_user_data_point("cpu", cpu_val);

sleep(1);

}

30.

The following segment demonstrates the use of timers to collect wasted time, and the use of lr_wasted_time to remove that wasted time from the transactions. The output log segments below show that the effects are not reported in the Vuser log, but are reported in the Analysis session.

31.

In the following example, lr_whoami retrieves information about a Vuser and places it into a message string. The message string contains Vuser login information that is used to connect with a server.

Note that memory for vuser_group is allocated automatically. Do not alter the string.

Page 61: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

vuser_group, id, scid);

In these examples, web_save_param_length creates three new parameters, Param7_Length, Param10_Length,and Param16_Length, and stores the length of each respective source parameter as a hexidecimal number.

// Create a parameter 7 characters long

lr_save_string("ABCDEFG", "Param7");

web_save_param_length("Param7", "Base=Hexadecimal", LAST);

// Output: Action.c(9): Notify: Saving Parameter "Param7_Length = 7"

// Create a parameter 10 characters long

lr_save_string("ABCDEFGHIJ", "Param10");

web_save_param_length("Param10", "Base=Hexadecimal", LAST);

//Output is in hexadecimal:

//Action.c(14): Notify: Saving Parameter "Param10_Length = A"

// Create a parameter 16 characters long

lr_save_string("ABCDEFGHIJKLMNOP", "Param16");

web_save_param_length("Param16", "Base=Hexadecimal", LAST);

//Output is in hexadecimal:

//Action.c(18): Notify: Saving Parameter "Param16_Length = 10"

The following examples are presented for web_reg_save_param.

Example 1: Saving simple text strings

Case of saving a single string

Case requiring handling arrays

Example 2: Saving a text by using binary boundaries

Example 3: Saving a text specified with an offset and length

Example 4: Boundaries containing special characters

Example 1: Saving simple text strings

In this example, web_reg_save_param is used to save a value from the response to a web_submit_form call. The value saved is used in a subsequent web_submit_form call.

In the Mercury Tours sample program, the server response to the web_submit_form call below contains the following radio button options:

<tr bgcolor=#66cccc><th>Flight<th>Departure time<th>Cost

Page 62: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

<tr bgcolor=#66CCff><td align=center><input type = radio name=outboundFlight value=230;378;11/20/2003 checked >Blue Sky Air 230<td align=center>8am<td align=center>$ 378

<tr bgcolor=#eeeeee><td align=center><input type = radio name=outboundFlight value=231;337;11/20/2003>Blue Sky Air 231<td align=center>1pm<td align=center>$ 337

and so on.

To submit a reservation, the outboundFlight value is required. web_reg_save_param is used to save the outboundFlightvalue.

Case of saving a single string

Case requiring handling arrays

Case of saving a single stringTo reserve the default flight, save the "checked" value, and pass it to web_submit_form. The html segment for the default value is:

name=outboundFlight value=230;378;11/20/2003 checked >

/*This web_reg_save_param call applies to the following action function: web_submit_form. */

web_reg_save_param("outFlightVal", "LB=outboundFlight value=", "RB= checked >", LAST);

web_submit_form("reservations.pl", "Snapshot=t4.inf", ITEMDATA, "Name=depart", "Value=London", ENDITEM,

"Name=departDate", "Value=11/20/2003", ENDITEM,

"Name=arrive", "Value=New York", ENDITEM,

"Name=returnDate", "Value=11/21/2003", ENDITEM,

"Name=numPassengers", "Value=1", ENDITEM,

"Name=roundtrip", "Value=<OFF>", ENDITEM,

"Name=seatPref", "Value=None", ENDITEM,

"Name=seatType", "Value=Coach", ENDITEM,

"Name=findFlights.x", "Value=83", ENDITEM,

"Name=findFlights.y", "Value=16", ENDITEM, LAST); /*

The result of the web_reg_save_param having been called before the web_submit_form is:

Action.c(15): Notify: Saving Parameter "outFlightVal = 230;378;11/20/2003"

*/

// Now use the saved outFlightVal

web_submit_form("reservations.pl_2",

"Snapshot=t5.inf",

ITEMDATA,

"Name=outboundFlight", "Value={outFlightVal}", ENDITEM,

Page 63: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

"Name=reserveFlights.x", "Value=92", ENDITEM,

"Name=reserveFlights.y", "Value=10", ENDITEM,

LAST);

/*

Action.c(34): Notify: Parameter Substitution: parameter "outFlightVal" = "230;378;11/20/2003" */

Case requiring handling arraysIf you want to test the last option returned by the web_submit_form call, save all the matches and then handle the array.

This example shows the use of web_reg_save_param with "ORD=ALL" to get an array of parameters. The last item in the array is then used to correlate a web_submit_form call.

char outFlightParam[50]; // The name of the parameter for correlation

char outFlightParamVal[50]; // The formatted value of outFlightParam

/*

This web_reg_save_param call applies to the following action function, web_submit_form. Because of the "ORD=ALL" argument, it saves all the values that have the given left and right boundaries to an array of parameters.

The SaveLen argument is used to restrict the length to 18 characters because the default value is "230;378;11/20/2003 checked >". We restrict the length so as not to capture the " checked ".

*/

web_reg_save_param("outFlightVal",

"LB=outboundFlight value=", "RB=>",

"ORD=ALL",

"SaveLen=18",

LAST);

web_submit_form("reservations.pl",

"Snapshot=t4.inf",

ITEMDATA,

"Name=depart", "Value=London", ENDITEM,

"Name=departDate", "Value=11/20/2003", ENDITEM,

"Name=arrive", "Value=New York", ENDITEM,

"Name=returnDate", "Value=11/21/2003", ENDITEM,

"Name=numPassengers", "Value=1", ENDITEM,

"Name=roundtrip", "Value=<OFF>", ENDITEM,

"Name=seatPref", "Value=None", ENDITEM,

Page 64: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

"Name=seatType", "Value=Coach", ENDITEM,

"Name=findFlights.x", "Value=83", ENDITEM,

"Name=findFlights.y", "Value=16", ENDITEM,

LAST);

/*

The result of the web_reg_save_param having been called before the web_submit_form is:

Notify: Saving Parameter "outFlightVal_1 = 230;378;11/20/2003"

Notify: Saving Parameter "outFlightVal_2 = 231;337;11/20/2003"

Notify: Saving Parameter "outFlightVal_3 = 232;357;11/20/2003"

Notify: Saving Parameter "outFlightVal_4 = 233;309;11/20/2003"

Notify: Saving Parameter "outFlightVal_count = 4"

The next problem is to get the highest array element, identified with the parameter outFlightVal_count. This parameter isautomatically created by the script recorder. You do not have to enter anything in the script.

*/

/* Get the name of the parameter, in this case "outFlightVal_4".

Put it in brackets so it can be an input to an lr_eval_string call.

Note that the brackets in the second argument to sprintf are not indicating a script parameter to sprintf. They are string literals that will be part of outFlightParam after the call.

In the second call to sprintf, those brackets indicate a parameter to lr_eval_string.

*/

sprintf(outFlightParam, "{outFlightVal_%s}",

lr_eval_string("{outFlightVal_count}"));

/* outFlightParam is now "{outFlightVal_4}" */

/* Now get the "Value" argument for web_submit_form, in the

format "Value=xxxx")

*/

sprintf(outFlightParamVal, "Value=%s",

lr_eval_string(outFlightParam));

lr_message("The value argument is : %s", outFlightParamVal);

// The value argument is : Value=233;309;11/20/2003

/* Now the string outFlightParamVal can be passed

to web_submit_form */

Page 65: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

web_submit_form("reservations.pl_2",

"Snapshot=t5.inf",

ITEMDATA,

"Name=outboundFlight",outFlightParamVal, ENDITEM,

"Name=reserveFlights.x", "Value=92", ENDITEM,

"Name=reserveFlights.y", "Value=10", ENDITEM,

LAST);

Example 2: Saving a text by using binary boundaries

The following example uses BIN type boundaries. The left boundary is composed of 3F and DD. The right boundary is composed of CCand b.

web_reg_save_param("p", "LB/BIN=\\x3F\\xDD", "RB/BIN=\\xCCb", LAST);

Example 3: Saving a text specified with an offset and length

The following example specifies an offset and length. The boundaries for the HTML string "Astra on TESTSERVER", are "Astra " (note the space which follows the word) and "TestServer". This should return "on" but since the offset is 1 (i.e. start at the second character) and the length of data to save is 1, then the string saved to TestParam is "n".

web_reg_save_param("Param1", "LB=Astra ", "RB= TESTSERVER",

"SaveOffset=1", "SaveLen=1", LAST);

Example 4: Boundaries containing special characters

The following example shows the use of escaping in the C language when the boundaries contain special characters.

The following HTML segment contains new line characters (paragraph markers) after each "<strong>" and quote marks around each class name. We want to save "Georgiana Darcy" to parameter "UserName". The segment containing the new line and quotes has to be included in the left boundary because "Name:", which precedes the segment, is required for the occurrence to be unique. The ORD attribute cannot be used in this case because the length of the list preceding the relevant element varies.

<span class="surveyQuestionReview"><strong> UserID:</strong></span><strong>

</strong> <span class="surveyAnswerReview">Revere18041775</span> <br>

<span class="surveyQuestionReview"><strong> Name:</strong></span><strong>

</strong> <span class="surveyAnswerReview">Georgiana Darcy</span> <br>

<span class="surveyQuestionReview"><strong> Company:</strong></span><strong>

</strong> <span class="surveyAnswerReview">Pride and Prejudice</span> <br>

Page 66: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

The function is:

web_reg_save_param("UserName",

"LB=Name:</strong></span><strong> \n </strong> <span class=\"surveyAnswerReview\">",

"RB=</span> <br>",

LAST);

Note the \n for the new line character, and that the quote characters need to be escaped: \".

In the following example, web_reg_find searches for the text string "Welcome". If the string is not found, it fails and the script execution stops.

// Run the Web Tours sample

web_url("MercuryWebTours",

"URL=http://localhost/MercuryWebTours/",

"Resource=0",

"RecContentType=text/html",

"Referer=",

"Snapshot=t1.inf",

"Mode=HTML",

LAST);

// Set up check for successful login by looking for "Welcome"

web_reg_find("Text=Welcome",

LAST);

// Now log in

web_submit_form("login.pl",

"Snapshot=t2.inf",

ITEMDATA,

"Name=username", "Value=jojo", ENDITEM,

"Name=password", "Value=bean", ENDITEM,

"Name=login.x", "Value=35", ENDITEM,

"Name=login.y", "Value=14", ENDITEM,

LAST);

-------

In the following example, the web_find function searches for the name "John" in the employees.html page.

Page 67: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

web_url("index.html", "URL=http://server1/people/employees.html", "TargetFrame=", LAST);

web_find("Employee Check", "expect=notfound", "matchcase=yes", "onfailure=abort", "report=failure", "repeat=no", "what=John", LAST);

Example 2In the following example, the web_find function searches for the text "Home" which is between "Go to" and "Page".

web_url("index.html", "URL=http://server1/", "TargetFrame=", LAST);

web_find("Text Check", "RightOf=Go to", "LeftOf=page", "What=Home", LAST);

web_submit_data

Return Values Parameterization

Performs an "unconditional" or "contextless" form submission.

C PROGRAMS and functions in LOAD RUNNER/********************************************************************//* Function Name: cg_random/* Purpose : Generate random alphabets/numbers/symbols/* Input : No.of letters, Capital or small(0 -for capital letters, 1 -for small letters, /* 2 - mixed case, 3 -numbers, 4 -symbols)/* Output : Random alphabets/numbers/symbols (param_name)/* Created by : G.Raviteja/******************************************************************/

cg_random(char* param_name,int length,int alpha_num){ char buff[42] = ""; int i,r; char c; srand((unsigned int) time(0)); //Before invoking rand, call srand to seed the pseudo-random number generator

if(alpha_num == 0) { for(i=0;i<length;i++) { r=rand() % 25 + 65; // A-Z = 65-90 = rand() % 25 + 65 [for values within specific range using the mod (%) operator] c= (char) r; buff[i]=c; printf("%c",c);

Page 68: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

} }

else if(alpha_num == 1) { for(i=0;i<length;i++) { r=rand() % 25 + 97; // a-z = 97-122 = rand() % 25 + 97 [for values within specific range using the mod (%) operator] c= (char) r; buff[i]=c; printf("%c",c); }

}

else if(alpha_num == 2) { for(i=0;i<length;i++) { r=rand() % 57 + 65; // a-z = 65-122 = rand() % 57 + 65 [for values within specific range using the mod (%) operator] if(r>90 && r<97) { r=r+10; c= (char) r; }

else { c= (char) r; }

buff[i]=c; printf("%c",c); }

}

else if(alpha_num == 3) { for(i=0;i<length;i++) { r=rand() % 9 + 48; // 0-9 = 48-57 = rand() % 9 + 48 [for values within specific range using the mod (%) operator] c= (char) r; buff[i]=c; printf("%c",c); }

}

else if(alpha_num == 4) { for(i=0;i<length;i++) { r=rand() % 14 + 33; // !-/ = 33-47 = rand() % 14 + 33 [for values within specific range using the mod (%) operator] c= (char) r; buff[i]=c; printf("%c",c); }

}

else { lr_output_message("==>Enter value between 0-4 for argument 3<=="); }

Page 69: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

lr_save_string(buff,param_name);

return 0;}

/********************************************************************//* Function Name: cg_file_write/* Purpose : File write/* Input : Buffer and file name/* Output : Data written to file/* Created by : G.Raviteja/* www.easyloadrunner.blogspot.in/******************************************************************/

int cg_file_write(char* buffer,char* filename){ int fp; fp = fopen (filename,"w"); if(fp == NULL) { lr_error_message("ERROR: Unable to open file"); }

fprintf(fp,"%s",buffer); fclose(fp); }/********************************************************************//* Function Name: cg_file_read/* Purpose : File read/* Input : file name/* Output : Reads content from file/* Created by : G.Raviteja/* www.easyloadrunner.blogspot.in/******************************************************************/

int cg_file_read(char* filename){ int fp;

char data[1000]; char* buff;

int i=1; int total, count =0;

//char* filename = "test1.txt";

fp = fopen(filename,"r");

if(fp == NULL) { lr_error_message("Cannot open %s", filename); return -1; }

else { while(! feof(fp)) { // Read 1000 bytes while maintaining a running count

//count = fread(data, sizeof(char), 1000, fp);

Page 70: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

count = fgets(data, 1000, fp);

if (ferror(fp)) {

lr_output_message ("Error reading file %s", filename);

break;

}

lr_output_message( "The line %d is ==> \"%s\"",i, data);

i++;

/*// Get the first line from the file

if (fgets(data, 100, fp) == NULL)

lr_output_message("fgets error");

else

lr_output_message( "The line %d is ==> \"%s\"",i, data);

i++;*/

} }

fclose(fp);

if (ferror(fp)) { lr_error_message("Error closing file %s", filename); }

}

/********************************************************************//* Function Name: cg_PlainToURL/* Purpose : converts a plain text string into URL format string/* Input : StrIn - Input String, /* Output : URL format string (StrOut - Output buffer)/* Created by : G.Raviteja/* www.easyloadrunner.blogspot.in/******************************************************************/

char* cg_PlainToURL(char* strIn, char* strOut){ int i; char curChar; char curStr[4] = {0};

strOut[0] = '\0';

for (i=0;curChar=strIn[i];i++) { if(isdigit(curChar) || isalpha(curChar)) // Verify whether the character is digit or alphabet { sprintf(curStr,"%c",curChar); // If yes, then print as such }

else { sprintf(curStr,"%%%X",curChar); // else convert it into hex string }

Page 71: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

strcat(strOut,curStr); // Concatenate the output

}

return strOut;}

/********************************************************************//* Function Name: cg_PlainToURL_lr/* Purpose : converts a plain text string into URL format string/* Input : sIn - String which needs to be converted to URL format/* Output : URL formatted string/* Created by : G.Raviteja/* www.easyloadrunner.blogspot.in/******************************************************************/cg_PlainToURL_lr(char* sIn){ //char sIn[] = "t es%d$ + eprst_";

lr_save_string(sIn, "InputParam");

web_convert_param("InputParam", "SourceEncoding=PLAIN", "TargetEncoding=URL", LAST);

lr_output_message("%s", lr_eval_string("{InputParam}"));}

/********************************************************************//* Function Name: cg_HTMLToPlain_lr/* Purpose : converts a URL format string into plain text string/* Input : sIn1 - HTML string which needs to be converted to Plain format/* Output : Plain formatted string/* Created by : G.Raviteja/* www.easyloadrunner.blogspot.in/******************************************************************/cg_HTMLToPlain_lr(char* sIn1){ //char sIn1[] = "v%20mg%25d%24%20%2B%20vmguruprasath%5F";

lr_save_string(sIn1, "InputParam");

web_convert_param("InputParam", "SourceEncoding=HTML", "TargetEncoding=PLAIN", LAST);

lr_output_message("%s", lr_eval_string("{InputParam}"));

}

/********************************************************************//* Function Name: cg_LTrim/* Purpose : Trims spaces on the left of the string/* Input : source string and the string to be trimmed/* Output : left trimmed string/* Created by : G.Raviteja/* www.easyloadrunner.blogspot.in/******************************************************************/

char* cg_ltrim(char *string, char junk){ char* original = string;

Page 72: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

char *p = original; int trimmed = 0; do { if (*original != junk || trimmed) { trimmed = 1; *p++ = *original; } }

while (*original++ != '\0');

return string;}

/********************************************************************//* Function Name: cg_rtrim/* Purpose : Trims spaces on the right of the string/* Input : source string and the string to be trimmed/* Output : right trimmed string/* Created by : G.Raviteja/* www.easyloadrunner.blogspot.in/******************************************************************/

char* cg_rtrim(char* string, char junk){ char* original = string + strlen(string); while(*--original == junk); *(original + 1) = '\0'; return string;}

/********************************************************************//* Function Name: cg_find_replace/* Purpose : Finds a string/character from the source and replaces with/* the specified replace string/character. /* Input : source string, search string, replace string/* Output : /* Created by : G.Raviteja/* www.easyloadrunner.blogspot.in/******************************************************************/

char* cg_replace(const char* src,const char* search,const char* replace){ /* We need to find the length of the source string, seach and replace string*/

size_t size = strlen(src) + 1; size_t searchlen = strlen(search); size_t replacelen = strlen(replace);

/* Allocate memory to values */

char* value = (char*)malloc(size);

/* defining return value */

char* ret = value;

ret = value;

/* Verify Malloc */

if (value != NULL) { /* loop untill no match is found */ for(;;)

Page 73: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

{ /* Find the search string */

const char* match = (char*)strstr(src,search);

if(match != NULL) { /* Found search text at location match, * Find how many characters to copy in match */

size_t count = match - src;

/* Re-allocate memory, use a temp variable for pointer */

char* temp;

/* Calculating the total length of the string after allocation */

size += replacelen - searchlen;

/* realloc memory*/

temp = (char*)realloc(value,size);

if(temp == NULL) { /* Re allocation of memory failed so free the malloc'd memory*/

free(value);

return NULL; }

/* Re-allocation successful. Now point the pointer to value */

ret = temp + (ret - value);

value = temp;

/* copy from the source to where we matched. * Then move the source pointer to this point and move the * destination pointer ahead by same amount */

memmove(ret,src,count);

src += count; ret += count;

/* Now copy the replacement text 'replace' at the position of match. * Adjust the source pointer by the text we replaced * Adjust the destination pointer with the amount of replacement */

memmove(ret,replace,replacelen);

src += searchlen; ret += replacelen;

}

else /* No Match found */ { /* Copy the remaining part of the string */

strcpy(ret,src);

break; }

Page 74: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

} }

return value;}

void cg_find_replace(const char* source,const char* str,const char* repl){ char* after;

after = cg_replace(source,str,repl);

lr_output_message("The find string is: '%s' and replace string is '%s'",str,repl);

if(after != NULL) { lr_output_message("The string after replacement::> %s",after); free(after); }}

/********************************************************************//* Function Name: cg_substr_index/* Purpose : Extracts a string between the start index and end index. /* Input : Source string, Stat index and end index/* Output : Extracted sting between the start and end index/* Created by : G.Raviteja/* www.easyloadrunner.blogspot.in/******************************************************************/

char* cg_substr_index(char* source,int begin, int end){ int length = end-begin;

char* newstring; char* tmpstring;

int i;

if(length<0) { return("-1");

}

newstring = (char*)malloc(length+1);

memset(newstring,'\0',length+1);

tmpstring = (char*)strdup(source);

for(i=1;i<begin;i++) { tmpstring++; }

strncpy(newstring,tmpstring,length);

lr_output_message("Substring is ::>%s",newstring);

return newstring;

}

Page 75: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

/********************************************************************//* Function Name: cg_substr_lb_index/* Purpose : Extracts a string between the start index and end of string. /* Input : Source string and start index/* Output : Extracted string from start index to last./* Created by : G.Raviteja/* www.easyloadrunner.blogspot.in/******************************************************************/ char* cg_substr_lb_index(char* src,int startIndex){ char* buffer; char* temp;

int cnt;

int length = strlen(src);

if(length<0) { return("-1");

}

buffer = (char*)malloc(length+1);

memset(buffer,'\0',length+1);

temp = (char*)strdup(src);

for(cnt=1;cnt<startIndex;cnt++) { temp++; }

strncpy(buffer,temp,length);

lr_output_message("Substring from left boundary is ::>%s",buffer);

return buffer;

}

/********************************************************************//* Function Name: cg_substr/* Purpose : Extract a string between left boundary and right boundary. /* Input : /* Output : /* Created by : G.Raviteja/* www.easyloadrunner.blogspot.in/******************************************************************/ char* cg_substr(char* source,char* lbound, char* rbound){

char* lposition; char* rposition; int begin,end;

int length;

char* newstring; char* tmpstring;

char* tmp;

Page 76: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

int i;

int lblength = strlen(lbound);

lposition = (char *)strstr(source, lbound);

// strstr has returned the address. Now calculate * the offset from the beginning of str

begin = (int)(lposition - source + 1);

lr_output_message ("The lbound \"%s\" was found at position %d", lbound, begin);

begin = begin + lblength;

rposition = (char *)strstr(source, rbound); // strstr has returned the address. Now calculate * the offset from the beginning of str end = (int)(rposition - source + 1);

lr_output_message ("The rbound \"%s\" was found at position %d", rbound, end);

length= end-begin;

if(length<0) { tmp = (char*)malloc(length + 1);

tmp = (char*)strdup(source);

for(i=1;i<begin;i++) { tmp++; }

rposition = (char *)strstr(tmp, rbound);

end = (int)(rposition - tmp + 1);

lr_output_message ("The new rbound \"%s\" was found at position %d", rbound, end);

length= end - 1;

if(length<0) { lr_output_message("ERROR: Right boundary value is found before left boundary value");

return("-1"); }

}

newstring = (char*)malloc(length+1);

memset(newstring,'\0',length+1);

tmpstring = (char*)strdup(source);

for(i=1;i<begin;i++) { tmpstring++; }

strncpy(newstring,tmpstring,length);

Page 77: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

lr_output_message("Substring is ::>%s",newstring);

return newstring; }

/********************************************************************//* Function Name: cg_substr_lb/* Purpose : Extract a string between left boundary and end of string. /* Input : /* Output : /* Created by : G.Raviteja/*www.easyloadrunner.blogspot.in/******************************************************************/

char* cg_substr_lb(char* src,char* lbound){

char* lpos; char* newstring; char* tmpstring;

int start,end,length,i;

int lblength = strlen(lbound);

lpos = (char *)strstr(src, lbound);

// strstr has returned the address. Now calculate * the offset from the beginning of str

start = (int)(lpos - src + 1);

lr_output_message ("The lbound \"%s\" was found at position %d", lbound, start);

start = start + lblength; length= strlen(src);

if(length<0) { lr_output_message("-->Enter string with some characters<--");

return("-1"); }

newstring = (char*)malloc(length+1);

memset(newstring,'\0',length+1);

tmpstring = (char*)strdup(src);

for(i=1;i<start;i++) { tmpstring++; }

strncpy(newstring,tmpstring,length);

lr_output_message("Substring is ::>%s",newstring);

return newstring;

}

Page 78: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

/********************************************************************//* Function Name: cg_substr_lb_cnt/* Purpose : Extract a string between left boundary and end of string/* for the given occurence.. /* Input : /* Output : /* Created by : G.Raviteja/* www.easyloadrunner.blogspot.in/******************************************************************/ char* cg_substr_lb_cnt(char* src,char* lbound, int cnt){

char* lpos; char* newstring; char* tmpstring;

int start,end,length,i,j;

int lblength = strlen(lbound);

lpos = (char *)strstr(src, lbound);

// strstr has returned the address. Now calculate * the offset from the beginning of str

start = (int)(lpos - src + 1);

if(start<0) {

lr_output_message("-->ERROR:The left boundary value'%s' - Not found in source <--",lbound);

return("-1"); }

//lr_output_message ("The lbound \"%s\" was found at position %d", lbound, start);

start = start + lblength; // calculate the start position length= strlen(src);

if(length<0) { lr_output_message("-->ERROR:Enter string with some characters<--");

return("-1"); }

newstring = (char*)malloc(length+1);

memset(newstring,'\0',length+1);

tmpstring = (char*)strdup(src);

/* Msg: move pointer for the number of occcurence */

for (j=0;j<cnt;j++) { for(i=1;i<start;i++) { tmpstring++; }

strncpy(newstring,tmpstring,length);

Page 79: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

lpos = (char *)strstr(newstring, lbound);

start = (int)(lpos - newstring + 1);

if(start<0) {

lr_output_message("-->Last occurence of '%s' found for occurance count %d ;the occurence value entered is %d<--",lbound,j+1,cnt);

break; }

else { lr_output_message ("The lbound \"%s\" was found at position %d", lbound, start);

/* Calculate new start position */

start = start + lblength; length= strlen(newstring);

if(length<0) { lr_output_message("-->ERROR:Enter string with some characters<--");

return("-1"); } }

}

lr_output_message("Substring with occurence count %d is ::>%s",j+1,newstring);

return newstring;

}

/***************************************************************************//* Function Name: cg_substr_cnt/* Purpose : Extract a string between left boundary and right boundary. /* for the given occurrence/* Input : /* Output : /* Created by : G.Raviteja/* www.easyloadrunner.blogspot.in/************************************************************************/

char* cg_substr_cnt(char* source,char* lbound, char* rbound, int cnt){

char* lposition; char* rposition; int begin,end,i,j,length;

char* newstring; char* tmpstring;

char* newstring1; char* tmp; char* temp;

Page 80: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

int lblength = strlen(lbound);

lposition = (char *)strstr(source, lbound);

// strstr has returned the address. Now calculate * the offset from the beginning of str

begin = (int)(lposition - source + 1);

length= strlen(source);

if(length<0) { lr_output_message("Enter string with some characters"); }

newstring = (char*)malloc(length+1);

memset(newstring,'\0',length+1);

strncpy(newstring,source,length);

/* Verifying count values */

if(cnt == 0) { lr_output_message("Enter occurrence value as 1 or >1");

return("-1"); }

/* Moving begin index for the number of occurence */

if(cnt>1) { temp = (char*)malloc(length+1); temp = (char*)strdup(source);

for(j=0;j<cnt;j++) { for(i=1;i<begin;i++) { temp++; }

lposition = (char *)strstr(temp, lbound);

begin = (int)(lposition - temp + 1);

begin = begin + lblength; length= strlen(newstring);

strncpy(newstring,temp,length);

//lr_output_message("The newstring value is :%s",newstring);

}

/* Noting down the new begin position */

lposition = (char *)strstr(newstring, lbound);

begin = (int)(lposition - newstring + 1);

if(begin<0) {

Page 81: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

lr_output_message("The argument occurence count exceeds the left boundary occurrence count");

return("-1");

} }

newstring1 = (char*)malloc(length+1);

memset(newstring1,'\0',length+1);

tmpstring = (char*)strdup(newstring);

begin = begin + lblength;

/* Extracting string from the new begin value */

for(i=1;i<begin;i++) { tmpstring++; }

/* Finding right boundary in the new string */

rposition = (char *)strstr(tmpstring, rbound);

end = (int)(rposition - tmpstring + 1);

/* Calculating length upto the begining of right boundary*/

length = end - 1;

if(length < 0) { lr_output_message("last occurrence of left boundary reached");

length = strlen(newstring);

}

/* Copying the extracted string to newstring 1*/ strncpy(newstring1,tmpstring,length);

lr_output_message("Substring is ::>%s",newstring1);

return newstring1;

}

What is injector in LoadRunner?Injectors can also be called as load generators in LoadRunner. In order to create multiple Vuser script it is essential to create a scenario where the load generator has to be specified first. This provides vital host information such as it is local or remote host. The load generators must add the IP addresses of the participating machines from where the Vusers are assimilated to run scripts but prior to that the load generator must be installed in them as they are to be used as injectors

Tips for Scenario BuildingThe following steps can be used for performance test execution:

1. Add load generators and connect.

Page 82: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

2. Add scenario groups: Add one or more scripts to the list of scenarios.

3. Create run-time settings: Pace users based on feedback from business analysts or users.a. Disable Loggingb. Determine where to put think time in the script from business analysts or users. Think time can be randomized when a non-random value is in the script.

4. Simulate browser cache: This option instructs the Vuser to simulate a browser with a cache. A cache is used to keep local copies of frequently accessed documents and thereby reduces the time connected to the network. By default, cache simulation is enabled. If you disable this option, all Vusers emulate a browser with no cache available.

Note: Unlike a regular browser cache, the cache assigned to a Vuser simulates storage of graphic files only. The cache doesnot store text or other page contents associated with the webpage. Every Vuser has its own cache—every Vuser must save and retrieve images from the cache. When the cache is disabled, LoadRunner still downloads each page image only once.

5. Simulate a new user for each iteration: Instructs VuGen to reset all HTTP contexts between iterations to their states at the end of the init section. This setting allows the Vuser to more accurately emulate a new user beginning a browsing session. It resets all cookies, closes all keep-alive connections, clears the cache, and resets the user names and passwords (enabled by default).

6. Schedule by scenario: As the number of users increases, there may be a need to adjust the rampup. Duration should be for one hour on most tests with the exception of stress tests.

7. Schedule by group: Allows testers to stagger the scenarios by group, meaning scenario B can start 10 minutes after scenario A. Ramp-up is how frequently a number of Vusers will log into the system per scenario. Duration is how long a particular scenario group will execute after ramp-up. Testers may manipulate duration to cease testing at a similar time.

Load runner Controller materialwhat is load runner controller ?Controller is manage and maintain the scenario . using controller you control all the vuser in single work station .

Scenario: Describes are sequence of actions done by the V user.

What is the extension of scenario file?.lrsWhat are the elements of scenario?

1) Virtual users2) Scripts3) Number of load generators4) Real time monitors5) Runtime settings

How will you create a scenario in vugen?1. Go to tool bar.

2. Click on the controller scenario

3. Select the scenario (manual/Goal oriented)

4. Select Load generator

5. enter the script name

6. Click on ok.

What does controller do?Controller is the tool which is used to design and run the scenariosController organized and manages scenario elements

Before scenario execution:-Used to design scenarioUsed to initiate scenario run

During scenario execution:-Runs many Vusers simultaneouslyControls each vuser

Page 83: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

(Initialize, run, pause, and stop)Displays execution status of each Vuser.Displays messages from each VuserMonitors system and network resources

After scenario execution:-Collects and organizes performance dataLaunches the analysis tools.

Head of the load runner-> Agent process (agent process nu lr lo 2types)

Installation of L.R1. Exe-(Here controller & Load generator both are in same place)2. Service-(Here only LG is present. LG is here service purpose to controller)

Script runtime settings Scenario Runtime settingsLoad generator lo script create chesetappudu (Vugen) chese runtime settingsEedhi script generate chesetappudu Vugen lo chese runtime settingLG lo script aye runtime settings options

Load controller lo scenario design chesetappudu chese runtime setting

Edhi controller lo unte runtime settingsLC lo runtime settings options motham okke vidhamgaa unteene script aneedhi correct ga run authundhi

Load Controller lo ye modifications chesina I mean ye operations chesina save cheyali appude aa changes apply avuthayi

Load generator/ Load controller (to generate load we use load generators)Requests two types1. Local request (coming from working computer)2. Remote request (coming from another location)

Load generator: - It generates the user loads to the controller by using agent process.Load generator is internal component of load controllerExe of load generator: - MDRV.exeMDRV (Mercury driver virtual)It is a driver program given by mercury

Agent Process: - It establishes communication between the load generator and load controller.Exe of agent Preprocess: - magnetproc.exe Magentproc->mercury agent process

Load Generator: - To generate the number of Vusers wile running the scenario in load controller by using agentprocess OrIt generates the user loads, two types of load generator are there.

Two types of load generator:1) Host2) Remote

Local host: - if we use the load generator as controller machine then that is called as local host. OrUse the load generator in the controller machine is called local host

Remote host: - : if we use the load generator other than the controller machine, than that is called remote host.

Page 84: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

OrOther then the controller machine is called remote host as a load generator

What is the other name for load generator?Injector (OR) Host machine

Load generator system configuration?250 USER LOAD

1) Processor (Dual core)2) Hard disk 80 GB3) RAM 1GB OR ABOVE

500 USER LOAD 1) Processor: (Dual core) 2) Hard disk: 80GB 3) RAM: 2GB OR above 1000 User load 1) Processor: 4 CPU boxes (two dual core processor) 2) Hard disk: 120 GB 3) RAM:-4GB OR ABOVE

Controller:This component uses for running the multi user business scenarios.Controller Scenario:Lr has two types of scenarios. 1. Manual Scenario, 2. Goal Oriented Scenario

1. Manual Scenario:Create the controller scenario based on the no of uses.List of options available under manual scenario.Load Generator, Group Name and Result Directory.

Goal Oriented Scenario:To create the scenario based on the types of goals.List of options available under goal oriented scenario.1. Load Generator,

2. 2. Script Name.Goal oriented scenario:-To create the scenario based on the below specified goal is called goal oriented scenarioGoals:-

1) Number of Vusers2) Hits per second3) Transactions per second4) Response time5) Pages per minute

Goal Types:1. Virtual users,2. Hits/second,3. Transaction per second,4. Transaction Response time & pages per minutes.

1. Virtual Users: Define the no of uses to run under goal oriented scenario.

2. Hits/second: Send the no of request made by the client to the server.

3. Transaction per second: To set the no of transactions passed of the server per second.

4. Transaction Response time: To set the time taken by the server to process to our request. Depends on the acceptable response time criteria you can set this goal.

Page 85: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

5. Pages per minutes: Specify the no of pages to be downloaded per second from the server.

What are vuser groups?Vuser group is a collection of Vusers within a scenario

Note: - Each group can be assigned a different script to emulate different business process

Schedule by scenario-> same scenario->single group->having Common Runtime settings-> 500vusers.Schedule by group-. Group of scenarios-> different groups

Scenario Building:

1. Scheduling by Scenario, 2. Schedule by Group.

1. Scheduling by Scenario: To run all the scripts at the same time in the load controller. We can use this option.

2. Schedule by Group: To run the scenario in group wise, we can use this option.Scenario Start Times: To start the scenario execution automatically without the user interaction.

Schedule Builders:Ramp Up: To set the time for initializing the v users.

Load all v users simultaneously.

Start no of users every time

Duration: To set the time duration to run all the v users. Run until completion

Run for (Duration)

Run indefinitely.

Ramp Down: To down the v users from the run status. Stop all v users simultaneously.

Stop one user for every time.

What do you mean by the ip spoofing?IP spoofing enables each host machine to “spoof” the using many different IP address.

IP spoofing:To allocate the IP address for each vuser we can use IP spoofingNavigation:Create the multy IP address using IP wizard in Load Runner tools (not in Vugen tools) in installation tools. Go to scenarios in load controllerEnable IP spoofer (eekada IP address annedhi each user ki allocate avuthundhi)

What will happen if it is 100%?If the Processor usage reaches up to 100% some times the server may be happened in the server

When you initialize Vusers? What happens?Vusers status changes from DOWN to Pending to Initialization to READY. If Vusers fails to initialize the vuser status tender to failure.

What are the vuser statuses while running the scenario?1) Down2) Pending3) Init4) Ready5) Run6) Rendezvous7) Passed8) Fail9) Error

Page 86: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

10) Gradually existing11) Stop

Counters:

Processor: Processor time

Description: (4 C P U boxes) up to 70% or 80% of the C P U utilization is acceptable.

Memory: Available memory bytes committed bytes.Page faults per second: how many pages are not able to down load.

Disk: Physical diskAverage disk read queue length, Write queue length, Log files & general information

Data Base: Cache hit ratio, I/O batch writes per second, Lazy writes per second &Out standing records.Monitoring:Keep watching the data on the server in controllerMonitoring done 2 ways1 controller2. Run -> Perfmon

Why we consider Percentile rather than response times?

Why Percentiles are always chosen:

A percentile tells me at which part of the curve I am looking at and how many transactions are represented by that metric. Tovisualize this look at the following chart:

This chart shows the 50th and 90th percentile along with the average of the same transaction. It shows that the average is

Page 87: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

influenced far mor heavily by the 90th, thus by outliers and not by the bulk of the transactions

The green line represents the average. As you can see it is very volatile. The other two lines represent the 50th and 90th percentile. As we can see the 50th percentile (or median) is rather stable but has a couple of jumps. These jumps represent real performance degradation for the majority (50%) of the transactions. The 90th percentile (this is the start of the “tail”) is a lot more volatile, which means that the outliers slowness depends on data or user behavior. What’s important here is that the average is heavily influenced (dragged) by the 90th percentile, the tail, rather than the bulk of the transactions.If the 50th percentile (median) of a response time is 500ms that means that 50% of my transactions are either as fast or faster than 500ms. If the 90th percentile of the same transaction is at 1000ms it means that 90% are as fast or faster and only 10% are slower. The average in this case could either be lower than 500ms (on a heavy front curve), a lot higher (long tail) or somewhere in between. A percentile gives me a much better sense of my real world performance, because it shows mea slice of my response time curve.

For exactly that reason percentiles are perfect for automatic baselining. If the 50th percentile moves from 500ms to 600ms I know that 50% of my transactions suffered a 20% performance degradation. You need to react to that.

In many cases we see that the 75th or 90th percentile does not change at all in such a scenario. This means the slow transactions didn’t get any slower, only the normal ones did. Depending on how long your tail is the average might not have moved at all in such a scenario!

In other cases we see the 98th percentile degrading from 1s to 1.5 seconds while the 95th is stable at 900ms. This means that your application as a whole is stable, but a few outliers got worse, nothing to worry about immediately. Percentile-based alerts do not suffer from false positives, are a lot less volatile and don’t miss any important performance degradations! Consequently a baselining approach that uses percentiles does not require a lot of tuning variables to work effectively.

The screenshot below shows the Median (50th Percentile) for a particular transaction jumping from about 50ms to about 500ms and triggering an alert as it is significantly above the calculated baseline (green line). The chart labeled “Slow Response Time” on the other hand shows the 90thpercentile for the same transaction. These “outliers” also show an increasein response time but not significant enough to trigger an alert.

Page 88: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Here we see an automatic baselining dashboard with a violation at the 50th percentile. The violation is quite clear, at the same time the 90th percentile (right upper chart) does not violate. Because the outliers are so much slower than the bulk of the transaction an average would have been influenced by them and would not have have reacted quite as dramatically as the50th percentile. We might have missed this clear violation!

How can we use percentiles for tuning?

Percentiles are also great for tuning, and giving your optimizations a particular goal. Let’s say that something within my application is too slow in general and I need to make it faster. In this case I want to focus on bringing down the 90th percentile. This would ensure sure that the overall response time of the application goes down. In other cases I have unacceptably long outliers I want to focus on bringing down response time for transactions beyond the 98th or 99th percentile (only outliers). We see a lot of applications that have perfectly acceptable performance for the 90th percentile, with the 98th percentile being magnitudes worse.

In throughput oriented applications on the other hand I would want to make the majority of my transactions very fast, while accepting that an optimization makes a few outliers slower. I might therefore make sure that the 75th percentile goes down while trying to keep the 90th percentile stable or not getting a lot worse.

I could not make the same kind of observations with averages, minimum and maximum, but with percentiles they are very easy indeed.

ConclusionAverages are ineffective because they are too simplistic and one-dimensional. Percentiles are a really great and easy way of understanding the real performance characteristics of your application. They also provide a great basis for automatic baselining, behavioural learning and optimizing your application with a proper focus. In short, percentiles are great!

Why are my scripts/vusers failing?What are the possibilities in Vugen?

Page 89: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

1. The application that you are replaying against is not running.Simple? But it does happen, as such, when it fails on replay, take some time and try logging into the application manually and perform the business processes.

2. There were changes to the application.There were changes to the application in aspect that had affected the script. For a 3-tier architecture, anything could have changed such as the following:

a. Presentation layer: where links or buttons are removed,b. Application layer: where methods are changed or removed,c. Database layer: where calls or tables are changed or removed.d. Architecture level: where proxies or load balancers are changed or removed.

As such, verify with the application and infrastructure team if there were any changes made. You may have to re-script or amend the script accordingly to the changes.

3. There are dynamic values that need to be correlated.This is common in applications. They are usually in the form of Session IDs or returned values based on parameterization. You have two options here:

a. Use the auto-correlation feature to detect any dynamic values (which I don’t usually use) or,b. Perform manual correlation by recording two scripts of the same business process. From the two scripts, compare the recording logs and the APIs that had been generated for the differences.

4. The parameterization may be causing the problem.The parameterization may be causing the problem in the following manner:

a. Insufficient records: ensure that you have sufficient records for the replay, especially in iterations.b. Incorrect records: verify with the application or database team that you are holding on the valid values to be passed in as parameters. Parameterization may also result in different set of data being returned by the server as mentioned previously in(3). If that happens, correlate the value accordingly.For (1) to (4), it’s recommended to turn on Full Extended Log (all options enabled: Advanced Trace, Parameter Substitution, Data Returned From Server) in the Runtime Settings (Vugen) to verify the data that is been transmitted between the server and the client (script). Through this, you can find out what and where that could have gone wrong in the replay.

What are the possibilities in Controller?

5. Does it happen at the start of the scenario execution? We are focusing on the script only and leaving out the load testing setups. If the script/vuser fail at the start of the execution, verify the script again in Vugen, and if it still fails; it’s a script problem where you have to re-work from the previous point (1)to (4).

6. Does it fail on a particular Load Generator (LG)?This may be caused by inconsistent LG across the load testing environment. As such, ensure the following in order for the script to run properly (but not limited to the list):

a. Folder directories that the script may be accessing to (particularly for file upload and download business processes).b. Java settings like JVM and CLASSPATHs that can affect Java LoadRunner scripts.c. All LGs have the same version as the Controller (e.g. LR9.0 across all LGs in the load testing environment).

7. Does it happen at the middle of the scenario execution?

If it is the case, it may be caused by anything but unlikely script problems (since the script/vuser have already started running successfully at the start of the run in (5). When this happens, the Application under Test (AUT) maybe under load and unable to process all requests from the scripts/vusers and therefore returning errors to them. You can verify this with the following.

a. Manually log into your AUT again and verify if it is still running or experiencing any lags.b. Reduce the amount of vusers being generated in the scenario and re-run the test. If a reduced amount results in an error-free or non-script related errors, you are sure that the AUT is under load.

The above should be sufficient for you to troubleshoot script/vuser problems in Vugen and Controller. However, take note that it may not be limited to those and it will be advisable to carefully work the problem step-by-step to eliminate and possibilities

Page 90: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

How does collating the test results work in loadrunner controller?At the end of a test the results are collated by the LoadRunner controller. Each of the generators results are collected in a .eve(Event) file and the output messages for the controller are collected in a .mdb (Microsot Access) database. This happens in the directory specified for the results on the controller. A .lrr (loadrunner results) file is created. The .lrr file is text. The .eve file was text prior to around LoadRunner 7.5, but since then it has been anunpublished compressed format. When you start the analysis utility it take the information in the .lrr file and the .eve file and creates a .mdb (microsoft access database) or SQL Server database entries which contain each timing record and data point entries. If collation fails at the end of the test you will have only partial results for analysis.

Loadrunner Controller issuesBelow are some key facts to remember about controller. (Note: I am publishing some of these issues from my notes which I encountered at different times. I am just consolidating them here.)

The Maximum number of threads for driver. The number of threads per driver has been internally set for each specific protocol. Increasing Vuser Limit:

You can increase the Vuser limit on Windows NT by modifying the load generator's Windows Registry as follows:

Open the Windows Registry.

Select Find>Data and search for the term "SharedSection".

This search should return a path similar to this:

MyComputer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ Session Manager\Sub Systems\Windows

Modify the second value to 4096. Run-time settings - When you modify a script's run-time settings in the Controller, the new settings are saved with the Controller scenario. If, you open the script in VuGen and modify the run-time settings, use the Refresh button in the Controller to see the new settings. Compiled Vusers -

When the Vuser script is a compiled Vuser, the Controller doesn't send the dll to the remote machine. Workaround: Add the dll to the list of script files. In the Controller Scripts tab, right-click on your script name and select Details. In the Files tab, click Add and point to the dll. This will add your dll to the list of files to be transferred with the script.

You may receive the following error message when launching the Controller: "Cannot install license information, probably access to system resource was denied." This indicates that you need to log in with administrator permission, since you installed the product with administrator permission.

Workaround: Run setlicensepermissions.exe from the LoadRunner bin directory to change the registry permissions.

Environment variables on load generator machines - If you change the value of an environment variable on a load generator machine and you configured the load generator to automatically run virtual users, restart the machine to use the new value of the environment variable.

Output window - Keeping the Controller Output window open for long periods of time will affect the machine's memory usage.

Does LoadRunner transaction response time include the rendering time of the browser?NO, because LoadRunner is not designed for client-side activities.

Page 91: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Rendering time includes the time taken for the display of the web components, JavaScript or applet to load in the browser that is being activated after the HTML page is being received.

When we replay the scripts in LoadRunner, network traffic are being generated by the APIs (functions) and are expected to receive before the subsequent step can be executed. All this are taken place in memory and what LoadRunner does is to generate the traffic and receive the responses in memory. No user interface (UI) is launched in the process of replay for the purpose of rendering the pages received. Having no UI launched, rendering is omitted.

In a real user environment, the entire time for response in user perspective includes the request sending time, request processed time, response time and the browser loading (rendering time). However, in the context of LoadRunner, UI is not part of this entire request and response cycle.

For an end-to-end response time testing that includes the rendering of the UI, we can use the GUI VUser protocol.

What is the relation between Response Time and Throughput?The Throughput graph shows the amount of data in bytes that the Vusers received from the server in a second. When we compare this with the transaction response time, we will notice that as throughput decreased, the response time also decreased. Similarly, the peak throughput and highest response time would occur approximately at the same time.

How many types of graphs does LoadRunner have?LoadRunner has in total 5 different types of flag which are as follows:The Hits per second graph that depicts the traffic volume of the application being tested for.Pages download per second graph shows the rate at which the download processes are carried out at a particular instance of time.The Transaction response time (load )The Transaction response time (percentile) graphNetwork delay time graph shows the time elapsed for the request/ response activities in the application.

MONITORS:-Load Runner offers wide range of performance monitors for isolating bottlenecksMonitors display real time data during testingNote: - you can display up to 16 online monitors at a time

Different types of monitors

Client side monitors:-End to end transitions monitors; they provide end-user response times, hits per second, transaction per second

1) Hits per second2) HTTP Responses Per second3) Pages downloaded per second4) Throughput5) Transaction response time6) Transaction per second(Pass)7) Transaction per second(Failed)8) User defined data point9) Virtual user status10) Web transaction break down graphs

Server Monitors:-NT/UNIX/Linux monitorsProvide hardware, network and operating system performance metrics such as CPUMemory and network throughputNT server resourcesUnix/Linux server monitorsNote:-

Page 92: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Performance monitors are licensed by the load runner controllerA monitor cannot be configured unless the license has been purchasedTo find out which monitors your current license allows

Data base server resource monitors:-Data base monitorsProvides performance data inside the database such as activeDatabase connections

1) SQL ServerDatabase server resource monitorsMeasure statistics related to the SQL Server, oracle,Sybase and DB2 databases during the scenario session

Bottleneck: It is a pinpoint or breaking point where the server will get up gration and degration. (Up and down in graph)

How do you identify the performance bottlenecks?Performance bottlenecks can be detected by using monitors. These monitors might be application server monitors, web server monitors, Data base server monitors and network monitors. They help in finding time. The measurements made are usually performance time, throughput, Hits per sec and networks delay graphs.

What bottlenecks did u find?Memory leaks, dead logs and index sequences data base.

How do you identify the performance bottlenecks?Performance bottlenecks can be detected by using monitors. These monitors might be application server monitors, web server monitors, Data base server monitors and network monitors. They help in finding time. The measurements made are usually performance time, throughput, Hits per sec and networks delay graphs.What the difference between the HTML and URL based recording modes?HTML: to generates html resources script for non html resources like Zip files and bitmap files. Entire transactions will certain only one URL address.URL: it generates each step as an URL. It generates each step for all the request and resources from the server. Each and every transaction should contain different URL address.Script will be generated in three sessions.What the response time for transactions?4 seconds for almost all transactions.

What bottlenecks did u find?Memory leaks, dead logs and index sequences data base.

What is memory leak?After using the objects, memory should get free, if it is not getting free then that is called memory leak.

What is load generator?It generates the user loads, two types of load generator are there.Load Host: it we use the load generator as controller machine then that is called as local host.Remote Host: if we use the load generator other than the controller machine, than that is called remote host.

How can you find out memory leak?Definition of Memory Leak: after using the object memory, it should get free if it is not getting tree then that is called memory leak. We can find out by using JVM.How you find out memory leak?Who have find out the memory leaks in the initial stage only by using ramp down option? (Stop all users simultaneously)

Memory out of bound (Memory out of bound ani message vasthundhi screen meedha ee situation nu practical ga chesichudu)

Why did you use analyze?1. Client side Metrics: Response time, Through put, Hits per second, T P S.

2. Sever side Metrics: Resources, physical disk, Memory and Processors.What are the graphs are available in load controller?

Page 93: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

No of virtual users, Error graphs, Transactions response time, web source graph, web page break down graph, user defined data point graphs, system resource graphs, N/w monitors graph, fire well net work server graphs, data base resource graphs, streaming media graphs, ERP/CRM server graphs, java performance graphs, application componentgraphs, application deployment solution graphs, security graphs, middle ware performance graphs application traffic m/m graphs and intra structure resource graph.

Tuning:It is an area to find out the bottlenecks in different areas.Bottleneck may be: Application, application server, Data base server, Network and web server.

How did you plan the load? What are the criteria?There are two types of documents available for carrying performance testing.Task Distillation Management: Enter the P T application is divided into unit modules and is distributed over the terms. TL/PM is responsible for dividing the modules test engineers. It is also known as licensed agreements.Task Profiler: It maintains the no of transaction under tasks.

What is percentage mode?By using percentage mode we can distribute the no of virtual user to distribute the scripts. We can create manual scenario by using percentile mode.

Filters:-Filters let you display only a specific transaction status, transaction name, group, vuserDef: - “To get the data based on our specified condition”.

What is filter?To get the data based on our specified condition. You can set the filter for user id condition elapsed scenario conditiongraph represented data.

You can set the filters for user id condition, elapsed scenario condition, graph represented data

What is granularity?To set the time gap between two salvation points, we can use.

What is top command?Top command is used for the utility of UNIX servers to monitor the performance.

Performance Counters for Load Runner· Processor Usage – amount of time processor spends executing non-idle threads.

· Memory use – amount of physical memory available to processes on a computer.

· Disk time – amount of time disk is busy executing a read or write request.

· Bandwidth – shows the bits per second used by a network interface.

· Private bytes – number of bytes a process has allocated that can’t be shared amongst other processes. These are used to measure memory leaks and usage.

· Committed memory – amount of virtual memory used.

· Memory pages/second – number of pages written to or read from the disk in order to resolve hard page faults. Hard page faults are when code not from the current working set is called up from elsewhere and retrieved from a disk.

· Page faults/second – the overall rate in which fault pages are processed by the processor. This again occurs when a process requires code from outside its working set.

Page 94: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

· CPU interrupts per second – is the avg. number of hardware interrupts a processor is receiving and processing each second.

· Disk queue length – is the avg. no. of read and write requests queued for the selected disk during a sample interval.

· Network output queue length – length of the output packet queue in packets. Anything more than two means a delay and bottlenecking needs to be stopped.

· Network bytes total per second – rate which bytes are sent and received on the interface including framing characters.

· Response time – time from when a user enters a request until the first character of the response is received.

· Throughput – rate a computer or network receives requests per second.

· Amount of connection pooling – the number of user requests that are met by pooled connections. The more requests met by connections in the pool, the better the performance will be.

· Maximum active sessions – the maximum number of sessions that can be active at once.

· Hit ratios – This has to do with the number of SQL statements that are handled by cached data instead of expensive I/O operations. This is a good place to start for solving bottlenecking issues.

· Hits per second – the no. of hits on a web server during each second of a load test.

· Rollback segment - the amount of data that can rollback at any point in time.

· Database locks - locking of tables and databases needs to be monitored and carefully tuned.

· Top waits – are monitored to determine what wait times can be cut down when dealing with the how fast data is retrieved from memory

· Thread counts – An applications health can be measured by the no. of threads that are running and currently active.

· Garbage collection – has to do with returning unused memory back to the system. Garbage collection needs to be monitored for efficiency.

Difference in Response times with Different LoadGenrators. Why?I recently encountered this issue and the below solution fixed this issue

Issue:The response times of transactions for the users generated from a Load Generator on Windows 2003 are lower then the response times of the same transactions from Users generated from a Load generator on Windows 2008 R2

Solution:Perform this on Load generator on Windows 2008 R2

1. Control Panel> User Accounts >Turn User Account control on or off> Uncheck the Check Box with Name: User Account Control Box On to protect your computer

2. Add SSL Certificate:

a. Go to Fire Fox that is in the Bin dir (if it is for Ajax True Client)b. Open it> Tools > Options>Advance>View Certificate> Add Certificate

Page 95: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

c. How will I get Certificate?Play the application manually on this box. Then certificate may be downloaded in that location.

3. Turn Off Fire Wall

90TH PERCENTILE90th percentile Response Time is defined by many definitions but it can be easily understood by:

"The 90th percentile tells you the value for which 90% of the data points are smaller and 10% are bigger."

90% RT is the one factor we should always look in once the Analysis report gets generated

To calculate the 90% RT

1. Sort the transaction RT by their values

2. Remove the top 10% instances

3. The higher value left is the 9oth percentile RT.

For e.g. Consider we have a script with transaction name "T01_Performance_Testing" and there are 10 instances of this

transaction, i.e. we ran this transaction for 10 times.

Values of transaction's 10 instances are

1. Sort them by their values

2. Remove top 10% values, i.e. here 9Sec

3. 8 Sec is the 90th percentile RT.

Latency Vs BandwidthOne of the most commonly misunderstood concepts in networking is speed and capacity. Most people believe that capacity

and speed are the same thing. For example, it's common to hear "How fast is your connection?" Invariably, the answer will

be "640K", "1.5M" or something similar. These answers are actually referring to the bandwidth or capacity of the service, not

speed.

Speed and bandwidth are interdependent. The combination of latency and bandwidth gives users the perception of how

quickly a webpage loads or a file is transferred. It doesn't help that broadband providers keep saying "get high speed access"

when they probably should be saying "get high capacity access". Notice the term "Broadband" - it refers to how wide the

pipe is, not how fast.

Latency:

Latency is delay.

For our purposes, it is the amount of time it takes a packet to travel from source to destination. Together, latency and

bandwidth define the speed and capacity of a network.

Page 96: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Latency is normally expressed in milliseconds. One of the most common methods to measure latency is the utility ping. A

small packet of data, typically 32 bytes, is sent to a host and the RTT (round-trip time, time it takes for the packet to leave

the source host, travel to the destination host and return back to the source host) is measured.

The following are typical latencies as reported by others of popular circuits type to the first hop. Please remember however

that latency on the Internet is also affected by routing that an ISP may perform (ie, if your data packet has to travel further,

latencies increase).

Ethernet .3msAnalog Modem 100-200msISDN 15-30msDSL/Cable 10-20msStationary Satellite >500ms, mostly due to high orbital elevationDS1/T1 2-5ms

Bandwidth:

Bandwidth is normally expressed in bits per second. It's the amount of data that can be transferred during a second.

Solving bandwidth is easier than solving latency. To solve bandwidth, more pipes are added. For example, in early analog modems it was possible to increase bandwidth by bonding two or more modems. In fact, ISDN achieves 128K of bandwidth by bonding two 64K channels using a datalink protocol called multilink-ppp.

Bandwidth and latency are connected. If the bandwidth is saturated then congestion occurs and latency is increased. However, if the bandwidth of a circuit is not at peak, the latency will not decrease. Bandwidth can always be increased but latency cannot be decreased. Latency is the function of the electrical characteristics of the circuit.

How to calculate sessions per hour in performance testing? - Little's LawCalculating Sessions per hour: For this discussion, we will be focusing on a session as the total time for the user group to finish one complete set of transactions. We may wish to know the number sessions that will be completed for any given number of virtual users.

Example 1:- If a baseline test shows that a User Type takes a total of 120 seconds for a session, then in an hour long steady state test this User Type should be able to complete 3600 / 120 = 30 sessions per hour. Twenty of these users will complete 20 x 30 = 600 of these session in an hour. In other cases, we have a set number of sessions we want to complete during the test and want to determine the number of virtual users to start.

Example 2:Using the same conditions in our first example, if our target session rate for sessions per hour is 500, then 500 / 30 = 16.7 or 17 virtual users. A formula called Little's Law states this calculation of Virtual Users in slightly different terms. Using Little's Law with Example 2:

V.U. = R x D where R = Transaction Rate andD = Duration of the SessionIf our target rate is 500 sessions per hour (.139 sessions/sec) and our duration is 120 seconds, then Virtual Users = .139 x 120 = 16.7 or 17 virtual users.

Transactional Concurrency in Load testingHow many transaction will need to run per minute if a load test has to run for 2 hours with 5000 users, assuming averagelength of transaction if 5 minutes?

Page 97: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Solution:

Duration of load test -120 minutesUser load- 5000Average Length of transaction- 5 minutesNo. of transaction per minute-?

No. of transaction performed by single user in 120 minute = 120 minutes / 5 minute = 24 transaction

No. of transaction performed in 2 hours by 5000 users = 5000*24 =120000 transactions.

No. of transaction per minute =No. of transaction performed during 2 hour by 5000 users/duration of two hour = 120000/120= 1000 Transaction /Minute

Why response time of a page does not equal the sum of its requestsThe response time for a page typically differs from the sum of its requests. This does not mean that your data is incorrect. The difference can be caused by concurrent requests, page connection times, inter-request delays, and custom code within a page.

The most common reason for the sum of the individual request times within a page to exceed the total page response time is that requests are often sent concurrently (in parallel) to a server. Thus some of the individual request response times overlapso the sum of the request response times would exceed the page response time.

Additionally, the page response time can exceed the sum of the individual request response times within the page for the following reasons:

The individual request response times do not include time to establish connections but the page response time does include the connection request time.

Inter-request delays are not reflected in the individual request response time but are reflected in the page response time.

Custom code placed within a page is executed serially (after waiting for all previous individual requests to complete) and thus contributes to the page response time. It does not affect individual request response times. However, we recommend that you place custom code outside of a page, where it will not affect page response time.

Performance Center Interview Questions-Enough stuff on PC1. Tell something about performance center?2. Which of the cases performance center will be chosen over loadrunner?3. What are the types of access sites available in performance center?4. What is a user site in performance center?5. What is host in performance center?6. Can one system act as a controller and load generator in performance center?7. What is a timeslot in performance center?8. What is the significance of using the time slots in performance center?9. How to create Vuser Scripts in performance center?10. What are the steps followed to upload VuGen scripts in performance center?11. How to create test scripts directly in performance center?12. What is a monitor profile in performance center?13. How to add monitor graphs from performance center?14. What is auto start viewer in performance center?15. How to configure auto start viewer in performance center?

Page 98: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

16. What is the significance of options in performance center?17. Where the settings for Transaction Data and Server Resource Monitors will be set in performance center?18. What are the run time settings can be set in performance center options?19. How to set the time out settings for load generator and vuser in performance center?20. What is the debug information settings can be set in performance center options?21. How multiple ip address allocation per process or thread can be set in performance center?22. How to switch from one project to the other without logging out from performance center?23. How to create a new load test in performance center?24. How to enable spoofer in performance center?25. How to pause a scheduler at load test start in performance center?26. What are the options available in assigning the load generators to groups in performance center?27. How to set and change the group size by number in performance center?28. What is the advantage of using group size by percentage option in performance center?29. How to add multiple groups in performance center load test?30. What is the significance of using start time options in performance center scheduler?31. What is the significance of using schedule options in performance center scheduler?32. What is the significance of using run mode options in performance center scheduler?33. What are the actions available in performance center global schedule?34. What is the significance of using each action in performance center global schedule?35. How to add monitors in performance center load test?36. What do search results module displays in performance center?37. How to change personal information in performance center?38. What and where to see recently run load tests in performance center?39. What and where to see currently run load tests in performance center?40. What and where to see next reserved timeslots in performance center?41. What and where to see the dash board section of performance center?42. How to set service level agreements in performance center?43. What are the types of service level agreements available in performance center?44. How to download the load test results from performance center?45. How to analyze the results in performance center?46. What are the reports generated by performance center?47. How to upload test scripts directly from VuGen to performance center?48. How to import the scripts from one project to other in performance center?49. How to edit the uploaded scripts in performance center?50. How to import the monitors from one project to other in performance center?51. What are the prerequisites to import the scripts and monitor profiles in performance center?52. How to add more monitors to the existing monitor profile in performance center?53. How to add a project to be part of auto start viewer in performance center?54. What is the difference between the project and load test in performance center?55. How to assign virtual load generators to the groups in performance center?56. How to analyze the load test results from analyzer in performance center?57. How to publish the load test results to dashboard in performance center?58. What is the prerequisite to publish the load test results to dashboard in performance center?59. What are the details displayed after the load test is published to dashboard in performance center?

Difference between Loadrunner and performance center

Page 99: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Loadrunner Performance Center

Loadrunner is a industry standard enterprise level load testing tool

Performance Center is a web enabled load testing tool

Resource management (VuGen scripts, scenarios and results) is local to the person, who is using the loadrunner tool on his local machine

Resource management is centralized, since it is web enabled

If there are multiple performance test engineers using the shared lab, there is lot of dilemma how to reserve the lab for a specific load test

Using performance center the lab machines can be reserved for a time slot

Using load runner optimum usage of virtual users licenses is a problem, if more than one load tester is involved

Virtual users can be reserved based on the time slot. So the user licenses can be optimally used in this case

A single load test at a time can be initiated from a loadrunner controller

Multiple load tests can be executed simultaneously using performance center

Versioning of the resources is not possibleVersion of the resources is possible through performance center

Locally accessible platformA Web-based, 24x7, globally accessible platform

Assets can be shared only on the local projects Load test assets (VuGen scripts, results) can be shared across the

Page 100: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Loadrunner Performance Center

project

Monitoring will help identify infrastructure issues

Infrastructure topology definition and monitoring to help identify infrastructure issues

There is no traceability in loadrunnerPerformance requirements and defect traceability

There is no direct integration with HP Application Lifecycle Management and Business Availability Center

Integration with HP Application Lifecycle Management and Business Availability Center

Loadrunner is good, if you have a small load testing team sitting in one location

Performance center is good, if you have a large distrbuted load testing team sitting in different locations

Difference In Monitoring System Resources From Performance Center & ControllerYou might have monitored system resources from HP Performance Center or HP LoadRunner Controller application. But any time did you have faced any problem while collecting data (like %Processor Time, pages/sec etc for memory etc).There is difference in adding measurements from Performance Center & from Controller. Have you ever seen that when you add System IP for collecting data from this IP while executing your scenario, but the data is not collected. I have faced this problem. Let me explain my scenario in this case:In Performance Center:1. You create a scenario, add scripts to execute in Design tabs and add the monitors in the Monitors tab (you provide the UserID/Password while adding the performance counters to be monitored on the machine).2. You start the scenario, and the performance data is collected from this machine.

But do you really think it is so simple if you add performance counters for a machine on HP LoadRunner Controller.Try adding the performance counter in LoadRunner Controller scenario and start the scenario. You will see that the window resources graph doesn't display the data. (it has happened with me) .This is due to the fact that, while adding the machine under window resources, it doesn't ask for the system UserID/Password and the LoadRunner Controller machine UserID/Password overrides the UserID/Password of the system which is to be monitored.

So in this case, the password of the Controller machine and the Monitor machine should be same. Then only you can monitor the system resources added in the Controller scenario.

Page 101: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Analysis Scenario (Bottlenecks)In Running Vuser graph correlated with the response time graph you can see that as the number of Vusers increases, the average response time of the check itinerary transaction very gradually increases. In other words, the average response time steadily increases as the load increases. At 56 Vusers, there is a sudden, sharp increase in the average responsetime. We say that the test broke the server. That is the mean time before failure (MTBF). The response time clearly began to degrade when there were more than 56 Vusers running simultaneously.

Analysis - Comparing data from LoadRunner Graphs with Raw DataThe below post includes what kind of questions a Performance Engineer may encounter during Analysis session for a detailed oriented and curious client.

Performance Engineer:I provided the Transaction Response time summary Report and shown different Graphs to the customer

Client:I would like to have the raw transaction times (number shown in "Pass" column). This means a Transaction passed for 50 times during the test, they want to see the response times of each of the 50 passed transactions.

Performance Engineer:I provided the Response Times of the two transactions client requested with time stamps.

Page 102: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Client:What is the difference between first Buffer Time and Over All Response time?

Performance Engineer:The First Buffer Time is always less than the Overall Response timewhat we see in the Response times graph is the TIME When Response Completed. It will be obviously more than that of FirstBuffer Time.Please refer the below diagram.

Page 103: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Client:Thank you for the raw data and the above explanation Could you please verify that all data points were included as I cannot match the numbers in the spreadsheet? On the spreadsheet it shows that there were 19 data points for the Transaction1 and 18 data points for Transaction2 yet only 17 data points are available for each in the Raw Data why?

In addition, I cannot see the corresponding entry that matches the value of the maximum number displayed in the summary spreadsheet for either transaction.

The only number that I can currently match is the minimum number. Please let me know if there are other data points that need to be included.

Page 104: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

Performance Engineer:I provided the raw data for the login the Graph. Now I am getting you the Real Raw data from data points.

There is a difference between these two raw data (Real Raw data and Graphed Raw Data)For Example: In Real raw data, you see two values at 36 seconds. During that 36th second of the Test run two users took 26 sec and 23 seconds respectively.

The Graphed Raw data shows the average of these response times that happened at fraction of seconds. (Because our granularity is only 1 second We cannot go more granular than 1 second)Average of 26.738 and 23.211 = 24.975. This is what you are seeing in the Graph and But in summary you are seeing 26.738. This value is based on Real Raw data.

Coming to the question, Why we are not able to map the max values to the Maximum data point in Summary? The Web Page

Page 105: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

component Break down graph is also Average of different users activity at different point. So if you try to map the Max value in Summary with Max value in Web Page Break down Graph we are not mapping same values. Because, they might not occurred at the same time.

What the Response Time Summary shows is pretty much clear. 90 percentile shows how many transactions are below that particulat data point. If the 90 percent column is exceeding your SLA, then we have to correlate it with the Standard Deviation. If deviation is high. Then we need to go to the specific Graph and observe the trend to see where the deviation occurred.

Factors Affecting Performance of web applicationIt has been known for years that although software development constantly strives towards constant improvement, it will never completely be 100% perfect. An application’s performance, in turn, can only be as good as in comparison to its performance objectives.

Performance problems affect all types of systems, regardless of whether they are client/server or Web application systems. It is imperative to understand the factors affecting system performance before embarking on the task of handling them.

Generally speaking, the factors affecting performance may be divided into two large categories: project management oriented and technical.Project Management Factors Affecting Performance In the modern Software Development Life Cycle (SDLC), the main phases are subject to time constraints in order to address ever growing competition.

This causes the following project management issues to arise: Shorter coding time in development may lead to a lower quality product due to a lack of concentration on

performance.

Chances of missing information due to the rapid approach may disqualify the performance objectives.

Inconsistent internal designs may be observed after product deployment, for example, too much cluttering of objects and sequence of screen navigation.

Higher probability of violating coding standards, resulting in unoptimized code that may consume too many resources.

Module reuse for future projects may not be possible due to the project specific design.

Module may not be designed for scalability.

System may collapse due to a sudden increase in user load.

Technical Factors Affecting PerformanceWhile project management related issues have great impact on the output, technical problems may severely affect the application’s overall performance. The problems may stem from the selection of the technology platform, which may be designed for a specific purpose and does not perform well under different conditions.

Usually, however, the technical problems arise due to the developer’s negligence regarding performance. A common practice among many developers is not to optimize the code at the development stage. This code may unnecessarily utilize scarce system resources such as memory and processor. Such coding practice may lead to severe performance bottleneckssuch as:

memory leaks

array bound errors

inefficient buffering

too many processing cycles

larger number of HTTP transactions

too many file transfers between memory and disk

inefficient session state management

thread contention due to maximum concurrent users

poor architecture sizing for peak load

inefficient SQL statements

Page 106: Load Runner Introduction and Architecturedocshare01.docshare.tips/files/30615/306151083.pdf · Load Runner Introduction and Architecture LoadRunner is an industry-leading performance

lack of proper indexing on the database tables

inappropriate configuration of the serversThese problems are difficult to trace once the code is packaged for deployment and require special tools and methodologies. Another cluster of technical factors affecting performance is security.Performance of the application and its security are commonly at odds, since adding layers of security (SSL, private/public keys and so on) is extremely computation intensive. Network related issues must also be taken into account, especially with regard to Web applications. They may be coming from the various sources such as:

Older or unoptimized network infrastructure

Slow web site connections lead to network traffic and hence poor response time

Imbalanced load on servers affecting the performance