December 3, 2016 at 9:00 pm #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)?December 4, 2016 at 10:31 am #14637
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.xmlfile 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=0as 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
forkCounthas the same effect, it just depends on what version of Surefire OpenDJ is using (
forkModeis deprecated in 2.14).December 5, 2016 at 9:04 am #14643JnRouvignacParticipant
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.
Jean-NoelJanuary 6, 2017 at 11:43 pm #15208
You must be logged in to reply to this topic.