Make SingleFeatureTest max heap size configurable 62/61462/4
authorVratko Polak <vrpolak@cisco.com>
Mon, 7 Aug 2017 10:11:15 +0000 (12:11 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 11 Aug 2017 07:45:41 +0000 (07:45 +0000)
Currently, CSIT jobs of -only- type use 2GB of heap and CSIT
of -all- type use 3GB. But we are seeing occasional failures
in distribution, especially odl-integration-all feature can take
more heap than usual.

Address the TODO item by allowing maximum heap size to be specified
as a system property -- thus can be overridden by downstreams in
their pom.xml.

Change-Id: I84adda01f3bd20180c6d81d3da807d38b5af6fa1
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1aa0ac18166b3183e7733b50612f9706efa3c8b9)

features-test/src/main/java/org/opendaylight/odlparent/featuretest/SingleFeatureTest.java

index b902c4ded168af30b944c30c0d1e4ee3a365823a..be65e1c574e41b5ace867cdb1f1fc3bdfd511c82 100644 (file)
@@ -70,6 +70,10 @@ public class SingleFeatureTest {
     private static final String BUNDLES_DIAG_FORCE_PROP = "sft.diag.force";
     private static final String BUNDLES_DIAG_TIMEOUT_PROP = "sft.diag.timeout";
 
+    // Maximum heap size
+    private static final String HEAP_MAX_PROP = "sft.heap.max";
+    private static final String DEFAULT_HEAP_MAX = "2g";
+
     private static final String LOG4J_LOGGER_ORG_OPENDAYLIGHT_YANGTOOLS_FEATURETEST =
             "log4j.logger.org.opendaylight.odlparent.featuretest";
     private static final Logger LOG = LoggerFactory.getLogger(SingleFeatureTest.class);
@@ -125,7 +129,7 @@ public class SingleFeatureTest {
     private String karafDistroVersion;
 
     @ProbeBuilder
-    public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
+    public TestProbeBuilder probeConfiguration(final TestProbeBuilder probe) {
         // add this to test Karaf Commands, according to green Karaf book
         // also see http://iocanel.blogspot.ch/2012/01/advanced-integration-testing-with-pax.html
         // probe.setHeader(org.osgi.framework.Constants.DYNAMICIMPORT_PACKAGE, "*;status=provisional");
@@ -152,9 +156,11 @@ public class SingleFeatureTest {
      */
     @Configuration
     public Option[] config() throws IOException {
+        final String envMaxHeap = System.getenv(HEAP_MAX_PROP);
+        final String maxHeap = envMaxHeap != null ? envMaxHeap : DEFAULT_HEAP_MAX;
+
         return new Option[] {
-            // TODO: Find a way to inherit memory limits from Maven options.
-            new VMOption("-Xmx2g"),
+            new VMOption("-Xmx" + maxHeap),
             new VMOption("-XX:+HeapDumpOnOutOfMemoryError"),
             new VMOption("-XX:OnOutOfMemoryError=\"kill -3 %p\""),
             // inspired by org.apache.commons.lang.SystemUtils
@@ -213,7 +219,7 @@ public class SingleFeatureTest {
         };
     }
 
-    private String getNewJFRFile() throws IOException {
+    private static String getNewJFRFile() throws IOException {
         return File.createTempFile("SingleFeatureTest-Karaf-JavaFlightRecorder", ".jfr").getAbsolutePath();
     }