LoadRunner stress testing method

This article introduces how to use the LoadRunner tool. Based on the actual situation of the company, the article mainly describes the basic use of the tool in detail. The purpose is to help other personnel quickly master Loadrunner based on this manual and use it to perform stress testing.

LoadRunner overview

LoadRunner is an industry-standard load testing tool that predicts system behavior and performance. by simulating

Tens of millions of users implement concurrent load and real-time performance monitoring to confirm and find problems. LoadRunner can monitor the entire

Enterprise architecture is tested. By using LoadRunner, enterprises can minimize testing time, optimize performance and accelerate the release cycle of application systems. At present, enterprise network application environments must support a large number of users. The network architecture contains various application environments and software and hardware products are provided by different suppliers. Unpredictable user loads and increasingly complex application environments make companies constantly worried about problems such as slow user response and system crashes. These inevitably lead to loss of company earnings. Mercury Interactive's LoadRunner allows enterprises to protect their revenue sources, maximize the use of existing IT resources without purchasing additional hardware, and ensure the quality, reliability and availability of end-users testing applications in all aspects of the application system. The scalability has good reviews. LoadRunner is an automated load testing tool for various architectures that predicts system behavior and optimizes system performance. LoadRunner's test object is the entire enterprise's system. It helps you find and discover problems faster by simulating actual user operating behaviors and performing real-time performance monitoring. In addition, LoadRunner can support a wide range of protocols and technologies to provide special solutions for your special environment.

The basic steps

Using LoadRunner to complete testing is generally divided into four steps:

1) Create a virtual user script

  • Create script, choose protocol
  • Record script
  • Edit script
  • Check if there are any errors in the modified script

2) Scheduling virtual users and creating operating plans

  • Create Scenario, select script
  • Set the number of virtual users on the machine
  • Set Schedule
  • If simulating multi-machine testing, set Ip Spoofer

3) Run the script

  •  Monitoring scenarios

4) Analyze test results

  • Analyze scenarios

Install LoadRunner

LoadRunner is divided into Windows version and Unix version. If all our test environments were based on Windows

platform, then we only need to install the Windows version. The installation process explained in this chapter is the installation of the Windows version of LoadRunner 8.0.

System Requirements

At present, general working machines can meet the minimum requirements of LoadRunner 8.0. For detailed system requirements, please refer to the Mercury LoadRunner Installation Guide.

Installation process

There are two installation methods for LoadRunner 8.0 we use: one is the main computer used to create virtual users, execution plans, and analysis results; the other is the client computer where users create loads.

Main control computer installation

After logging into the system as Administrator, run Setup.exe in the root directory of the installation CD to enter the installation program (if you are installing on a network shared drive, it is best to map it as a network drive and then install it).

In the interface below, select the first item "LoadRunner Full Setup"

In the "Registration Information" interface, just click Next (no need to change, just n 8s)

In the installation type interface, select Typical

Find the license key from the CD and enter it into the corresponding location. Since we are going to do web application testing, here we select the license for 1,000 web users:

For the remaining steps, just follow the default options (you can change the installation directory)

After the installation is complete, remove the "register now" option and then restart the system

Client installation that generates load

Except for selecting the second item "Load Generator" in the first step and not entering the license, everything else is the same as the main control machine.

Load/stress testing using LoadRunner

Record basic user scripts

Creating user scripts requires the use of Virtual User Generator (hereinafter referred to as VuGen). Tip: It is best to run VuGen at a resolution of 1024*768, otherwise some toolbars will not be visible.

After starting VuGen, create a new user script through the menu and select the protocol for system communication. What we need to test is a Web application, so we need to select the Web (HTTP/HTML) protocol and enter the main form after confirmation.

Start the command to record the script through the "Start Record" button on the toolbar.

Add the address of the website to be tested in the URL;

In the Record into Action section, we want to record from the login system, so select "vuser_init";

Remove the Record the application startup option so that we can start recording at the appropriate time;

Click OK to enter the script recording interface.

