Jmeter (50) - From entry to advanced level - jmeter simulates weak network for testing (detailed tutorial)

1 Introduction

In actual work, network bandwidth will not maintain a certain value continuously and stably, but will fluctuate between high and low. Therefore, in order to make the test scene infinitely close to reality, we need to simulate it to achieve the effect. Also, in the actual testing work, due to business needs, the network speed will be limited, which is more realistic, so we also need to simulate weak networks for testing.

2. View the official website documentation

Refer to the official website documentation: The cps attribute is used to simulate low network speed, as shown in the figure below:

If you want to learn automated testing, I recommend a set of videos to you. This video can be said to be the number one automated testing tutorial on the entire network played by Bilibili. The number of people online at the same time has reached 1,000, and there are also notes that can be collected and distributed by various channels. Master technical communication: 798478386    

[Updated] A complete collection of the most detailed practical tutorials on Python interface automation testing taught by Bilibili (the latest practical version)_bilibili_bilibili [Updated] A complete collection of the most detailed practical tutorials on Python interface automated testing taught by Bilibili (practical version) The latest version) has a total of 200 videos, including: 1. Why interface automation is needed, 2. Overall view of request for interface automation, 3. Interface practice for interface automation, etc. For more exciting videos from UP master, please follow the UP account . icon-default.png?t=N7T8https://www.bilibili.com/video/BV17p4y1B77x/?spm_id_from=333.337 

3. Preparation

In order to test the real response time and use jmeter to simulate a weak network, we need to modify the jmeter configuration. Just modify the jmeter.properties file. Find the apache-jmeter-5.0/bin/jmeter.properties file in the jmeter installation directory and find the parameters, which are to limit http and https.

These are for HTTPthe HTTPS and HTTPS protocols respectively. This property defaults to zero, which means no limit. The acronym cpsstands for "characters per second." When you set the property above zero, the bandwidth will adjust according to your settings.

#httpclient.socket.http.cps=0
#httpclient.socket.https.cps=0

 as the picture shows:

4.CPS calculation logic

Check jmeter's JMeter Wiki where you can find the calculation logic of cps. You can also visit directly: https://cwiki.apache.org/confluence/display/JMETER/Controlling+Bandwidth+in+JMeter+to+simulate+different+ networks to view jmeter simulating different bandwidths

From the red circled part in the above figure, we can easily know the calculation logic of cps: cps = (target bandwidth in kbps * 1024) / 8, so cps=B/s rate.

5. Conversion of network bandwidth

1. Network rate
100Mbps=100Mbit/s, that is, megabits per second,
100MB/s=100MBytes/s, that is, megabytes per second,
1B=8bit

100Mbps=12.5MB/s, in theory, the normal 100M bandwidth download rate can reach 12.5MB/s 100MB/s=100 1024KB/s=100 1024*1024B/s
2. Comparison of data storage conversion for data hard drives and the like Different, data storage is expressed in decimal notation, 1MB=1000KB

6. Actual simulation of weak network

1. Jmeter configures different cps to test the changes in response time.

Jmeter simply creates a test script to access Du Niang, as shown in the figure below:

2. In order to avoid that the small amount of data is not representative and affects the test results, the thread group is set to 100. By default, the interface and test results (average time 0.153s) are as shown in the figure below:

3. The response time is very small. Set cps=40KB/s=40*1024B/s=40960 and check the network delay.

 4. After modifying the configuration, run jmeter (average time 0.307s). You can see that the average network delay is 0.154s, as shown in the figure below:

Through this setting method, Jmeter can perform weak network testing.

7. Summary

Here are a few simple examples of weak network testing tools: Fiddler, Clumsy. Clumsy is an open source network simulation tool developed based on C language. It can artificially create unstable network conditions under the Windows platform, and its application can facilitate debugging the performance of applications under extreme network conditions.

 

Guess you like

Origin blog.csdn.net/Faith_Lzt/article/details/133274995