Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2138008
  • 博文数量: 103
  • 博客积分: 206
  • 博客等级: 入伍新兵
  • 技术积分: 1819
  • 用 户 组: 普通用户
  • 注册时间: 2012-09-12 10:24
个人简介

效字当先,以质为本。

文章分类
文章存档

2019年(2)

2018年(4)

2017年(7)

2016年(3)

2015年(14)

2014年(33)

2013年(31)

2012年(9)

分类: IT业界

2017-02-24 19:28:20

一、下载jmeter;
二、配置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文件配置;

点击(此处)折叠或打开

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <jmeterTestPlan version="1.2" properties="2.8" jmeter="2.13 r1665067">
  3.   <hashTree>
  4.     <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="测试计划" enabled="true">
  5.       <stringProp name="TestPlan.comments"></stringProp>
  6.       <boolProp name="TestPlan.functional_mode">false</boolProp>
  7.       <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
  8.       <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true">
  9.         <collectionProp name="Arguments.arguments"/>
  10.       </elementProp>
  11.       <stringProp name="TestPlan.user_define_classpath"></stringProp>
  12.     </TestPlan>
  13.     <hashTree>
  14.       <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="线程组" enabled="true">
  15.         <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="循环控制器" enabled="true">
  16.           <boolProp name="LoopController.continue_forever">false</boolProp>
  17.           <intProp name="LoopController.loops">-1</intProp>
  18.         </elementProp>
  19.         <stringProp name="ThreadGroup.num_threads">${__P(NUM_THREADS)}</stringProp>
  20.         <stringProp name="ThreadGroup.ramp_time">1</stringProp>
  21.         <longProp name="ThreadGroup.start_time">1366681326000</longProp>
  22.         <longProp name="ThreadGroup.end_time">1366681326000</longProp>
  23.         <boolProp name="ThreadGroup.scheduler">true</boolProp>
  24.         <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
  25.         <stringProp name="ThreadGroup.duration">${__P(DURATION)}</stringProp>
  26.         <stringProp name="ThreadGroup.delay"></stringProp>
  27.       </ThreadGroup>
  28.       <hashTree>
  29.         <CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="CSV Data Set Config" enabled="true">
  30.           <stringProp name="filename">/da1/name/jmeter3.0/sh/data/tusou/all_kw.txt</stringProp>
  31.           <stringProp name="fileEncoding">utf-8</stringProp>
  32.           <stringProp name="variableNames">query</stringProp>
  33.           <stringProp name="delimiter">\t</stringProp>
  34.           <boolProp name="quotedData">true</boolProp>
  35.           <boolProp name="recycle">true</boolProp>
  36.           <boolProp name="stopThread">false</boolProp>
  37.           <stringProp name="shareMode">shareMode.all</stringProp>
  38.         </CSVDataSet>
  39.         <hashTree/>
  40.         <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP请求" enabled="true">
  41.           <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="用户定义的变量" enabled="true">
  42.             <collectionProp name="Arguments.arguments">
  43.               <elementProp name="" elementType="HTTPArgument">
  44.                 <boolProp name="HTTPArgument.always_encode">false</boolProp>
  45.                 <stringProp name="Argument.value"></stringProp>
  46.                 <stringProp name="Argument.metadata">=</stringProp>
  47.                 <boolProp name="HTTPArgument.use_equals">true</boolProp>
  48.                 <stringProp name="Argument.name"></stringProp>
  49.               </elementProp>
  50.             </collectionProp>
  51.           </elementProp>
  52.           <stringProp name="HTTPSampler.domain">${__P(DOMAIN)}</stringProp>
  53.           <stringProp name="HTTPSampler.port">${__P(PORT)}</stringProp>
  54.           <stringProp name="HTTPSampler.connect_timeout"></stringProp>
  55.           <stringProp name="HTTPSampler.response_timeout"></stringProp>
  56.           <stringProp name="HTTPSampler.protocol">http</stringProp>
  57.           <stringProp name="HTTPSampler.contentEncoding">utf-8</stringProp>
  58.           <stringProp name="HTTPSampler.path">search.html?kw=${query}</stringProp>
  59.           <stringProp name="HTTPSampler.method">GET</stringProp>
  60.           <boolProp name="HTTPSampler.follow_redirects">false</boolProp>
  61.           <boolProp name="HTTPSampler.auto_redirects">true</boolProp>
  62.           <boolProp name="HTTPSampler.use_keepalive">false</boolProp>
  63.           <boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
  64.           <stringProp name="HTTPSampler.implementation">Java</stringProp>
  65.           <boolProp name="HTTPSampler.monitor">false</boolProp>
  66.           <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
  67.         </HTTPSamplerProxy>
  68.         <hashTree/>
  69.         <SizeAssertion guiclass="SizeAssertionGui" testclass="SizeAssertion" testname="Size Assertion" enabled="false">
  70.           <stringProp name="SizeAssertion.size">100</stringProp>
  71.           <intProp name="SizeAssertion.operator">3</intProp>
  72.           <stringProp name="Assertion.test_field">SizeAssertion.response_network_size</stringProp>
  73.         </SizeAssertion>
  74.         <hashTree/>
  75.         <ResultCollector guiclass="SummaryReport" testclass="ResultCollector" testname="Summary Report" enabled="true">
  76.           <boolProp name="ResultCollector.error_logging">false</boolProp>
  77.           <objProp>
  78.             <name>saveConfig</name>
  79.             <value class="SampleSaveConfiguration">
  80.               <time>true</time>
  81.               <latency>true</latency>
  82.               <timestamp>true</timestamp>
  83.               <success>true</success>
  84.               <label>true</label>
  85.               <code>true</code>
  86.               <message>true</message>
  87.               <threadName>true</threadName>
  88.               <dataType>true</dataType>
  89.               <encoding>false</encoding>
  90.               <assertions>true</assertions>
  91.               <subresults>true</subresults>
  92.               <responseData>false</responseData>
  93.               <samplerData>false</samplerData>
  94.               <xml>true</xml>
  95.               <fieldNames>false</fieldNames>
  96.               <responseHeaders>false</responseHeaders>
  97.               <requestHeaders>false</requestHeaders>
  98.               <responseDataOnError>false</responseDataOnError>
  99.               <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
  100.               <assertionsResultsToSave>0</assertionsResultsToSave>
  101.               <bytes>true</bytes>
  102.               <url>true</url>
  103.               <threadCounts>true</threadCounts>
  104.             </value>
  105.           </objProp>
  106.           <stringProp name="filename">/da1/dongshiyue/log/${__P(NUM_THREADS)}_${__P(DURATION)}_${__P(PORT)}_${__P(SERVICES)}_${__time(YMDHMS,)}.log</stringProp>
  107.         </ResultCollector>
  108.         <hashTree/>
  109.         <ResultSaver guiclass="ResultSaverGui" testclass="ResultSaver" testname="保存响应到文件" enabled="false">
  110.           <stringProp name="FileSaver.filename"></stringProp>
  111.           <boolProp name="FileSaver.errorsonly">false</boolProp>
  112.           <boolProp name="FileSaver.skipautonumber">true</boolProp>
  113.           <boolProp name="FileSaver.skipsuffix">true</boolProp>
  114.           <boolProp name="FileSaver.successonly">false</boolProp>
  115.         </ResultSaver>
  116.         <hashTree/>
  117.         <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="察看结果树" enabled="false">
  118.           <boolProp name="ResultCollector.error_logging">false</boolProp>
  119.           <objProp>
  120.             <name>saveConfig</name>
  121.             <value class="SampleSaveConfiguration">
  122.               <time>true</time>
  123.               <latency>false</latency>
  124.               <timestamp>true</timestamp>
  125.               <success>true</success>
  126.               <label>true</label>
  127.               <code>true</code>
  128.               <message>true</message>
  129.               <threadName>false</threadName>
  130.               <dataType>false</dataType>
  131.               <encoding>false</encoding>
  132.               <assertions>true</assertions>
  133.               <subresults>true</subresults>
  134.               <responseData>false</responseData>
  135.               <samplerData>false</samplerData>
  136.               <xml>true</xml>
  137.               <fieldNames>false</fieldNames>
  138.               <responseHeaders>false</responseHeaders>
  139.               <requestHeaders>false</requestHeaders>
  140.               <responseDataOnError>false</responseDataOnError>
  141.               <saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
  142.               <assertionsResultsToSave>0</assertionsResultsToSave>
  143.               <bytes>true</bytes>
  144.               <url>true</url>
  145.               <threadCounts>true</threadCounts>
  146.             </value>
  147.           </objProp>
  148.           <stringProp name="filename"></stringProp>
  149.         </ResultCollector>
  150.         <hashTree/>
  151.         <ConstantThroughputTimer guiclass="TestBeanGUI" testclass="ConstantThroughputTimer" testname="Constant Throughput Timer" enabled="true">
  152.           <doubleProp>
  153.             <name>throughput</name>
  154.             <value>1200.0</value>
  155.             <savedValue>0.0</savedValue>
  156.           </doubleProp>
  157.           <intProp name="calcMode">1</intProp>    --注意这里是配置固定QPS节点,默认0为this thread only,1为all active thread,QPS为预期个数*60,因为此处是按照分钟算的,比如你的预期QPS为20,那么这里就应该填写为20*60=1200 
  158.         </ConstantThroughputTimer>
  159.         <hashTree/>
  160.       </hashTree>
  161.     </hashTree>
  162.   </hashTree>
  163. </jmeterTestPlan>
四、执行命令
/da1/dongshiyue/jmeter3.0/bin/jmeter.sh -JNUM_THREADS=5 -JDURATION=600 -JDOMAIN= -JPORT=8080  -n -t  ./tusou/tusou_stable.jmx


阅读(2193) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~