You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sa...@apache.org on 2011/06/10 20:18:02 UTC
svn commit: r1134403 [4/11] - in /lucene/dev/branches/solr2452: ./
dev-tools/idea/.idea/ dev-tools/maven/solr/contrib/clustering/
dev-tools/maven/solr/src/ lucene/ lucene/contrib/
lucene/contrib/highlighter/src/java/org/apache/lucene/search/highlight/ ...
Modified: lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/index/codecs/mocksep/MockSepCodec.java Fri Jun 10 18:17:44 2011
@@ -20,14 +20,19 @@ package org.apache.lucene.index.codecs.m
import java.io.IOException;
import java.util.Set;
+import org.apache.lucene.index.PerDocWriteState;
import org.apache.lucene.index.SegmentInfo;
import org.apache.lucene.index.SegmentWriteState;
import org.apache.lucene.index.SegmentReadState;
import org.apache.lucene.index.codecs.Codec;
+import org.apache.lucene.index.codecs.DefaultDocValuesProducer;
import org.apache.lucene.index.codecs.FieldsConsumer;
import org.apache.lucene.index.codecs.FieldsProducer;
import org.apache.lucene.index.codecs.FixedGapTermsIndexReader;
import org.apache.lucene.index.codecs.FixedGapTermsIndexWriter;
+import org.apache.lucene.index.codecs.PerDocConsumer;
+import org.apache.lucene.index.codecs.DefaultDocValuesConsumer;
+import org.apache.lucene.index.codecs.PerDocValues;
import org.apache.lucene.index.codecs.PostingsReaderBase;
import org.apache.lucene.index.codecs.PostingsWriterBase;
import org.apache.lucene.index.codecs.BlockTermsReader;
@@ -130,15 +135,17 @@ public class MockSepCodec extends Codec
}
@Override
- public void files(Directory dir, SegmentInfo segmentInfo, String codecId, Set<String> files) throws IOException {
+ public void files(Directory dir, SegmentInfo segmentInfo, int codecId, Set<String> files) throws IOException {
SepPostingsReaderImpl.files(segmentInfo, codecId, files);
BlockTermsReader.files(dir, segmentInfo, codecId, files);
FixedGapTermsIndexReader.files(dir, segmentInfo, codecId, files);
+ DefaultDocValuesConsumer.files(dir, segmentInfo, codecId, files);
}
@Override
public void getExtensions(Set<String> extensions) {
getSepExtensions(extensions);
+ DefaultDocValuesConsumer.getDocValuesExtensions(extensions);
}
public static void getSepExtensions(Set<String> extensions) {
@@ -146,4 +153,14 @@ public class MockSepCodec extends Codec
BlockTermsReader.getExtensions(extensions);
FixedGapTermsIndexReader.getIndexExtensions(extensions);
}
+
+ @Override
+ public PerDocConsumer docsConsumer(PerDocWriteState state) throws IOException {
+ return new DefaultDocValuesConsumer(state, BytesRef.getUTF8SortedAsUnicodeComparator());
+ }
+
+ @Override
+ public PerDocValues docsProducer(SegmentReadState state) throws IOException {
+ return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId);
+ }
}
Modified: lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/store/MockIndexOutputWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/store/MockIndexOutputWrapper.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/store/MockIndexOutputWrapper.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/store/MockIndexOutputWrapper.java Fri Jun 10 18:17:44 2011
@@ -110,7 +110,7 @@ public class MockIndexOutputWrapper exte
}
throw new IOException(message);
} else {
- if (dir.randomState.nextBoolean()) {
+ if (dir.randomState.nextInt(200) == 0) {
final int half = len/2;
delegate.writeBytes(b, offset, half);
Thread.yield();
Modified: lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java Fri Jun 10 18:17:44 2011
@@ -724,6 +724,47 @@ public abstract class LuceneTestCase ext
}
}
+
+ /**
+ * Returns a number of at least <code>i</code>
+ * <p>
+ * The actual number returned will be influenced by whether {@link #TEST_NIGHTLY}
+ * is active and {@link #RANDOM_MULTIPLIER}, but also with some random fudge.
+ */
+ public static int atLeast(Random random, int i) {
+ int min = (TEST_NIGHTLY ? 5*i : i) * RANDOM_MULTIPLIER;
+ int max = min+(min/2);
+ return _TestUtil.nextInt(random, min, max);
+ }
+
+ public static int atLeast(int i) {
+ return atLeast(random, i);
+ }
+
+ /**
+ * Returns true if something should happen rarely,
+ * <p>
+ * The actual number returned will be influenced by whether {@link #TEST_NIGHTLY}
+ * is active and {@link #RANDOM_MULTIPLIER}.
+ */
+ public static boolean rarely(Random random) {
+ int p = TEST_NIGHTLY ? 25 : 5;
+ p += (p * Math.log(RANDOM_MULTIPLIER));
+ int min = 100 - Math.min(p, 90); // never more than 90
+ return random.nextInt(100) >= min;
+ }
+
+ public static boolean rarely() {
+ return rarely(random);
+ }
+
+ public static boolean usually(Random random) {
+ return !rarely(random);
+ }
+
+ public static boolean usually() {
+ return usually(random);
+ }
// @deprecated (4.0) These deprecated methods should be removed soon, when all tests using no Epsilon are fixed:
@Deprecated
@@ -836,7 +877,7 @@ public abstract class LuceneTestCase ext
c.setMergeScheduler(new SerialMergeScheduler());
}
if (r.nextBoolean()) {
- if ((TEST_NIGHTLY && random.nextBoolean()) || r.nextInt(20) == 17) {
+ if (rarely(r)) {
// crazy value
c.setMaxBufferedDocs(_TestUtil.nextInt(r, 2, 7));
} else {
@@ -845,7 +886,7 @@ public abstract class LuceneTestCase ext
}
}
if (r.nextBoolean()) {
- if ((TEST_NIGHTLY && random.nextBoolean()) || r.nextInt(20) == 17) {
+ if (rarely(r)) {
// crazy value
c.setTermIndexInterval(random.nextBoolean() ? _TestUtil.nextInt(r, 1, 31) : _TestUtil.nextInt(r, 129, 1000));
} else {
@@ -882,7 +923,7 @@ public abstract class LuceneTestCase ext
LogMergePolicy logmp = r.nextBoolean() ? new LogDocMergePolicy() : new LogByteSizeMergePolicy();
logmp.setUseCompoundFile(r.nextBoolean());
logmp.setCalibrateSizeByDeletes(r.nextBoolean());
- if ((TEST_NIGHTLY && random.nextBoolean()) || r.nextInt(20) == 17) {
+ if (rarely(r)) {
logmp.setMergeFactor(_TestUtil.nextInt(r, 2, 4));
} else {
logmp.setMergeFactor(_TestUtil.nextInt(r, 5, 50));
@@ -892,7 +933,7 @@ public abstract class LuceneTestCase ext
public static TieredMergePolicy newTieredMergePolicy(Random r) {
TieredMergePolicy tmp = new TieredMergePolicy();
- if ((TEST_NIGHTLY && random.nextBoolean()) || r.nextInt(20) == 17) {
+ if (rarely(r)) {
tmp.setMaxMergeAtOnce(_TestUtil.nextInt(r, 2, 4));
tmp.setMaxMergeAtOnceExplicit(_TestUtil.nextInt(r, 2, 4));
} else {
@@ -1060,7 +1101,7 @@ public abstract class LuceneTestCase ext
/** Returns a new field instance, using the specified random.
* See {@link #newField(String, String, Field.Store, Field.Index, Field.TermVector)} for more information */
public static Field newField(Random random, String name, String value, Store store, Index index, TermVector tv) {
- if (!TEST_NIGHTLY && random.nextInt(20) > 0) {
+ if (usually(random)) {
// most of the time, don't modify the params
return new Field(name, value, store, index, tv);
}
@@ -1128,7 +1169,7 @@ public abstract class LuceneTestCase ext
};
public static String randomDirectory(Random random) {
- if (random.nextInt(20) == 0) {
+ if (rarely(random)) {
return CORE_DIRECTORIES[random.nextInt(CORE_DIRECTORIES.length)];
} else {
return "RAMDirectory";
@@ -1192,7 +1233,7 @@ public abstract class LuceneTestCase ext
public static IndexSearcher newSearcher(IndexReader r, boolean maybeWrap) throws IOException {
if (random.nextBoolean()) {
- if (maybeWrap && random.nextInt(20) == 0) {
+ if (maybeWrap && rarely()) {
return new IndexSearcher(new SlowMultiReaderWrapper(r));
} else {
return new IndexSearcher(r);
Modified: lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java Fri Jun 10 18:17:44 2011
@@ -51,12 +51,17 @@ import org.junit.Assert;
public class _TestUtil {
- /** Returns temp dir, containing String arg in its name;
+ /** Returns temp dir, based on String arg in its name;
* does not create the directory. */
public static File getTempDir(String desc) {
- File f = new File(LuceneTestCase.TEMP_DIR, desc + "." + LuceneTestCase.random.nextLong());
- LuceneTestCase.registerTempFile(f);
- return f;
+ try {
+ File f = createTempFile(desc, "tmp", LuceneTestCase.TEMP_DIR);
+ f.delete();
+ LuceneTestCase.registerTempFile(f);
+ return f;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
/**
@@ -286,6 +291,48 @@ public class _TestUtil {
sb.appendCodePoint(nextInt(r, blockStarts[block], blockEnds[block]));
return sb.toString();
}
+
+ /** Returns random string, with a given UTF-8 byte length*/
+ public static String randomFixedByteLengthUnicodeString(Random r, int length) {
+
+ final char[] buffer = new char[length*3];
+ int bytes = length;
+ int i = 0;
+ for (; i < buffer.length && bytes != 0; i++) {
+ int t;
+ if (bytes >= 4) {
+ t = r.nextInt(5);
+ } else if (bytes >= 3) {
+ t = r.nextInt(4);
+ } else if (bytes >= 2) {
+ t = r.nextInt(2);
+ } else {
+ t = 0;
+ }
+ if (t == 0) {
+ buffer[i] = (char) r.nextInt(0x80);
+ bytes--;
+ } else if (1 == t) {
+ buffer[i] = (char) nextInt(r, 0x80, 0x7ff);
+ bytes -= 2;
+ } else if (2 == t) {
+ buffer[i] = (char) nextInt(r, 0x800, 0xd7ff);
+ bytes -= 3;
+ } else if (3 == t) {
+ buffer[i] = (char) nextInt(r, 0xe000, 0xffff);
+ bytes -= 3;
+ } else if (4 == t) {
+ // Make a surrogate pair
+ // High surrogate
+ buffer[i++] = (char) nextInt(r, 0xd800, 0xdbff);
+ // Low surrogate
+ buffer[i] = (char) nextInt(r, 0xdc00, 0xdfff);
+ bytes -= 4;
+ }
+
+ }
+ return new String(buffer, 0, i);
+ }
public static CodecProvider alwaysCodec(final Codec c) {
CodecProvider p = new CodecProvider() {
@@ -370,7 +417,7 @@ public class _TestUtil {
List<Fieldable> fields = doc.getFields();
for (Fieldable field : fields) {
fieldInfos.addOrUpdate(field.name(), field.isIndexed(), field.isTermVectorStored(), field.isStorePositionWithTermVector(),
- field.isStoreOffsetWithTermVector(), field.getOmitNorms(), false, field.getOmitTermFreqAndPositions());
+ field.isStoreOffsetWithTermVector(), field.getOmitNorms(), false, field.getOmitTermFreqAndPositions(), field.docValuesType());
}
}
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/TestExternalCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/TestExternalCodecs.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/TestExternalCodecs.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/TestExternalCodecs.java Fri Jun 10 18:17:44 2011
@@ -490,11 +490,21 @@ public class TestExternalCodecs extends
}
@Override
+ public PerDocConsumer docsConsumer(PerDocWriteState state) throws IOException {
+ return null;
+ }
+
+ @Override
+ public PerDocValues docsProducer(SegmentReadState state) throws IOException {
+ return null;
+ }
+
+ @Override
public void getExtensions(Set<String> extensions) {
}
@Override
- public void files(Directory dir, SegmentInfo segmentInfo, String codecId, Set<String> files) {
+ public void files(Directory dir, SegmentInfo segmentInfo, int codecId, Set<String> files) {
}
}
@@ -506,7 +516,7 @@ public class TestExternalCodecs extends
provider.register(new RAMOnlyCodec());
provider.setDefaultFieldCodec("RamOnly");
- final int NUM_DOCS = 173;
+ final int NUM_DOCS = atLeast(173);
MockDirectoryWrapper dir = newDirectory();
dir.setCheckIndexOnClose(false); // we use a custom codec provider
IndexWriter w = new IndexWriter(
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java Fri Jun 10 18:17:44 2011
@@ -59,7 +59,8 @@ public class TestSearchForDuplicates ext
public void testRun() throws Exception {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw, true);
- doTest(random, pw, false);
+ final int MAX_DOCS = atLeast(225);
+ doTest(random, pw, false, MAX_DOCS);
pw.close();
sw.close();
String multiFileOutput = sw.getBuffer().toString();
@@ -67,7 +68,7 @@ public class TestSearchForDuplicates ext
sw = new StringWriter();
pw = new PrintWriter(sw, true);
- doTest(random, pw, true);
+ doTest(random, pw, true, MAX_DOCS);
pw.close();
sw.close();
String singleFileOutput = sw.getBuffer().toString();
@@ -76,7 +77,7 @@ public class TestSearchForDuplicates ext
}
- private void doTest(Random random, PrintWriter out, boolean useCompoundFiles) throws Exception {
+ private void doTest(Random random, PrintWriter out, boolean useCompoundFiles, int MAX_DOCS) throws Exception {
Directory directory = newDirectory();
Analyzer analyzer = new MockAnalyzer(random);
IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
@@ -90,8 +91,6 @@ public class TestSearchForDuplicates ext
writer.setInfoStream(System.out);
}
- final int MAX_DOCS = 225;
-
for (int j = 0; j < MAX_DOCS; j++) {
Document d = new Document();
d.add(newField(PRIORITY_FIELD, HIGH_PRIORITY, Field.Store.YES, Field.Index.ANALYZED));
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/analysis/TestMockAnalyzer.java Fri Jun 10 18:17:44 2011
@@ -114,6 +114,6 @@ public class TestMockAnalyzer extends Ba
/** blast some random strings through the analyzer */
public void testRandomStrings() throws Exception {
- checkRandomData(random, new MockAnalyzer(random), 10000*RANDOM_MULTIPLIER);
+ checkRandomData(random, new MockAnalyzer(random), atLeast(1000));
}
}
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java Fri Jun 10 18:17:44 2011
@@ -18,6 +18,7 @@ package org.apache.lucene.index;
*/
import java.io.IOException;
+import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
@@ -760,7 +761,7 @@ public class TestAddIndexes extends Luce
// from multiple threads
public void testAddIndexesWithThreads() throws Throwable {
- final int NUM_ITER = 15;
+ final int NUM_ITER = TEST_NIGHTLY ? 15 : 5;
final int NUM_COPY = 3;
CommitAndAddIndexes c = new CommitAndAddIndexes(NUM_COPY);
c.writer2.setInfoStream(VERBOSE ? System.out : null);
@@ -778,8 +779,6 @@ public class TestAddIndexes extends Luce
assertTrue("found unexpected failures: " + c.failures, c.failures.isEmpty());
- _TestUtil.checkIndex(c.dir2);
-
IndexReader reader = IndexReader.open(c.dir2, true);
assertEquals(expectedNumDocs, reader.numDocs());
reader.close();
@@ -868,6 +867,8 @@ public class TestAddIndexes extends Luce
if (t instanceof AlreadyClosedException || t instanceof MergePolicy.MergeAbortedException || t instanceof NullPointerException) {
report = !didClose;
+ } else if (t instanceof FileNotFoundException) {
+ report = !didClose;
} else if (t instanceof IOException) {
Throwable t2 = t.getCause();
if (t2 instanceof MergePolicy.MergeAbortedException) {
@@ -914,11 +915,11 @@ public class TestAddIndexes extends Luce
// LUCENE-1335: test simultaneous addIndexes & close
public void testAddIndexesWithRollback() throws Throwable {
- final int NUM_COPY = 50;
+ final int NUM_COPY = TEST_NIGHTLY ? 50 : 5;
CommitAndAddIndexes3 c = new CommitAndAddIndexes3(NUM_COPY);
c.launchThreads(-1);
- Thread.sleep(_TestUtil.nextInt(random, 100, 500));
+ Thread.sleep(_TestUtil.nextInt(random, 10, 500));
// Close w/o first stopping/joining the threads
if (VERBOSE) {
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java Fri Jun 10 18:17:44 2011
@@ -47,7 +47,7 @@ public class TestAtomicUpdate extends Lu
private static abstract class TimedThread extends Thread {
volatile boolean failed;
int count;
- private static float RUN_TIME_SEC = 0.5f * RANDOM_MULTIPLIER;
+ private static float RUN_TIME_MSEC = atLeast(500);
private TimedThread[] allThreads;
abstract public void doWork() throws Throwable;
@@ -58,7 +58,7 @@ public class TestAtomicUpdate extends Lu
@Override
public void run() {
- final long stopTime = System.currentTimeMillis() + (long) (1000*RUN_TIME_SEC);
+ final long stopTime = System.currentTimeMillis() + (long) RUN_TIME_MSEC;
count = 0;
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestByteSlices.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestByteSlices.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestByteSlices.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestByteSlices.java Fri Jun 10 18:17:44 2011
@@ -23,7 +23,7 @@ public class TestByteSlices extends Luce
public void testBasic() throws Throwable {
ByteBlockPool pool = new ByteBlockPool(new RecyclingByteBlockAllocator(ByteBlockPool.BYTE_BLOCK_SIZE, Integer.MAX_VALUE));
- final int NUM_STREAM = 100 * RANDOM_MULTIPLIER;
+ final int NUM_STREAM = atLeast(100);
ByteSliceWriter writer = new ByteSliceWriter(pool);
@@ -40,7 +40,7 @@ public class TestByteSlices extends Luce
counters[stream] = 0;
}
- int num = 10000 * RANDOM_MULTIPLIER;
+ int num = atLeast(10000);
for (int iter = 0; iter < num; iter++) {
int stream = random.nextInt(NUM_STREAM);
if (VERBOSE)
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestCodecs.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestCodecs.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestCodecs.java Fri Jun 10 18:17:44 2011
@@ -64,7 +64,7 @@ import org.apache.lucene.util._TestUtil;
public class TestCodecs extends LuceneTestCase {
private static String[] fieldNames = new String[] {"one", "two", "three", "four"};
- private final static int NUM_TEST_ITER = 20 * RANDOM_MULTIPLIER;
+ private final static int NUM_TEST_ITER = atLeast(20);
private final static int NUM_TEST_THREADS = 3;
private final static int NUM_FIELDS = 4;
private final static int NUM_TERMS_RAND = 50; // must be > 16 to test skipping
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java Fri Jun 10 18:17:44 2011
@@ -155,7 +155,8 @@ public class TestConsistentFieldNumbers
}
public void testFieldNumberGaps() throws IOException {
- for (int i = 0; i < 39; i++) {
+ int numIters = atLeast(13);
+ for (int i = 0; i < numIters; i++) {
Directory dir = newDirectory();
{
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
@@ -270,8 +271,8 @@ public class TestConsistentFieldNumbers
@Test
public void testManyFields() throws Exception {
- final int NUM_DOCS = 2000;
- final int MAX_FIELDS = 50;
+ final int NUM_DOCS = atLeast(200);
+ final int MAX_FIELDS = atLeast(50);
int[][] docs = new int[NUM_DOCS][4];
for (int i = 0; i < docs.length; i++) {
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java Fri Jun 10 18:17:44 2011
@@ -33,10 +33,14 @@ import org.apache.lucene.index.codecs.Bl
import org.apache.lucene.index.codecs.BlockTermsWriter;
import org.apache.lucene.index.codecs.Codec;
import org.apache.lucene.index.codecs.CoreCodecProvider;
+import org.apache.lucene.index.codecs.DefaultDocValuesProducer;
import org.apache.lucene.index.codecs.FieldsConsumer;
import org.apache.lucene.index.codecs.FieldsProducer;
import org.apache.lucene.index.codecs.FixedGapTermsIndexReader;
import org.apache.lucene.index.codecs.FixedGapTermsIndexWriter;
+import org.apache.lucene.index.codecs.PerDocConsumer;
+import org.apache.lucene.index.codecs.DefaultDocValuesConsumer;
+import org.apache.lucene.index.codecs.PerDocValues;
import org.apache.lucene.index.codecs.PostingsReaderBase;
import org.apache.lucene.index.codecs.PostingsWriterBase;
import org.apache.lucene.index.codecs.TermsIndexReaderBase;
@@ -192,15 +196,17 @@ public class TestDocTermOrds extends Luc
static final String PROX_EXTENSION = "prx";
@Override
- public void files(Directory dir, SegmentInfo segmentInfo, String id, Set<String> files) throws IOException {
+ public void files(Directory dir, SegmentInfo segmentInfo, int id, Set<String> files) throws IOException {
StandardPostingsReader.files(dir, segmentInfo, id, files);
BlockTermsReader.files(dir, segmentInfo, id, files);
FixedGapTermsIndexReader.files(dir, segmentInfo, id, files);
+ DefaultDocValuesConsumer.files(dir, segmentInfo, id, files);
}
@Override
public void getExtensions(Set<String> extensions) {
getStandardExtensions(extensions);
+ DefaultDocValuesConsumer.getDocValuesExtensions(extensions);
}
public static void getStandardExtensions(Set<String> extensions) {
@@ -209,12 +215,22 @@ public class TestDocTermOrds extends Luc
BlockTermsReader.getExtensions(extensions);
FixedGapTermsIndexReader.getIndexExtensions(extensions);
}
+
+ @Override
+ public PerDocConsumer docsConsumer(PerDocWriteState state) throws IOException {
+ return new DefaultDocValuesConsumer(state, BytesRef.getUTF8SortedAsUnicodeComparator());
+ }
+
+ @Override
+ public PerDocValues docsProducer(SegmentReadState state) throws IOException {
+ return new DefaultDocValuesProducer(state.segmentInfo, state.dir, state.fieldInfos, state.codecId);
+ }
}
public void testRandom() throws Exception {
MockDirectoryWrapper dir = newDirectory();
- final int NUM_TERMS = (TEST_NIGHTLY ? 100 : 20) * RANDOM_MULTIPLIER;
+ final int NUM_TERMS = atLeast(20);
final Set<BytesRef> terms = new HashSet<BytesRef>();
while(terms.size() < NUM_TERMS) {
final String s = _TestUtil.randomRealisticUnicodeString(random);
@@ -226,7 +242,7 @@ public class TestDocTermOrds extends Luc
final BytesRef[] termsArray = terms.toArray(new BytesRef[terms.size()]);
Arrays.sort(termsArray);
- final int NUM_DOCS = (TEST_NIGHTLY ? 1000 : 100) * RANDOM_MULTIPLIER;
+ final int NUM_DOCS = atLeast(100);
IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random));
@@ -317,7 +333,7 @@ public class TestDocTermOrds extends Luc
}
final String[] prefixesArray = prefixes.toArray(new String[prefixes.size()]);
- final int NUM_TERMS = (TEST_NIGHTLY ? 100 : 20) * RANDOM_MULTIPLIER;
+ final int NUM_TERMS = atLeast(20);
final Set<BytesRef> terms = new HashSet<BytesRef>();
while(terms.size() < NUM_TERMS) {
final String s = prefixesArray[random.nextInt(prefixesArray.length)] + _TestUtil.randomRealisticUnicodeString(random);
@@ -329,7 +345,7 @@ public class TestDocTermOrds extends Luc
final BytesRef[] termsArray = terms.toArray(new BytesRef[terms.size()]);
Arrays.sort(termsArray);
- final int NUM_DOCS = (TEST_NIGHTLY ? 1000 : 100) * RANDOM_MULTIPLIER;
+ final int NUM_DOCS = atLeast(100);
IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random));
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestDocsAndPositions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestDocsAndPositions.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestDocsAndPositions.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestDocsAndPositions.java Fri Jun 10 18:17:44 2011
@@ -57,7 +57,8 @@ public class TestDocsAndPositions extend
IndexReader reader = writer.getReader();
writer.close();
- for (int i = 0; i < (TEST_NIGHTLY ? 39 : 13) * RANDOM_MULTIPLIER; i++) {
+ int num = atLeast(13);
+ for (int i = 0; i < num; i++) {
BytesRef bytes = new BytesRef("1");
ReaderContext topReaderContext = reader.getTopReaderContext();
AtomicReaderContext[] leaves = ReaderUtil.leaves(topReaderContext);
@@ -112,7 +113,7 @@ public class TestDocsAndPositions extend
Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir,
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(newLogMergePolicy()));
- int numDocs = TEST_NIGHTLY ? 131 : 47;
+ int numDocs = atLeast(47);
int max = 1051;
int term = random.nextInt(max);
Integer[][] positionsInDoc = new Integer[numDocs][];
@@ -120,7 +121,7 @@ public class TestDocsAndPositions extend
Document doc = new Document();
ArrayList<Integer> positions = new ArrayList<Integer>();
StringBuilder builder = new StringBuilder();
- int num = TEST_NIGHTLY ? 3049 : 499;
+ int num = atLeast(131);
for (int j = 0; j < num; j++) {
int nextInt = random.nextInt(max);
builder.append(nextInt).append(" ");
@@ -141,7 +142,8 @@ public class TestDocsAndPositions extend
IndexReader reader = writer.getReader();
writer.close();
- for (int i = 0; i < (TEST_NIGHTLY ? 39 : 13) * RANDOM_MULTIPLIER; i++) {
+ int num = atLeast(13);
+ for (int i = 0; i < num; i++) {
BytesRef bytes = new BytesRef("" + term);
ReaderContext topReaderContext = reader.getTopReaderContext();
AtomicReaderContext[] leaves = ReaderUtil.leaves(topReaderContext);
@@ -193,7 +195,7 @@ public class TestDocsAndPositions extend
Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir,
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(newLogMergePolicy()));
- int numDocs = TEST_NIGHTLY ? 499 : 131;
+ int numDocs = atLeast(49);
int max = 15678;
int term = random.nextInt(max);
int[] freqInDoc = new int[numDocs];
@@ -202,7 +204,7 @@ public class TestDocsAndPositions extend
StringBuilder builder = new StringBuilder();
for (int j = 0; j < 199; j++) {
int nextInt = random.nextInt(max);
- builder.append(nextInt).append(" ");
+ builder.append(nextInt).append(' ');
if (nextInt == term) {
freqInDoc[i]++;
}
@@ -215,7 +217,8 @@ public class TestDocsAndPositions extend
IndexReader reader = writer.getReader();
writer.close();
- for (int i = 0; i < (TEST_NIGHTLY ? 39 : 13) * RANDOM_MULTIPLIER; i++) {
+ int num = atLeast(13);
+ for (int i = 0; i < num; i++) {
BytesRef bytes = new BytesRef("" + term);
ReaderContext topReaderContext = reader.getTopReaderContext();
AtomicReaderContext[] leaves = ReaderUtil.leaves(topReaderContext);
@@ -291,7 +294,8 @@ public class TestDocsAndPositions extend
IndexReader reader = writer.getReader();
writer.close();
- for (int i = 0; i < (TEST_NIGHTLY ? 39 : 13) * RANDOM_MULTIPLIER; i++) {
+ int num = atLeast(13);
+ for (int i = 0; i < num; i++) {
BytesRef bytes = new BytesRef("even");
ReaderContext topReaderContext = reader.getTopReaderContext();
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java Fri Jun 10 18:17:44 2011
@@ -137,7 +137,7 @@ public class TestFieldInfos extends Luce
try {
readOnly.addOrUpdate("bogus", random.nextBoolean(), random.nextBoolean(),
random.nextBoolean(), random.nextBoolean(), random.nextBoolean(),
- random.nextBoolean(), random.nextBoolean());
+ random.nextBoolean(), random.nextBoolean(), null);
fail("instance should be read only");
} catch (IllegalStateException e) {
// expected
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java Fri Jun 10 18:17:44 2011
@@ -516,7 +516,7 @@ public class TestFieldsReader extends Lu
public void testNumericField() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random, dir);
- final int numDocs = _TestUtil.nextInt(random, 500, 1000) * RANDOM_MULTIPLIER;
+ final int numDocs = atLeast(500);
final Number[] answers = new Number[numDocs];
final NumericField.DataType[] typeAnswers = new NumericField.DataType[numDocs];
for(int id=0;id<numDocs;id++) {
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java Fri Jun 10 18:17:44 2011
@@ -30,18 +30,23 @@ import org.apache.lucene.store.LockObtai
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.LineFileDocs;
import org.apache.lucene.util.LuceneTestCase;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
public class TestFlushByRamOrCountsPolicy extends LuceneTestCase {
- private LineFileDocs lineDocFile;
+ private static LineFileDocs lineDocFile;
- @Before
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ @BeforeClass
+ public static void beforeClass() throws Exception {
lineDocFile = new LineFileDocs(random);
}
+
+ @AfterClass
+ public static void afterClass() throws Exception {
+ lineDocFile.close();
+ lineDocFile = null;
+ }
public void testFlushByRam() throws CorruptIndexException,
LockObtainFailedException, IOException, InterruptedException {
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestGlobalFieldNumbers.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestGlobalFieldNumbers.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestGlobalFieldNumbers.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestGlobalFieldNumbers.java Fri Jun 10 18:17:44 2011
@@ -42,7 +42,8 @@ import org.apache.lucene.util._TestUtil;
public class TestGlobalFieldNumbers extends LuceneTestCase {
public void testGlobalFieldNumberFiles() throws IOException {
- for (int i = 0; i < (TEST_NIGHTLY ? 39 : 13); i++) {
+ int num = atLeast(3);
+ for (int i = 0; i < num; i++) {
Directory dir = newDirectory();
{
IndexWriterConfig config = newIndexWriterConfig(TEST_VERSION_CURRENT,
@@ -113,7 +114,8 @@ public class TestGlobalFieldNumbers exte
}
public void testIndexReaderCommit() throws IOException {
- for (int i = 0; i < (TEST_NIGHTLY ? 39 : 13); i++) {
+ int num = atLeast(3);
+ for (int i = 0; i < num; i++) {
Directory dir = newDirectory();
{
IndexWriterConfig config = newIndexWriterConfig(TEST_VERSION_CURRENT,
@@ -156,7 +158,8 @@ public class TestGlobalFieldNumbers exte
}
public void testGlobalFieldNumberFilesAcrossCommits() throws IOException {
- for (int i = 0; i < (TEST_NIGHTLY ? 39 : 13); i++) {
+ int num = atLeast(3);
+ for (int i = 0; i < num; i++) {
Directory dir = newDirectory();
{
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
@@ -207,7 +210,8 @@ public class TestGlobalFieldNumbers exte
}
public void testGlobalFieldNumberOnOldCommit() throws IOException {
- for (int i = 0; i < (TEST_NIGHTLY ? 39 : 13); i++) {
+ int num = atLeast(3);
+ for (int i = 0; i < num; i++) {
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random)).setIndexDeletionPolicy(
@@ -282,9 +286,9 @@ public class TestGlobalFieldNumbers exte
}
public void testOptimize() throws IOException {
- for (int i = 0; i < 2; i++) {
+ for (int i = 0; i < 2*RANDOM_MULTIPLIER; i++) {
Set<String> fieldNames = new HashSet<String>();
- final int numFields = 2 + random.nextInt(200);
+ final int numFields = 2 + (TEST_NIGHTLY ? random.nextInt(200) : random.nextInt(20));
for (int j = 0; j < numFields; j++) {
fieldNames.add("field_" + j);
}
@@ -306,9 +310,9 @@ public class TestGlobalFieldNumbers exte
}
public void testAddIndexesStableFieldNumbers() throws IOException {
- for (int i = 0; i < 2; i++) {
+ for (int i = 0; i < 2*RANDOM_MULTIPLIER; i++) {
Set<String> fieldNames = new HashSet<String>();
- final int numFields = 2 + random.nextInt(50);
+ final int numFields = 2 + (TEST_NIGHTLY ? random.nextInt(50) : random.nextInt(10));
for (int j = 0; j < numFields; j++) {
fieldNames.add("field_" + j);
}
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexFileDeleter.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexFileDeleter.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexFileDeleter.java Fri Jun 10 18:17:44 2011
@@ -53,6 +53,8 @@ public class TestIndexFileDeleter extend
setMergePolicy(mergePolicy)
);
+ writer.setInfoStream(VERBOSE ? System.out : null);
+
int i;
for(i=0;i<35;i++) {
addDoc(writer, i);
@@ -146,7 +148,9 @@ public class TestIndexFileDeleter extend
copyFile(dir, "segments_2", "segments_1");
// Create a bogus cfs file shadowing a non-cfs segment:
- copyFile(dir, "_1.cfs", "_2.cfs");
+ assertTrue(dir.fileExists("_3.fdt"));
+ assertTrue(!dir.fileExists("_3.cfs"));
+ copyFile(dir, "_1.cfs", "_3.cfs");
String[] filesPre = dir.listAll();
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexReaderOnDiskFull.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexReaderOnDiskFull.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexReaderOnDiskFull.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexReaderOnDiskFull.java Fri Jun 10 18:17:44 2011
@@ -30,6 +30,7 @@ import org.apache.lucene.search.TermQuer
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
public class TestIndexReaderOnDiskFull extends LuceneTestCase {
/**
@@ -74,7 +75,7 @@ public class TestIndexReaderOnDiskFull e
}
long diskUsage = startDir.getRecomputedActualSizeInBytes();
- long diskFree = diskUsage+100;
+ long diskFree = diskUsage+_TestUtil.nextInt(random, 50, 200);
IOException err = null;
@@ -219,8 +220,8 @@ public class TestIndexReaderOnDiskFull e
dir.close();
- // Try again with 10 more bytes of free space:
- diskFree += 10;
+ // Try again with more bytes of free space:
+ diskFree += TEST_NIGHTLY ? _TestUtil.nextInt(random, 5, 20) : _TestUtil.nextInt(random, 50, 200);
}
startDir.close();
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java Fri Jun 10 18:17:44 2011
@@ -50,8 +50,6 @@ import org.apache.lucene.util.LuceneTest
import org.apache.lucene.util._TestUtil;
public class TestIndexReaderReopen extends LuceneTestCase {
-
- private File indexDir;
public void testReopen() throws Exception {
final Directory dir1 = newDirectory();
@@ -151,22 +149,12 @@ public class TestIndexReaderReopen exten
// at the end of every iteration, commit the index and reopen/recreate the reader.
// in each iteration verify the work of previous iteration.
// try this once with reopen once recreate, on both RAMDir and FSDir.
- public void testCommitReopenFS () throws IOException {
- Directory dir = newFSDirectory(indexDir);
- doTestReopenWithCommit(random, dir, true);
- dir.close();
- }
- public void testCommitRecreateFS () throws IOException {
- Directory dir = newFSDirectory(indexDir);
- doTestReopenWithCommit(random, dir, false);
- dir.close();
- }
- public void testCommitReopenRAM () throws IOException {
+ public void testCommitReopen () throws IOException {
Directory dir = newDirectory();
doTestReopenWithCommit(random, dir, true);
dir.close();
}
- public void testCommitRecreateRAM () throws IOException {
+ public void testCommitRecreate () throws IOException {
Directory dir = newDirectory();
doTestReopenWithCommit(random, dir, false);
dir.close();
@@ -699,7 +687,7 @@ public class TestIndexReaderReopen exten
public void testThreadSafety() throws Exception {
final Directory dir = newDirectory();
- final int n = 30 * RANDOM_MULTIPLIER;
+ final int n = atLeast(30);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random)));
for (int i = 0; i < n; i++) {
@@ -1086,13 +1074,6 @@ public class TestIndexReaderReopen exten
protected abstract IndexReader openReader() throws IOException;
protected abstract void modifyIndex(int i) throws IOException;
}
-
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- indexDir = _TestUtil.getTempDir("IndexReaderReopen");
- }
public void testCloseOrig() throws Throwable {
Directory dir = newDirectory();
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java Fri Jun 10 18:17:44 2011
@@ -73,6 +73,7 @@ import org.apache.lucene.util.LuceneTest
import org.apache.lucene.util.ThreadInterruptedException;
import org.apache.lucene.util.UnicodeUtil;
import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.index.codecs.preflexrw.PreFlexRWCodec;
public class TestIndexWriter extends LuceneTestCase {
@@ -1524,7 +1525,7 @@ public class TestIndexWriter extends Luc
if (VERBOSE) {
w.w.setInfoStream(System.out);
}
- final int docCount = 200*RANDOM_MULTIPLIER;
+ final int docCount = atLeast(200);
final int fieldCount = _TestUtil.nextInt(rand, 1, 5);
final List<Integer> fieldIDs = new ArrayList<Integer>();
@@ -1589,7 +1590,8 @@ public class TestIndexWriter extends Luc
System.out.println("TEST: cycle x=" + x + " r=" + r);
}
- for(int iter=0;iter<1000*RANDOM_MULTIPLIER;iter++) {
+ int num = atLeast(1000);
+ for(int iter=0;iter<num;iter++) {
String testID = idsList[rand.nextInt(idsList.length)];
if (VERBOSE) {
System.out.println("TEST: test id=" + testID);
@@ -1762,4 +1764,18 @@ public class TestIndexWriter extends Luc
reader.close();
dir.close();
}
+
+ // LUCENE-3183
+ public void testEmptyFieldNameTIIOne() throws IOException {
+ Directory dir = newDirectory();
+ IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random));
+ iwc.setTermIndexInterval(1);
+ iwc.setReaderTermsIndexDivisor(1);
+ IndexWriter writer = new IndexWriter(dir, iwc);
+ Document doc = new Document();
+ doc.add(newField("", "a b c", Field.Store.NO, Field.Index.ANALYZED));
+ writer.addDocument(doc);
+ writer.close();
+ dir.close();
+ }
}
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java Fri Jun 10 18:17:44 2011
@@ -874,7 +874,7 @@ public class TestIndexWriterDelete exten
public void testDeleteAllSlowly() throws Exception {
final Directory dir = newDirectory();
RandomIndexWriter w = new RandomIndexWriter(random, dir);
- final int NUM_DOCS = 1000 * RANDOM_MULTIPLIER;
+ final int NUM_DOCS = atLeast(1000);
final List<Integer> ids = new ArrayList<Integer>(NUM_DOCS);
for(int id=0;id<NUM_DOCS;id++) {
ids.add(id);
@@ -917,7 +917,7 @@ public class TestIndexWriterDelete exten
w.setInfoStream(VERBOSE ? System.out : null);
Document doc = new Document();
doc.add(newField("field", "go 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20", Field.Store.NO, Field.Index.ANALYZED));
- int num = TEST_NIGHTLY ? 6 * RANDOM_MULTIPLIER : 3 * RANDOM_MULTIPLIER;
+ int num = atLeast(3);
for (int iter = 0; iter < num; iter++) {
int count = 0;
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java Fri Jun 10 18:17:44 2011
@@ -930,7 +930,8 @@ public class TestIndexWriterExceptions e
addDoc(w);
w.close();
- for(int i=0;i<200;i++) {
+ int iter = TEST_NIGHTLY ? 200 : 20;
+ for(int i=0;i<iter;i++) {
if (VERBOSE) {
System.out.println("TEST: iter " + i);
}
@@ -1222,7 +1223,8 @@ public class TestIndexWriterExceptions e
FailOnTermVectors[] failures = new FailOnTermVectors[] {
new FailOnTermVectors(FailOnTermVectors.AFTER_INIT_STAGE),
new FailOnTermVectors(FailOnTermVectors.INIT_STAGE), };
- for (int j = 0; j < 3 * RANDOM_MULTIPLIER; j++) {
+ int num = atLeast(3);
+ for (int j = 0; j < num; j++) {
for (FailOnTermVectors failure : failures) {
MockDirectoryWrapper dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnJRECrash.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnJRECrash.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnJRECrash.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterOnJRECrash.java Fri Jun 10 18:17:44 2011
@@ -64,7 +64,7 @@ public class TestIndexWriterOnJRECrash e
}
} else {
// we are the fork, setup a crashing thread
- final int crashTime = _TestUtil.nextInt(random, 500, 4000);
+ final int crashTime = TEST_NIGHTLY ? _TestUtil.nextInt(random, 500, 4000) : _TestUtil.nextInt(random, 300, 1000);
Thread t = new Thread() {
@Override
public void run() {
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterOptimize.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterOptimize.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterOptimize.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterOptimize.java Fri Jun 10 18:17:44 2011
@@ -37,7 +37,7 @@ public class TestIndexWriterOptimize ext
MockDirectoryWrapper dir = newDirectory();
final Document doc = new Document();
- doc.add(newField("content", "aaa", Field.Store.YES, Field.Index.ANALYZED));
+ doc.add(newField("content", "aaa", Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS));
final int incrMin = TEST_NIGHTLY ? 15 : 40;
for(int numDocs=10;numDocs<500;numDocs += _TestUtil.nextInt(random, incrMin, 5*incrMin)) {
LogDocMergePolicy ldmp = new LogDocMergePolicy();
@@ -78,7 +78,7 @@ public class TestIndexWriterOptimize ext
MockDirectoryWrapper dir = newDirectory();
final Document doc = new Document();
- doc.add(newField("content", "aaa", Field.Store.YES, Field.Index.ANALYZED));
+ doc.add(newField("content", "aaa", Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS));
LogDocMergePolicy ldmp = new LogDocMergePolicy();
ldmp.setMinMergeDocs(1);
@@ -183,7 +183,7 @@ public class TestIndexWriterOptimize ext
setMergePolicy(newLogMergePolicy(51))
);
Document doc = new Document();
- doc.add(newField("field", "aaa", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS));
+ doc.add(newField("field", "aaa", Store.NO, Index.NOT_ANALYZED));
for(int i=0;i<100;i++)
writer.addDocument(doc);
writer.optimize(false);
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterReader.java Fri Jun 10 18:17:44 2011
@@ -658,7 +658,7 @@ public class TestIndexWriterReader exten
((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(2);
- int num = 100 * RANDOM_MULTIPLIER;
+ int num = atLeast(100);
for (int i = 0; i < num; i++) {
writer.addDocument(createDocument(i, "test", 4));
}
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterUnicode.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterUnicode.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterUnicode.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestIndexWriterUnicode.java Fri Jun 10 18:17:44 2011
@@ -175,7 +175,7 @@ public class TestIndexWriterUnicode exte
BytesRef utf8 = new BytesRef(20);
CharsRef utf16 = new CharsRef(20);
- int num = 100000 * RANDOM_MULTIPLIER;
+ int num = atLeast(100000);
for (int iter = 0; iter < num; iter++) {
boolean hasIllegal = fillUnicode(buffer, expected, 0, 20);
@@ -281,7 +281,7 @@ public class TestIndexWriterUnicode exte
char[] chars = new char[2];
final Set<String> allTerms = new HashSet<String>();
- int num = 200 * RANDOM_MULTIPLIER;
+ int num = atLeast(200);
for (int i = 0; i < num; i++) {
final String s;
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestLazyBug.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestLazyBug.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestLazyBug.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestLazyBug.java Fri Jun 10 18:17:44 2011
@@ -126,15 +126,15 @@ public class TestLazyBug extends LuceneT
}
public void testLazyWorks() throws Exception {
- doTest(new int[] { 399 });
+ doTest(new int[] { NUM_DOCS-1 });
}
public void testLazyAlsoWorks() throws Exception {
- doTest(new int[] { 399, 150 });
+ doTest(new int[] { NUM_DOCS-1, NUM_DOCS/2 });
}
public void testLazyBroken() throws Exception {
- doTest(new int[] { 150, 399 });
+ doTest(new int[] { NUM_DOCS/2, NUM_DOCS-1 });
}
}
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestLongPostings.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestLongPostings.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestLongPostings.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestLongPostings.java Fri Jun 10 18:17:44 2011
@@ -70,7 +70,7 @@ public class TestLongPostings extends Lu
// randomness (ie same seed will point to same dir):
Directory dir = newFSDirectory(_TestUtil.getTempDir("longpostings" + "." + random.nextLong()));
- final int NUM_DOCS = (int) ((TEST_NIGHTLY ? 4e6 : (RANDOM_MULTIPLIER*2e3)) * (1+random.nextDouble()));
+ final int NUM_DOCS = atLeast(2000);
if (VERBOSE) {
System.out.println("TEST: NUM_DOCS=" + NUM_DOCS);
@@ -145,7 +145,8 @@ public class TestLongPostings extends Lu
assertTrue(r.docFreq(new Term("field", s1)) > 0);
assertTrue(r.docFreq(new Term("field", s2)) > 0);
- for(int iter=0;iter<1000*RANDOM_MULTIPLIER;iter++) {
+ int num = atLeast(1000);
+ for(int iter=0;iter<num;iter++) {
final String term;
final boolean doS1;
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestMultiFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestMultiFields.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestMultiFields.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestMultiFields.java Fri Jun 10 18:17:44 2011
@@ -27,7 +27,7 @@ public class TestMultiFields extends Luc
public void testRandom() throws Exception {
- int num = 2 * RANDOM_MULTIPLIER;
+ int num = atLeast(2);
for (int iter = 0; iter < num; iter++) {
Directory dir = newDirectory();
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestNRTThreads.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestNRTThreads.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestNRTThreads.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestNRTThreads.java Fri Jun 10 18:17:44 2011
@@ -43,7 +43,6 @@ import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
-import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
@@ -105,6 +104,7 @@ public class TestNRTThreads extends Luce
final LineFileDocs docs = new LineFileDocs(random);
final File tempDir = _TestUtil.getTempDir("nrtopenfiles");
final MockDirectoryWrapper dir = newFSDirectory(tempDir);
+ dir.setCheckIndexOnClose(false); // don't double-checkIndex, we do it ourselves.
final IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random));
if (LuceneTestCase.TEST_NIGHTLY) {
@@ -157,7 +157,7 @@ public class TestNRTThreads extends Luce
final int NUM_INDEX_THREADS = 2;
final int NUM_SEARCH_THREADS = 3;
- final int RUN_TIME_SEC = LuceneTestCase.TEST_NIGHTLY ? 300 : 5;
+ final int RUN_TIME_SEC = LuceneTestCase.TEST_NIGHTLY ? 300 : RANDOM_MULTIPLIER;
final AtomicBoolean failed = new AtomicBoolean();
final AtomicInteger addCount = new AtomicInteger();
@@ -328,11 +328,11 @@ public class TestNRTThreads extends Luce
if (addedField != null) {
doc.removeField(addedField);
}
- } catch (Exception exc) {
+ } catch (Throwable t) {
System.out.println(Thread.currentThread().getName() + ": hit exc");
- exc.printStackTrace();
+ t.printStackTrace();
failed.set(true);
- throw new RuntimeException(exc);
+ throw new RuntimeException(t);
}
}
if (VERBOSE) {
@@ -448,6 +448,7 @@ public class TestNRTThreads extends Luce
System.out.println(Thread.currentThread().getName() + ": search done");
}
} catch (Throwable t) {
+ System.out.println(Thread.currentThread().getName() + ": hit exc");
failed.set(true);
t.printStackTrace(System.out);
throw new RuntimeException(t);
@@ -565,8 +566,10 @@ public class TestNRTThreads extends Luce
assertFalse(writer.anyNonBulkMerges);
writer.close(false);
+ _TestUtil.checkIndex(dir);
s.close();
dir.close();
+ _TestUtil.rmDir(tempDir);
docs.close();
if (VERBOSE) {
System.out.println("TEST: done [" + (System.currentTimeMillis()-t0) + " ms]");
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestNorms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestNorms.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestNorms.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestNorms.java Fri Jun 10 18:17:44 2011
@@ -143,7 +143,8 @@ public class TestNorms extends LuceneTes
}
private void doTestNorms(Random random, Directory dir) throws IOException {
- for (int i=0; i<5; i++) {
+ int num = atLeast(1);
+ for (int i=0; i<num; i++) {
addDocs(random, dir,12,true);
verifyIndex(dir);
modifyNormsForF1(dir);
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestPayloads.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestPayloads.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestPayloads.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestPayloads.java Fri Jun 10 18:17:44 2011
@@ -474,7 +474,7 @@ public class TestPayloads extends Lucene
public void testThreadSafety() throws Exception {
final int numThreads = 5;
- final int numDocs = 50 * RANDOM_MULTIPLIER;
+ final int numDocs = atLeast(50);
final ByteArrayPool pool = new ByteArrayPool(numThreads, 5);
Directory dir = newDirectory();
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestPerFieldCodecSupport.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestPerFieldCodecSupport.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestPerFieldCodecSupport.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestPerFieldCodecSupport.java Fri Jun 10 18:17:44 2011
@@ -274,7 +274,8 @@ public class TestPerFieldCodecSupport ex
Index[] indexValue = new Index[] { Index.ANALYZED, Index.ANALYZED_NO_NORMS,
Index.NOT_ANALYZED, Index.NOT_ANALYZED_NO_NORMS };
final int docsPerRound = 97;
- for (int i = 0; i < 5; i++) {
+ int numRounds = atLeast(1);
+ for (int i = 0; i < numRounds; i++) {
CodecProvider provider = new CodecProvider();
Codec[] codecs = new Codec[] { new StandardCodec(),
new SimpleTextCodec(), new MockSepCodec(),
@@ -284,7 +285,8 @@ public class TestPerFieldCodecSupport ex
for (Codec codec : codecs) {
provider.register(codec);
}
- for (int j = 0; j < 30 * RANDOM_MULTIPLIER; j++) {
+ int num = atLeast(30);
+ for (int j = 0; j < num; j++) {
provider.setFieldCodec("" + j, codecs[random.nextInt(codecs.length)].name);
}
IndexWriterConfig config = newIndexWriterConfig(random,
@@ -294,7 +296,8 @@ public class TestPerFieldCodecSupport ex
IndexWriter writer = newWriter(dir, config);
for (int j = 0; j < docsPerRound; j++) {
final Document doc = new Document();
- for (int k = 0; k < 30 * RANDOM_MULTIPLIER; k++) {
+ num = atLeast(30);
+ for (int k = 0; k < num; k++) {
Field field = newField("" + k, _TestUtil
.randomRealisticUnicodeString(random, 128), indexValue[random
.nextInt(indexValue.length)]);
@@ -308,7 +311,6 @@ public class TestPerFieldCodecSupport ex
writer.commit();
assertEquals((i + 1) * docsPerRound, writer.maxDoc());
writer.close();
- _TestUtil.checkIndex(dir, provider);
}
dir.close();
}
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestRollingUpdates.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestRollingUpdates.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestRollingUpdates.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestRollingUpdates.java Fri Jun 10 18:17:44 2011
@@ -36,7 +36,7 @@ public class TestRollingUpdates extends
final LineFileDocs docs = new LineFileDocs(random);
final IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
- final int SIZE = (TEST_NIGHTLY ? 200 : 20) * RANDOM_MULTIPLIER;
+ final int SIZE = atLeast(20);
int id = 0;
IndexReader r = null;
final int numUpdates = (int) (SIZE * (2+random.nextDouble()));
@@ -82,7 +82,7 @@ public class TestRollingUpdates extends
for (int r = 0; r < 3; r++) {
final IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMaxBufferedDocs(2));
- final int numUpdates = (TEST_NIGHTLY ? 200 : 20) * RANDOM_MULTIPLIER;
+ final int numUpdates = atLeast(20);
int numThreads = _TestUtil.nextInt(random, 2, 6);
IndexingThread[] threads = new IndexingThread[numThreads];
for (int i = 0; i < numThreads; i++) {
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestStressAdvance.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestStressAdvance.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestStressAdvance.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestStressAdvance.java Fri Jun 10 18:17:44 2011
@@ -40,7 +40,8 @@ public class TestStressAdvance extends L
doc.add(f);
final Field idField = newField("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);
doc.add(idField);
- for(int id=0;id<5000*RANDOM_MULTIPLIER;id++) {
+ int num = atLeast(5000);
+ for(int id=0;id<num;id++) {
if (random.nextInt(4) == 3) {
f.setValue("a");
aDocs.add(id);
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java Fri Jun 10 18:17:44 2011
@@ -27,7 +27,7 @@ public class TestStressIndexing extends
private static abstract class TimedThread extends Thread {
volatile boolean failed;
int count;
- private static int RUN_TIME_SEC = 1 * RANDOM_MULTIPLIER;
+ private static int RUN_TIME_MSEC = atLeast(1000);
private TimedThread[] allThreads;
abstract public void doWork() throws Throwable;
@@ -38,7 +38,7 @@ public class TestStressIndexing extends
@Override
public void run() {
- final long stopTime = System.currentTimeMillis() + 1000*RUN_TIME_SEC;
+ final long stopTime = System.currentTimeMillis() + RUN_TIME_MSEC;
count = 0;
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java Fri Jun 10 18:17:44 2011
@@ -93,7 +93,7 @@ public class TestStressIndexing2 extends
public void testMultiConfig() throws Throwable {
// test lots of smaller different params together
- int num = 3 * RANDOM_MULTIPLIER;
+ int num = atLeast(3);
for (int i = 0; i < num; i++) { // increase iterations for better testing
if (VERBOSE) {
System.out.println("\n\nTEST: top iter=" + i);
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestThreadedOptimize.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestThreadedOptimize.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestThreadedOptimize.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestThreadedOptimize.java Fri Jun 10 18:17:44 2011
@@ -47,14 +47,13 @@ public class TestThreadedOptimize extend
failed = true;
}
- public void runTest(Random random, Directory directory, MergeScheduler merger) throws Exception {
+ public void runTest(Random random, Directory directory) throws Exception {
IndexWriter writer = new IndexWriter(
directory,
newIndexWriterConfig(TEST_VERSION_CURRENT, ANALYZER).
setOpenMode(OpenMode.CREATE).
setMaxBufferedDocs(2).
- setMergeScheduler(merger).
setMergePolicy(newLogMergePolicy())
);
@@ -65,8 +64,8 @@ public class TestThreadedOptimize extend
for(int i=0;i<200;i++) {
Document d = new Document();
- d.add(newField("id", Integer.toString(i), Field.Store.YES, Field.Index.NOT_ANALYZED));
- d.add(newField("contents", English.intToEnglish(i), Field.Store.NO, Field.Index.ANALYZED));
+ d.add(newField("id", Integer.toString(i), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
+ d.add(newField("contents", English.intToEnglish(i), Field.Store.NO, Field.Index.ANALYZED_NO_NORMS));
writer.addDocument(d);
}
@@ -86,8 +85,8 @@ public class TestThreadedOptimize extend
writerFinal.optimize(false);
for(int k=0;k<17*(1+iFinal);k++) {
Document d = new Document();
- d.add(newField("id", iterFinal + "_" + iFinal + "_" + j + "_" + k, Field.Store.YES, Field.Index.NOT_ANALYZED));
- d.add(newField("contents", English.intToEnglish(iFinal+k), Field.Store.NO, Field.Index.ANALYZED));
+ d.add(newField("id", iterFinal + "_" + iFinal + "_" + j + "_" + k, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
+ d.add(newField("contents", English.intToEnglish(iFinal+k), Field.Store.NO, Field.Index.ANALYZED_NO_NORMS));
writerFinal.addDocument(d);
}
for(int k=0;k<9*(1+iFinal);k++)
@@ -135,8 +134,7 @@ public class TestThreadedOptimize extend
*/
public void testThreadedOptimize() throws Exception {
Directory directory = newDirectory();
- runTest(random, directory, new SerialMergeScheduler());
- runTest(random, directory, new ConcurrentMergeScheduler());
+ runTest(random, directory);
directory.close();
}
}
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestTieredMergePolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestTieredMergePolicy.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestTieredMergePolicy.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestTieredMergePolicy.java Fri Jun 10 18:17:44 2011
@@ -66,7 +66,8 @@ public class TestTieredMergePolicy exten
}
public void testPartialOptimize() throws Exception {
- for(int iter=0;iter<10*RANDOM_MULTIPLIER;iter++) {
+ int num = atLeast(10);
+ for(int iter=0;iter<num;iter++) {
if (VERBOSE) {
System.out.println("TEST: iter=" + iter);
}
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestTransactions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestTransactions.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestTransactions.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/TestTransactions.java Fri Jun 10 18:17:44 2011
@@ -42,7 +42,7 @@ public class TestTransactions extends Lu
private static abstract class TimedThread extends Thread {
volatile boolean failed;
- private static float RUN_TIME_SEC = 0.5f * RANDOM_MULTIPLIER;
+ private static float RUN_TIME_MSEC = atLeast(500);
private TimedThread[] allThreads;
abstract public void doWork() throws Throwable;
@@ -53,7 +53,7 @@ public class TestTransactions extends Lu
@Override
public void run() {
- final long stopTime = System.currentTimeMillis() + (long) (1000*RUN_TIME_SEC);
+ final long stopTime = System.currentTimeMillis() + (long) (RUN_TIME_MSEC);
try {
do {
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java Fri Jun 10 18:17:44 2011
@@ -134,7 +134,7 @@ public class TestSurrogates extends Luce
System.out.println("\nTEST: top now seek");
}
- int num = 100 * RANDOM_MULTIPLIER;
+ int num = atLeast(100);
for (int iter = 0; iter < num; iter++) {
// pick random field+term
@@ -197,7 +197,7 @@ public class TestSurrogates extends Luce
}
{
- int num = 100 * RANDOM_MULTIPLIER;
+ int num = atLeast(100);
for (int iter = 0; iter < num; iter++) {
// seek to random spot
@@ -287,7 +287,7 @@ public class TestSurrogates extends Luce
for(int f=0;f<numField;f++) {
String field = "f" + f;
- final int numTerms = (TEST_NIGHTLY ? 10000 : 1000) * RANDOM_MULTIPLIER;
+ final int numTerms = atLeast(1000);
final Set<String> uniqueTerms = new HashSet<String>();
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java Fri Jun 10 18:17:44 2011
@@ -67,7 +67,7 @@ public class BaseTestRangeFilter extends
static TestIndex unsignedIndexDir;
static int minId = 0;
- static int maxId = 10000;
+ static int maxId = atLeast(500);
static final int intLength = Integer.toString(Integer.MAX_VALUE).length();
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestBoolean2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestBoolean2.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestBoolean2.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestBoolean2.java Fri Jun 10 18:17:44 2011
@@ -232,7 +232,7 @@ public class TestBoolean2 extends Lucene
try {
// increase number of iterations for more complete testing
- int num = (TEST_NIGHTLY ? 50 : 10) * RANDOM_MULTIPLIER;
+ int num = atLeast(10);
for (int i=0; i<num; i++) {
int level = random.nextInt(3);
q1 = randBoolQuery(new Random(random.nextLong()), random.nextBoolean(), level, field, vals, null);
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java Fri Jun 10 18:17:44 2011
@@ -314,7 +314,7 @@ public class TestBooleanMinShouldMatch e
// increase number of iterations for more complete testing
- int num = (TEST_NIGHTLY ? 50 : 10) * RANDOM_MULTIPLIER;
+ int num = atLeast(10);
for (int i=0; i<num; i++) {
int lev = random.nextInt(maxLev);
final long seed = random.nextLong();
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestCustomSearcherSort.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestCustomSearcherSort.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestCustomSearcherSort.java Fri Jun 10 18:17:44 2011
@@ -39,7 +39,7 @@ public class TestCustomSearcherSort exte
private IndexReader reader;
private Query query = null;
// reduced from 20000 to 2000 to speed up test...
- private final static int INDEX_SIZE = 2000 * RANDOM_MULTIPLIER;
+ private final static int INDEX_SIZE = atLeast(2000);
/**
* Create index and query for test cases.
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestDateFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestDateFilter.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestDateFilter.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestDateFilter.java Fri Jun 10 18:17:44 2011
@@ -32,7 +32,6 @@ import java.io.IOException;
* DateFilter JUnit tests.
*
*
- * @version $Revision$
*/
public class TestDateFilter extends LuceneTestCase {
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestDocBoost.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestDocBoost.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestDocBoost.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestDocBoost.java Fri Jun 10 18:17:44 2011
@@ -31,7 +31,6 @@ import org.apache.lucene.util.LuceneTest
/** Document boost unit test.
*
*
- * @version $Revision$
*/
public class TestDocBoost extends LuceneTestCase {
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestFieldCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestFieldCache.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestFieldCache.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestFieldCache.java Fri Jun 10 18:17:44 2011
@@ -33,7 +33,7 @@ import java.io.PrintStream;
public class TestFieldCache extends LuceneTestCase {
protected IndexReader reader;
- private static final int NUM_DOCS = 1000 * RANDOM_MULTIPLIER;
+ private static final int NUM_DOCS = atLeast(1000);
private String[] unicodeStrings;
private Directory directory;
@@ -185,7 +185,8 @@ public class TestFieldCache extends Luce
}
// seek the enum around (note this isn't a great test here)
- for (int i = 0; i < 100 * RANDOM_MULTIPLIER; i++) {
+ int num = atLeast(100);
+ for (int i = 0; i < num; i++) {
int k = _TestUtil.nextInt(random, 1, nTerms-1);
BytesRef val1 = termsIndex.lookup(k, val);
assertEquals(TermsEnum.SeekStatus.FOUND, tenum.seek(val1));
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery2.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery2.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestFuzzyQuery2.java Fri Jun 10 18:17:44 2011
@@ -57,18 +57,21 @@ public class TestFuzzyQuery2 extends Luc
/** epsilon for score comparisons */
static final float epsilon = 0.00001f;
+ static int[][] mappings = new int[][] {
+ new int[] { 0x40, 0x41 },
+ new int[] { 0x40, 0x0195 },
+ new int[] { 0x40, 0x0906 },
+ new int[] { 0x40, 0x1040F },
+ new int[] { 0x0194, 0x0195 },
+ new int[] { 0x0194, 0x0906 },
+ new int[] { 0x0194, 0x1040F },
+ new int[] { 0x0905, 0x0906 },
+ new int[] { 0x0905, 0x1040F },
+ new int[] { 0x1040E, 0x1040F }
+ };
public void testFromTestData() throws Exception {
// TODO: randomize!
- assertFromTestData(new int[] { 0x40, 0x41 });
- assertFromTestData(new int[] { 0x40, 0x0195 });
- assertFromTestData(new int[] { 0x40, 0x0906 });
- assertFromTestData(new int[] { 0x40, 0x1040F });
- assertFromTestData(new int[] { 0x0194, 0x0195 });
- assertFromTestData(new int[] { 0x0194, 0x0906 });
- assertFromTestData(new int[] { 0x0194, 0x1040F });
- assertFromTestData(new int[] { 0x0905, 0x0906 });
- assertFromTestData(new int[] { 0x0905, 0x1040F });
- assertFromTestData(new int[] { 0x1040E, 0x1040F });
+ assertFromTestData(mappings[random.nextInt(mappings.length)]);
}
public void assertFromTestData(int codePointTable[]) throws Exception {
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java Fri Jun 10 18:17:44 2011
@@ -46,7 +46,7 @@ public class TestMultiValuedNumericRange
DecimalFormat format = new DecimalFormat("00000000000", new DecimalFormatSymbols(Locale.US));
- int num = (TEST_NIGHTLY ? 5000 : 500) * RANDOM_MULTIPLIER;
+ int num = atLeast(500);
for (int l = 0; l < num; l++) {
Document doc = new Document();
for (int m=0, c=random.nextInt(10); m<=c; m++) {
@@ -60,7 +60,7 @@ public class TestMultiValuedNumericRange
writer.close();
IndexSearcher searcher=newSearcher(reader);
- num = 50 * RANDOM_MULTIPLIER;
+ num = atLeast(50);
for (int i = 0; i < num; i++) {
int lower=random.nextInt(Integer.MAX_VALUE);
int upper=random.nextInt(Integer.MAX_VALUE);
Modified: lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestNot.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestNot.java?rev=1134403&r1=1134402&r2=1134403&view=diff
==============================================================================
--- lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestNot.java (original)
+++ lucene/dev/branches/solr2452/lucene/src/test/org/apache/lucene/search/TestNot.java Fri Jun 10 18:17:44 2011
@@ -30,7 +30,6 @@ import org.apache.lucene.document.Field;
/** Similarity unit test.
*
*
- * @version $Revision$
*/
public class TestNot extends LuceneTestCase {