mirror of https://github.com/apache/lucene.git
LUCENE-3076: add -Dtests.codecprovider
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1100175 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
826b1d32bd
commit
2f75783026
|
@ -73,6 +73,7 @@
|
||||||
</condition>
|
</condition>
|
||||||
<property name="tests.multiplier" value="1" />
|
<property name="tests.multiplier" value="1" />
|
||||||
<property name="tests.codec" value="randomPerField" />
|
<property name="tests.codec" value="randomPerField" />
|
||||||
|
<property name="tests.codecprovider" 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" />
|
||||||
|
@ -499,6 +500,8 @@
|
||||||
<sysproperty key="tests.verbose" value="${tests.verbose}"/>
|
<sysproperty key="tests.verbose" value="${tests.verbose}"/>
|
||||||
<!-- set the codec tests should run with -->
|
<!-- set the codec tests should run with -->
|
||||||
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
||||||
|
<!-- set the codec provider tests should run with -->
|
||||||
|
<sysproperty key="tests.codecprovider" value="${tests.codecprovider}"/>
|
||||||
<!-- 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 -->
|
||||||
|
|
|
@ -71,6 +71,11 @@ public class CodecProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @lucene.internal */
|
||||||
|
public synchronized Set<String> listAll() {
|
||||||
|
return codecs.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<String> getAllExtensions() {
|
public Collection<String> getAllExtensions() {
|
||||||
return knownExtensions;
|
return knownExtensions;
|
||||||
|
|
|
@ -137,6 +137,8 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
// tests)
|
// tests)
|
||||||
/** Gets the codec to run tests with. */
|
/** Gets the codec to run tests with. */
|
||||||
public static final String TEST_CODEC = System.getProperty("tests.codec", "randomPerField");
|
public static final String TEST_CODEC = System.getProperty("tests.codec", "randomPerField");
|
||||||
|
/** Gets the codecprovider to run tests with */
|
||||||
|
public static final String TEST_CODECPROVIDER = System.getProperty("tests.codecprovider", "random");
|
||||||
/** Gets the locale to run tests with */
|
/** Gets the locale to run tests with */
|
||||||
public static final String TEST_LOCALE = System.getProperty("tests.locale", "random");
|
public static final String TEST_LOCALE = System.getProperty("tests.locale", "random");
|
||||||
/** Gets the timezone to run tests with */
|
/** Gets the timezone to run tests with */
|
||||||
|
@ -329,15 +331,38 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
tempDirs.clear();
|
tempDirs.clear();
|
||||||
stores = Collections.synchronizedMap(new IdentityHashMap<MockDirectoryWrapper,StackTraceElement[]>());
|
stores = Collections.synchronizedMap(new IdentityHashMap<MockDirectoryWrapper,StackTraceElement[]>());
|
||||||
savedCodecProvider = CodecProvider.getDefault();
|
savedCodecProvider = CodecProvider.getDefault();
|
||||||
if ("randomPerField".equals(TEST_CODEC)) {
|
if ("random".equals(TEST_CODECPROVIDER)) {
|
||||||
if (random.nextInt(4) == 0) { // preflex-only setup
|
if ("randomPerField".equals(TEST_CODEC)) {
|
||||||
codec = installTestCodecs("PreFlex", CodecProvider.getDefault());
|
if (random.nextInt(4) == 0) { // preflex-only setup
|
||||||
} else { // per-field setup
|
codec = installTestCodecs("PreFlex", CodecProvider.getDefault());
|
||||||
CodecProvider.setDefault(new RandomCodecProvider(random));
|
} else { // per-field setup
|
||||||
|
CodecProvider.setDefault(new RandomCodecProvider(random));
|
||||||
|
codec = installTestCodecs(TEST_CODEC, CodecProvider.getDefault());
|
||||||
|
}
|
||||||
|
} else { // ordinary setup
|
||||||
codec = installTestCodecs(TEST_CODEC, CodecProvider.getDefault());
|
codec = installTestCodecs(TEST_CODEC, CodecProvider.getDefault());
|
||||||
}
|
}
|
||||||
} else { // ordinary setup
|
} else {
|
||||||
codec = installTestCodecs(TEST_CODEC, CodecProvider.getDefault());
|
// someone specified their own codecprovider by class
|
||||||
|
try {
|
||||||
|
Class<? extends CodecProvider> cpClazz = Class.forName(TEST_CODECPROVIDER).asSubclass(CodecProvider.class);
|
||||||
|
CodecProvider cp = cpClazz.newInstance();
|
||||||
|
String codecName;
|
||||||
|
if (TEST_CODEC.startsWith("random")) { // TODO: somehow do random per-field?!
|
||||||
|
Set<String> codecSet = cp.listAll();
|
||||||
|
String availableCodecs[] = codecSet.toArray(new String[codecSet.size()]);
|
||||||
|
codecName = availableCodecs[random.nextInt(availableCodecs.length)];
|
||||||
|
} else {
|
||||||
|
codecName = TEST_CODEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
codec = cp.lookup(codecName);
|
||||||
|
cp.setDefaultFieldCodec(codecName);
|
||||||
|
CodecProvider.setDefault(cp);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Could not instantiate CodecProvider: " + TEST_CODECPROVIDER);
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
savedLocale = Locale.getDefault();
|
savedLocale = Locale.getDefault();
|
||||||
locale = TEST_LOCALE.equals("random") ? randomLocale(random) : localeForName(TEST_LOCALE);
|
locale = TEST_LOCALE.equals("random") ? randomLocale(random) : localeForName(TEST_LOCALE);
|
||||||
|
@ -360,16 +385,13 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
String codecDescription;
|
String codecDescription;
|
||||||
CodecProvider cp = CodecProvider.getDefault();
|
CodecProvider cp = CodecProvider.getDefault();
|
||||||
|
|
||||||
if ("randomPerField".equals(TEST_CODEC)) {
|
if ("randomPerField".equals(TEST_CODEC) && cp instanceof RandomCodecProvider) {
|
||||||
if (cp instanceof RandomCodecProvider)
|
codecDescription = cp.toString();
|
||||||
codecDescription = cp.toString();
|
|
||||||
else
|
|
||||||
codecDescription = "PreFlex";
|
|
||||||
} else {
|
} else {
|
||||||
codecDescription = codec.toString();
|
codecDescription = codec.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CodecProvider.getDefault() == savedCodecProvider)
|
if ("random".equals(TEST_CODECPROVIDER) && CodecProvider.getDefault() == savedCodecProvider)
|
||||||
removeTestCodecs(codec, CodecProvider.getDefault());
|
removeTestCodecs(codec, CodecProvider.getDefault());
|
||||||
CodecProvider.setDefault(savedCodecProvider);
|
CodecProvider.setDefault(savedCodecProvider);
|
||||||
Locale.setDefault(savedLocale);
|
Locale.setDefault(savedLocale);
|
||||||
|
|
|
@ -450,6 +450,7 @@
|
||||||
>
|
>
|
||||||
<sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/>
|
<sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/>
|
||||||
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
||||||
|
<sysproperty key="tests.codecprovider" value="${tests.codecprovider}"/>
|
||||||
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
||||||
<sysproperty key="tests.locale" value="${tests.locale}"/>
|
<sysproperty key="tests.locale" value="${tests.locale}"/>
|
||||||
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
</condition>
|
</condition>
|
||||||
|
|
||||||
<property name="tests.multiplier" value="1" />
|
<property name="tests.multiplier" value="1" />
|
||||||
|
<property name="tests.codecprovider" value="random" />
|
||||||
<property name="tests.codec" value="randomPerField" />
|
<property name="tests.codec" value="randomPerField" />
|
||||||
<property name="tests.locale" value="random" />
|
<property name="tests.locale" value="random" />
|
||||||
<property name="tests.timezone" value="random" />
|
<property name="tests.timezone" value="random" />
|
||||||
|
|
|
@ -146,6 +146,7 @@
|
||||||
>
|
>
|
||||||
<sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/>
|
<sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/>
|
||||||
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
||||||
|
<sysproperty key="tests.codecprovider" value="${tests.codecprovider}"/>
|
||||||
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
||||||
<sysproperty key="tests.locale" value="${tests.locale}"/>
|
<sysproperty key="tests.locale" value="${tests.locale}"/>
|
||||||
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
||||||
|
|
|
@ -118,6 +118,7 @@
|
||||||
>
|
>
|
||||||
<sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/>
|
<sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/>
|
||||||
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
||||||
|
<sysproperty key="tests.codecprovider" value="${tests.codecprovider}"/>
|
||||||
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
||||||
<sysproperty key="tests.locale" value="${tests.locale}"/>
|
<sysproperty key="tests.locale" value="${tests.locale}"/>
|
||||||
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
||||||
|
|
|
@ -171,6 +171,7 @@
|
||||||
<sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/>
|
<sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/>
|
||||||
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
||||||
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
||||||
|
<sysproperty key="tests.codecprovider" value="${tests.codecprovider}"/>
|
||||||
<sysproperty key="tests.locale" value="${tests.locale}"/>
|
<sysproperty key="tests.locale" value="${tests.locale}"/>
|
||||||
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
||||||
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
|
<sysproperty key="tests.multiplier" value="${tests.multiplier}"/>
|
||||||
|
@ -231,6 +232,7 @@
|
||||||
>
|
>
|
||||||
<sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/>
|
<sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/>
|
||||||
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
||||||
|
<sysproperty key="tests.codecprovider" value="${tests.codecprovider}"/>
|
||||||
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
||||||
<sysproperty key="tests.locale" value="${tests.locale}"/>
|
<sysproperty key="tests.locale" value="${tests.locale}"/>
|
||||||
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
||||||
|
|
|
@ -115,6 +115,7 @@
|
||||||
>
|
>
|
||||||
<sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/>
|
<sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/>
|
||||||
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
||||||
|
<sysproperty key="tests.codecprovider" value="${tests.codecprovider}"/>
|
||||||
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
||||||
<sysproperty key="tests.locale" value="${tests.locale}"/>
|
<sysproperty key="tests.locale" value="${tests.locale}"/>
|
||||||
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
||||||
|
|
|
@ -114,6 +114,7 @@
|
||||||
>
|
>
|
||||||
<sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/>
|
<sysproperty key="java.util.logging.config.file" value="${common-solr.dir}/testlogging.properties"/>
|
||||||
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
<sysproperty key="tests.luceneMatchVersion" value="${tests.luceneMatchVersion}"/>
|
||||||
|
<sysproperty key="tests.codecprovider" value="${tests.codecprovider}"/>
|
||||||
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
<sysproperty key="tests.codec" value="${tests.codec}"/>
|
||||||
<sysproperty key="tests.locale" value="${tests.locale}"/>
|
<sysproperty key="tests.locale" value="${tests.locale}"/>
|
||||||
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
<sysproperty key="tests.timezone" value="${tests.timezone}"/>
|
||||||
|
|
Loading…
Reference in New Issue