Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-2114

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • None
    • None
    • Maven Surefire Plugin

    Description

      Hi Team, 

      I'm using maven surefire plugin (Latest Version) to execute tests on two testing frameworks (e.g, jUnit, jBehave).

      Have tried to implement parallelisation by spawning couple of Threads which in turn create processes to execute surefire jar, taking it from -

      ManagementFactory.getRuntimeMXBean().getSystemProperties().get("sun.java.command");

      Code snippet to show process creation - CustomRunner.java

        void run() {
          ProcessBuilder processBuilder = new ProcessBuilder(commandArray);
          Map<String, String> environment = processBuilder.environment();
          environment.put("platformIndex", String.valueOf(platformIndex));
          try {
              processBuilder.inheritIO();
              Process p = processBuilder.start();
              LOGGER.info("Is Alive {} {}", p.isAlive(), LocalTime.now());
              int statusCode = p.waitFor();
          } catch (Exception e) {
              e.printStackTrace();
          }
      }

      EntryPoint.java

      for (int i = 0; i < 3; i++) {
         Thread thread = new Thread(new CustomRunner(commandArray, String.valueOf(i)));
         thread.start();
         threadList.add(thread);
       }
      threadList.forEach(thread -> {
         try {
           thread.join();
         } catch (InterruptedException e) {
           throw new RuntimeException(e);
         }
      });
          
      System.exit(exitcode);

      After running two or sometimes three processes in corresponding Threads, the process execution got stuck on p.waitFor();

      Then the process exits after 30 secs and with error message "Surefire is going to kill self fork JVM. The exit has elapsed 30 seconds after System.exit(0)." resulting in Build Failure (sometimes it doesn't) though the tests have passed in their respective processes.

      Seems like surefire execution is stuck in some processes. Could you please let me know what can be the possible reasons for it and how to mitigate this? Tried extending the ForkedProcessTimeoutInSeconds to few minutes but no luck.

      Any help is much appreciated.

      Attachments

        1. surefire.log
          64 kB
          Kamalpreet

        Activity

          People

            Unassigned Unassigned
            kamalpreet.k Kamalpreet
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: