繁体   English   中英

GitLab Runner 不一致:exec-maven-plugin:1.6.0:java org.apache.http.conn.HttpHostConnectException

[英]GitLab Runner Inconsistency: exec-maven-plugin:1.6.0:java org.apache.http.conn.HttpHostConnectException

我们在 GitLab 上有一个自动化项目,它使用我们专用的“shell”GitLab runner。 项目本身是一个运行 Cucumbers 测试并生成报告的 Selenium 项目。 它最近在 Jenkins 上运行没有任何问题。 为了模拟 Jenkins 环境,我创建了一个 shell GitLab runner,在相同版本的机器上安装了 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

并且构建失败。 如果管道有效,那很好。 如果没有,则需要修复。 但是拥有不稳定的管道是没有人想要的。

提前致谢。

添加

<properties>
    <java.version>...</java.version>
    <exec.mainClass>....<mainClass>
    <exec.cleanupDaemonThreads>false</exec.cleanupDaemonThreads>
</properties>

到您的 pom.xml 或添加

-Dexec.cleanupDaemonThreads=false

到命令行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM