JMeter 3.0 testplan不能在非GUI模式下工作

时间:2016-11-01 14:33:32

标签: jmeter performance-testing

该计划在GUI模式下运行良好。 它也以非GUI模式运行,但不发送正确的(?)HTTP请求......

这就是我发布它的方式: sh jmeter.sh -n -t thread-test.jmx -l thread-test.csv

在GUI中运行时,请求是正确的:

GET http://www.bing.com/

[no cookies]

Request Headers:
Connection: keep-alive
Host: www.bing.com
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_73)

但是当使用非GUI模式运行时,请求没有要显示的数据: 无数据显示

采样器结果如下所示:

Thread Name: Thread Group 1-1
Sample Start: 2016-11-01 15:24:04 CET
Load time: 141
Connect Time: 0
Latency: 141
Size in bytes: 85790
Headers size in bytes: 0
Body size in bytes: 0
Sample Count: 1
Error Count: 0
Data type ("text"|"bin"|""): text
Response code: 200
Response message: OK

回复标题:

SampleResult字段: 内容类型: DataEncoding:null

有什么想法吗?我很难过......

这是测试计划:

 <?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="2.9" jmeter="3.0 r1743807">
  <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">stoptest</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">1</stringProp>
        </elementProp>
        <stringProp name="ThreadGroup.num_threads">1</stringProp>
        <stringProp name="ThreadGroup.ramp_time">1</stringProp>
        <longProp name="ThreadGroup.start_time">1478003529000</longProp>
        <longProp name="ThreadGroup.end_time">1478003529000</longProp>
        <boolProp name="ThreadGroup.scheduler">false</boolProp>
        <stringProp name="ThreadGroup.duration"></stringProp>
        <stringProp name="ThreadGroup.delay"></stringProp>
      </ThreadGroup>
      <hashTree>
        <HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Request" enabled="true">
          <elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" enabled="true">
            <collectionProp name="Arguments.arguments"/>
          </elementProp>
          <stringProp name="HTTPSampler.domain">www.bing.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.BROWSER_COMPATIBLE_MULTIPART">true</boolProp>
          <boolProp name="HTTPSampler.image_parser">true</boolProp>
          <boolProp name="HTTPSampler.concurrentDwn">true</boolProp>
          <boolProp name="HTTPSampler.monitor">false</boolProp>
          <stringProp name="HTTPSampler.embedded_url_re"></stringProp>
        </HTTPSamplerProxy>
        <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>true</fieldNames>
              <responseHeaders>false</responseHeaders>
              <requestHeaders>false</requestHeaders>
              <responseDataOnError>false</responseDataOnError>
              <saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
              <assertionsResultsToSave>0</assertionsResultsToSave>
              <bytes>true</bytes>
              <threadCounts>true</threadCounts>
              <idleTime>true</idleTime>
            </value>
          </objProp>
          <stringProp name="filename">/Users/jboive/Downloads/apache-jmeter-3.0/bin/thread-test.csv</stringProp>
        </ResultCollector>
        <hashTree/>
      </hashTree>
    </hashTree>
  </hashTree>
</jmeterTestPlan>

这是日志:

2016/11/01 15:24:31 INFO  - jmeter.util.JMeterUtils: Setting Locale to en_US 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: Loading user properties from: /Users/jboive/Downloads/apache-jmeter-3.0/bin/user.properties 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: Loading system properties from: /Users/jboive/Downloads/apache-jmeter-3.0/bin/system.properties 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: Copyright (c) 1998-2016 The Apache Software Foundation 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: Version 3.0 r1743807 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: java.version=1.8.0_73 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: java.vm.name=Java HotSpot(TM) 64-Bit Server VM 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: os.name=Mac OS X 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: os.arch=x86_64 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: os.version=10.12.1 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: file.encoding=UTF-8 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: Max memory     =514850816 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: Available Processors =8 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: Default Locale=English (United States) 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: JMeter  Locale=English (United States) 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: JMeterHome=/Users/jboive/Downloads/apache-jmeter-3.0 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: user.dir  =/Users/jboive/Downloads/apache-jmeter-3.0/bin 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: PWD       =/Users/jboive/Downloads/apache-jmeter-3.0/bin 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: IP: 10.0.1.19 Name: iMac.local FullName: 10.0.1.19 
2016/11/01 15:24:31 INFO  - jmeter.gui.action.LookAndFeelCommand: Using look and feel: com.apple.laf.AquaLookAndFeel [Mac OS X, System] 
2016/11/01 15:24:31 INFO  - jmeter.JMeter: Loaded icon properties from org/apache/jmeter/images/icon.properties 
2016/11/01 15:24:33 INFO  - jmeter.engine.util.CompoundVariable: Note: Function class names must contain the string: '.functions.' 
2016/11/01 15:24:33 INFO  - jmeter.engine.util.CompoundVariable: Note: Function class names must not contain the string: '.gui.' 
2016/11/01 15:24:35 INFO  - org.jmeterplugins.repository.PluginManager: Plugins Status: [jpgc-graphs-basic=2.0, jpgc-graphs-additional=2.0, jpgc-autostop=0.1, blazemeter-debugger=0.3, jpgc-functions=2.0, jmeter-ftp=3.0, jpgc-filterresults=2.1, jmeter-http=3.0, jmeter-jdbc=3.0, jmeter-jms=3.0, jmeter-monitors=3.0, jmeter-core=3.0, jmeter-junit=3.0, jmeter-java=3.0, jmeter-ldap=3.0, jmeter-mail=3.0, jmeter-mongodb=3.0, jmeter-native=3.0, jpgc-plugins-manager=0.10, jpgc-synthesis=2.0, jmeter-tcp=3.0, jmeter-components=3.0] 
2016/11/01 15:24:36 INFO  - jmeter.util.BSFTestElement: Registering JMeter version of JavaScript engine as work-round for BSF-22 
2016/11/01 15:24:36 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/html is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
2016/11/01 15:24:36 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for application/xhtml+xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
2016/11/01 15:24:36 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for application/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
2016/11/01 15:24:36 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
2016/11/01 15:24:36 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/vnd.wap.wml is org.apache.jmeter.protocol.http.parser.RegexpHTMLParser 
2016/11/01 15:24:36 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/css is org.apache.jmeter.protocol.http.parser.CssParser 
2016/11/01 15:24:37 INFO  - jorphan.exec.KeyToolUtils: keytool found at 'keytool' 
2016/11/01 15:24:37 INFO  - jmeter.protocol.http.proxy.ProxyControl: HTTP(S) Test Script Recorder SSL Proxy will use keys that support embedded 3rd party resources in file /Users/jboive/Downloads/apache-jmeter-3.0/bin/proxyserver.jks 
2016/11/01 15:24:37 INFO  - jmeter.gui.util.MenuFactory: Skipping org.apache.jmeter.protocol.mongodb.config.MongoSourceElement 
2016/11/01 15:24:37 INFO  - jmeter.gui.util.MenuFactory: Skipping org.apache.jmeter.protocol.mongodb.sampler.MongoScriptSampler 
2016/11/01 15:24:37 INFO  - jmeter.gui.util.MenuFactory: Skipping org.apache.jmeter.visualizers.DistributionGraphVisualizer 
2016/11/01 15:24:37 INFO  - jmeter.samplers.SampleResult: Note: Sample TimeStamps are START times 
2016/11/01 15:24:37 INFO  - jmeter.samplers.SampleResult: sampleresult.default.encoding is set to ISO-8859-1 
2016/11/01 15:24:37 INFO  - jmeter.samplers.SampleResult: sampleresult.useNanoTime=true 
2016/11/01 15:24:37 INFO  - jmeter.samplers.SampleResult: sampleresult.nanoThreadSleep=5000 
2016/11/01 15:24:37 INFO  - jmeter.gui.util.MenuFactory: Skipping org.apache.jmeter.visualizers.SplineVisualizer 
2016/11/01 15:24:49 INFO  - jmeter.services.FileServer: Default base='/Users/jboive/Downloads/apache-jmeter-3.0/bin' 
2016/11/01 15:24:49 INFO  - jmeter.gui.action.Load: Loading file: /Users/jboive/Downloads/apache-jmeter-3.0/bin/thread-test.jmx 
2016/11/01 15:24:49 INFO  - jmeter.services.FileServer: Set new base='/Users/jboive/Downloads/apache-jmeter-3.0/bin' 
2016/11/01 15:24:49 INFO  - jmeter.save.SaveService: Testplan (JMX) version: 2.2. Testlog (JTL) version: 2.2 
2016/11/01 15:24:49 INFO  - jmeter.save.SaveService: Using SaveService properties file encoding UTF-8 
2016/11/01 15:24:49 INFO  - jmeter.save.SaveService: Using SaveService properties version 2.9 
2016/11/01 15:24:49 INFO  - jmeter.save.SaveService: All converter versions present and correct 
2016/11/01 15:24:49 INFO  - jmeter.save.SaveService: Loading file: /Users/jboive/Downloads/apache-jmeter-3.0/bin/thread-test.jmx 
2016/11/01 15:24:49 INFO  - jmeter.services.FileServer: Set new base='/Users/jboive/Downloads/apache-jmeter-3.0/bin' 
2016/11/01 15:24:53 INFO  - jmeter.samplers.SampleEvent: List of sample_variables: [] 
2016/11/01 15:29:59 INFO  - jmeter.engine.StandardJMeterEngine: Running the test! 
2016/11/01 15:29:59 INFO  - jmeter.samplers.SampleEvent: List of sample_variables: [] 
2016/11/01 15:29:59 INFO  - jmeter.gui.util.JMeterMenuBar: setRunning(true,*local*) 
2016/11/01 15:29:59 INFO  - jmeter.engine.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group 
2016/11/01 15:29:59 INFO  - jmeter.engine.StandardJMeterEngine: Starting 1 threads for group Thread Group. 
2016/11/01 15:29:59 INFO  - jmeter.engine.StandardJMeterEngine: Test will stop on error 
2016/11/01 15:29:59 INFO  - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 1 ramp-up 1 perThread 1000.0 delayedStart=false 
2016/11/01 15:29:59 INFO  - jmeter.threads.ThreadGroup: Started thread group number 1 
2016/11/01 15:29:59 INFO  - jmeter.engine.StandardJMeterEngine: All thread groups have been started 
2016/11/01 15:29:59 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-1 
2016/11/01 15:29:59 INFO  - jmeter.protocol.http.sampler.HTTPHCAbstractImpl: Local host = iMac.local 
2016/11/01 15:29:59 INFO  - jmeter.protocol.http.sampler.HTTPHC4Impl: HTTP request retry count = 0 
2016/11/01 15:29:59 INFO  - jmeter.protocol.http.parser.BaseParser: Created org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser 
2016/11/01 15:29:59 INFO  - jmeter.threads.JMeterThread: Thread is done: Thread Group 1-1 
2016/11/01 15:29:59 INFO  - jmeter.threads.JMeterThread: Thread finished: Thread Group 1-1 
2016/11/01 15:29:59 INFO  - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test 
2016/11/01 15:29:59 INFO  - jmeter.gui.util.JMeterMenuBar: setRunning(false,*local*) 

2 个答案:

答案 0 :(得分:1)

这里没有错。

在GUI模式下,“查看结果树”显示所有字段。

在非GUI模式下,您为查看结果树设置的输出是CSV,它不存储所有字段,如响应数据,编码......

这就是为什么你没有所有数据。

要拥有您想要的产品,请点击&#34;配置&#34;查看结果树中的按钮,然后选择XML字段。将您的文件重命名为thread-test.xml。

enter image description here

答案 1 :(得分:1)

实际上您的测试计划确实有效,它只是在.jtl结果文件中存储了一小部分指标,足以填充Aggregate Report等监听器或构建{{3} }。

数据正在被削减为保存请求,尤其是响应会导致大量磁盘IO开销并消耗大量内存,因此建议避免保存额外数据或仅在发生错误时执行此操作。

如果出于某种原因需要在非GUI模式下获得完整图片,则可通过JMeter Properties控制。为了获得与GUI模式相同级别的详细信息,请将以下行添加到 user.properties 文件(位于JMeter的“bin”文件夹中)

jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.response_data=true
jmeter.save.saveservice.samplerData=true
jmeter.save.saveservice.requestHeaders=true
jmeter.save.saveservice.url=true
jmeter.save.saveservice.responseHeaders=true

需要JMeter重启才能选择属性。请参阅HTML Reporting Dashboard以了解有关JMeter属性以及设置和/或覆盖它们的方法的更多信息