我们在GitLab上有一个自动化项目,该项目使用我们专用的“外壳” GitLab运行器。项目本身是一个Selenium项目,它运行Cucumbers测试并生成报告。它最近在Jenkins上运行,没有任何问题。为了模拟Jenkins环境,我创建了一个外壳的GitLab运行程序,该运行程序在具有相同版本的计算机上安装了Java,Maven等。在线挖掘大量资源。从我的“主机”文件一直修改了所有内容。但是没有设法解决这个问题。
测试运行正常并生成报告。但是“生成报告部分”是不一致的。这意味着有时它无法生成Cucumber报告。这两天工作正常,第二天撞墙。
pom文件部分:
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
问题不是测试的执行,它们总是成功的。之后发生问题。Cucumber无法在很少的构建中一次生成报告,即使在代码方面和基础架构方面都没有改变。
这是测试成功后得到的错误:
[WARNING]
org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:23723 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'ip-XcensoredX', ip: 'ip-XcensoredX', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-1051-aws', java.version: '11.0.4'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute (DriverCommandExecutor.java:91)
at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:694)
at org.openqa.selenium.remote.RemoteWebDriver.quit (RemoteWebDriver.java:533)
at com.company.testautomation.util.WebDriverUtils.shutDown (WebDriverUtils.java:589)
at com.company.testautomation.CucumberRunner.<init> (CucumberRunner.java:142)
at com.company.testautomation.CucumberRunner.main (CucumberRunner.java:69)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:282)
at java.lang.Thread.run (Thread.java:834)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:23723 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect (DefaultHttpClientConnectionOperator.java:159)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect (PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute (MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute (MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute (ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute (RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute (RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute (InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute (CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute (CloseableHttpClient.java:56)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute (ApacheHttpClient.java:139)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute (ApacheHttpClient.java:87)
at org.openqa.selenium.remote.HttpCommandExecutor.execute (HttpCommandExecutor.java:161)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute (DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:694)
at org.openqa.selenium.remote.RemoteWebDriver.quit (RemoteWebDriver.java:533)
at com.company.testautomation.util.WebDriverUtils.shutDown (WebDriverUtils.java:589)
at com.company.testautomation.CucumberRunner.<init> (CucumberRunner.java:142)
at com.company.testautomation.CucumberRunner.main (CucumberRunner.java:69)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:282)
at java.lang.Thread.run (Thread.java:834)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect (Native Method)
at java.net.AbstractPlainSocketImpl.doConnect (AbstractPlainSocketImpl.java:399)
at java.net.AbstractPlainSocketImpl.connectToAddress (AbstractPlainSocketImpl.java:242)
at java.net.AbstractPlainSocketImpl.connect (AbstractPlainSocketImpl.java:224)
at java.net.SocksSocketImpl.connect (SocksSocketImpl.java:403)
at java.net.Socket.connect (Socket.java:591)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket (PlainConnectionSocketFactory.java:75)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect (DefaultHttpClientConnectionOperator.java:142)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect (PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute (MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute (MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute (ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute (RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute (RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute (InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute (CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute (CloseableHttpClient.java:56)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute (ApacheHttpClient.java:139)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute (ApacheHttpClient.java:87)
at org.openqa.selenium.remote.HttpCommandExecutor.execute (HttpCommandExecutor.java:161)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute (DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:694)
at org.openqa.selenium.remote.RemoteWebDriver.quit (RemoteWebDriver.java:533)
at com.company.testautomation.util.WebDriverUtils.shutDown (WebDriverUtils.java:589)
at com.company.testautomation.CucumberRunner.<init> (CucumberRunner.java:142)
at com.company.testautomation.CucumberRunner.main (CucumberRunner.java:69)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:282)
at java.lang.Thread.run (Thread.java:834)
[WARNING] thread Thread[OkHttp ConnectionPool,5,com.company.testautomation.CucumberRunner] was interrupted but is still alive after waiting at least 15000msecs
[WARNING] thread Thread[OkHttp ConnectionPool,5,com.company.testautomation.CucumberRunner] will linger despite being asked to die via interruption
[WARNING] thread Thread[Okio Watchdog,5,com.company.testautomation.CucumberRunner] will linger despite being asked to die via interruption
[WARNING] thread Thread[UrlChecker-19,5,com.company.testautomation.CucumberRunner] will linger despite being asked to die via interruption
[WARNING] NOTE: 3 thread(s) did not finish despite being asked to via interruption. This is not a problem with exec:java, it is a problem with the running code. Although not serious, it should be remedied.
[WARNING] Couldn't destroy threadgroup org.codehaus.mojo.exec.ExecJavaMojo$IsolatedThreadGroup[name=com.company.testautomation.CucumberRunner,maxpri=10]
java.lang.IllegalThreadStateException
at java.lang.ThreadGroup.destroy (ThreadGroup.java:776)
at org.codehaus.mojo.exec.ExecJavaMojo.execute (ExecJavaMojo.java:321)
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.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at 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 org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:29 h
[INFO] Finished at: 2019-11-29T00:17:20+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (Execute Cucumber tests) on project TestAutomation: An exception occured while executing the Java class. org.apache.http.conn.HttpHostConnectException: Connect to localhost:23723 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
[ERROR] Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
[ERROR] System info: host: 'ip-XcensoredX', ip: 'XcensoredX', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-1051-aws', java.version: '11.0.4'
[ERROR] Driver info: driver.version: RemoteWebDriver
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
并且构建失败。如果管道有效,那就好。如果不是,则需要修复。但是没有人希望拥有不稳定的管道。
提前致谢。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。