From a1d5267ad320c22fd6ec021f3674e68c687e9f04 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Tue, 5 Jul 2016 16:48:32 +0200 Subject: [PATCH] Option to performance profile SingleFeatureTest with Java Mission Control FlightRecorder via -Dkaraf.featureTest.profile=true Change-Id: I7450f44bb4543718253bda742d111c5050d5bf2b Signed-off-by: Michael Vorburger --- .../odlparent/featuretest/SingleFeatureTest.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/features-test/src/main/java/org/opendaylight/odlparent/featuretest/SingleFeatureTest.java b/features-test/src/main/java/org/opendaylight/odlparent/featuretest/SingleFeatureTest.java index 8798a54ab..54e4726ed 100644 --- a/features-test/src/main/java/org/opendaylight/odlparent/featuretest/SingleFeatureTest.java +++ b/features-test/src/main/java/org/opendaylight/odlparent/featuretest/SingleFeatureTest.java @@ -51,12 +51,15 @@ import org.slf4j.LoggerFactory; @RunWith(PerRepoTestRunner.class) public class SingleFeatureTest { + private static final String MAVEN_REPO_LOCAL = "maven.repo.local"; private static final String ORG_OPS4J_PAX_URL_MVN_LOCAL_REPOSITORY = "org.ops4j.pax.url.mvn.localRepository"; private static final String ORG_OPS4J_PAX_URL_MVN_REPOSITORIES = "org.ops4j.pax.url.mvn.repositories"; private static final String ETC_ORG_OPS4J_PAX_URL_MVN_CFG = "etc/org.ops4j.pax.url.mvn.cfg"; private static final String ETC_ORG_OPS4J_PAX_LOGGING_CFG = "etc/org.ops4j.pax.logging.cfg"; private static final String KEEP_UNPACK_DIRECTORY_PROP = "karaf.keep.unpack"; + private static final String PROFILE_PROP = "karaf.featureTest.profile"; + 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); @@ -118,6 +121,12 @@ public class SingleFeatureTest { // TODO: Find a way to inherit memory limits from Maven options. new VMOption("-Xmx2g"), new VMOption("-XX:MaxPermSize=512m"), + when(Boolean.getBoolean(PROFILE_PROP)).useOptions( + new VMOption("-XX:+UnlockCommercialFeatures"), + new VMOption("-XX:+FlightRecorder"), + new VMOption("-XX:FlightRecorderOptions=defaultrecording=true,dumponexit=true,dumponexitpath=" + + getNewJFRFile()) + ), getKarafDistroOption(), when(Boolean.getBoolean(KEEP_UNPACK_DIRECTORY_PROP)).useOptions(keepRuntimeFolder()), configureConsole().ignoreLocalConsole(), @@ -160,6 +169,10 @@ public class SingleFeatureTest { }; } + private String getNewJFRFile() throws IOException { + return File.createTempFile("SingleFeatureTest-Karaf-JavaFlightRecorder", ".jfr").getAbsolutePath(); + } + private Option standardKarafFeatures() throws IOException { String url = maven().groupId("org.apache.karaf.features").artifactId("standard").classifier("features").type( "xml").version(getKarafVersion()).getURL(); -- 2.36.6