Showing posts with label Maven2. Show all posts
Showing posts with label Maven2. Show all posts

Friday, June 27, 2008

Increasing memory of JUnit TestCases in Maven2

The WSO2 Mashup Server uses Maven2 as its build system. Since of late we were facing an issue where our integration tests were failing regularly with the exception "Caused by: java.lang.OutOfMemoryError: Java heap space". This is the JIRA that tracked this issue . During the integration test phase we start up an instance of the mashup server and deploy some test scripts. We them bombard the server with around 110 request (within a second or two) hence it ran out of memory before the tests completed.

Increasing memory given to maven using MAVEN_OPTS did not solve the problem. As this setting just increases the memory given to the build process and not the individual test cases. The solution was to use the following configuration in the surefire plugin.


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>pertest</forkMode>
<argLine>-Xms256m -Xmx512m</argLine> <testFailureIgnore>false</testFailureIgnore>
<skip>false</skip>
<includes>
<include>**/*IntegrationTestSuite.java</include>
</includes>
</configuration>
</plugin>


The pom for the integration test can be found here. This fixed the heap space issue and now we have our test cases running on the nightly build. You can see the status of our nightly builds at http://builder.wso2.org/browse/MASHUP-NIGHTLY