在Jenkins上使用Maven-jmeter插件进行负载测试给出了“非HTTP响应代码:javax.net.ssl.SSLHandshakeException”
我正在使用Jmeter 3.0进行负载测试API。我使用Maven-Jmeter插件来运行我的负载测试。目前使用com.lazerycode.jmeter插件版本2.0.3。 Test在我的本地机器上运行良好,但是当我通过Jenkins运行它时,我得到“非HTTP响应代码:javax.net.ssl.SSLHandshakeException”。我已经搜索了几乎所有在各种论坛上提出的建议,但错误并没有解决。我错过了什么?任何帮助表示赞赏。在Jenkins上使用Maven-jmeter插件进行负载测试给出了“非HTTP响应代码:javax.net.ssl.SSLHandshakeException”
请参阅下面的错误堆栈。
httpSample t="1069" it="0" lt="0" ts="1485212600015" s="false" lb="ServiceProxy:TC#1: GET- Health Check For Proxy Service" **rc="Non HTTP response code: javax.net.ssl.SSLHandshakeException" rm="Non HTTP response message: Received fatal alert: handshake_failure"** tn="Service Proxy Regression Test Plan 1-1" dt="text" by="2566" ng="1" na="1">
****** received : [[[Non HTTP response code: javax.net.ssl.SSLHandshakeException]]]
****** comparison: [[[200 ]]]
class="java.lang.String">javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1979)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1086)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343)
at org.apache.http.conn.ssl.SSLSocketFactory.createLayeredSocket(SSLSocketFactory.java:573)
at org.apache.http.conn.ssl.SSLSocketFactory.createLayeredSocket(SSLSocketFactory.java:447)
at org.apache.jmeter.protocol.http.sampler.LazySchemeSocketFactory.createLayeredSocket(LazySchemeSocketFactory.java:121)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.updateSecureConnection(DefaultClientConnectionOperator.java:219)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.layerProtocol(ManagedClientConnectionImpl.java:421)
at org.apache.jmeter.protocol.http.sampler.MeasuringConnectionManager$MeasuredConnection.layerProtocol(MeasuringConnectionManager.java:152)
at org.apache.http.impl.client.DefaultRequestDirector.establishRoute(DefaultRequestDirector.java:815)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:616)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:447)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:884)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:619)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:379)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1146)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1135)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:465)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:410)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:241)
at java.lang.Thread.run(Thread.java:745)
...
我能解决这个问题。这里是解决方案:
1)我使用maven-jmeter插件和maven-jmeter分析插件。简单来说,通过maven项目运行jmeter。要解决SSLHandshakeException问题,请将您的maven命令放在jenkins作业中的“Execute Shell”区域而不是“目标”区域。我还将命令更改为“mvn -B -f ./pom.xml verify -s settings.xml”。
但是,在做了#1之后,我发现我的性能测试运行了两次。所以我遵循了解决方案#2。
2)我在jenkins而不是maven项目中使用了自由式项目。我把这个命令放在“Execute shell”区域。我正在'cmd失败'错误。这是由于老版本的maven被用在slave上。我指定了我想在奴隶上使用的maven的确切版本,并且工作正常。
这里是如何看起来像:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
export http_proxy=http://example.com:8080
export HTTP_PROXY=http://example.com:8080
export https_proxy=http://example.com:8080
export HTTPS_PROXY=http://example.com:8080
/usr/share/maven-3.3.9/bin/mvn -B -f ./pom.xml verify -s settings.xml -DSERVICE_P_NUM_OF_USERS=1 -DSERVICE_P_RAMP_UP_TIME=1
我已经看到了这个错误。然后我发现这个错误是由于Jenkins-slave的Java版本造成的。升级Java版本,看看它是否有帮助。
你是如何运行的詹金斯?作为Windows服务?如果是的话,我遇到了问题。推荐通过像'tomcat'等任何服务器来运行Jenkins .http://stackoverflow.com/questions/41163291/how-to-run-selenium-tests-using-testng-framework-and-jenkins –