Skip to content

Apache Lucene open-source search software

SOLR-2002: add -Dtests.iter

Robert Muir6e05f994b88d
diff --git a/lucene/common-build.xml b/lucene/common-build.xml
index 057240ac204..979992e5382 100644
--- a/lucene/common-build.xml
+++ b/lucene/common-build.xml
@@ -67,6 +67,7 @@
<property name="tests.locale" value="random" />
<property name="tests.timezone" value="random" />
<property name="tests.directory" value="RAMDirectory" />
+ <property name="tests.iter" value="1" />
<property name="javac.deprecation" value="off"/>
<property name="javac.debug" value="on"/>
@@ -447,6 +448,8 @@
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
<!-- set the directory tests should run with -->
<sysproperty key="tests.directory" value="${tests.directory}"/>
+ <!-- set the number of times tests should run -->
+ <sysproperty key="tests.iter" value="${tests.iter}"/>
<!-- TODO: create propertyset for test properties, so each project can have its own set -->
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
diff --git a/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java b/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
index fb837f918a0..abc5b266f35 100644
--- a/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
+++ b/lucene/src/test/org/apache/lucene/util/LuceneTestCase.java
@@ -367,7 +367,8 @@ public abstract class LuceneTestCase extends TestCase {
@Override
public void run(TestResult result) {
- if (LuceneTestCaseJ4.TEST_METHOD == null ||
+ for (int i = 0; i < LuceneTestCaseJ4.TEST_ITER; i++)
+ if (LuceneTestCaseJ4.TEST_METHOD == null ||
getName().equals(LuceneTestCaseJ4.TEST_METHOD))
super.run(result);
}
diff --git a/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java b/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
index bb65ddb0913..8e90e9e60c3 100644
--- a/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
+++ b/lucene/src/test/org/apache/lucene/util/LuceneTestCaseJ4.java
@@ -52,6 +52,7 @@ import org.junit.runner.Description;
import org.junit.runner.RunWith;
import org.junit.runner.manipulation.Filter;
import org.junit.runner.manipulation.NoTestsRemainException;
+import org.junit.runner.notification.RunNotifier;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
@@ -155,6 +156,8 @@ public class LuceneTestCaseJ4 {
static final String TEST_TIMEZONE = System.getProperty("tests.timezone", "random");
/** Gets the directory to run tests with */
static final String TEST_DIRECTORY = System.getProperty("tests.directory", "RAMDirectory");
+ /** Get the number of times to run tests */
+ static final int TEST_ITER = Integer.parseInt(System.getProperty("tests.iter", "1"));
private static final Pattern codecWithParam = Pattern.compile("(.*)\\(\\s*(\\d+)\\s*\\)");
@@ -720,6 +723,13 @@ public class LuceneTestCaseJ4 {
/** optionally filters the tests to be run by TEST_METHOD */
public static class LuceneTestCaseRunner extends BlockJUnit4ClassRunner {
+
+ @Override
+ protected void runChild(FrameworkMethod arg0, RunNotifier arg1) {
+ for (int i = 0; i < TEST_ITER; i++)
+ super.runChild(arg0, arg1);
+ }
+
public LuceneTestCaseRunner(Class<?> clazz) throws InitializationError {
super(clazz);
Filter f = new Filter() {
diff --git a/solr/build.xml b/solr/build.xml
index 9ee7bae8beb..3e222d51806 100644
--- a/solr/build.xml
+++ b/solr/build.xml
@@ -434,6 +434,7 @@
<sysproperty key="tests.locale" value="${tests.locale}"/>
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
+ <sysproperty key="tests.iter" value="${tests.iter}"/>
<sysproperty key="jetty.insecurerandom" value="1"/>
<sysproperty key="tempDir" file="@{tempDir}/@{threadNum}"/>
<sysproperty key="testmethod" value="${testmethod}"/>
diff --git a/solr/common-build.xml b/solr/common-build.xml
index 86f3d1e946e..c55078eaaba 100644
--- a/solr/common-build.xml
+++ b/solr/common-build.xml
@@ -54,6 +54,7 @@
<property name="tests.codec" value="random" />
<property name="tests.locale" value="random" />
<property name="tests.timezone" value="random" />
+ <property name="tests.iter" value="1" />
<condition property="dir.prop" value="-Dsolr.directoryFactory=solr.StandardDirectoryFactory">
<isset property="use.fsdir"/>
diff --git a/solr/contrib/clustering/build.xml b/solr/contrib/clustering/build.xml
index 51a2e6512e4..090e1210df0 100644
--- a/solr/contrib/clustering/build.xml
+++ b/solr/contrib/clustering/build.xml
@@ -113,6 +113,7 @@
<sysproperty key="tests.locale" value="${tests.locale}"/>
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
+ <sysproperty key="tests.iter" value="${tests.iter}"/>
<sysproperty key="jetty.insecurerandom" value="1"/>
<sysproperty key="tempDir" file="${junit.output.dir}"/>
<sysproperty key="testmethod" value="${testmethod}"/>
diff --git a/solr/contrib/dataimporthandler/build.xml b/solr/contrib/dataimporthandler/build.xml
index cb5e8cc43b1..8ba2cbb9637 100644
--- a/solr/contrib/dataimporthandler/build.xml
+++ b/solr/contrib/dataimporthandler/build.xml
@@ -165,6 +165,7 @@
<sysproperty key="tests.locale" value="${tests.locale}"/>
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
+ <sysproperty key="tests.iter" value="${tests.iter}"/>
<sysproperty key="jetty.insecurerandom" value="1"/>
<sysproperty key="tempDir" file="${tempDir}"/>
<sysproperty key="testmethod" value="${testmethod}"/>
@@ -220,6 +221,7 @@
<sysproperty key="tests.locale" value="${tests.locale}"/>
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
+ <sysproperty key="tests.iter" value="${tests.iter}"/>
<sysproperty key="jetty.insecurerandom" value="1"/>
<sysproperty key="tempDir" file="${tempDir}"/>
<sysproperty key="testmethod" value="${testmethod}"/>
diff --git a/solr/contrib/extraction/build.xml b/solr/contrib/extraction/build.xml
index 85c6e572eae..805d3a1a7e2 100644
--- a/solr/contrib/extraction/build.xml
+++ b/solr/contrib/extraction/build.xml
@@ -114,6 +114,7 @@
<sysproperty key="tests.locale" value="${tests.locale}"/>
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
+ <sysproperty key="tests.iter" value="${tests.iter}"/>
<sysproperty key="jetty.insecurerandom" value="1"/>
<sysproperty key="tempDir" file="${tempDir}"/>
<sysproperty key="testmethod" value="${testmethod}"/>