当前位置:网站首页>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
边栏推荐
- Pick up the premise idea of programming
- 消费互联网的产业链其实是很短的,它仅仅承接平台上下游的对接和撮合的角色
- Unity shader (basic concept)
- Over 100000 words_ Ultra detailed SSM integration practice_ Manually implement permission management
- 小程序弹出半角遮罩层
- Detailed explanation of diffusion model
- 如何成为一名高级数字 IC 设计工程师(5-2)理论篇:ULP 低功耗设计技术精讲(上)
- Information Security Experiment 3: the use of PGP email encryption software
- Sqlplus garbled code problem, find the solution
- 根据热门面试题分析Android事件分发机制(二)---事件冲突分析处理
猜你喜欢

Dynamics 365Online ApplicationUser创建方式变更

小程序滑动、点击切换简洁UI

sqlplus乱码问题,求解答

esp8266使用TF卡并读写数据(基于arduino)

How to speed up video playback in browser

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

Lesson 1: finding the minimum of a matrix

Esp8266 uses TF card and reads and writes data (based on Arduino)

Unity uses mesh to realize real-time point cloud (I)

flex弹性布局
随机推荐
Octopus future star won a reward of 250000 US dollars | Octopus accelerator 2022 summer entrepreneurship camp came to a successful conclusion
CDZSC_2022寒假个人训练赛21级(1)
Scratch crawler mysql, Django, etc
Oracle installation enhancements error
Lecture 1: stack containing min function
In fact, it's very simple. It teaches you to easily realize the cool data visualization big screen
如何使用clipboard.js库实现复制剪切功能
How will fashion brands enter the meta universe?
Information Security Experiment 2: using x-scanner scanning tool
Impression notes finally support the default markdown preview mode
VSCode+mingw64
Schema-validation: wrong column type encountered in column XXX in table XXX
Information Security Experiment 1: implementation of DES encryption algorithm
Pick up the premise idea of programming
Diffusion模型详解
Elaborate on MySQL mvcc multi version control
What is MD5
农牧业未来发展蓝图--垂直农业+人造肉
[Frida practice] "one line" code teaches you to obtain all Lua scripts in wegame platform
信息安全实验一:DES加密算法的实现