Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-2921

Enable parallel test execution for compatible tests

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.21.0
    • Build, Tests
    • None

    Description

      One area to improve the execution time of our builds is to enable parallel test execution for all tests that can support that. Parallel tests are run in multiple threads on the same JVM rather than in forked JVMs (our current configuration). Thus, any tests that don't rely on JVM-global state (e.g., does not use environment variables, system properties, changing the default locale, shares an output file, etc.) should be able to support parallel test execution. Considering the amount of overhead introduced by JVM forks for every test, I'd hypothesize that this change could shave off at least 5-10 minutes from the total build time.

      JUnit 5 provides the ResourceLock annotation which can be used to create generic locks (similar to ReadWriteLock in Java) for various resources. It defines some default ones like for setting the locale, system properties, system out, system error, and the timezone. Any other shared resources outside those contexts could likely use custom string values for the annotation.

      Custom Resources

      • log4j2.MarkerManager (since MarkerManager uses a static map, tests that create non-trivial markers may interfere with each other)
      • log4j2.StatusLogger (covers both changing the logger level as well as relying on StatusData entries in the logger)
      • log4j2.TestLogger (this test class maintains static state)
      • log4j2.LoggerContextFactory (for tests that change LogManager.setFactory() or depend on the currently configured LoggerContextFactory via LogManager methods)
      • log4j2.Level (defining custom levels)
      • java.lang.SecurityManager (for tests setting a SecurityManager)

      JUnit and Surefire Options

      • junit.jupiter.execution.parallel.enabled = true
      • junit.jupiter.execution.parallel.mode.default = concurrent
      • <reuseForks>true</reuseForks>
      • <forkCount> is currently 1, though this might be useful to change to 1C

      Attachments

        Issue Links

          Activity

            People

              pkarwasz Piotr Karwasz
              mattsicker Matt Sicker
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: