在user.csv上循环,然后在jmeter中的data.csv上循环 [英] loop on user.csv and then loop on data.csv in jmeter

查看:61
本文介绍了在user.csv上循环,然后在jmeter中的data.csv上循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要做这样的事情:


    foreach user in a users.csv:
        foreach data in data.csv:
            send http request
    

我看过此帖子此页面

但是,据我所知,它不是并行执行的.因此,不可能模拟在10分钟内用户逐渐加载数据.

However, as far I've been to figure out, it's NOT performed in parallel. So, it's not posible to simulate for example that during 10 minutes the users are loading data progressively.

因此,我希望每个用户都是一个线程,然后每个用户都执行HTTP请求,因为data.csv文件中包含许多数据.通过这种方式,我发现在几台jmeter服务器上执行这种测试是最简单的.

So, I'd like each user is a thread and then each user perform an HTTP request as many data is in data.csv file. By this way, I figure out it's easiest to perform these kind of tests on several jmeter servers.

有什么想法吗?

推荐答案

示例测试计划

  • 线程组-根据您的方案的用户数和迭代数.如果您没有特定的循环计数,请勾选Forever
    • CSV数据集配置
      • 文件名:users.csv
      • 变量名称:user
      • 所有下拉列表:False
      • 共享模式:All Threads
      • Thread Group - Number of users and iterations as per your scenario. If you don't have specific loop count in mind - tick Forever
        • CSV Data Set Config
          • Filename: users.csv
          • Variable Names: user
          • All dropdowns: False
          • Sharing Mode: All Threads
          • CSV数据集配置
            • 文件名:data.csv
            • 变量名称:data
            • 允许引用数据&在EOF上回收:False
            • 在EOF上停止线程:True
            • 共享模式:Current Thread
            • CSV Data Set Config
              • Filename: data.csv
              • Variable Names: data
              • Allow Quoted Data & Recycle on EOF: False
              • Stop Thread on EOF: True
              • Sharing Mode: Current Thread

              演示:

              如果您需要示例测试计划:

              If you want example test plan:

              <?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="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="User Defined Variables" 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="Loop Controller" enabled="true">
                        <boolProp name="LoopController.continue_forever">false</boolProp>
                        <intProp name="LoopController.loops">-1</intProp>
                      </elementProp>
                      <stringProp name="ThreadGroup.num_threads">3</stringProp>
                      <stringProp name="ThreadGroup.ramp_time">1</stringProp>
                      <longProp name="ThreadGroup.start_time">1455338605000</longProp>
                      <longProp name="ThreadGroup.end_time">1455338605000</longProp>
                      <boolProp name="ThreadGroup.scheduler">false</boolProp>
                      <stringProp name="ThreadGroup.duration"></stringProp>
                      <stringProp name="ThreadGroup.delay"></stringProp>
                    </ThreadGroup>
                    <hashTree>
                      <CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="CSV Data Set Config" enabled="true">
                        <stringProp name="delimiter">,</stringProp>
                        <stringProp name="fileEncoding"></stringProp>
                        <stringProp name="filename">users.csv</stringProp>
                        <boolProp name="quotedData">false</boolProp>
                        <boolProp name="recycle">false</boolProp>
                        <stringProp name="shareMode">shareMode.all</stringProp>
                        <boolProp name="stopThread">false</boolProp>
                        <stringProp name="variableNames">user</stringProp>
                      </CSVDataSet>
                      <hashTree/>
                      <WhileController guiclass="WhileControllerGui" testclass="WhileController" testname="While Controller" enabled="true">
                        <stringProp name="WhileController.condition">${__javaScript(&quot;${data}&quot; != &quot;&lt;EOF&gt;&quot;,)}</stringProp>
                      </WhileController>
                      <hashTree>
                        <CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="CSV Data Set Config" enabled="true">
                          <stringProp name="filename">data.csv</stringProp>
                          <stringProp name="fileEncoding"></stringProp>
                          <stringProp name="variableNames">data</stringProp>
                          <stringProp name="delimiter">,</stringProp>
                          <boolProp name="quotedData">false</boolProp>
                          <boolProp name="recycle">false</boolProp>
                          <boolProp name="stopThread">true</boolProp>
                          <stringProp name="shareMode">shareMode.thread</stringProp>
                        </CSVDataSet>
                        <hashTree/>
                        <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="${user} - ${data}" enabled="true">
                          <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
                            <collectionProp name="Arguments.arguments"/>
                          </elementProp>
                          <stringProp name="HTTPSampler.domain">example.com</stringProp>
                          <stringProp name="HTTPSampler.port"></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"></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>
                        </HTTPSamplerProxy>
                        <hashTree/>
                      </hashTree>
                      <ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results 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>false</xml>
                            <fieldNames>false</fieldNames>
                            <responseHeaders>false</responseHeaders>
                            <requestHeaders>false</requestHeaders>
                            <responseDataOnError>false</responseDataOnError>
                            <saveAssertionResultsFailureMessage>false</saveAssertionResultsFailureMessage>
                            <assertionsResultsToSave>0</assertionsResultsToSave>
                            <bytes>true</bytes>
                            <threadCounts>true</threadCounts>
                          </value>
                        </objProp>
                        <stringProp name="filename"></stringProp>
                      </ResultCollector>
                      <hashTree/>
                    </hashTree>
                  </hashTree>
                </hashTree>
              </jmeterTestPlan>
              

              您可能还希望根据测试场景调整配置,我仅概述了基本用法,在这种情况下,请查看使用CSV数据集配置指南介绍了所有CSV数据集配置选项.

              You may also wish to adjust config according to your test scenario, I outlined only basic usage, in that case check out Using CSV DATA SET CONFIG guide for all CSV Data Set configuration options explained.

              这篇关于在user.csv上循环,然后在jmeter中的data.csv上循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