Watching the live broadcast of beautiful women every day, do you know how to use jmeter to perform stress testing on the live broadcast room?

01 Install the plugin

Jmeter itself supports the HTTP method. To test the WebSocket interface, you must first install the plug-in.

To install the plugin:

1. First download the plugin manager

Visit the website: https://jmeter-plugins.org/install/Install/Download
the jmeter-plugins-manager-1.3 .jar package
Put the downloaded package in the lib/ext directory of jmeter and restart Jmeter**

 

picture

2. After downloading, you can view the plug-in management tool under the Jmeter project, click to enter to download the plug-in that supports websocket

 

02 Debug websocket request

Debug websocket request is normal, add a thread group, add sampler, add websocket request

1) Check whether the request method used is ws or wss

2) The port number must be correct

3) Fill in the server address and path

4) Add the view result tree to observe whether the operation result is successful

picture

picture

picture

 

03 Enter the topic
After completing the above prerequisites, you can start to enter the topic. First analyze the business scenario & test requirements, and start writing test cases. Here we simulate the scenario: 60 users log in at the same time in the live broadcast room, that is, 60 users are online at the same time (The number setting is relatively small for the convenience of experimentation. In the later stage, it is necessary to add a certain number of users, such as 200, 500, 1000, etc.) and the scene where some users send messages to chat in the live broadcast room, observe whether the screen & video of the live broadcast room Caton, the performance of the server changes.

1. Data preparation: 60 user accounts & passwords

picture

2. Add a CSV data file and parameterize the account password

picture

picture

3. Write the login interface well, and use the variable name in the CSV file for the account password in the requested data (obtain the actual account password in the txt file)
picture

4. Next, enter the live broadcast room, that is, each user needs to bind the room after logging in to successfully enter the live broadcast room (see the actual business scenario here, and analyze the business of the live broadcast room. Which interfaces & data associations between interfaces, etc.)

Since binding to the live room requires an id, this id is returned by the websocket interface, and it is different every time, so here we need to parameterize this id, and then use it for the interface bound to the room.

picture

Add a post-processor, the JSON extractor extracts the clientId for use

picture

The binding room interface and the sending message interface that will be used next need to use the login status. Here we also parameterize the auth returned by the login interface. (Similarly, auth is also parameterized)

picture

 

Add configuration element-HTTP information header manager (write the auth variable in, and the interface that needs to be used for login will be taken directly from here, no need to write it separately)

picture

Bind the room interface, the clientId uses dynamically extracted data, and the data in the parameters can be passed according to the specific business logic

picture

Run it, and check whether the parameters returned by the request are correct in the added viewing result tree (the following example is successful)

picture

5. Add a message sending interface to check whether the operation result is successful

picture

picture

 

Summary of problems encountered:

Problem Description: Interface requests frequently report errors

Reason for analysis: interface limit, requests cannot exceed 60 times per minute (this is the characteristic of different business systems, mainly depends on whether there is a limit)

Solution: add a timer under the interface request, delay 1000ms request once, so that it will not exceed 60 times in 1 minute

Finally, I would like to thank everyone who has read my article carefully. Reciprocity is always necessary. Although it is not a very valuable thing, you can take it away if you need it:

These materials should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey, and I hope it can help you! Partners can click the small card below to receive

Guess you like

Origin blog.csdn.net/kk_lzvvkpj/article/details/130115749
Recommended