首页 > 解决方案 > 在我的测试运行中没有得到相同数量的结果

问题描述

在相同的 Jmeter 测试中,我在 csv 中得到了不同的结果。在一个我得到〜80在其他我得到〜800。是否有一个设置,我总是在 .csv 中获得相同数量的结果?

我也在使用从站,所以这应该只是扩大规模,一个从站应该是 80,如果是 10 个从站,它应该是 800?

一切都在一个大的 CI/CD 管道中。所以我尝试了多次运行。但从来没有为同一个测试得到相同的结果。

这是我的 jmx xml。

<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.3">
  <hashTree>
    <TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Testplan OneHundred" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">true</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>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>
    <hashTree>
      <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="ThreadGroup1" enabled="true">
        <stringProp name="ThreadGroup.on_sample_error">stoptestnow</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">100</stringProp>
        </elementProp>
        <stringProp name="LoopController.loops">100</stringProp>
        <stringProp name="ThreadGroup.ramp_time">0</stringProp>
        <stringProp name="ThreadGroup.duration">0</stringProp>
        <stringProp name="ThreadGroup.delay">0</stringProp>
        <boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.num_threads">10</stringProp>
      </ThreadGroup>
      <hashTree>
        <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="GetRequest" enabled="true">
          <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="Variables pré-définies" 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>
              </elementProp>
            </collectionProp>
          </elementProp>
          <stringProp name="HTTPSampler.domain">traefik_reverse-proxy_1/dashboard</stringProp>
          <stringProp name="HTTPSampler.port">80</stringProp>
          <stringProp name="HTTPSampler.protocol">http</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>
          <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
          <stringProp name="HTTPSampler.connect_timeout"></stringProp>
          <stringProp name="HTTPSampler.response_timeout"></stringProp>
        </HTTPSamplerProxy>
        <hashTree>
          <HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
            <collectionProp name="HeaderManager.headers">
              <elementProp name="" elementType="Header">
                <stringProp name="Header.name">Host</stringProp>
                <stringProp name="Header.value">fend</stringProp>
              </elementProp>
            </collectionProp>
          </HeaderManager>
          <hashTree/>
          <ResultCollector guiclass="StatVisualizer" testclass="ResultCollector" testname="Aggregate 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>false</xml>
                <fieldNames>true</fieldNames>
                <responseHeaders>false</responseHeaders>
                <requestHeaders>false</requestHeaders>
                <responseDataOnError>false</responseDataOnError>
                <saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
                <assertionsResultsToSave>0</assertionsResultsToSave>
                <bytes>true</bytes>
                <sentBytes>true</sentBytes>
                <url>true</url>
                <threadCounts>true</threadCounts>
                <idleTime>true</idleTime>
                <connectTime>true</connectTime>
              </value>
            </objProp>
            <stringProp name="filename">/masterdata/results/auth/cb/response_eight_get.csv</stringProp>
          </ResultCollector>
          <hashTree/>
        </hashTree>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

这是我在终端内收到的消息:

aiting for possible Shutdown/StopTestNow/Heapdump message on port 4445
summary +      1 in 00:00:01 =    1.2/s Avg:   771 Min:   771 Max:   771 Err:     0 (0.00%) Active: 80 Started: 30 Finished: 0
summary +    104 in 00:00:21 =    4.9/s Avg:  9733 Min:    10 Max: 21163 Err:    80 (76.92%) Active: 0 Started: 30 Finished: 80
summary =    105 in 00:00:22 =    4.7/s Avg:  9647 Min:    10 Max: 21163 Err:    80 (76.19%)
Tidying up remote @ Tue Oct 27 22:08:54 UTC 2020 (1603836534920)
... end of run

以及 results.csv 中的最后几个条目

1603836484132,15040,GetRequest,Non HTTP response code: java.net.SocketException,Non HTTP response message: Socket closed,ThreadGroup1 1-9,text,false,,2682,0,4,4,http://traefik_reverse-proxy_1/dashboard/,0,0,185
1603836484168,14999,GetRequest,Non HTTP response code: java.net.SocketException,Non HTTP response message: Socket closed,ThreadGroup1 1-1,text,false,,2682,0,4,4,http://traefik_reverse-proxy_1/dashboard/,0,0,154
1603836484179,14998,GetRequest,Non HTTP response code: java.net.SocketException,Non HTTP response message: Socket closed,ThreadGroup1 1-4,text,false,,2682,0,4,4,http://traefik_reverse-proxy_1/dashboard/,0,0,137

标签: jmeter

解决方案


  1. 您的线程组中有 10 个用户和 100 个循环,因此您应该得到 1000 个总结果(如果一切顺利)

  2. 同时你有Stop Test Now一个采样器错误,这意味着你的测试将立即停止(而不是优雅地),只要一个请求失败

    在此处输入图像描述

  3. 所有 JMeter 从站都绝对独立地执行相同的测试计划,因此对于 1 个从站,您将有 1000 个结果,对于 2 个从站 - 2000,对于 8 个从站 - 8000 等,但同样只有在一切正常的情况下,任何单一故障都会导致您的测试以立即停止强制终止连接(并添加更多错误),因此您可能希望将此“在采样器错误后采取的操作”切换为Continue,它将允许您每次运行测试时获得相同数量的结果。

更多信息:如何在 JMeter 中执行分布式测试


推荐阅读