Do not use the browser's "back" function during recording, LoadRunner support is not very good. During the recording process, a toolbar will appear on the screen, and the functions of each button are as shown in the picture above. After the recording is completed, press the "End Recording" button, VuGen automatically generates the user script and exits the recording process.

Improve test scripts

After recording a basic user script, we still need to improve the test script and enhance the script before official use.

flexibility. Generally, we use the following methods to improve the test script. Insert transactions, insert junctions, insert annotations, and parameterize input. Here we only give examples of how to set up parameterization, and others are only briefly introduced.

insert transaction

Transaction: In order to measure the performance of the server, we need to define a transaction. For example: We are in the script

There is an operation of opening a document. In order to measure the response time of this operation, we define this operation as a transaction. In this way, when running the test script, when LoadRunner reaches the starting point of the transaction, LoadRunner will start timing until it runs. At the end of the transaction, the timer ends. The running time of this transaction will be reflected in the results.

The transaction insertion operation can be performed during the recording process or after the recording ends. LoadRunner runs on

Insert an unlimited number of transactions into your script.

The specific operation method is as follows: In front of the operation that needs to define a transaction, insert it through the menu or toolbar. Enter a name for this transaction. Note: The name of the transaction should be meaningful and be able to clearly explain the actions completed by the transaction. After inserting the start point of the transaction, you need to insert the "end point" of the transaction after the operation that needs to define the transaction. It can also be inserted through the menu or toolbar. By default, Transaction Name lists the most recent transaction name. Under normal circumstances, the transaction name does not need to be modified. The state of a transaction is LR_AUTO by default. Under normal circumstances, we do not need to modify it, except when writing code manually, it may be necessary to manually set the status of the transaction.

​​​​​​​Insert rendezvous point

Rendezvous points are inserted to measure server performance under heavy load. In a test plan, it might be

The system is required to be able to withstand 1,000 people submitting data at the same time. In LoadRunner, you can add a rendezvous point before the data submission operation. In this way, when the virtual user runs to the rendezvous point where the data is submitted, LoadRunner will check how many users run to the rendezvous point at the same time. If there are less than 1,000 people, LoadRunner will order users who have arrived at the meeting point to wait here. When the number of users waiting at the meeting point reaches 1,000, LoadRunner will order 1,000 people to submit data at the same time, thereby meeting the requirements in the test plan.

Note: Rendezvous points are often used in conjunction with transactions. The rendezvous point can only be inserted into the Action part, and the rendezvous point cannot be inserted into vuser_init and vuser_end. The specific operation method is as follows: Before the rendezvous point needs to be inserted, enter the name of the rendezvous point through the menu or toolbar operation. Note: The name of the rendezvous point should be meaningful and be able to clearly explain the actions completed by the rendezvous point.

​​​​​​​Insert comments

I won’t go into details about the role of comments, but it’s best to insert comments during the recording process. The specific operation method is as follows: Operate through the menu or toolbar before the comment needs to be inserted.

​​​​​​​Parameterized input

If the user fills in and submits some data during the script recording process, such as logging in as admin. These operations are recorded in the script. When multiple virtual users run scripts, they will submit the same records, which does not conform to the actual operation situation and may cause conflicts. In order to simulate the actual environment more realistically, a variety of inputs are required. Parameterized input is a good approach. Parameterization involves the following two tasks:

① Use parameters instead of constant values ​​in the script.

②Set parameter attributes and data sources.

Parameterization can only be used for parameters within a function. You cannot use parameters to represent strings that are not function parameters. In addition, not all functions can be parameterized.

To explain parameterized input, we will use an example. In this example we parameterize the user's login name. First look at the following script and find the user login part through script recording, as shown in the figure

Select the login name in the box, right-click the mouse, a dialog box will pop up, and select the "Replace with a parameters" option to replace the username with parameters. For specific usage of various parameters, please refer to the relevant help documents.

​​​​​​​Run the test script on a single machine

After going through the above steps, the script can be run. Running scripts can be done through the menu or toolbar.

