当前位置:网站首页>Basic use of JMeter to proficiency (I) creation and testing of the first task thread from installation
Basic use of JMeter to proficiency (I) creation and testing of the first task thread from installation
2022-07-07 09:45:00 【qq_ thirty-six million nine hundred and sixty-seven thousand an】
( One )jemter Introduce
Apache JMeter yes 100% pure JAVA Desktop applications , Designed to test clients / Server side structure software ( for example web Applications ). It can be used to test the performance of static and dynamic resources , for example : Static files ,Java Servlet,CGI Scripts,Java Object, Database and FTP Servers and so on .JMeter Can be used to simulate a large load to test a server , Robustness of network or object or analysis of overall performance under different loads .
meanwhile ,JMeter Can help you regression test your application . Through the test scripts you create and assertions To verify that your program returns the expected value . For better adaptability ,JMeter Allow to call secondary development of jar Package to enrich your test scenarios ;JMeter Allows you to use regular expressions to create these assertions.
But use JMeter Can't verify JS Program , You can't verify the page either UI, So you need to talk to Selenium Cooperate to complete Web2.0 Application testing .
( Two )
1.http://jmeter.apache.org/ Download the latest version of JMeter, Unzip the file to any directory
2. install JDK, Configure environment variables JAVA_HOME
JDK Environment variable configuration gate
3. System requirements :JMeter2.11 need JDK1.6 The above version supports running
4.JMeter Can run on the following operating systems :Unix,Windows and Open VMS.
JMeter Plug in installation
Plug in download address : http://jmeter-plugins.org/downloads/all/
Download the plug-in and unzip it : find JMeterPlugins-Extras.jar, hold JMeterPlugins-Extras.jar Put it in apache-jmeter-2.12\lib\ext Catalog .
5. Should be avoided jdk Path and jmeter The path has Chinese and spaces , Otherwise, there will be abnormalities , It can also cause problems with remote testing .
6. Get into bin Directory double click jmeter. bat Or configure environment variables to create JMETER_HOME,cmd Run in jmeter
( 3、 ... and )jmeter Directory structure
(1)backup Catalog Script backup directory , The documents inside are all in the form of .jmx The file at the end of the suffix
The directory does not exist after the actual installation and decompression , This is due to the use of JMeter after ,JMeter Automatically create this directory , Then I backed up the script file .
(2)bin Catalog Executable Directory
Jmeter.bat: It's startup jmeter The main script for .
Jmeter-server.bar: It is used to implement online load .
Jmeter.properties: yes jmeter The main configuration file , exceed 80% The configuration items are all implemented through this file .(PS: After modifying the configuration file , To restart Jmeter To take effect )
Jmeter.bat open Jmeter main interface
Jmeter The log file name used is defined to Jmeter.properties in , Default in Jmeter.log Check the log
(3)dosc Catalog
docs The files in the directory are JMeter Of Java Docs, and printable_docs Of usermanual The content in the subdirectory is JMeter User's manual documentation for , among component_reference.html Is the most commonly used core component help document . What is stored in this directory is jmeter Official document API file , It is mainly used for secondary development .
(4)extras Catalog
The files in this directory provide tools for building Ant Support for , have access to Ant To achieve test automation , For example, batch script execution , produce HTML Format report , Test run time , You can record the test data ,Jmeter It will automatically generate a .jtl file , Put the document in extras Under the table of contents , function “ant -Dtest= file name report”, You can generate test statistics report . It can also be used for continuous integration .
(5)lib Catalog
This directory contains two subdirectories , among ext Subdirectories contain JMeter At the heart of jar package , the other one junit Subdirectories store JUnit The test script . User extensions depend on packages , It should go straight to lib Under the table of contents , Instead of lib/ext Next .
Be careful : Can't recognize zip In the form of Bao Wenjian , Therefore, the required package files are required to be .jar ending
(6)Licenses jmeter Software license file directory
(7)printable_docs Catalog
This directory holds jmeter Official help documents .printable_docs Of demos There are some commonly used JMeter Script case , As a reference . Can print half version catalog .
(8)LICENSE JMeter —— License description
(9)NOTICE JMeter —— A simple message says
(10) README.md ——JMeter Official basic introduction
jmeter.properties The main content of the document is
# Default language settings
language=en
# capture cookie switch
CookieManager.save.cookies=true
# Configure the font and size of the editor
jsyntaxtextarea.font.family= Song style
jsyntaxtextarea.font.size=20
# Configure the default encoding format
sampleresult.default.encoding=UTF-8
#SSL To configure : Focus on the following configurations # Appoint HTTPS Protocol layer
# Appoint HTTPS Protocol layer
https.default.protocol=TLS
# Appoint SSL edition , It may need to be modified in practice
https.default.protocol=SSLv3
# Set the startup protocol
https.socket.protocols=SSLv2Hello SSLv3 TLSv1
# Cache control , control SSL Whether it can be reused in multiple iterations
https.use.cached.ssl.context=true
#JMeter Test project automatic backup configuration
# Set whether to enable automatic backup , The default is true jmeter.gui.action.save.backup_on_save=true
# Set up automatic backup directory , Backup to by default JMeter Root directory backups Next
jmeter.gui.action.save.backup_directory=# Set the number of automatic backup items , The default is recent 10 individual
jmeter.gui.action.save.keep_backup_max_count=10
# Remote host configuration
# Configure the remote host IP, Default to native . Comma "," You can set up multiple remote hosts remote_hosts=127.0.0.1
# Examples of multiple remote host assignments are as follows , among : After the port
remote_hosts=127.0.0.1:1099,127.0.0.1:1200,127.0.0.1:1300 about RMID
Please refer to the option description in the configuration file
# Log management configuration
# Format log log_format_type=default
# Set the log output level log_level.jmeter=INFO
# Set up junit Log output level log_level.jmeter.junit=DEBUG
# Set the log output target file , The default is jmeter.log log_file=jmeter.log
jmeter.bat Key configuration changes
# For better use jmeter, Need to be right jmeter.bat Some of the configurations in are optimized according to the current machine configuration , The key configuration items are described here , You can modify it according to the configuration of your machine .jvm Related configuration , In about 80 Row or so , Find these configurations , Modify the value according to the current hardware configuration of the machine .
set HEAP=-Xms2048m -Xmx2048m set NEW=-XX:NewSize=512m
-XX:MaxNewSize=512m set SURVIVOR=-XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=50% set TENURING=-XX:MaxTenuringThreshold=2 if %current_minor% LEQ “8” ( rem Increase MaxPermSize if you use a
lot of Javascript in your Test Plan : set PERM=-XX:PermSize=512m
-XX:MaxPermSize=1024m)
# Format output report template
jmeter.save.saveservice.output_format = csv
( Four ) Create the first thread

