From 46ab6a1533b3d936925fe46687902150c7cbdab2 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Mon, 25 Nov 2013 14:35:12 +0100 Subject: [PATCH] Include JVM Arg line in reproduce line --- pom.xml | 11 +++++- .../junit/listeners/ReproduceInfoPrinter.java | 36 +++++++++++++++---- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 1a6f59e7a10..e0b772d9474 100644 --- a/pom.xml +++ b/pom.xml @@ -35,11 +35,11 @@ true onerror + ${env.ES_TESTS_JVM_OPTION1} ${env.ES_TESTS_JVM_OPTION2} ${env.ES_TESTS_JVM_OPTION3} ${env.ES_TESTS_JVM_OPTION4} - INFO @@ -370,6 +370,9 @@ **/Abstract*.class **/*StressTest.class + + ${tests.jvm.argline} + ${tests.jvm.option1} ${tests.jvm.option2} @@ -385,6 +388,12 @@ ${tests.failfast} + ${tests.jvm.argline} + + ${tests.jvm.option1} + ${tests.jvm.option2} + ${tests.jvm.option3} + ${tests.jvm.option4} ${tests.iters} ${tests.maxfailures} ${tests.failfast} diff --git a/src/test/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java b/src/test/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java index ed4a7ed6831..2bd8151204c 100644 --- a/src/test/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java +++ b/src/test/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java @@ -14,6 +14,8 @@ import org.junit.runner.notification.Failure; import org.junit.runner.notification.RunListener; import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; /** * A {@link RunListener} that emits to {@link System#err} a string with command @@ -72,6 +74,7 @@ public class ReproduceInfoPrinter extends RunListener { @Override public ReproduceErrorMessageBuilder appendAllOpts(Description description) { super.appendAllOpts(description); + appendJVMArgLine(); return appendESProperties(); } @@ -87,15 +90,36 @@ public class ReproduceInfoPrinter extends RunListener { } return this; } - + public ReproduceErrorMessageBuilder appendESProperties() { for (String sysPropName : Arrays.asList( - "es.logger.level", "es.node.mode", "es.node.local")) { - if (System.getProperty(sysPropName) != null && !System.getProperty(sysPropName).isEmpty()) { - appendOpt(sysPropName, System.getProperty(sysPropName)); - } + "es.logger.level", "es.node.mode", "es.node.local")) { + if (System.getProperty(sysPropName) != null && !System.getProperty(sysPropName).isEmpty()) { + appendOpt(sysPropName, System.getProperty(sysPropName)); + } } return this; - } + } + + public ReproduceErrorMessageBuilder appendJVMArgLine() { + StringBuilder builder = new StringBuilder(); + Set values = new HashSet(); + for (String sysPropName : Arrays.asList( + "tests.jvm.option1", "tests.jvm.option2", "tests.jvm.option3", "tests.jvm.option4", "tests.jvm.argline")) { + if (System.getProperty(sysPropName) != null && !System.getProperty(sysPropName).isEmpty()) { + String propValue = System.getProperty(sysPropName).trim(); + if (!values.contains(propValue)) { + builder.append(propValue); + values.add(propValue); // deduplicate + builder.append(' '); + } + } + } + if (builder.length() > 0) { + appendOpt("tests.jvm.argline", "\"" + builder.toString().trim() + "\""); + } + + return this; + } } }