You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2013/04/12 21:51:47 UTC
svn commit: r1467437 - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/core/ lucene/core/src/test/org/apache/lucene/analysis/
lucene/core/src/test/org/apache/lucene/search/ lucene/test-framework/
lucene/test-framework/src/java/org/apache/lucene/in...
Author: rmuir
Date: Fri Apr 12 19:51:46 2013
New Revision: 1467437
URL: http://svn.apache.org/r1467437
Log:
speed up tests to run faster locally
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/analysis/TestGraphTokenizers.java
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java
lucene/dev/branches/branch_4x/lucene/test-framework/ (props changed)
lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java
lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/analysis/TestGraphTokenizers.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/analysis/TestGraphTokenizers.java?rev=1467437&r1=1467436&r2=1467437&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/analysis/TestGraphTokenizers.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/analysis/TestGraphTokenizers.java Fri Apr 12 19:51:46 2013
@@ -319,7 +319,7 @@ public class TestGraphTokenizers extends
};
Random random = random();
- checkRandomData(random, a, 5, atLeast(1000));
+ checkRandomData(random, a, 5, atLeast(100));
}
}
@@ -344,7 +344,7 @@ public class TestGraphTokenizers extends
};
Random random = random();
- checkRandomData(random, a, 5, atLeast(1000));
+ checkRandomData(random, a, 5, atLeast(100));
}
}
@@ -368,7 +368,7 @@ public class TestGraphTokenizers extends
};
Random random = random();
- checkRandomData(random, a, 5, atLeast(1000));
+ checkRandomData(random, a, 5, atLeast(100));
}
}
@@ -392,7 +392,7 @@ public class TestGraphTokenizers extends
};
Random random = random();
- checkRandomData(random, a, 5, atLeast(1000));
+ checkRandomData(random, a, 5, atLeast(100));
}
}
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java?rev=1467437&r1=1467436&r2=1467437&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java Fri Apr 12 19:51:46 2013
@@ -44,26 +44,27 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
/** tests BooleanScorer2's minShouldMatch */
@SuppressCodecs({"Appending", "Lucene3x", "Lucene40", "Lucene41"})
public class TestMinShouldMatch2 extends LuceneTestCase {
- Directory dir;
- DirectoryReader r;
- AtomicReader reader;
- IndexSearcher searcher;
+ static Directory dir;
+ static DirectoryReader r;
+ static AtomicReader reader;
+ static IndexSearcher searcher;
static final String alwaysTerms[] = { "a" };
static final String commonTerms[] = { "b", "c", "d" };
static final String mediumTerms[] = { "e", "f", "g" };
static final String rareTerms[] = { "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ @BeforeClass
+ public static void beforeClass() throws Exception {
dir = newDirectory();
RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
- final int numDocs = 1000;
+ final int numDocs = atLeast(300);
for (int i = 0; i < numDocs; i++) {
Document doc = new Document();
@@ -93,14 +94,17 @@ public class TestMinShouldMatch2 extends
});
}
- @Override
- public void tearDown() throws Exception {
+ @AfterClass
+ public static void afterClass() throws Exception {
reader.close();
dir.close();
- super.tearDown();
+ searcher = null;
+ reader = null;
+ r = null;
+ dir = null;
}
- private void addSome(Document doc, String values[]) {
+ private static void addSome(Document doc, String values[]) {
List<String> list = Arrays.asList(values);
Collections.shuffle(list, random());
int howMany = _TestUtil.nextInt(random(), 1, list.size());
Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java?rev=1467437&r1=1467436&r2=1467437&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java Fri Apr 12 19:51:46 2013
@@ -1136,7 +1136,7 @@ public abstract class BaseDocValuesForma
doc.add(dvField);
// index some docs
- int numDocs = atLeast(1000);
+ int numDocs = atLeast(300);
for (int i = 0; i < numDocs; i++) {
idField.setStringValue(Integer.toString(i));
long value = _TestUtil.nextLong(random(), minValue, maxValue);
@@ -1218,7 +1218,7 @@ public abstract class BaseDocValuesForma
doc.add(dvField);
// index some docs
- int numDocs = atLeast(1000);
+ int numDocs = atLeast(300);
for (int i = 0; i < numDocs; i++) {
idField.setStringValue(Integer.toString(i));
final int length;
@@ -1289,7 +1289,7 @@ public abstract class BaseDocValuesForma
doc.add(dvField);
// index some docs
- int numDocs = atLeast(1000);
+ int numDocs = atLeast(300);
for (int i = 0; i < numDocs; i++) {
idField.setStringValue(Integer.toString(i));
final int length;
@@ -1801,7 +1801,7 @@ public abstract class BaseDocValuesForma
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, conf);
// index some docs
- int numDocs = atLeast(1000);
+ int numDocs = atLeast(300);
for (int i = 0; i < numDocs; i++) {
Document doc = new Document();
Field idField = new StringField("id", Integer.toString(i), Field.Store.NO);
@@ -1922,7 +1922,7 @@ public abstract class BaseDocValuesForma
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, conf);
// index some docs
- int numDocs = atLeast(1000);
+ int numDocs = atLeast(300);
for (int i = 0; i < numDocs; i++) {
Document doc = new Document();
Field idField = new StringField("id", Integer.toString(i), Field.Store.NO);
Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java?rev=1467437&r1=1467436&r2=1467437&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/index/BaseTermVectorsFormatTestCase.java Fri Apr 12 19:51:46 2013
@@ -520,7 +520,7 @@ public abstract class BaseTermVectorsFor
public void testRareVectors() throws IOException {
final RandomDocumentFactory docFactory = new RandomDocumentFactory(10, 20);
for (Options options : validOptions()) {
- final int numDocs = _TestUtil.nextInt(random(), 10, 10000);
+ final int numDocs = atLeast(200);
final int docWithVectors = random().nextInt(numDocs);
final Document emptyDoc = new Document();
final Directory dir = newDirectory();
@@ -560,7 +560,7 @@ public abstract class BaseTermVectorsFor
}
final Directory dir = newDirectory();
final RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
- final RandomDocument doc = docFactory.newDocument(_TestUtil.nextInt(random(), 1, 2), _TestUtil.nextInt(random(), 50000, 100000), options);
+ final RandomDocument doc = docFactory.newDocument(_TestUtil.nextInt(random(), 1, 2), atLeast(20000), options);
writer.addDocument(doc.toDocument());
final IndexReader reader = writer.getReader();
assertEquals(doc, reader.getTermVectors(0));
@@ -575,7 +575,7 @@ public abstract class BaseTermVectorsFor
for (Options options : validOptions()) {
final Directory dir = newDirectory();
final RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
- final RandomDocument doc = docFactory.newDocument(_TestUtil.nextInt(random(), 500, 1000), 5, options);
+ final RandomDocument doc = docFactory.newDocument(atLeast(100), 5, options);
writer.addDocument(doc.toDocument());
final IndexReader reader = writer.getReader();
assertEquals(doc, reader.getTermVectors(0));
@@ -614,7 +614,7 @@ public abstract class BaseTermVectorsFor
public void testRandom() throws IOException {
final RandomDocumentFactory docFactory = new RandomDocumentFactory(5, 20);
- final int numDocs = _TestUtil.nextInt(random(), 100, 1000);
+ final int numDocs = atLeast(100);
final RandomDocument[] docs = new RandomDocument[numDocs];
for (int i = 0; i < numDocs; ++i) {
docs[i] = docFactory.newDocument(_TestUtil.nextInt(random(), 1, 3), _TestUtil.nextInt(random(), 10, 50), randomOptions());
@@ -636,7 +636,7 @@ public abstract class BaseTermVectorsFor
public void testMerge() throws IOException {
final RandomDocumentFactory docFactory = new RandomDocumentFactory(5, 20);
- final int numDocs = _TestUtil.nextInt(random(), 100, 500);
+ final int numDocs = atLeast(100);
final int numDeletes = random().nextInt(numDocs);
final Set<Integer> deletes = new HashSet<Integer>();
while (deletes.size() < numDeletes) {
@@ -645,7 +645,7 @@ public abstract class BaseTermVectorsFor
for (Options options : validOptions()) {
final RandomDocument[] docs = new RandomDocument[numDocs];
for (int i = 0; i < numDocs; ++i) {
- docs[i] = docFactory.newDocument(_TestUtil.nextInt(random(), 1, 3), _TestUtil.nextInt(random(), 10, 50), options);
+ docs[i] = docFactory.newDocument(_TestUtil.nextInt(random(), 1, 3), atLeast(10), options);
}
final Directory dir = newDirectory();
final RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
@@ -677,11 +677,11 @@ public abstract class BaseTermVectorsFor
// don't share mutable data
public void testClone() throws IOException, InterruptedException {
final RandomDocumentFactory docFactory = new RandomDocumentFactory(5, 20);
- final int numDocs = _TestUtil.nextInt(random(), 100, 1000);
+ final int numDocs = atLeast(100);
for (Options options : validOptions()) {
final RandomDocument[] docs = new RandomDocument[numDocs];
for (int i = 0; i < numDocs; ++i) {
- docs[i] = docFactory.newDocument(_TestUtil.nextInt(random(), 1, 3), _TestUtil.nextInt(random(), 10, 50), options);
+ docs[i] = docFactory.newDocument(_TestUtil.nextInt(random(), 1, 3), atLeast(10), options);
}
final Directory dir = newDirectory();
final RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1467437&r1=1467436&r2=1467437&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java Fri Apr 12 19:51:46 2013
@@ -626,7 +626,7 @@ public abstract class LuceneTestCase ext
* is active and {@link #RANDOM_MULTIPLIER}.
*/
public static boolean rarely(Random random) {
- int p = TEST_NIGHTLY ? 10 : 5;
+ int p = TEST_NIGHTLY ? 10 : 1;
p += (p * Math.log(RANDOM_MULTIPLIER));
int min = 100 - Math.min(p, 50); // never more than 50
return random.nextInt(100) >= min;
Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java?rev=1467437&r1=1467436&r2=1467437&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleSetupAndRestoreClassEnv.java Fri Apr 12 19:51:46 2013
@@ -199,7 +199,7 @@ final class TestRuleSetupAndRestoreClass
return super.toString() + ": " + format.toString() + ", " + dvFormat.toString();
}
};
- } else if ("SimpleText".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal == 9 && !shouldAvoidCodec("SimpleText"))) {
+ } else if ("SimpleText".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal == 9 && LuceneTestCase.rarely(random) && !shouldAvoidCodec("SimpleText"))) {
codec = new SimpleTextCodec();
} else if ("Appending".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal == 8 && !shouldAvoidCodec("Appending"))) {
codec = new AppendingRWCodec();