使用 JMeter 插件 PathNotFoundException 进行 VSTS 负载测试?

VSTS Load Testing With JMeter plugin PathNotFoundException?

我在 JMeter 中创建了一个负载测试以检索有效的访问令牌,然后对我的 webAPI 执行多个请求以测试查询,这在 JMeter 中有效。

我的测试计划使用 JSONPathExtractor 插件从 JSON 响应中提取令牌,然后将该令牌存储为 属性 以用于后续测试组。 我想在 Visual Studio Team Services 中上传并 运行 这些 JMeter 测试,但是我得到了 "internal error occurred in the service when initializing the test run".

这是从 VSTS 生成的日志文件:

2016/10/20 13:26:22 INFO  - jmeter.util.JMeterUtils: Setting Locale to en_US 
2016/10/20 13:26:22 INFO  - jmeter.JMeter: Loading user properties from: C:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension.8\Downloads[=10=]\approot\JMeterLoadTest\clt_jmeterdrop\bin\user.properties 
2016/10/20 13:26:22 INFO  - jmeter.JMeter: Loading system properties from: C:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension.8\Downloads[=10=]\approot\JMeterLoadTest\clt_jmeterdrop\bin\system.properties 
2016/10/20 13:26:23 INFO  - jmeter.JMeter: Copyright (c) 1998-2015 The Apache Software Foundation 
2016/10/20 13:26:23 INFO  - jmeter.JMeter: Version 2.13 r1665067 
2016/10/20 13:26:23 INFO  - jmeter.JMeter: java.version=1.8.0_60 
2016/10/20 13:26:23 INFO  - jmeter.JMeter: java.vm.name=Java HotSpot(TM) 64-Bit Server VM 
2016/10/20 13:26:23 INFO  - jmeter.JMeter: os.name=Windows Server 2012 R2 
2016/10/20 13:26:23 INFO  - jmeter.JMeter: os.arch=amd64 
2016/10/20 13:26:23 INFO  - jmeter.JMeter: os.version=6.3 
2016/10/20 13:26:23 INFO  - jmeter.JMeter: file.encoding=Cp1252 
2016/10/20 13:26:23 INFO  - jmeter.JMeter: Default Locale=English (United States) 
2016/10/20 13:26:23 INFO  - jmeter.JMeter: JMeter  Locale=English (United States) 
2016/10/20 13:26:23 INFO  - jmeter.JMeter: JMeterHome=C:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension.8\Downloads[=10=]\approot\JMeterLoadTest\clt_jmeterdrop 
2016/10/20 13:26:23 INFO  - jmeter.JMeter: user.dir  =C:\Windows\system32 
2016/10/20 13:26:23 INFO  - jmeter.JMeter: PWD       =C:\Windows\System32 
2016/10/20 13:26:23 INFO  - jmeter.JMeter: IP: 10.0.0.4 Name: vstsloadagent0 FullName: vstsloadagent0.oykuxugkk15uzmtpoj4pw2mxgh.fx.internal.cloudapp.net 
2016/10/20 13:26:23 INFO  - jmeter.services.FileServer: Default base='C:\Windows\system32' 
2016/10/20 13:26:23 INFO  - jmeter.services.FileServer: Set new base='d:[=10=]\tded1\TestRun\Out' 
2016/10/20 13:26:23 INFO  - jmeter.save.SaveService: Testplan (JMX) version: 2.2. Testlog (JTL) version: 2.2 
2016/10/20 13:26:23 INFO  - jmeter.save.SaveService: Using SaveService properties file encoding UTF-8 
2016/10/20 13:26:23 INFO  - jmeter.save.SaveService: Using SaveService properties file version 1656252 
2016/10/20 13:26:23 INFO  - jmeter.save.SaveService: Using SaveService properties version 2.8 
2016/10/20 13:26:23 INFO  - jmeter.save.SaveService: All converter versions present and correct 
2016/10/20 13:26:23 INFO  - jmeter.save.SaveService: Loading file: d:[=10=]\tded1\TestRun\Out\JMeter Tile Test (Complete).jmx 
2016/10/20 13:26:23 INFO  - jmeter.protocol.http.control.CookieManager: Settings: Delete null: true Check: true Allow variable: true Save: false Prefix: COOKIE_ 
2016/10/20 13:26:23 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Cannot find .className property for htmlParser, using default 
2016/10/20 13:26:23 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/html is  
2016/10/20 13:26:23 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for application/xhtml+xml is  
2016/10/20 13:26:23 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for application/xml is  
2016/10/20 13:26:23 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/xml is  
2016/10/20 13:26:23 INFO  - jmeter.protocol.http.sampler.HTTPSamplerBase: Parser for text/vnd.wap.wml is org.apache.jmeter.protocol.http.parser.RegexpHTMLParser 
2016/10/20 13:26:23 ERROR - jmeter.JMeter: Error in NonGUIDriver java.lang.IllegalArgumentException: Problem loading XML from:'d:[=10=]\tded1\TestRun\Out\JMeter Tile Test (Complete).jmx', conversion error com.thoughtworks.xstream.converters.ConversionException: com/jayway/jsonpath/PathNotFoundException : com/jayway/jsonpath/PathNotFoundException
---- Debugging information ----
message             : com/jayway/jsonpath/PathNotFoundException
cause-exception     : java.lang.NoClassDefFoundError
cause-message       : com/jayway/jsonpath/PathNotFoundException
first-jmeter-class  : org.apache.jmeter.save.converters.TestElementConverter.unmarshal(TestElementConverter.java:102)
class               : org.apache.jmeter.save.ScriptWrapper
required-type       : com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor
converter-type      : org.apache.jmeter.save.ScriptWrapperConverter
path                : /jmeterTestPlan/hashTree/hashTree/hashTree[3]/hashTree/hashTree[3]/com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor
line number         : 118
version             : 2.13 r1665067
-------------------------------
    at org.apache.jmeter.save.SaveService.readTree(SaveService.java:586)
    at org.apache.jmeter.save.SaveService.loadTree(SaveService.java:537)
    at org.apache.jmeter.JMeter.runNonGui(JMeter.java:750)
    at org.apache.jmeter.JMeter.startNonGui(JMeter.java:737)
    at org.apache.jmeter.JMeter.start(JMeter.java:395)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.jmeter.NewDriver.main(NewDriver.java:264)
Caused by: com.thoughtworks.xstream.converters.ConversionException: com/jayway/jsonpath/PathNotFoundException : com/jayway/jsonpath/PathNotFoundException
---- Debugging information ----
message             : com/jayway/jsonpath/PathNotFoundException
cause-exception     : java.lang.NoClassDefFoundError
cause-message       : com/jayway/jsonpath/PathNotFoundException
first-jmeter-class  : org.apache.jmeter.save.converters.TestElementConverter.unmarshal(TestElementConverter.java:102)
class               : org.apache.jmeter.save.ScriptWrapper
required-type       : com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor
converter-type      : org.apache.jmeter.save.ScriptWrapperConverter
path                : /jmeterTestPlan/hashTree/hashTree/hashTree[3]/hashTree/hashTree[3]/com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor
line number         : 118
version             : 2.13 r1665067
-------------------------------
    at org.apache.jmeter.save.ScriptWrapperConverter.createConversionException(ScriptWrapperConverter.java:105)
    at org.apache.jmeter.save.ScriptWrapperConverter.unmarshal(ScriptWrapperConverter.java:97)
    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.core.TreeUnmarshaller.start(TreeUnmarshaller.java:134)
    at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarshal(AbstractTreeMarshallingStrategy.java:32)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1206)
    at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1190)
    at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1061)
    at org.apache.jmeter.save.SaveService.readTree(SaveService.java:559)
    ... 9 more
Caused by: java.lang.NoClassDefFoundError: com/jayway/jsonpath/PathNotFoundException
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
    at java.lang.Class.getConstructor0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at org.apache.jmeter.save.converters.TestElementConverter.unmarshal(TestElementConverter.java:102)
    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 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 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: java.lang.ClassNotFoundException: com.jayway.jsonpath.PathNotFoundException
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 59 more

VSTS 负载测试似乎找不到 JSONPathExtractor 插件。如何将其包含在我的 .jmx 文件或支持文件上传中?非常感谢!

您的问题是您的计划依赖于 JMeter-plugins 项目的第 3 方插件 JSON Path Extractor。 所以你需要添加它,只要它的依赖项。

但更好的选择是使用 JMeter 3.0 和本机 JSON Post 处理器:

这可能是由 JMeter 版本引起的,因为 VSTS 负载测试仍在测试代理上使用 JMeter 2.13 版本,有关详细信息,请参阅此 link:Apache JMeter tests:

Q: What is the supported JMeter version?

A: The load test agents run Apache JMeter version 2.13, the latest version available currently.

已经有用户为此投稿,您可以在这里投票:Support jMeter 3.0

这不是 JMeter 或其版本的问题,而是 VSTS 的问题,visual studio 不会 recognize/support JSON JMeter 脚本中使用的路径提取器,最好使用正则表达式。