🤡 :默认自带节点
🥶 :可选节点
💩 :变量必填
👺 :变量非必填
文件整体结构
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.3">
<hashTree>
<TestPlan></TestPlan>
<hashTree>
<SetupThreadGroup></SetupThreadGroup>
<ThreadGroup></ThreadGroup>
<hashTree>
<HeaderManager></HeaderManager>
<hashTree/>
<HTTPSamplerProxy></HTTPSamplerProxy>
<hashTree/>
<HTTPSamplerProxy></HTTPSamplerProxy>
<hashTree/>
<CSVDataSet></CSVDataSet>
<hashTree/>
<Arguments></Arguments>
<hashTree/>
</hashTree>
<ThreadGroup></ThreadGroup>
<hashTree>
<HTTPSamplerProxy></HTTPSamplerProxy>
<hashTree/>
<CSVDataSet></CSVDataSet>
<hashTree/>
</hashTree>
<BackendListener></BackendListener>
<hashTree/>
<PostThreadGroup></PostThreadGroup>
<hashTree/>
</hashTree>
</jmeterTestPlan>
测试计划
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="👺 plan name " enabled="true">
<stringProp name="TestPlan.comments">👺 plan description
</stringProp>
<boolProp name="TestPlan.functional_mode">💩 false
</boolProp>
<boolProp name="TestPlan.tearDown_on_shutdown">💩 true
</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">💩 false
</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="👺 args-name" elementType="Argument">
<stringProp name="Argument.name">👺 args-name
</stringProp>
<stringProp name="Argument.value">👺 args-value
</stringProp>
<stringProp name="Argument.metadata">=
</stringProp>
</elementProp>
<elementProp name="👺 args-name2" elementType="Argument">
<stringProp name="Argument.name">👺 args-name2
</stringProp>
<stringProp name="Argument.value">👺 args-value2
</stringProp>
<stringProp name="Argument.metadata">=
</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="TestPlan.user_define_classpath">👺 /Users/bjhl/Documents/apache-maven-3.6.3/lib/commons-cli-1.4.jar,/Users/bjhl/Documents/apache-maven-3.6.3/lib/guava-25.1-android.jar
</stringProp>
</TestPlan>
线程组
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="👺 Group name" enabled="true">
<stringProp name="TestPlan.comments">👺 Group comments
</stringProp>
<stringProp name="ThreadGroup.on_sample_error">💩 continue
</stringProp>
<stringProp name="ThreadGroup.num_threads">💩 1
</stringProp>
<stringProp name="ThreadGroup.ramp_time">💩 1
</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">💩 false
</boolProp>
<stringProp name="LoopController.loops">👺 1
</stringProp>
</elementProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">💩 true
</boolProp>
<boolProp name="ThreadGroup.delayedStart">💩 true
</boolProp>
<boolProp name="ThreadGroup.scheduler">💩 true
</boolProp>
<stringProp name="ThreadGroup.duration">👺 12
</stringProp>
<stringProp name="ThreadGroup.delay">👺 32
</stringProp>
</ThreadGroup>
前置线程组
<SetupThreadGroup guiclass="🤢 SetupThreadGroupGui" testclass="🤢 SetupThreadGroup" testname="setUp Thread Group" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue
</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false
</boolProp>
<stringProp name="LoopController.loops">1
</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1
</stringProp>
<stringProp name="ThreadGroup.ramp_time">1
</stringProp>
<boolProp name="ThreadGroup.scheduler">false
</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true
</boolProp>
</SetupThreadGroup>
后置线程组
<PostThreadGroup guiclass="🤢 PostThreadGroupGui" testclass="🤢 PostThreadGroup" testname="tearDown Thread Group" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue
</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false
</boolProp>
<stringProp name="LoopController.loops">1
</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1
</stringProp>
<stringProp name="ThreadGroup.ramp_time">1
</stringProp>
<boolProp name="ThreadGroup.scheduler">false
</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true
</boolProp>
</PostThreadGroup>
<🤢 hashTree/>
GET-http请求配置
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="👺 HTTP Request" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="👺 get_key" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">💩 true
</boolProp>
<stringProp name="Argument.value">👺 get_value
</stringProp>
<stringProp name="Argument.metadata">=
</stringProp>
<boolProp name="HTTPArgument.use_equals">true
</boolProp>
<stringProp name="Argument.name">👺 get_key
</stringProp>
<stringProp name="HTTPArgument.content_type">?? text/plain
</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="TestPlan.comments">👺
</stringProp>
<stringProp name="HTTPSampler.domain">💩
</stringProp>
<stringProp name="HTTPSampler.port">👺
</stringProp>
<stringProp name="HTTPSampler.protocol">👺
</stringProp>
<stringProp name="HTTPSampler.contentEncoding">??
</stringProp>
<stringProp name="HTTPSampler.path">💩 /index.html
</stringProp>
<stringProp name="HTTPSampler.method">💩 GET
</stringProp>
<boolProp name="HTTPSampler.follow_redirects">💩 true
</boolProp>
<boolProp name="HTTPSampler.auto_redirects">💩 false
</boolProp>
<boolProp name="HTTPSampler.use_keepalive">💩 true
</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">💩 false
</boolProp>
<boolProp name="HTTPSampler.BROWSER_COMPATIBLE_MULTIPART">true
</boolProp>
<stringProp name="HTTPSampler.embedded_url_re">👺
</stringProp>
<stringProp name="HTTPSampler.connect_timeout">👺
</stringProp>
<stringProp name="HTTPSampler.response_timeout">👺
</stringProp>
</HTTPSamplerProxy>
<hashTree/>
post-http请求配置
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="👺 HTTP Request" enabled="true">
<boolProp name="HTTPSampler.postBodyRaw">?? true
</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
<collectionProp name="Arguments.arguments">
<elementProp name="?? " elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">💩 false
</boolProp>
<stringProp name="Argument.value">👺 {"aa":"bb"}
</stringProp>
<stringProp name="Argument.metadata">=
</stringProp>
</elementProp>
</collectionProp>
</elementProp>
<stringProp name="TestPlan.comments">👺
</stringProp>
<stringProp name="HTTPSampler.domain">💩 www.baidu.com
</stringProp>
<stringProp name="HTTPSampler.port">👺 443
</stringProp>
<stringProp name="HTTPSampler.protocol">👺 https
</stringProp>
<stringProp name="HTTPSampler.contentEncoding">👺
</stringProp>
<stringProp name="HTTPSampler.path">💩 /index.html
</stringProp>
<stringProp name="HTTPSampler.method">💩 POST
</stringProp>
<boolProp name="HTTPSampler.follow_redirects">💩 true
</boolProp>
<boolProp name="HTTPSampler.auto_redirects">💩 false
</boolProp>
<boolProp name="HTTPSampler.use_keepalive">💩 true
</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">💩 false
</boolProp>
<stringProp name="HTTPSampler.embedded_url_re">👺
</stringProp>
<stringProp name="HTTPSampler.connect_timeout">👺
</stringProp>
<stringProp name="HTTPSampler.response_timeout">👺
</stringProp>
</HTTPSamplerProxy>
<hashTree/>
----------------
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
<elementProp name="sd" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false
</boolProp>
<stringProp name="Argument.value">sd
</stringProp>
<stringProp name="Argument.metadata">=
</stringProp>
<boolProp name="HTTPArgument.use_equals">true
</boolProp>
<stringProp name="Argument.name">sd
</stringProp>
</elementProp>
</collectionProp>
</elementProp>
HTTP信息头管理器
可以放在线程组下,也可放到计划下
<HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="👺 HTTP Header Manager" enabled="true">
<collectionProp name="HeaderManager.headers">
<stringProp name="TestPlan.comments">👺 sda
</stringProp>
<elementProp name="👺 User-Agent" elementType="Header">
<stringProp name="Header.name">👺 User-Agent
</stringProp>
<stringProp name="Header.value">👺 Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:48.0) Gecko/20100101 Firefox/48.0
</stringProp>
</elementProp>
<elementProp name=" 👺 Accept" elementType="Header">
<stringProp name="Header.name">👺 Accept
</stringProp>
<stringProp name="Header.value">👺 text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
</stringProp>
</elementProp>
</collectionProp>
</HeaderManager>
<hashTree/>
CSV文件
可以放在线程组下,也可放到计划下
<CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="👺 CSV Data Set Config" enabled="true">
<stringProp name="TestPlan.comments">👺 sds
</stringProp>
<stringProp name="delimiter">💩 ,
</stringProp>
<stringProp name="fileEncoding">?? utf-8
</stringProp>
<stringProp name="filename">💩 /Users/bjhl/jmeter/jmeter5.2.1/data/token.txt
</stringProp>
<boolProp name="ignoreFirstLine">💩 false
</boolProp>
<boolProp name="quotedData">💩 false
</boolProp>
<boolProp name="recycle">💩 true
</boolProp>
<stringProp name="shareMode">💩 shareMode.all
</stringProp>
<boolProp name="stopThread">💩 false
</boolProp>
<stringProp name="variableNames">💩 变量名
</stringProp>
</CSVDataSet>
<hashTree/>
用户自定义变量
两种,一种是ArgumentsPanel,一种是HTTPArgumentsPanel。
可以放在线程组下,也可放到计划下
One
<Arguments guiclass="ArgumentsPanel" testclass="Arguments" testname="👺 User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments">
<stringProp name="TestPlan.comments">👺 sdsd
</stringProp>
<elementProp name="👺 user_key" elementType="Argument">
<stringProp name="Argument.name">👺 user_key
</stringProp>
<stringProp name="Argument.value">👺 user_value
</stringProp>
<stringProp name="Argument.metadata">=
</stringProp>
</elementProp>
<elementProp name="👺 user_key1" elementType="Argument">
<stringProp name="Argument.name">👺 user_key1
</stringProp>
<stringProp name="Argument.value">👺 value1
</stringProp>
<stringProp name="Argument.metadata">=
</stringProp>
</elementProp>
</collectionProp>
</Arguments>
<hashTree/>
Two
<Arguments guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="👺 User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments">
<elementProp name="👺 sds" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">true
</boolProp>
<stringProp name="Argument.value">👺 sdsd
</stringProp>
<stringProp name="Argument.metadata">=
</stringProp>
<boolProp name="HTTPArgument.use_equals">true
</boolProp>
<stringProp name="Argument.name">👺 sds
</stringProp>
</elementProp>
</collectionProp>
</Arguments>
<hashTree/>
cookie管理
可以放在线程组下,也可放到计划下
<CookieManager guiclass="CookiePanel" testclass="CookieManager" testname="👺 HTTP Cookie Manager" enabled="true">
<collectionProp name="CookieManager.cookies">
<stringProp name="TestPlan.comments">👺 s
</stringProp>
<elementProp name="👺 a1" elementType="Cookie" testname="👺 a1">
<stringProp name="Cookie.value">👺 a1
</stringProp>
<stringProp name="Cookie.domain">👺 a1
</stringProp>
<stringProp name="Cookie.path">👺 a1
</stringProp>
<boolProp name="Cookie.secure">?? true
</boolProp>
<longProp name="Cookie.expires">0
</longProp>
<boolProp name="Cookie.path_specified">true
</boolProp>
<boolProp name="Cookie.domain_specified">true
</boolProp>
</elementProp>
</collectionProp>
<boolProp name="CookieManager.clearEachIteration">💩 false
</boolProp>
<boolProp name="CookieManager.controlledByThreadGroup">💩 false
</boolProp>
</CookieManager>
<hashTree/>
正则表达式提取器
Mysql压测
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
// 添加JDBC驱动
<stringProp name="TestPlan.user_define_classpath">/Users/bjhl/Downloads/apache-jmeter-5.3/bin/mysql-connector-java-8.0.11.jar
</stringProp>
</TestPlan>
...
<JDBCSampler guiclass="TestBeanGUI" testclass="JDBCSampler" testname="JDBC Request" enabled="true">
<stringProp name="dataSource">stress_testing
</stringProp>
<stringProp name="query">select * from st_data limit 1
</stringProp>
<stringProp name="queryArguments"></stringProp>
<stringProp name="queryArgumentsTypes"></stringProp>
<stringProp name="queryTimeout"></stringProp>
<stringProp name="queryType">Select Statement
</stringProp>
<stringProp name="resultSetHandler">Store as String
</stringProp>
<stringProp name="resultSetMaxRows"></stringProp>
<stringProp name="resultVariable"></stringProp>
<stringProp name="variableNames"></stringProp>
</JDBCSampler>
<hashTree/>
// 配置JDBC连接池
<JDBCDataSource guiclass="TestBeanGUI" testclass="JDBCDataSource" testname="JDBC Connection Configuration" enabled="true">
<boolProp name="autocommit">true
</boolProp>
<stringProp name="checkQuery"></stringProp>
<stringProp name="connectionAge">5000
</stringProp>
<stringProp name="connectionProperties"></stringProp>
<stringProp name="dataSource">stress_testing
</stringProp>
<stringProp name="dbUrl">jdbc:mysql://172.16.34.15:3307/stress_testing?serverTimezone=UTC&characterEncoding=utf-8
</stringProp>
<stringProp name="driver">com.mysql.jdbc.Driver
</stringProp>
<stringProp name="initQuery"></stringProp>
<boolProp name="keepAlive">true
</boolProp>
<stringProp name="password">DSIcGCGOfDnSBHQB
</stringProp>
<stringProp name="poolMax">10
</stringProp>
<boolProp name="preinit">false
</boolProp>
<stringProp name="timeout">10000
</stringProp>
<stringProp name="transactionIsolation">DEFAULT
</stringProp>
<stringProp name="trimInterval">60000
</stringProp>
<stringProp name="username">stress_rw
</stringProp>
</JDBCDataSource>
<hashTree/>