二、配置java环境;
默认在jmeter中自带有jdk和Jira,所以在个人环境中可以这样配置:/home/yourname/.bashrc
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export JMETER_HOME=/da1/yourname/jmeter3.0
export JAVA_HOME=$JMETER_HOME/jdk
export JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$JMETER_HOME/tools
CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
三、Jmx文件配置;
点击(此处)折叠或打开
- <?xml version="1.0" encoding="UTF-8"?>
- <jmeterTestPlan version="1.2" properties="2.8" jmeter="2.13 r1665067">
- <hashTree>
- <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="测试计划" enabled="true">
- <stringProp name="TestPlan.comments"></stringProp>
- <boolProp name="TestPlan.functional_mode">false</boolProp>
- <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
- <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true">
- <collectionProp name="Arguments.arguments"/>
- </elementProp>
- <stringProp name="TestPlan.user_define_classpath"></stringProp>
- </TestPlan>
- <hashTree>
- <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="线程组" enabled="true">
- <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="循环控制器" enabled="true">
- <boolProp name="LoopController.continue_forever">false</boolProp>
- <intProp name="LoopController.loops">-1</intProp>
- </elementProp>
- <stringProp name="ThreadGroup.num_threads">${__P(NUM_THREADS)}</stringProp>
- <stringProp name="ThreadGroup.ramp_time">1</stringProp>
- <longProp name="ThreadGroup.start_time">1366681326000</longProp>
- <longProp name="ThreadGroup.end_time">1366681326000</longProp>
- <boolProp name="ThreadGroup.scheduler">true</boolProp>
- <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
- <stringProp name="ThreadGroup.duration">${__P(DURATION)}</stringProp>
- <stringProp name="ThreadGroup.delay"></stringProp>
- </ThreadGroup>
- <hashTree>
- <CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="CSV Data Set Config" enabled="true">
- <stringProp name="filename">/da1/name/jmeter3.0/sh/data/tusou/all_kw.txt</stringProp>
- <stringProp name="fileEncoding">utf-8</stringProp>
- <stringProp name="variableNames">query</stringProp>
- <stringProp name="delimiter">\t</stringProp>
- <boolProp name="quotedData">true</boolProp>
- <boolProp name="recycle">true</boolProp>
- <boolProp name="stopThread">false</boolProp>
- <stringProp name="shareMode">shareMode.all</stringProp>
- </CSVDataSet>
- <hashTree/>
- <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP请求" enabled="true">
- <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true">
- <collectionProp name="Arguments.arguments">
- <elementProp name="" elementType="HTTPArgument">
- <boolProp name="HTTPArgument.always_encode">false</boolProp>
- <stringProp name="Argument.value"></stringProp>
- <stringProp name="Argument.metadata">=</stringProp>
- <boolProp name="HTTPArgument.use_equals">true</boolProp>
- <stringProp name="Argument.name"></stringProp>
- </elementProp>
- </collectionProp>
- </elementProp>
- <stringProp name="HTTPSampler.domain">${__P(DOMAIN)}</stringProp>
- <stringProp name="HTTPSampler.port">${__P(PORT)}</stringProp>
- <stringProp name="HTTPSampler.connect_timeout"></stringProp>
- <stringProp name="HTTPSampler.response_timeout"></stringProp>
- <stringProp name="HTTPSampler.protocol">http</stringProp>
- <stringProp name="HTTPSampler.contentEncoding">utf-8</stringProp>
- <stringProp name="HTTPSampler.path">search.html?kw=${query}</stringProp>
- <stringProp name="HTTPSampler.method">GET</stringProp>
- <boolProp name="HTTPSampler.follow_redirects">false</boolProp>
- <boolProp name="HTTPSampler.auto_redirects">true</boolProp>
- <boolProp name="HTTPSampler.use_keepalive">false</boolProp>
- <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
- <stringProp name="HTTPSampler.implementation">Java</stringProp>
- <boolProp name="HTTPSampler.monitor">false</boolProp>
- <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
- </HTTPSamplerProxy>
- <hashTree/>
- <SizeAssertion guiclass="SizeAssertionGui" testclass="SizeAssertion" testname="Size Assertion" enabled="false">
- <stringProp name="SizeAssertion.size">100</stringProp>
- <intProp name="SizeAssertion.operator">3</intProp>
- <stringProp name="Assertion.test_field">SizeAssertion.response_network_size</stringProp>
- </SizeAssertion>
- <hashTree/>
- <ResultCollector guiclass="SummaryReport" testclass="ResultCollector" testname="Summary Report" enabled="true">
- <boolProp name="ResultCollector.error_logging">false</boolProp>
- <objProp>
- <name>saveConfig</name>
- <value class="SampleSaveConfiguration">
- <time>true</time>
- <latency>true</latency>
- <timestamp>true</timestamp>
- <success>true</success>
- <label>true</label>
- <code>true</code>
- <message>true</message>
- <threadName>true</threadName>
- <dataType>true</dataType>
- <encoding>false</encoding>
- <assertions>true</assertions>
- <subresults>true</subresults>
- <responseData>false</responseData>
- <samplerData>false</samplerData>
- <xml>true</xml>
- <fieldNames>false</fieldNames>
- <responseHeaders>false</responseHeaders>
- <requestHeaders>false</requestHeaders>
- <responseDataOnError>false</responseDataOnError>
- <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
- <assertionsResultsToSave>0</assertionsResultsToSave>
- <bytes>true</bytes>
- <url>true</url>
- <threadCounts>true</threadCounts>
- </value>
- </objProp>
- <stringProp name="filename">/da1/dongshiyue/log/${__P(NUM_THREADS)}_${__P(DURATION)}_${__P(PORT)}_${__P(SERVICES)}_${__time(YMDHMS,)}.log</stringProp>
- </ResultCollector>
- <hashTree/>
- <ResultSaver guiclass="ResultSaverGui" testclass="ResultSaver" testname="保存响应到文件" enabled="false">
- <stringProp name="FileSaver.filename"></stringProp>
- <boolProp name="FileSaver.errorsonly">false</boolProp>
- <boolProp name="FileSaver.skipautonumber">true</boolProp>
- <boolProp name="FileSaver.skipsuffix">true</boolProp>
- <boolProp name="FileSaver.successonly">false</boolProp>
- </ResultSaver>
- <hashTree/>
- <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="察看结果树" enabled="false">
- <boolProp name="ResultCollector.error_logging">false</boolProp>
- <objProp>
- <name>saveConfig</name>
- <value class="SampleSaveConfiguration">
- <time>true</time>
- <latency>false</latency>
- <timestamp>true</timestamp>
- <success>true</success>
- <label>true</label>
- <code>true</code>
- <message>true</message>
- <threadName>false</threadName>
- <dataType>false</dataType>
- <encoding>false</encoding>
- <assertions>true</assertions>
- <subresults>true</subresults>
- <responseData>false</responseData>
- <samplerData>false</samplerData>
- <xml>true</xml>
- <fieldNames>false</fieldNames>
- <responseHeaders>false</responseHeaders>
- <requestHeaders>false</requestHeaders>
- <responseDataOnError>false</responseDataOnError>
- <saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
- <assertionsResultsToSave>0</assertionsResultsToSave>
- <bytes>true</bytes>
- <url>true</url>
- <threadCounts>true</threadCounts>
- </value>
- </objProp>
- <stringProp name="filename"></stringProp>
- </ResultCollector>
- <hashTree/>
- <ConstantThroughputTimer guiclass="TestBeanGUI" testclass="ConstantThroughputTimer" testname="Constant Throughput Timer" enabled="true">
- <doubleProp>
- <name>throughput</name>
- <value>1200.0</value>
- <savedValue>0.0</savedValue>
- </doubleProp>
- <intProp name="calcMode">1</intProp> --注意这里是配置固定QPS节点,默认0为this thread only,1为all active thread,QPS为预期个数*60,因为此处是按照分钟算的,比如你的预期QPS为20,那么这里就应该填写为20*60=1200
- </ConstantThroughputTimer>
- <hashTree/>
- </hashTree>
- </hashTree>
- </hashTree>
- </jmeterTestPlan>
/da1/dongshiyue/jmeter3.0/bin/jmeter.sh -JNUM_THREADS=5 -JDURATION=600 -JDOMAIN=www.baidu.com -JPORT=8080 -n -t ./tusou/tusou_stable.jmx