当前位置:网站首页>Mr. Ali taught you how to use JMeter for pressure test (detailed drawing)
Mr. Ali taught you how to use JMeter for pressure test (detailed drawing)
2022-06-21 13:50:00 【Automated test】
One . Preface
Stress testing is the key to every project Web A test that needs to be done before an application goes online , He can help us find bottlenecks in the system , Reduce the chance of problems after being released to the production environment ; Estimate the carrying capacity of the system , So that we can make some countermeasures according to it . So stress testing is a very important step , Now I'll take you to use a stress testing tool JMeter.
Two . About JMeter
Apache JMeter yes Apache Organization development based on Java Pressure testing tools for . For stress testing software , It was originally designed for Web Application testing , But then it expanded to other areas of testing . It can be used to test static and dynamic resources , For example, static files 、Java Little service program 、CGI Script 、Java object 、 database 、FTP The server , wait .JMeter Can be used for server 、 Network or object simulating huge load , Test their strength and analyze their overall performance from different stress categories . in addition ,JMeter Ability to function on Applications / regression testing , Verify that your program returns what you expect by creating a script with assertions . For maximum flexibility ,JMeter Allow regular expressions to create assertions .
Apache jmeter Can be used for static and dynamic resources ( file ,Servlet,Perl Script ,java object , Databases and queries ,FTP Servers and so on ) Test the performance of . It can be used on servers 、 Networks or objects simulate heavy loads to test their strength or analyze the overall performance under different types of stress . You can use it for performance analysis of graphics or for testing your server with large concurrent loads / Script / object .
3、 ... and . preparation
because JMeter It's using JAVA Written , So use JMeter Before , Install first JAVA Environmental Science , In this article, it's better to install JAVA The environment ..
JAVA Environment variable configuration :( What you don't understand can be inquired by Baidu experience )
Unzip the downloaded binary package , Get into bin Catalog , Use jmeter.bat Start the program .
After startup, there will be two windows , One cmd window , One JMeter Of GUI. Don't ignore the front CMD Window prompt message :

JMeter:

CMD Window prompt message
================================================================================
Don't use GUI mode for load testing !, only for Test creation and Test debugging.
For load testing, use NON GUI Mode:
jmeter -n -t [jmx file] -l [results file] -e -o [Path to web report folder]
& increase Java Heap to meet your test requirements:
Modify current env variable HEAP="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m" in the jmeter batch file
Check : https://jmeter.apache.org/usermanual/best-practices.html
================================================================================
It means : Do not use GUI Run the pressure test ,GUI For stress test creation and debugging only ; Do not use when performing stress tests GUI. Use the following command to execute the test :
jmeter -n -t [jmx file] -l [results file] -e -o [Path to web report folder]
And modify JMeter Environment variables for batch files :HEAP="-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m"
Change the language to Chinese
The official default is to provide us with simplified Chinese . adopt 【Options】->【Choose Language】 Change to simplified Chinese
Four . Create the test
1. Create thread group
stay “ test plan ” Right click 【 add to 】-->【Threads(Users)】-->【 Thread group 】.

Set the number of threads and the number of loops . I set the number of threads here to 500, Cycle time .

2. The configuration element
Right click on the thread group we just created 【 add to 】-->【 The configuration element 】-->【HTTP Request defaults 】.

Configure the program protocol we need to test 、 Address and port

When all interface tests have the same access domain name and port , You can use this component , Once the server address changes , Just change the default value of the request .
3. structure HTTP request
stay “ Thread group ” Right click 【 add to -】->【samlper】-->【HTTP request 】 Set up what we need to test API Request path and data for . I use it here json

4. add to HTTP Request header
Right click on the thread group we just created 【 add to 】-->【 The configuration element 】-->【HTTP Header Manager 】.
Because the data I want to transmit is json, So set up a Content-Type:application/json

5. Add assertions
Right click on the thread group we just created 【 add to 】-->【 Assertion 】-->【 Response assertion 】.
Judge whether the request is normal according to the response data . I will only judge whether the response code is 200. You can also configure error messages

6. Add view result tree
Right click on the thread group we just created 【 add to 】-->【 Monitor 】-->【 Look at the fruit tree 】.
Add... Directly , Then click the run button to see the results .

7. add to Summary Report
Right click on the thread group we just created 【 add to 】-->【 Monitor 】-->【Summary Report】.
Add... Directly , Then click the run button to see the results .

In order not to cause unnecessary argument , Hide the TPS. This data has no value , Just for the article demonstration .
8. Test plan created
Remember to save .
5、 ... and . Execute test plan
We said earlier , Executing a test plan doesn't work GUI, It needs to be executed from the command line .

The order I'm executing here is :

explain :
testplan/RedisLock.jmx Plan file path for test
testplan/result/result.txt Path to test results file
testplan/webreport by web Report save path
Web The report is as follows :

6、 ... and . summary
The number of threads and the number of loops will affect the final test report , Please test more . Thank you for coming along ~

Thank everyone who reads my article carefully , Watching the rise and attention of fans all the way , Reciprocity is always necessary , Although it's not very valuable , If you can use it, you can take it :
① 2000 Multiple software test eBooks ( There should be both mainstream and classic books )
② software test / Automated test standard library data ( The most complete Chinese version )
③ Project source code ( Forty or fifty interesting and classic training projects and source code )
④ Python programing language 、API Interface automation testing 、web automated testing 、App automated testing ( Suitable for Xiaobai to learn )


⑤ Python Learning Roadmap ( Farewell to bad learning )
In my QQ In the technology exchange group ( Technical exchange and resource sharing , The ad came in and broke your leg )
You can take it by yourself , Group number 550412533( remarks “csdn999”)550412533 The free information in the group is the essence of my more than 10 year test career . There is also a great God of the same trade to exchange technology .
边栏推荐
- Turn to the countdown for coupon issuance! First look at the rules of interstellar pocket donation
- Automation operation and maintenance 1 - installation and deployment of ansible
- MySQL - transaction management
- Async get and post request interface data (add, delete, modify and query pages)
- 如何使用搜索引擎?
- Is it safe to open a securities account by downloading the app of qiniu business school? Is there a risk?
- Generalized Focal Loss: Learning Qualified and Distributed Bounding Boxes for Dense Object Detection
- seaborn绘图风格的设置
- How to write test cases
- Making my footprint map using API
猜你喜欢
![[deeply understand tcapulusdb technology] tmonitor system upgrade](/img/ec/bbfb7e2f19a94b69ec0a6092fd3032.png)
[deeply understand tcapulusdb technology] tmonitor system upgrade

PHP uses grafika to synthesize pictures and generate poster images

Automatic operation and maintenance 4 - variables and encryption in ansible

Explanation of vim, makefile and GDB tools

Kubernetes快速實戰與核心原理剖析

Babbitt yuancosmos daily must read: wechat may ban a official account for the first time on the grounds of "involving secondary transactions in digital collections", and the new regulations of the pla

618 Nuggets digital collection? Burberry and other luxury brands fight against metauniverse

Postman testing websocket interface

Turn to the countdown for coupon issuance! First look at the rules of interstellar pocket donation

Iterm2 file transfer with remote server
随机推荐
Six possible challenges when practicing Devops
[googolu] takeout rebate system - business domain name of KFC configuration applet
1. memory partition model
MySQL - view properties
Blazer page element authorization -- use of the authorizeview component
2. reference
How to read AI summit papers?
Are you still using generator to generate crud code of XXX management system? Let's see what I wrote
Azure applicationinsights integrated in blazor
C language elementary level (IX) enumeration
A blazor webassembly application that can automatically generate page components based on objects or types
Memcached (high performance memory object cache)
Is it safe to open a securities account by downloading the app of qiniu business school? Is there a risk?
seaborn数据总体分布的可视化策略
[test process and theory - test process system]
Master the basic usage of SQLite3
Kubernets Rapid Practical fighting and Core Principle Analysis
17 commonly used o & M monitoring systems
Postman testing websocket interface
C language elementary order (VI) function