Jenkins突然退出测试

huangapple go评论72阅读模式
英文:

Jenkins quits tests suddenly

问题

以下是翻译的内容:

我正在使用Java Maven从Jenkins执行TestNg测试,一切似乎都正常,但Jenkins会随机停止执行测试并提示:

[ERROR] 会话ID为空。在调用quit()后继续使用WebDriver?
构建信息:版本:'4.0.0-alpha-6',修订版本:'5f43a29cfc'
系统信息:主机:'******',IP:'172.**.**.**',os.name:'Windows 10',os.arch:'amd64',os.version:'10.0',java.version:'11.0.8'
驱动程序信息:driver.version:RemoteWebDriver
[INFO]
[INFO] 结果:
[INFO]
[INFO] 运行的测试:0,失败:0,错误:0,跳过:0
[INFO]
[ERROR] 存在测试失败。
驱动程序信息:driver.version:RemoteWebDriver
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:733)
...
at java.base/java.lang.Thread.run(Thread.java:834)
[JENKINS] 正在记录测试结果
[Checks API] 找不到合适的检查发布者。
[INFO] ------------------------------------------------------------------------
[INFO] 构建成功
[INFO] ------------------------------------------------------------------------
[INFO] 总时间:45:28 分钟
[INFO] 完成时间:2020-09-30T17:33:07+02:00
[INFO] ------------------------------------------------------------------------
当我在我的笔记本电脑上运行测试时,这种情况不会发生(Jenkins位于Windows虚拟机上)。
是什么原因导致了这个问题呢?
<details>
<summary>英文:</summary>
I am executing TestNg tests with Java Maven from Jenkins and everything seems to be okay but Jenkins stops executing the tests randomly and prompts:
[ERROR] Session ID is null. Using WebDriver after calling quit()?
Build info: version: &#39;4.0.0-alpha-6&#39;, revision: &#39;5f43a29cfc&#39;
System info: host: &#39;******&#39;, ip: &#39;172.**.**.**&#39;, os.name: &#39;Windows 10&#39;, os.arch: &#39;amd64&#39;, os.version: &#39;10.0&#39;, java.version: &#39;11.0.8&#39;
Driver info: driver.version: RemoteWebDriver
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[ERROR] There are test failures.
Driver info: driver.version: RemoteWebDriver
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:733)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:305)
at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:265)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1314)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:1159)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:932)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.jvnet.hudson.maven3.launcher.Maven35Launcher.main(Maven35Launcher.java:130)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
at jenkins.maven3.agent.Maven35Main.launch(Maven35Main.java:178)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:139)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:70)
at hudson.remoting.UserRequest.perform(UserRequest.java:211)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:369)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
[JENKINS] Recording test results
[Checks API] No suitable checks publisher found.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  45:28 min
[INFO] Finished at: 2020-09-30T17:33:07+02:00
[INFO] ------------------------------------------------------------------------
This does not happen when i run the tests in my laptop (jenkins is on a windows vm).
What could cause this problem?
</details>
# 答案1
**得分**: 0
```xml
我的可靠配置:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myProject</groupId>
<artifactId>myProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>7</maven.compiler.source>
<maven.compiler.target>7</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>anotherJavaProject</groupId>
<artifactId>anotherJavaProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
这是 testng.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite">
<listeners>
<listener class-name="listeners.TestNGListeners"></listener>
</listeners>
<test name="test1">
<parameter name="package" value="registration" />
<parameter name="iterationstorun" value="1,2" />
<parameter name="resource" value="src/main/resources/excel/test1.xlsx" />
<parameter name="browser" value="chrome" />
<parameter name="exitonfail" value="no" />
<parameter name="email" value="yes" />
<classes>
<class name="utils.Class" />
</classes>
</test>
<test name="test2">
<parameter name="package" value="registration" />
<parameter name="iterationstorun" value='1,2' />
<parameter name="resource" value="src/main/resources/excel/test2.xlsx" />
<parameter name="browser" value="chrome" />
<parameter name="exitonfail" value="no" />
<classes>
<class name="utils.Class" />
</classes>
</test>
</suite>
英文:

My surefire:

&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;groupId&gt;myProject&lt;/groupId&gt;
&lt;artifactId&gt;myProject&lt;/artifactId&gt;
&lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
&lt;properties&gt;
&lt;maven.compiler.source&gt;7&lt;/maven.compiler.source&gt;
&lt;maven.compiler.target&gt;7&lt;/maven.compiler.target&gt;
&lt;/properties&gt;
&lt;build&gt;
&lt;plugins&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
&lt;version&gt;3.0.0-M5&lt;/version&gt;
&lt;configuration&gt;
&lt;suiteXmlFiles&gt;
&lt;suiteXmlFile&gt;testng.xml&lt;/suiteXmlFile&gt;
&lt;/suiteXmlFiles&gt;
&lt;/configuration&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/build&gt;
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;anotherJavaProject&lt;/groupId&gt;
&lt;artifactId&gt;anotherJavaProject&lt;/artifactId&gt;
&lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;/project&gt;

and this is the testng.xml file:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE suite SYSTEM &quot;https://testng.org/testng-1.0.dtd&quot;&gt;
&lt;suite name=&quot;Suite&quot;&gt;
&lt;listeners&gt;
&lt;listener class-name=&quot;listeners.TestNGListeners&quot;&gt;&lt;/listener&gt;
&lt;/listeners&gt;
&lt;test name=&quot;test1&quot;&gt;
&lt;parameter name=&quot;package&quot; value=&quot;registration&quot; /&gt;
&lt;parameter name=&quot;iterationstorun&quot; value=&quot;1,2&quot; /&gt;
&lt;parameter name=&quot;resource&quot;
value=&quot;src/main/resources/excel/test1.xlsx&quot; /&gt;
&lt;parameter name=&quot;browser&quot; value=&quot;chrome&quot; /&gt;
&lt;parameter name=&quot;exitonfail&quot; value=&quot;no&quot; /&gt;
&lt;parameter name=&quot;email&quot; value=&quot;yes&quot; /&gt;
&lt;classes&gt;
&lt;class name=&quot;utils.Class&quot; /&gt;
&lt;/classes&gt;
&lt;/test&gt;    
&lt;test name=&quot;test2&quot;&gt;
&lt;parameter name=&quot;package&quot; value=&quot;registration&quot; /&gt;
&lt;parameter name=&quot;iterationstorun&quot; value=&#39;1,2&#39; /&gt;
&lt;parameter name=&quot;resource&quot;
value=&quot;src/main/resources/excel/test2.xlsx&quot; /&gt;
&lt;parameter name=&quot;browser&quot; value=&quot;chrome&quot; /&gt;
&lt;parameter name=&quot;exitonfail&quot; value=&quot;no&quot; /&gt;
&lt;classes&gt;
&lt;class name=&quot;utils.Class&quot; /&gt;
&lt;/classes&gt; 
&lt;/test&gt;   
&lt;/suite&gt;

答案2

得分: 0

使用Eclipse运行测试时,我发现问题出现在extent报告中。
我认为问题可能是这个:https://github.com/anshooarora/extentreports-java/issues/497

Jenkins没有记录任何关于这个问题的信息:

java.lang.OutOfMemoryError: Java heap space
at java.base/java.lang.StringCoding$StringDecoder.decode(StringCoding.java:195)
at java.base/java.lang.StringCoding.decode(StringCoding.java:331)
at java.base/java.lang.String.<init>(String.java:592)
at java.base/java.lang.String.<init>(String.java:614)
at com.aventstack.extentreports.append.JsonDeserializer.deserialize(JsonDeserializer.java:27)
at com.aventstack.extentreports.append.RawEntityConverter.convertAndApply(RawEntityConverter.java:27)
at com.aventstack.extentreports.AbstractProcessor.convertRawEntities(AbstractProcessor.java:98)
at com.aventstack.extentreports.ExtentReports.createDomainFromJsonArchive(ExtentReports.java:377)
at com.aventstack.extentreports.ExtentReports.createDomainFromJsonArchive(ExtentReports.java:392)
at utils.ExcelDataProvider.test(ExcelDataProvider.java:126)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:135)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:598)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:821)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at org.testng.TestRunner$$Lambda$87/0x0000000100158840.accept(Unknown Source)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:588)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
英文:

Running the test with Eclipse I found out that the problem is in the extent report.
I think this is the issue: https://github.com/anshooarora/extentreports-java/issues/497

Jenkins wasn't logging anything of this:

java.lang.OutOfMemoryError: Java heap space
at java.base/java.lang.StringCoding$StringDecoder.decode(StringCoding.java:195)
at java.base/java.lang.StringCoding.decode(StringCoding.java:331)
at java.base/java.lang.String.&lt;init&gt;(String.java:592)
at java.base/java.lang.String.&lt;init&gt;(String.java:614)
at com.aventstack.extentreports.append.JsonDeserializer.deserialize(JsonDeserializer.java:27)
at com.aventstack.extentreports.append.RawEntityConverter.convertAndApply(RawEntityConverter.java:27)
at com.aventstack.extentreports.AbstractProcessor.convertRawEntities(AbstractProcessor.java:98)
at com.aventstack.extentreports.ExtentReports.createDomainFromJsonArchive(ExtentReports.java:377)
at com.aventstack.extentreports.ExtentReports.createDomainFromJsonArchive(ExtentReports.java:392)
at utils.ExcelDataProvider.test(ExcelDataProvider.java:126)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:135)
at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:598)
at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174)
at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:821)
at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at org.testng.TestRunner$$Lambda$87/0x0000000100158840.accept(Unknown Source)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:588)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
at org.testng.SuiteRunner.run(SuiteRunner.java:286)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)

huangapple
  • 本文由 发表于 2020年9月30日 23:41:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/64141108.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定