Here you can choose Chinese and English
(1) There can only be one test plan in a script , There must be at least one thread group in the test plan , At least one sampler ( Simulate user requests ), There has to be at least one listener ( Analyze system performance )
(2) Add thread group 
setup thread group: Pre execution before test
thread group( Thread group ): Generally speaking, a thread group , Think of it as a virtual user group , Each thread in a thread group can be understood as a virtual user . The number of threads in the thread group will not change during the test execution .
teardown thread group: Execute after test
Right click here to add a thread group thread group
(3) Set the number of threads
Set acceleration time
Set the number of times to execute the test 
Vernacular understood as 1 A thread executes once in a second , for example :
{
Concurrency number = Number of threads /Ramp-Up time* Number of cycles
Ramp-up That is, how many seconds to complete
Input in sequence 3,0,2
It's a cycle 2 Time
The order of execution is 1,1,2,2,3,3
The execution time of the loop is almost the same , for instance 1,1, The number of cycles is serial execution from the source code ( It's just a little similar to parallel execution )
When Ramp-up=0, Use the maximum capacity of the pressure test server to continuously send requests
}
(4) Controller and sampler
JMeter There are two types of controllers : Sampler and logic controller . Use these components to drive the test .
The sampler tells JMeter Send request to server . If you wish JMeter send out HTTP request , Then add a HTTP Request Sampler. You can also customize the request by adding one or more configuration elements to the sampler .
The logic controller allows you to customize JMeter The logic used to decide when to send a request . You can add one Interleave Logic Controller In two HTTP Request Samplers Alternate between .
Sampler can also be translated into sampler ; It is used to simulate the operation of the user , To the server ( The system under test ) issue Http request 、WebService(SOAP/XML-RPC Request) Request or Java Request etc. .
(5) Test a login 
View the result tree here , Successfully logged in 
Change password to login 
Login failed 
So far, the first simple test is completed . Similarly, Baidu can also be used here to test
You can get the request method through the developer tool 、 Request parameters to request
Or by fiddler、wireshark This packet capturing tool obtains , I don't want to describe it in detail
边栏推荐
- Kubernetes cluster capacity expansion to add node nodes
- 12、 Sort
- shake数据库中怎么使用Mongo-shake实现MongoDB的双向同步啊?
- 【原创】程序员团队管理的核心是什么?
- NATAPP内网穿透
- 第一讲:鸡蛋的硬度
- How to use Mongo shake to realize bidirectional synchronization of mongodb in shake database?
- 如何使用clipboard.js库实现复制剪切功能
- Information Security Experiment 3: the use of PGP email encryption software
- 细说Mysql MVCC多版本控制
猜你喜欢

沙龙预告|GameFi 领域的瓶颈和解决方案
![[4g/5g/6g topic foundation -147]: Interpretation of the white paper on 6G's overall vision and potential key technologies -2-6g's macro driving force for development](/img/21/6a183e4e10daed90c66235bdbdc3bf.png)
[4g/5g/6g topic foundation -147]: Interpretation of the white paper on 6G's overall vision and potential key technologies -2-6g's macro driving force for development

Elaborate on MySQL mvcc multi version control

信息安全实验一:DES加密算法的实现

In fact, it's very simple. It teaches you to easily realize the cool data visualization big screen

JS reverse tutorial second issue - Ape anthropology first question

战略合作|SubQuery 成为章鱼网络浏览器的秘密武器

How to use clipboard JS library implements copy and cut function

如何使用clipboard.js库实现复制剪切功能

Lecture 1: stack containing min function
随机推荐
2020CCPC威海 J - Steins;Game (sg函数、线性基)
esp8266使用TF卡并读写数据(基于arduino)
Impression notes finally support the default markdown preview mode
Addition, deletion, modification and query of ThinkPHP database
【BW16 应用篇】安信可BW16模组/开发板AT指令实现MQTT通讯
NATAPP内网穿透
Detailed explanation of diffusion model
章鱼未来之星获得25万美金奖励|章鱼加速器2022夏季创业营圆满落幕
csdn涨薪技术-浅学Jmeter的几个常用的逻辑控制器使用
Final keyword
创建一个长度为6的int型数组,要求数组元素的值都在1-30之间,且是随机赋值。同时,要求元素的值各不相同。
C# XML的应用
The difference between viewpager2 and viewpager and the implementation of viewpager2 in the rotation chart
【原创】程序员团队管理的核心是什么?
Elaborate on MySQL mvcc multi version control
数据库多表关联查询问题
Over 100000 words_ Ultra detailed SSM integration practice_ Manually implement permission management
Liunx command
Pick up the premise idea of programming
CSDN salary increase technology - learn about the use of several common logic controllers of JMeter