Apache Lucene open-source search software
add tests.docvaluesformat
Robert Muir08936e1c818c
diff --git a/lucene/common-build.xml b/lucene/common-build.xmlindex db392366103..e88916c37f1 100644--- a/lucene/common-build.xml+++ b/lucene/common-build.xml@@ -88,6 +88,7 @@<property name="tests.multiplier" value="1" /><property name="tests.codec" value="random" /><property name="tests.postingsformat" value="random" />+ <property name="tests.docvaluesformat" value="random" /><property name="tests.locale" value="random" /><property name="tests.timezone" value="random" /><property name="tests.directory" value="random" />@@ -864,6 +865,8 @@<sysproperty key="tests.codec" value="${tests.codec}"/><!-- set the postingsformat tests should run with --><sysproperty key="tests.postingsformat" value="${tests.postingsformat}"/>+ <!-- set the docvaluesformat tests should run with -->+ <sysproperty key="tests.docvaluesformat" value="${tests.docvaluesformat}"/><!-- set the locale tests should run with --><sysproperty key="tests.locale" value="${tests.locale}"/><!-- set the timezone tests should run with -->diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene42/Lucene42Codec.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene42/Lucene42Codec.javaindex 8911fd6c06b..53eb829f208 100644--- a/lucene/core/src/java/org/apache/lucene/codecs/lucene42/Lucene42Codec.java+++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene42/Lucene42Codec.java@@ -123,7 +123,7 @@ public class Lucene42Codec extends Codec {}@Override- public DocValuesFormat docValuesFormat() {+ public final DocValuesFormat docValuesFormat() {return docValuesFormat;}@@ -133,7 +133,7 @@ public class Lucene42Codec extends Codec {private final NormsFormat normsFormat = new Lucene42NormsFormat();@Override- public NormsFormat normsFormat() {+ public final NormsFormat normsFormat() {return normsFormat;}}diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.javaindex 38604652d83..06c38659b1b 100644--- a/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java+++ b/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java@@ -253,6 +253,9 @@ public abstract class LuceneTestCase extends Assert {/** Gets the postingsFormat to run tests with. */public static final String TEST_POSTINGSFORMAT = System.getProperty("tests.postingsformat", "random");++ /** Gets the docValuesFormat to run tests with */+ public static final String TEST_DOCVALUESFORMAT = System.getProperty("tests.docvaluesformat", "random");/** Gets the directory to run tests with */public static final String TEST_DIRECTORY = System.getProperty("tests.directory", "random");diff --git a/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java b/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.javaindex 5674b2fbac0..6cd78fd4407 100644--- a/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java+++ b/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java@@ -28,6 +28,7 @@ import java.util.Set;import java.util.TimeZone;import org.apache.lucene.codecs.Codec;+import org.apache.lucene.codecs.DocValuesFormat;import org.apache.lucene.codecs.PostingsFormat;import org.apache.lucene.codecs.asserting.AssertingCodec;import org.apache.lucene.codecs.compressing.CompressingCodec;@@ -137,32 +138,51 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule {int randomVal = random.nextInt(10);if ("Lucene40".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) &&"random".equals(TEST_POSTINGSFORMAT) &&+ "random".equals(TEST_DOCVALUESFORMAT) &&randomVal == 0 &&!shouldAvoidCodec("Lucene40"))) {codec = Codec.forName("Lucene40");assert (PostingsFormat.forName("Lucene40") instanceof Lucene40RWPostingsFormat) : "fix your classpath to have tests-framework.jar before lucene-core.jar";} else if ("Lucene41".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) &&"random".equals(TEST_POSTINGSFORMAT) &&+ "random".equals(TEST_DOCVALUESFORMAT) &&randomVal == 1 &&!shouldAvoidCodec("Lucene41"))) {codec = Codec.forName("Lucene41");assert codec instanceof Lucene41RWCodec : "fix your classpath to have tests-framework.jar before lucene-core.jar";- } else if (!"random".equals(TEST_POSTINGSFORMAT)) {+ } else if (("random".equals(TEST_POSTINGSFORMAT) == false) || ("random".equals(TEST_DOCVALUESFORMAT) == false)) {+ // the user wired postings or DV+final PostingsFormat format;- if ("MockRandom".equals(TEST_POSTINGSFORMAT)) {+ if ("MockRandom".equals(TEST_POSTINGSFORMAT) || "random".equals(TEST_POSTINGSFORMAT)) {format = new MockRandomPostingsFormat(random);} else {format = PostingsFormat.forName(TEST_POSTINGSFORMAT);}++ final DocValuesFormat dvFormat;+ if ("random".equals(TEST_DOCVALUESFORMAT)) {+ // pick one from SPI+ String formats[] = DocValuesFormat.availableDocValuesFormats().toArray(new String[0]);+ dvFormat = DocValuesFormat.forName(formats[random.nextInt(formats.length)]);+ } else {+ dvFormat = DocValuesFormat.forName(TEST_DOCVALUESFORMAT);+ }+codec = new Lucene42Codec() {@Overridepublic PostingsFormat getPostingsFormatForField(String field) {return format;}+ @Override+ public DocValuesFormat getDocValuesFormatForField(String field) {+ return dvFormat;+ }+@Overridepublic String toString() {- return super.toString() + ": " + format.toString();+ return super.toString() + ": " + format.toString() + ", " + dvFormat.toString();}};} else if ("SimpleText".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal == 9 && !shouldAvoidCodec("SimpleText"))) {