add tests.docvaluesformat

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1436703 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-01-22 00:37:55 +00:00
parent ce40b505b4
commit 08936e1c81
4 changed files with 31 additions and 5 deletions

View File

@ -88,6 +88,7 @@
<property name="tests.multiplier" value="1" /> <property name="tests.multiplier" value="1" />
<property name="tests.codec" value="random" /> <property name="tests.codec" value="random" />
<property name="tests.postingsformat" value="random" /> <property name="tests.postingsformat" value="random" />
<property name="tests.docvaluesformat" value="random" />
<property name="tests.locale" value="random" /> <property name="tests.locale" value="random" />
<property name="tests.timezone" value="random" /> <property name="tests.timezone" value="random" />
<property name="tests.directory" value="random" /> <property name="tests.directory" value="random" />
@ -864,6 +865,8 @@
<sysproperty key="tests.codec" value="${tests.codec}"/> <sysproperty key="tests.codec" value="${tests.codec}"/>
<!-- set the postingsformat tests should run with --> <!-- set the postingsformat tests should run with -->
<sysproperty key="tests.postingsformat" value="${tests.postingsformat}"/> <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 --> <!-- set the locale tests should run with -->
<sysproperty key="tests.locale" value="${tests.locale}"/> <sysproperty key="tests.locale" value="${tests.locale}"/>
<!-- set the timezone tests should run with --> <!-- set the timezone tests should run with -->

View File

@ -123,7 +123,7 @@ public class Lucene42Codec extends Codec {
} }
@Override @Override
public DocValuesFormat docValuesFormat() { public final DocValuesFormat docValuesFormat() {
return docValuesFormat; return docValuesFormat;
} }
@ -133,7 +133,7 @@ public class Lucene42Codec extends Codec {
private final NormsFormat normsFormat = new Lucene42NormsFormat(); private final NormsFormat normsFormat = new Lucene42NormsFormat();
@Override @Override
public NormsFormat normsFormat() { public final NormsFormat normsFormat() {
return normsFormat; return normsFormat;
} }
} }

View File

@ -253,6 +253,9 @@ public abstract class LuceneTestCase extends Assert {
/** Gets the postingsFormat to run tests with. */ /** Gets the postingsFormat to run tests with. */
public static final String TEST_POSTINGSFORMAT = System.getProperty("tests.postingsformat", "random"); 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 */ /** Gets the directory to run tests with */
public static final String TEST_DIRECTORY = System.getProperty("tests.directory", "random"); public static final String TEST_DIRECTORY = System.getProperty("tests.directory", "random");

View File

@ -28,6 +28,7 @@ import java.util.Set;
import java.util.TimeZone; import java.util.TimeZone;
import org.apache.lucene.codecs.Codec; import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.PostingsFormat; import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.asserting.AssertingCodec; import org.apache.lucene.codecs.asserting.AssertingCodec;
import org.apache.lucene.codecs.compressing.CompressingCodec; import org.apache.lucene.codecs.compressing.CompressingCodec;
@ -137,32 +138,51 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule {
int randomVal = random.nextInt(10); int randomVal = random.nextInt(10);
if ("Lucene40".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && if ("Lucene40".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) &&
"random".equals(TEST_POSTINGSFORMAT) && "random".equals(TEST_POSTINGSFORMAT) &&
"random".equals(TEST_DOCVALUESFORMAT) &&
randomVal == 0 && randomVal == 0 &&
!shouldAvoidCodec("Lucene40"))) { !shouldAvoidCodec("Lucene40"))) {
codec = Codec.forName("Lucene40"); codec = Codec.forName("Lucene40");
assert (PostingsFormat.forName("Lucene40") instanceof Lucene40RWPostingsFormat) : "fix your classpath to have tests-framework.jar before lucene-core.jar"; 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) && } else if ("Lucene41".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) &&
"random".equals(TEST_POSTINGSFORMAT) && "random".equals(TEST_POSTINGSFORMAT) &&
"random".equals(TEST_DOCVALUESFORMAT) &&
randomVal == 1 && randomVal == 1 &&
!shouldAvoidCodec("Lucene41"))) { !shouldAvoidCodec("Lucene41"))) {
codec = Codec.forName("Lucene41"); codec = Codec.forName("Lucene41");
assert codec instanceof Lucene41RWCodec : "fix your classpath to have tests-framework.jar before lucene-core.jar"; 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; final PostingsFormat format;
if ("MockRandom".equals(TEST_POSTINGSFORMAT)) { if ("MockRandom".equals(TEST_POSTINGSFORMAT) || "random".equals(TEST_POSTINGSFORMAT)) {
format = new MockRandomPostingsFormat(random); format = new MockRandomPostingsFormat(random);
} else { } else {
format = PostingsFormat.forName(TEST_POSTINGSFORMAT); 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() { codec = new Lucene42Codec() {
@Override @Override
public PostingsFormat getPostingsFormatForField(String field) { public PostingsFormat getPostingsFormatForField(String field) {
return format; return format;
} }
@Override
public DocValuesFormat getDocValuesFormatForField(String field) {
return dvFormat;
}
@Override @Override
public String toString() { public 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"))) { } else if ("SimpleText".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal == 9 && !shouldAvoidCodec("SimpleText"))) {