Include JVM Arg line in reproduce line

This commit is contained in:
Simon Willnauer 2013-11-25 14:35:12 +01:00
parent 32d073bbf8
commit 46ab6a1533
2 changed files with 40 additions and 7 deletions

11
pom.xml
View File

@ -35,11 +35,11 @@
<tests.shuffle>true</tests.shuffle> <tests.shuffle>true</tests.shuffle>
<tests.output>onerror</tests.output> <tests.output>onerror</tests.output>
<tests.client.ratio></tests.client.ratio> <tests.client.ratio></tests.client.ratio>
<tests.jvm.argline></tests.jvm.argline>
<tests.jvm.option1>${env.ES_TESTS_JVM_OPTION1}</tests.jvm.option1> <tests.jvm.option1>${env.ES_TESTS_JVM_OPTION1}</tests.jvm.option1>
<tests.jvm.option2>${env.ES_TESTS_JVM_OPTION2}</tests.jvm.option2> <tests.jvm.option2>${env.ES_TESTS_JVM_OPTION2}</tests.jvm.option2>
<tests.jvm.option3>${env.ES_TESTS_JVM_OPTION3}</tests.jvm.option3> <tests.jvm.option3>${env.ES_TESTS_JVM_OPTION3}</tests.jvm.option3>
<tests.jvm.option4>${env.ES_TESTS_JVM_OPTION4}</tests.jvm.option4> <tests.jvm.option4>${env.ES_TESTS_JVM_OPTION4}</tests.jvm.option4>
<es.logger.level>INFO</es.logger.level> <es.logger.level>INFO</es.logger.level>
</properties> </properties>
@ -370,6 +370,9 @@
<exclude>**/Abstract*.class</exclude> <exclude>**/Abstract*.class</exclude>
<exclude>**/*StressTest.class</exclude> <exclude>**/*StressTest.class</exclude>
</excludes> </excludes>
<argLine>
${tests.jvm.argline}
</argLine>
<jvmArgs> <jvmArgs>
<param>${tests.jvm.option1}</param> <param>${tests.jvm.option1}</param>
<param>${tests.jvm.option2}</param> <param>${tests.jvm.option2}</param>
@ -385,6 +388,12 @@
<haltOnFailure>${tests.failfast}</haltOnFailure> <haltOnFailure>${tests.failfast}</haltOnFailure>
<systemProperties> <systemProperties>
<!-- RandomizedTesting library system properties --> <!-- RandomizedTesting library system properties -->
<tests.jvm.argline>${tests.jvm.argline}</tests.jvm.argline>
<!-- the option[1..4] should go away soon once the jenkins skript if adjusted-->
<tests.jvm.option1>${tests.jvm.option1}</tests.jvm.option1>
<tests.jvm.option2>${tests.jvm.option2}</tests.jvm.option2>
<tests.jvm.option3>${tests.jvm.option3}</tests.jvm.option3>
<tests.jvm.option4>${tests.jvm.option4}</tests.jvm.option4>
<tests.iters>${tests.iters}</tests.iters> <tests.iters>${tests.iters}</tests.iters>
<tests.maxfailures>${tests.maxfailures}</tests.maxfailures> <tests.maxfailures>${tests.maxfailures}</tests.maxfailures>
<tests.failfast>${tests.failfast}</tests.failfast> <tests.failfast>${tests.failfast}</tests.failfast>

View File

@ -14,6 +14,8 @@ import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunListener; import org.junit.runner.notification.RunListener;
import java.util.Arrays; 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 * A {@link RunListener} that emits to {@link System#err} a string with command
@ -72,6 +74,7 @@ public class ReproduceInfoPrinter extends RunListener {
@Override @Override
public ReproduceErrorMessageBuilder appendAllOpts(Description description) { public ReproduceErrorMessageBuilder appendAllOpts(Description description) {
super.appendAllOpts(description); super.appendAllOpts(description);
appendJVMArgLine();
return appendESProperties(); return appendESProperties();
} }
@ -87,15 +90,36 @@ public class ReproduceInfoPrinter extends RunListener {
} }
return this; return this;
} }
public ReproduceErrorMessageBuilder appendESProperties() { public ReproduceErrorMessageBuilder appendESProperties() {
for (String sysPropName : Arrays.asList( for (String sysPropName : Arrays.asList(
"es.logger.level", "es.node.mode", "es.node.local")) { "es.logger.level", "es.node.mode", "es.node.local")) {
if (System.getProperty(sysPropName) != null && !System.getProperty(sysPropName).isEmpty()) { if (System.getProperty(sysPropName) != null && !System.getProperty(sysPropName).isEmpty()) {
appendOpt(sysPropName, System.getProperty(sysPropName)); appendOpt(sysPropName, System.getProperty(sysPropName));
} }
} }
return this; return this;
} }
public ReproduceErrorMessageBuilder appendJVMArgLine() {
StringBuilder builder = new StringBuilder();
Set<String> values = new HashSet<String>();
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;
}
} }
} }