2011-04-18 343 views
2

我正在尝试加载测试WCF REST服务。
该服务只接受一个参数并返回一个页面。
我想通过这个单一参数的多个。使用JMeter进行负载测试

例子:

server:8080/service/?id=1 
server:8080/service/?id=2 
server:8080/service/?id=3 
server:8080/service/?id=4 
server:8080/service/?id=5 
server:8080/service/?id=6 
......  

我该怎么办呢?
任何想法?

回答

3

看看Loop controllerCounter,如果您还有疑问请给我留言。


UPDATE

你的反应没声音客气。
无论如何,这是怎么回事 - CSV data config

你可以放在那里的任意数据。

它适用于我,这里是JMeter项目。这些三线\ tmp目录\ data.csv为内容

1 
2 
3 

得到这些电话:
把CSV文件在C

http://localhost:81/index.php?id=1 
http://localhost:81/index.php?id=2 
http://localhost:81/index.php?id=3 


<?xml version="1.0" encoding="UTF-8"?> 
<jmeterTestPlan version="1.2" properties="2.1"> 
    <hashTree> 
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test plan" 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="Variables definidas por el Usuario" enabled="true"> 
    <collectionProp name="Arguments.arguments"/> 
     </elementProp> 
     <stringProp name="TestPlan.user_define_classpath"></stringProp> 
    </TestPlan> 
    <hashTree> 
     <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true"> 
    <stringProp name="ThreadGroup.on_sample_error">continue</stringProp> 
    <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Controlador Loop" 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> 
    <longProp name="ThreadGroup.start_time">1303164070000</longProp> 
    <longProp name="ThreadGroup.end_time">1303164070000</longProp> 
    <boolProp name="ThreadGroup.scheduler">false</boolProp> 
    <stringProp name="ThreadGroup.duration"></stringProp> 
    <stringProp name="ThreadGroup.delay"></stringProp> 
     </ThreadGroup> 
     <hashTree> 
    <LoopController guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true"> 
     <boolProp name="LoopController.continue_forever">true</boolProp> 
     <stringProp name="LoopController.loops">3</stringProp> 
    </LoopController> 
    <hashTree> 
     <CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="CSV Data Set Config" enabled="true"> 
     <stringProp name="delimiter">,</stringProp> 
     <stringProp name="fileEncoding"></stringProp> 
     <stringProp name="filename">c:\tmp\data.csv</stringProp> 
     <boolProp name="quotedData">false</boolProp> 
     <boolProp name="recycle">true</boolProp> 
     <stringProp name="shareMode">Current thread group</stringProp> 
     <boolProp name="stopThread">false</boolProp> 
     <stringProp name="variableNames">A</stringProp> 
     </CSVDataSet> 
     <hashTree/> 
     <HTTPSampler guiclass="HttpTestSampleGui" testclass="HTTPSampler" 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="id" elementType="HTTPArgument"> 
      <boolProp name="HTTPArgument.always_encode">false</boolProp> 
      <stringProp name="Argument.value">${A}</stringProp> 
      <stringProp name="Argument.metadata">=</stringProp> 
      <boolProp name="HTTPArgument.use_equals">true</boolProp> 
      <stringProp name="Argument.name">id</stringProp> 
     </elementProp> 
      </collectionProp> 
     </elementProp> 
     <stringProp name="HTTPSampler.domain">localhost</stringProp> 
     <stringProp name="HTTPSampler.port">81</stringProp> 
     <stringProp name="HTTPSampler.connect_timeout"></stringProp> 
     <stringProp name="HTTPSampler.response_timeout"></stringProp> 
     <stringProp name="HTTPSampler.protocol"></stringProp> 
     <stringProp name="HTTPSampler.contentEncoding"></stringProp> 
     <stringProp name="HTTPSampler.path">index.php</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.monitor">false</boolProp> 
     <stringProp name="HTTPSampler.embedded_url_re"></stringProp> 
     </HTTPSampler> 
     <hashTree/> 
    </hashTree> 
    <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="Result Tree" 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> 
     </value> 
     </objProp> 
     <stringProp name="filename"></stringProp> 
    </ResultCollector> 
    <hashTree/> 
     </hashTree> 
    </hashTree> 
    </hashTree> 
</jmeterTestPlan> 
+0

是不是实际上我想要的。 id = 1或2或3只是语法。我可以是任何东西。 – DarthVader 2011-04-18 21:00:26

+0

是的,csv配置工程,循环控制器和计数器不合适。谢谢。 – DarthVader 2011-04-19 13:15:58