After executing the "Run" command, VuGen first compiles the script and checks whether there are syntax and other errors. If there are errors, VuGen

An error will be prompted. Double-click the error message and VuGen can locate the line where the error occurred. To verify the script is correct

To ensure the accuracy, we can also debug the script, such as adding breakpoints in the script. The operation is exactly the same as in VC. I believe no one will feel unfamiliar. If the compilation passes, it will start running. Then the running results will appear.

Implement tests

Select script to create virtual user

Enable "controller" to pop up the window as shown in the figure

Select the script you just recorded and saved, add it to the plan, and click "OK" as shown below.

Modify the number of virtual users as needed and click "Edit Schedule" to refine the plan. Here you can set detailed plans for adding, running, and reducing virtual users.

Click the "Run" label in the above picture to enter the run panel. Here you can control the operation of the program and monitor various system resources.

​​​​​​​​Add resource monitoring window

Loadruner has four default performance monitoring windows, namely "running vuser", "transaction response time", and "number of clicks per second". The last one can be selected according to the user. Loadrunner can also display 1-16 windows at the same time. The method is to right-click and select "View Pictures" in the pop-up menu to select the number of pictures to display. You can also customize the number.

This article takes Windows system resources as an example. Other systems can choose the corresponding system resources. Open the directory tree in the available picture, select system resources, find the windows resource and double-click it, the windows resource monitoring window will automatically replace the original window as shown above.

​​​​​​​​Add windows performance counters

Select the windows resource monitoring window with the mouse, right-click and select "ADD Measurements.." from the pop-up menu to pop up the window as shown in the figure.

Click "Add" to enter the IP address of the monitored server and click OK, as shown in the figure

If you can connect to the server normally, all counters will be displayed in the resource measurement. At this time, if you click "OK", the system will select all by default. All performance curves will be displayed in the monitoring window. You cannot filter and display a certain curve individually. If you select Click "Add" after a certain counter, and other performance indicators under the project will pop up. Select the required counter and click "Add" as shown in the figure.

At this time, please note that the user you log in to the client (that is, the machine where you have Loadrunner installed) should be an administrator, and you must also ensure that the user is also an administrator on the monitored server. In this way, although all performance curves will still be displayed in the monitoring window, you can pop up the menu by right-clicking the mouse and select a curve you specified to display individually. The method is to double-click the monitoring window to enlarge the display, and then right-click to select "Only display the specified image." The monitoring windows can also overlap each other and other operations. It is powerful and complex display operations can be performed through the right-click menu selection. Commonly used ones include web program server diagrams, database server resource diagrams, etc., and the adding methods are the same. What are the counters, what are their meanings, and what is the ideal value? You can refer to the relevant help documentation.

​​​​​​​Configuring result options

Select "Results->Results settings" from the menu bar to pop up the results options dialog box:

Enter the result name here and select the path where the results will be saved. Since multiple results may be compared later, the result name here should best reflect the characteristics of this test, such as "High Load Official Document Test".

​​​​​​​Execute script

After the settings are completed at this point, it is simple, click "Start scenario" to start running. Pay attention to observing various parameters during operation, and you can also perform various operations on virtual users.

Analyze results

After the script is executed, we start "Analysis" to analyze the test results. Select the Open option from the menu:

Select "LoadRunner results" as the file type, browse the previously saved results file, and click to open. After waiting for the analysis to complete, the analyzer will give some default data and charts:

By merging and cross-analyzing various data charts, the test conclusion is finally given (please refer to the relevant help documents for the meanings and usage of various charts).

Finally: The complete software testing video tutorial below has been compiled and uploaded. Friends who need it can get it by themselves [guaranteed 100% free]

Software Testing Interview Document

We must study to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Alibaba, Tencent, Byte, etc., and some Byte bosses have given authoritative answers. After finishing this set I believe everyone can find a satisfactory job based on the interview information.

Guess you like

Origin blog.csdn.net/weixin_50829653/article/details/133362838