Docker->Maven->Failsafe->Surefire starting fork fails with “The forked VM terminated without properly saying goodbye. VM crash or System.exit called?”

前端 未结 8 1975
生来不讨喜
生来不讨喜 2020-12-30 04:51

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

相关标签:
8条回答
  • 2020-12-30 05:25

    I have encountered the same issue in the following environment: docker image from alpine 3.7, maven surefire plugin version 2.21.0.

    The root cause of that is described at SUREFIRE-1422: surefire tries to use ps -p to check forked process. The solution for me was to add procps:

    RUN apk add --no-cache procps
    
    0 讨论(0)
  • 2020-12-30 05:26

    Just hit the same problem when building inside maven:3.5.4-jdk-8 using surefire 2.21.0. Upgrading surefire didn't help either, but disabling forking finally did the trick.

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.1</version>
        <configuration>
            <forkCount>0</forkCount>
        </configuration>
    </plugin>
    
    0 讨论(0)
  • 2020-12-30 05:29

    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.

    * Update *

    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.

    0 讨论(0)
  • 2020-12-30 05:32

    I couldn't fix this no matter how hard I tried. Removed java 11 and installed java 8 fixed everything.

    sudo add-apt-repository ppa:openjdk-r/ppa -y
    sudo apt update
    sudo apt install openjdk-8-jdk openjdk-8-jre
    
    0 讨论(0)
  • 2020-12-30 05:39

    We suddenly experienced the exact same issue, but only on our CI/CD pipeline (gitlab). The error message was:

    error occurred in starting fork, check output in log
    Process Exit Code: 1
    org.apache.maven.surefire.booter.SurefireBooterForkException: 
    The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
    

    It turned out that it was related to a new version of the OpenJDK docker image.

    Setting the useSystemClassLoader property to false solved the issue:

       <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
        <configuration>
          <includes>
            <include>**/*Test.java</include>
          </includes>
          <useSystemClassLoader>false</useSystemClassLoader>
        </configuration>
      </plugin>
    
    0 讨论(0)
  • 2020-12-30 05:44

    I know it's been a while but will add my solution to the problem which took me more than a day to FIX.

    Problem: I'm running my integration tests in the PaaS in a docker container and have no control on the memory allocation for my process. the default behavior is for failsafe/surfire to fork a JVM and run the tests on it. I could not find a way to control the memory allocation for that forked JVM and tests kept failing with the error "Error occurred in starting fork" also saw "The forked VM terminated without saying properly goodbye docker" in the logs depending on which version of failsafe I was trying.

    Solution: My solution was to disable forking of the JVM and have all the tests run in the same JVM as the main maven process, now this may not be the ideal solution for many but it would work if you can only control the max memory allocation of the main maven process.

    To disable forking it's as simple as setting the forkMode in the config:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <configuration>
            <forkCount>0</forkCount>
        </configuration>
    

    .....

    UPDATE: Since giving this solution it seems like you can now pass params to the forked JVM so shouldn't need the earlier solution.

    From the maven docs under Forked Test Execution:

    With the argLine property, you can specify additional parameters to be passed to the forked JVM process, such as memory settings. System property variables from the main maven process are passed to the forked process as well. Additionally, you can use the element systemPropertyVariables to specify variables and values to be added to the system properties during the test execution.

    https://maven.apache.org/surefire/maven-failsafe-plugin/examples/fork-options-and-parallel-execution.html

    0 讨论(0)
提交回复
热议问题