spring-bootgithub-actionscicdmaven-surefire-plugin

Error: Surefire is going to kill self fork JVM. The exit has elapsed 30 seconds after System.exit(0)


I've got a Spring Boot (not web) project that has unit tests that produce child process. These processes take some time to be completed after main thread is completed.

The tests are done by GitHub action with mvn package command.

This command will throw an error

Error: Surefire is going to kill self fork JVM. The exit has elapsed 30 seconds after System.exit(0)

As mentioned in similar question and in maven-surefire-plugin docs, I have to either set surefire.exitTimeout or <forkedProcessExitTimeoutInSeconds> property with increased value in seconds. But it's not really clear where I can set that property.

I tried the following:

<project>
    <properties>
        <forkedProcessTimeoutInSeconds>60</forkedProcessTimeoutInSeconds>
        <surefire.timeout>60</surefire.timeout>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <additionalProperties>
                        <forkedProcessTimeoutInSeconds>60</forkedProcessTimeoutInSeconds>
                        <surefire.timeout>60</surefire.timeout>
                    </additionalProperties>
                    <arguments>
                        <argument>--forkedProcessTimeoutInSeconds=60</argument>
                        <argument>--surefire.timeout=60</argument>
                    </arguments>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

But all the options above are ignored by maven-surefire-plugin.

Could you please suggest me how can I increase timeout?

My pom.xml: https://github.com/yvasyliev/reddit-telegram-forwarder/blob/3.0.0/pom.xml


Solution

  • I found a solution:

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <forkedProcessExitTimeoutInSeconds>60</forkedProcessExitTimeoutInSeconds>
                </configuration>
            </plugin>
        </plugins>
    </build>