当前位置:网站首页>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
边栏推荐
- 如何成为一名高级数字 IC 设计工程师(5-3)理论篇:ULP 低功耗设计技术精讲(下)
- The configuration and options of save actions are explained in detail, and you won't be confused after reading it
- Colorbar of using vertexehelper to customize controls (II)
- 用flinksql的方式 写进 sr的表,发现需要删除的数据没有删除,参照文档https://do
- 2020CCPC威海 J - Steins;Game (sg函数、线性基)
- [4G/5G/6G专题基础-146]: 6G总体愿景与潜在关键技术白皮书解读-1-总体愿景
- 进程和线程的区别
- thinkphp3.2信息泄露
- 数据库多表关联查询问题
- Loxodonframework quick start
猜你喜欢

Arthas simple instructions
![[Frida practice]](/img/20/fc68bcf2f55b140d6754af6364896b.png)
[Frida practice] "one line" code teaches you to obtain all Lua scripts in wegame platform

信息安全实验二 :使用X-SCANNER扫描工具

基于智慧城市与储住分离数字家居模式垃圾处理方法

Elaborate on MySQL mvcc multi version control

Impression notes finally support the default markdown preview mode

Information Security Experiment 2: using x-scanner scanning tool

How to use clipboard JS library implements copy and cut function

Diffusion模型详解

Sqlplus garbled code problem, find the solution
随机推荐
JS inheritance prototype
The configuration and options of save actions are explained in detail, and you won't be confused after reading it
網易雲微信小程序
Arthas simple instructions
**Grafana installation**
Upload taro pictures to Base64
【原创】程序员团队管理的核心是什么?
Unity shader (basic concept)
[4g/5g/6g topic foundation-146]: Interpretation of white paper on 6G overall vision and potential key technologies-1-overall vision
Octopus future star won a reward of 250000 US dollars | Octopus accelerator 2022 summer entrepreneurship camp came to a successful conclusion
flink. CDC sqlserver. 可以再次写入sqlserver中么 有连接器的 dem
JS reverse tutorial second issue - Ape anthropology first question
Strategic cooperation subquery becomes the secret weapon of Octopus web browser
大佬们,请问 MySQL-CDC 有什么办法将 upsert 消息转换为 append only 消
根据热门面试题分析Android事件分发机制(二)---事件冲突分析处理
[bw16 application] Anxin can realize mqtt communication with bw16 module / development board at instruction
ComputeShader
C# Socke 服务器,客户端,UDP
Addition, deletion, modification and query of ThinkPHP database
第一讲:鸡蛋的硬度