Hi noble Jenkins developers,
I am wondering how to make my unit tests (well, they're integration ones in reality, aren't they), based on Jenkins Unit test harness, faster.
I have like 35 tests, and it takes approximately 9 minutes to execute them. I want to reduce this time. I use the default Surefire settings, and if I try to play around with forking options like advised on Surefire page
https://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html, I run into different problems.
For example, if I set configuration
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<systemProperties>
<property>
<name>hudson.udp</name>
<value>33849</value>
</property>
</systemProperties>
<reuseForks>true</reuseForks>
<forkCount>5</forkCount>
</configuration>
</plugin>
I get errors like
Caused by: java.nio.file.FileSystemException: C:\Users\me\AppData\Local\Temp\hudson4898380288667948066test\jobs\test0\builds\2015-11-12_14-44-25\log: The process cannot access the file because it is being used by another process.
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:269)
If I use more sophisticated configuration like
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<systemProperties>
<property>
<name>hudson.udp</name>
<value>33849</value>
</property>
</systemProperties>
<reuseForks>true</reuseForks>
<forkCount>2</forkCount>
<parallel>classes</parallel>
<threadCount>5</threadCount>
</configuration>
</plugin>
I get errors like:
testJobSetup(com.myproject.BuildStepConfigurationTest) Time elapsed: 0.158 sec <<< ERROR!
java.lang.IllegalStateException: second instance
....
SEVERE: Timer task hudson.model.Queue$MaintainTask@a4da332 failed
java.lang.NullPointerException
at hudson.model.Queue.maintain(Queue.java:994)
at hudson.model.Queue$MaintainTask.doRun(Queue.java:2033)
....
testJobSetup2(com.myproject.BuildStepConfigurationTest) Time elapsed: 0.201 sec <<< ERROR!
java.lang.NullPointerException: null
at hudson.ProxyConfiguration.getXmlFile(ProxyConfiguration.java:202)
at hudson.ProxyConfiguration.load(ProxyConfiguration.java:206)
at jenkins.model.Jenkins.<init>(Jenkins.java:782)
at hudson.model.Hudson.<init>(Hudson.java:82)
....
If I run tests with default Surefire settings, it takes about 9 minutes, but at least the tests run fine.
Are there any guidelines about how to make unit tests run as fast as possible? How to tune Surefire, etc.
Thanks in advance!
Regards,
Kirill.