Docker->Maven->Failsafe->Surefire 启动分叉失败,并显示“分叉的 VM 在没有正确告别的情况下终止。虚拟机崩溃或系统退出调用?”

根据标题:我正在尝试从Jenkins奴隶运行Maven自动测试,该测试是容器化的,经过一周的斗争,现在我的想法已经用完了。它在具有4G RAM的AWS实例上按原样工作,但在不受限制的(在RAM和CPU)容器中,它会失败并出现如下错误。它运行时的唯一情况是当我禁用Forhelfare插件的分叉时,但这不是一个选项。

我尝试了各种Java / Maven / Failsafe / Surefire选项,我可以使用Google找到,但没有运气(例如添加全局Java -Xmx选项以及pom.xml中的每个插件)。

有没有人像这样成功运行它?

看起来这应该更容易处理,但是如果我有的话,我现在会把所有的头发都从我的头上拉下来。我仍然不喜欢承认失败的想法。请帮忙!

这些是插件在失败后创建的转储:

故障安全摘要.xml:

<?xml version="1.0" encoding="UTF-8"?>
<failsafe-summary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-sure
fire-plugin/xsd/failsafe-summary.xsd" result="254" timeout="false">
    <completed>0</completed>
    <errors>0</errors>
    <failures>0</failures>
    <skipped>0</skipped>
    <failureMessage>org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM cras
h or System.exit called?
Command was /bin/sh -c cd /var/lib/jenkins/workspace/ui_acceptance_test_chrome_docker_freestyle &amp;&amp; /usr/lib/jvm/java-1.8-openjdk/jre/bin/ja
va -Dfile.encoding=UTF-8 -jar /var/lib/jenkins/workspace/ui_acceptance_test_chrome_docker_freestyle/target/surefire/surefirebooter81206735832436906
05.jar /var/lib/jenkins/workspace/ui_acceptance_test_chrome_docker_freestyle/target/surefire 2017-10-10T15-02-35_189-jvmRun1 surefire59539140137458
58339tmp surefire_03559885505222114015tmp
Error occurred in starting fork, check output in log
Process Exit Code: 1
       at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:686)
       at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:535)
       at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:280)
       at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
       at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1124)
       at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:954)
       at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:832)
       at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
       at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
       at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
       at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
       at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
       at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
       at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
       at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
       at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:498)
       at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
       at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
       at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
       at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
</failureMessage>
</failsafe-summary>

2017-10-10T15-02-35_189-jvmRun1.dump:

# Created on 2017-10-10T15:02:36.303
Killing self fork JVM. Maven process died.

答案 1

尝试降级到 Surefire 1.18.1。我今晚遇到了这个问题,并花了几个小时来讨论它,到目前为止,还不清楚为什么Surefire的新版本在Docker下突破。

* 更新 *

我在Alpine Linux上遇到了一个问题,但是当使用Ubuntu或Debian基础映像时,一切都很好。因此,1.21中的某些内容正在破坏与某些操作系统的兼容性。


答案 2

我在以下环境中遇到了同样的问题:来自alpine 3.7的docker图像,maven surefire插件版本2.21.0。

SUREFIRE-1422 中描述了其根本原因:surefire 尝试使用来检查分叉进程。对我来说,解决方案是添加 procps:ps -p

RUN apk add --no-cache procps

推荐