Docker->Maven->Failsafe->Surefire 启动 fork 失败,并显示“分叉的虚拟机在没有正确告别的情况下终止.虚拟机崩溃或调用 System.exit?"

根据标题:我正在尝试从容器化的 Jenkins slave 运行 Maven 自动化测试,在与此作斗争一周后,我的想法已经不多了.它在具有 4G RAM 的 AWS 实例上按原样工作,但在不受限制的(在 RAM 和 CPU 上)容器中,它失败并出现如下错误.它运行的唯一情况是我禁用了 Failsafe 插件的分叉,但这不是未来的选择.

As per title: I'm trying to run Maven automated test from Jenkins slave that is containerized and after battling this for a week now I'm running out of ideas. It works as is on AWS instance with 4G of RAM but in unrestricted (on RAM and CPU) container it fails with error like below. The only circumstances when it runs is when I disable forking for Failsafe plugin but that is not an option going forward.

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

I tried all sorts of Java/Maven/Failsafe/Surefire options I could have found using Google but no luck (like adding global Java -Xmx options and also per plugin in pom.xml).

有人这样成功运行过吗?

Has anyone ran it successfully like this?

看起来这应该更容易处理,但如果我有头发的话,我现在已经把头上的所有头发都拔掉了.我仍然不喜欢承认失败的想法.请帮忙!

It would seem this should be a lot easier to deal with but I'd would have pulled by now all hair from my head should I have any. I still don't like the idea of admitting the defeat. Please help!

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

These are the dumps the plugin creates after failure:

failsafe-summary.xml:

failsafe-summary.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:

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

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

推荐答案

尝试降级到 Surefire 1.18.1.今晚我遇到了这个问题并花了几个小时,到目前为止,为什么新版本的 Surefire 在 Docker 下会中断并不容易.

Try downgrading to Surefire 1.18.1. I ran into this issue tonight and spent a couple hours on it, so far it's not easily apparent why newer builds of Surefire break under Docker.

* 更新 *

我在使用 Alpine linux 时遇到了问题,但是当使用 Ubuntu 或 Debian 基础映像时,一切都很好.所以 1.21 中的某些东西破坏了与某些操作系统的兼容性.

I was having an issue with Alpine linux, but when using an Ubuntu or Debian base image everything was fine. So something within 1.21 is breaking compatibility with certain operating systems.

相关文章