从 JMeter 3.0 到 JMeter 3.3 的 OauthSampler

OauthSampler from JMeter 3.0 to JMeter 3.3

我有一个在 JMeter 3.0 中运行良好的测试计划(它是用这个版本构思的)。

我尝试将 JMeter 升级到 3.3,现在几乎没有新错误。

2018-02-19 16:40:51,544 INFO o.a.j.s.FileServer: Default base='D:\Automation\bin'
2018-02-19 16:40:51,544 INFO o.a.j.s.FileServer: Set new base='D:\Automation\bin'
2018-02-19 16:40:51,711 INFO o.a.j.s.SaveService: Testplan (JMX) version: 2.2. Testlog (JTL) version: 2.2
2018-02-19 16:40:51,714 INFO o.a.j.s.SaveService: Using SaveService properties file encoding UTF-8
2018-02-19 16:40:51,717 INFO o.a.j.s.SaveService: Using SaveService properties version 3.2
2018-02-19 16:40:51,721 INFO o.a.j.s.SaveService: Loading file: D:\Automation\bin\ENDPOINT.jmx
2018-02-19 16:40:51,969 INFO o.a.j.p.h.c.CacheManager: Will only cache the following methods: [GET]
2018-02-19 16:40:52,048 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/html is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser
2018-02-19 16:40:52,048 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for application/xhtml+xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser
2018-02-19 16:40:52,048 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for application/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser
2018-02-19 16:40:52,048 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser
2018-02-19 16:40:52,048 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/vnd.wap.wml is org.apache.jmeter.protocol.http.parser.RegexpHTMLParser
2018-02-19 16:40:52,048 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/css is org.apache.jmeter.protocol.http.parser.CssParser
2018-02-19 16:40:52,321 INFO o.a.j.s.FileServer: Set new base='D:\Automation\bin'
2018-02-19 16:40:52,670 INFO o.a.j.s.SampleResult: Note: Sample TimeStamps are START times
2018-02-19 16:40:52,671 INFO o.a.j.s.SampleResult: sampleresult.default.encoding is set to ISO-8859-1
2018-02-19 16:40:52,671 INFO o.a.j.s.SampleResult: sampleresult.useNanoTime=true
2018-02-19 16:40:52,671 INFO o.a.j.s.SampleResult: sampleresult.nanoThreadSleep=5000
2018-02-19 16:40:53,049 WARN o.j.r.Plugin: Unable to load class: com.atlantbh.jmeter.plugins.oauth.OAuthSampler
java.lang.NoClassDefFoundError: org/apache/jmeter/protocol/http/sampler/HTTPSampler2
    at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_151]
    at java.lang.ClassLoader.defineClass(Unknown Source) ~[?:1.8.0_151]
    at java.security.SecureClassLoader.defineClass(Unknown Source) ~[?:1.8.0_151]
    at java.net.URLClassLoader.defineClass(Unknown Source) ~[?:1.8.0_151]
    at java.net.URLClassLoader.access0(Unknown Source) ~[?:1.8.0_151]
    at java.net.URLClassLoader.run(Unknown Source) ~[?:1.8.0_151]
    at java.net.URLClassLoader.run(Unknown Source) ~[?:1.8.0_151]
    at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_151]
    at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_151]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_151]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_151]
    at org.jmeterplugins.repository.Plugin.getJARPath(Plugin.java:193) [jmeter-plugins-manager-0.19.jar:?]
    at org.jmeterplugins.repository.Plugin.detectInstalledPlugin(Plugin.java:107) [jmeter-plugins-manager-0.19.jar:?]
    at org.jmeterplugins.repository.Plugin.detectInstalled(Plugin.java:96) [jmeter-plugins-manager-0.19.jar:?]
    at org.jmeterplugins.repository.PluginManager.load(PluginManager.java:84) [jmeter-plugins-manager-0.19.jar:?]
    at org.jmeterplugins.repository.PluginManagerMenuItem.run(PluginManagerMenuItem.java:41) [jmeter-plugins-manager-0.19.jar:?]
Caused by: java.lang.ClassNotFoundException: org.apache.jmeter.protocol.http.sampler.HTTPSampler2
    at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_151]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_151]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_151]
    ... 16 more

如何克服这个错误?我知道 OAuth Sampler 已被弃用。有没有办法来解决这个问题?当我尝试从文件中读取时我也有一些错误(可能不相关)。

2018-02-19 16:41:07,229 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``{import org.ini4j.*; Wini ini = new Wini(new File(vars.get("SettingsFile"))); St . . . '' : Typed variable declaration : Class: Wini not found in namespace
2018-02-19 16:41:07,229 WARN o.a.j.f.BeanShell: Error running BSH script
org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval    Sourced file: inline evaluation of: ``{import org.ini4j.*; Wini ini = new Wini(new File(vars.get("SettingsFile"))); St . . . '' : Typed variable declaration : Class: Wini not found in namespace
    at org.apache.jmeter.util.BeanShellInterpreter.bshInvoke(BeanShellInterpreter.java:183) ~[ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.util.BeanShellInterpreter.eval(BeanShellInterpreter.java:189) ~[ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.functions.BeanShell.execute(BeanShell.java:100) [ApacheJMeter_functions.jar:3.3 r1808647]
    at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:137) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:112) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:92) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.testelement.AbstractTestElement.getPropertyAsString(AbstractTestElement.java:281) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.config.Argument.getValue(Argument.java:146) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.config.Arguments.getArgumentsAsMap(Arguments.java:94) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.engine.PreCompiler.createArgumentsMap(PreCompiler.java:114) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jmeter.engine.PreCompiler.addNode(PreCompiler.java:101) [ApacheJMeter_core.jar:3.3 r1808647]
    at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:996) [jorphan.jar:3.3 r1808647]
    at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:978) [jorphan.jar:3.3 r1808647]
    at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:369) [ApacheJMeter_core.jar:3.3 r1808647]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_151]
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
    at org.apache.jmeter.util.BeanShellInterpreter.bshInvoke(BeanShellInterpreter.java:166) ~[ApacheJMeter_core.jar:3.3 r1808647]
    ... 14 more

正在研究提交 2651c6ffc534e0137849377fce4b1b0e1aafca47 the file src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java has been removed as a part of issue 60727 during JMeter 3.2 release

因此,您可以与 OAuth Sampler 一起使用的最高 JMeter 版本是 JMeter 3.1

您可以通过 JMeter Plugins Forum and clarify the status and the plans or use one of alternative approaches described in How to Run Performance Tests on OAuth Secured Apps with JMeter 联系 JMeter 插件开发人员 and/or 维护人员,他们应该是 JMeter-version-agnostic。

您可以从Apache JMeter Archives页面

下载JMeter 3.1