Tagged: , ,

This topic has 3 replies, 2 voices, and was last updated 5 years, 6 months ago by GuyPaddock.

  • Author
  • #14636

    We’re working on an extension to OpenDJ and are leveraging the existing test framework in, among other modules, opendj-server-legacy. However, the cycle time between making test edits and running the tests seems to still be around 3-5 mins because of all the other build steps, even when run in only that Maven module.

    This is the command being run: mvn integration-test -Pprecommit -DignoreCopyrightErrors=true

    Is there another Maven command to run JUST the tests, if ONLY the test code has changed (i.e. compile only the tests, and run them)?


    Okay, after spending pretty much the entire day writing a test and having to wait for builds, I came up with an answer to my own question.

    The answer is that it doesn’t seem possible to run the tests directly because of the way that files are unpacked, copied, and compiled. The normal tricks for invoking “Surefire” (the Maven plugin being used to run the tests) directly therefore won’t work here.

    However, it is possible to skip most of the phases that are time consuming leading up to the tests themselves, taking the cycle time from around 5-10 mins on my machine for “opendj-server-legacy” down to about 30 secs to 1 min.

    Most of the inspiration for this approach comes from:

    Step #1: Define a new profile called “q” in the opendj-server-legacy/pom.xml file that is as follows:

      <!-- (Q)uick profile, for running phases quickly
      Inspired by:
        <!-- The next one is counter-intuitive.

    (For a complete example file, see: https://gist.github.com/GuyPaddock/da0a652a6cba285d37cd4953a181c4e7)

    Step #2: Shorten the JRE’s spin-up time for Maven by disabling some of the JRE’s run-time optimizations.
    export MAVEN_OPTS="-client -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xverify:none"

    Step #3: Invoke the integration tests with the following command:
    mvn -Pq,precommit integration-test

    Also note that if you are trying to debug tests through an IDE like IntelliJ, you’ll also want to pass -DforkMode=never -DforkCount=0 as arguments. This guarantees that tests are executed within the Maven process instead of in a separate process, so that the IDE debugger can remain attached during the testing process. Technically, both forkMode and forkCount has the same effect, it just depends on what version of Surefire OpenDJ is using (forkMode is deprecated in 2.14).

    • This reply was modified 5 years, 7 months ago by GuyPaddock. Reason: Formatting
    • This reply was modified 5 years, 6 months ago by GuyPaddock. Reason: Fixed profile argument

    Hi Guy,

    I think you summed it all up: it is currently not possible to do this simply.
    Thanks for your analysis and detailed report, I am sure it will help people that want to do the same as you.



    Just realized that the command I posted should be a capital letter “P”, not lowercase. So, it should be:

    mvn -Pq,precommit integration-test

    Okay, just updated the original post.

    • This reply was modified 5 years, 6 months ago by GuyPaddock.
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

©2022 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?