Tagged: , ,

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of GuyPaddock GuyPaddock 4 months, 2 weeks ago.

  • Author
    Posts
  • #14636
    Profile photo of GuyPaddock GuyPaddock 
    Participant

    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)?

    #14637
    Profile photo of GuyPaddock GuyPaddock 
    Participant

    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:
    http://blog2.vorburger.ch/2016/06/improve-maven-build-speed-with-q.html

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

    <profile>
      <!-- (Q)uick profile, for running phases quickly
    
      Inspired by:
      http://blog2.vorburger.ch/2016/06/improve-maven-build-speed-with-q.html
      -->
      <id>q</id>
      <properties>
        <assembly.skipAssembly>true</assembly.skipAssembly>
        <checkstyle.skip>true</checkstyle.skip>
        <enforcer.skip>true</enforcer.skip>
        <findbugs.skip>true</findbugs.skip>
        <ignoreCopyrightErrors>true</ignoreCopyrightErrors>
        <invoker.skip>true</invoker.skip>
        <jacoco.skip>true</jacoco.skip>
        <maven.antrun.skip>true</maven.antrun.skip>
        <maven.clean.skip>true</maven.clean.skip>
        <maven.javadoc.skip>true</maven.javadoc.skip>
        <maven.source.skip>true</maven.source.skip>
        <maven.site.skip>true</maven.site.skip>
    
        <!-- The next one is counter-intuitive.
        See:
        http://stackoverflow.com/questions/17944108/maven-compiler-plugin-always-detecting-a-set-of-sources-as-stale
        -->
        <maven.compiler.useIncrementalCompilation>false</maven.compiler.useIncrementalCompilation>
      </properties>
    </profile>

    (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 months, 2 weeks ago by Profile photo of GuyPaddock GuyPaddock. Reason: Formatting
    • This reply was modified 4 months, 2 weeks ago by Profile photo of GuyPaddock GuyPaddock. Reason: Fixed profile argument
    #14643
    Profile photo of JnRouvignac JnRouvignac 
    Participant

    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.

    Cheers,
    Jean-Noel

    #15208
    Profile photo of GuyPaddock GuyPaddock 
    Participant

    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 4 months, 2 weeks ago by Profile photo of GuyPaddock GuyPaddock.
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

©2017 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?