运行 使用 Jmeter Maven 插件的 JMX 监控收集器侦听器

Run JMX monitor collector listener using Jmeter Maven Plugin

我正在使用 Jmeter maven 插件来执行 jmx 测试文件,它可以很好地进行 GUI 压力测试和 Web 服务测试:

<plugin>
        <groupId>com.lazerycode.jmeter</groupId>
        <artifactId>jmeter-maven-plugin</artifactId>
        <version>1.10.1</version>
        <executions>
            <execution>
                <id>jmeter-test</id>
                <phase>test</phase>
                <goals>
                    <goal>jmeter</goal>
                </goals>
                <configuration>
                    <overrideRootLogLevel>debug</overrideRootLogLevel>
                    <testFilesIncluded>
                        <jMeterTestFile>pim_stress.jmx</jMeterTestFile>
                    </testFilesIncluded>
                    <resultsFileNameDateFormat>ddMMyyyy</resultsFileNameDateFormat>
                    <ignoreResultFailures>false</ignoreResultFailures>
                    <propertiesUser>
                        <threadgroup.numberOfThreads>10</threadgroup.numberOfThreads>
                        <threadgroup.rampUp>1</threadgroup.rampUp>
                        <threadgroup.host>localhost</threadgroup.host>
                        <threadgroup.port>8332</threadgroup.port>
                    </propertiesUser>
                    <workingDirectory>target/</workingDirectory>
                </configuration>
            </execution>
        </executions>
</plugin>

然后我需要在我的 Jmeter 磁盘应用程序 (Jmeter 2.9) 中添加一个 JMXMon Samples Collector 侦听器类型的侦听器,这个侦听器用于在测试 运行ning 时随时间绘制 JMX 性能指标,更新后的 jmeter 测试在 Jmeter 2.9 中运行良好,在侦听器部分之后:

        <kg.apc.jmeter.jmxmon.JMXMonCollector guiclass="kg.apc.jmeter.vizualizers.JMXMonGui" testclass="kg.apc.jmeter.jmxmon.JMXMonCollector" testname="jp@gc - JMXMon Samples Collector" 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>
            </value>
          </objProp>
          <stringProp name="filename">${__P(result.monitoring)}</stringProp>
          <longProp name="interval_grouping">1000</longProp>
          <boolProp name="graph_aggregated">false</boolProp>
          <stringProp name="include_sample_labels"></stringProp>
          <stringProp name="exclude_sample_labels"></stringProp>
          <stringProp name="start_offset"></stringProp>
          <stringProp name="end_offset"></stringProp>
          <boolProp name="include_checkbox_state">false</boolProp>
          <boolProp name="exclude_checkbox_state">false</boolProp>
          <collectionProp name="samplers">
            <collectionProp name="-362669779">
              <stringProp name="868201267">NbSessionsTotal</stringProp>
              <stringProp name="942166118">service:jmx:remoting-jmx://localhost:4697</stringProp>
              <stringProp name="105365">jmx</stringProp>
              <stringProp name="-1255434677">jmxadmin@1</stringProp>
              <stringProp name="377390660">pim.monitoring:service=JmxSystem</stringProp>
              <stringProp name="868201267">NbSessionsTotal</stringProp>
              <stringProp name="0"></stringProp>
              <stringProp name="1237">false</stringProp>
            </collectionProp>
          </collectionProp>
        </kg.apc.jmeter.jmxmon.JMXMonCollector>

但是当我尝试通过 Jmeter maven 插件(出于测试自动化原因)运行 这个测试计划(jmx 文件)时,它 return 一个错误:

Caused by: com.thoughtworks.xstream.converters.ConversionException: kg.apc.jmeter.jmxmon.JMXMonCollector : kg.apc.jmeter.jmxmon.JMXMonCollector
---- Debugging information ----
message             : kg.apc.jmeter.jmxmon.JMXMonCollector
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : kg.apc.jmeter.jmxmon.JMXMonCollector
class               : org.apache.jorphan.collections.ListedHashTree
required-type       : org.apache.jorphan.collections.ListedHashTree
converter-type      : org.apache.jmeter.save.converters.HashTreeConverter
path                : /jmeterTestPlan/hashTree/hashTree/hashTree/kg.apc.jmeter.jmxmon.JMXMonCollector
line number         : 430
-------------------------------
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:71)
at org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:71)
at org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:65)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:66)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:50)
at org.apache.jmeter.save.ScriptWrapperConverter.unmarshal(ScriptWrapperConverter.java:95)
... 19 more
Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: kg.apc.jmeter.jmxmon.JMXMonCollector
at com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:79)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.DynamicProxyMapper.realClass(DynamicProxyMapper.java:55)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.PackageAliasingMapper.realClass(PackageAliasingMapper.java:88)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.ClassAliasingMapper.realClass(ClassAliasingMapper.java:79)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.ArrayMapper.realClass(ArrayMapper.java:74)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.SecurityMapper.realClass(SecurityMapper.java:71)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at org.apache.jmeter.save.SaveService$XStreamWrapper.realClass(SaveService.java:94)
at com.thoughtworks.xstream.mapper.MapperWrapper.realClass(MapperWrapper.java:30)
at com.thoughtworks.xstream.mapper.CachingMapper.realClass(CachingMapper.java:47)
at com.thoughtworks.xstream.core.util.HierarchicalStreams.readClassType(HierarchicalStreams.java:29)
at com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter.readItem(AbstractCollectionConverter.java:70)
at org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:72)
... 35 more

有人有想法吗?...非常感谢!

我认为您添加了 JMeter 插件以使用 JMeter GUI 实例,但在 jmeter-maven-plugin 配置中省略了这一步。如果您需要运行 JMeter 测试计划与maven 的非标准插件,您还需要配置jmeter-maven 插件:

https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/Adding-additional-libraries-to-the-classpath#adding-jars-to-the-libext-directory