LUCENE-3175: optimized slow tests to run faster if not TESTS_NIGHTLY

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1140980 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Simon Willnauer 2011-06-29 07:11:13 +00:00
parent fed96d4fc6
commit b13294bf0a
3 changed files with 20 additions and 21 deletions

View File

@ -142,8 +142,8 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase {
public void testAddIndexOnDiskFull() throws IOException
{
int START_COUNT = 57;
int NUM_DIR = 50;
int END_COUNT = START_COUNT + NUM_DIR*25;
int NUM_DIR = TEST_NIGHTLY ? 50 : 5;
int END_COUNT = START_COUNT + NUM_DIR* (TEST_NIGHTLY ? 25 : 5);
// Build up a bunch of dirs that have indexes which we
// will then merge together by calling addIndexes(*):

View File

@ -48,6 +48,8 @@ import java.util.concurrent.atomic.AtomicInteger;
public class TestIndexWriterReader extends LuceneTestCase {
static PrintStream infoStream = VERBOSE ? System.out : null;
private final int numThreads = TEST_NIGHTLY ? 5 : 3;
public static int count(Term t, IndexReader r) throws IOException {
int count = 0;
DocsEnum td = MultiFields.getTermDocsEnum(r,
@ -381,7 +383,7 @@ public class TestIndexWriterReader extends LuceneTestCase {
addDirThreads.launchThreads(numDirs);
addDirThreads.joinThreads();
//assertEquals(100 + numDirs * (3 * numIter / 4) * addDirThreads.NUM_THREADS
//assertEquals(100 + numDirs * (3 * numIter / 4) * addDirThreads.numThreads
// * addDirThreads.NUM_INIT_DOCS, addDirThreads.mainWriter.numDocs());
assertEquals(addDirThreads.count.intValue(), addDirThreads.mainWriter.numDocs());
@ -393,7 +395,7 @@ public class TestIndexWriterReader extends LuceneTestCase {
IndexReader reader = IndexReader.open(mainDir, true);
assertEquals(addDirThreads.count.intValue(), reader.numDocs());
//assertEquals(100 + numDirs * (3 * numIter / 4) * addDirThreads.NUM_THREADS
//assertEquals(100 + numDirs * (3 * numIter / 4) * addDirThreads.numThreads
// * addDirThreads.NUM_INIT_DOCS, reader.numDocs());
reader.close();
@ -403,10 +405,9 @@ public class TestIndexWriterReader extends LuceneTestCase {
private class AddDirectoriesThreads {
Directory addDir;
final static int NUM_THREADS = 5;
final static int NUM_INIT_DOCS = 100;
int numDirs;
final Thread[] threads = new Thread[NUM_THREADS];
final Thread[] threads = new Thread[numThreads];
IndexWriter mainWriter;
final List<Throwable> failures = new ArrayList<Throwable>();
IndexReader[] readers;
@ -432,7 +433,7 @@ public class TestIndexWriterReader extends LuceneTestCase {
}
void joinThreads() {
for (int i = 0; i < NUM_THREADS; i++)
for (int i = 0; i < numThreads; i++)
try {
threads[i].join();
} catch (InterruptedException ie) {
@ -462,7 +463,7 @@ public class TestIndexWriterReader extends LuceneTestCase {
}
void launchThreads(final int numIter) {
for (int i = 0; i < NUM_THREADS; i++) {
for (int i = 0; i < numThreads; i++) {
threads[i] = new Thread() {
@Override
public void run() {
@ -489,7 +490,7 @@ public class TestIndexWriterReader extends LuceneTestCase {
}
};
}
for (int i = 0; i < NUM_THREADS; i++)
for (int i = 0; i < numThreads; i++)
threads[i].start();
}
@ -759,14 +760,13 @@ public class TestIndexWriterReader extends LuceneTestCase {
IndexReader r = writer.getReader();
final int NUM_THREAD = 5;
final float SECONDS = 0.5f;
final long endTime = (long) (System.currentTimeMillis() + 1000.*SECONDS);
final List<Throwable> excs = Collections.synchronizedList(new ArrayList<Throwable>());
final Thread[] threads = new Thread[NUM_THREAD];
for(int i=0;i<NUM_THREAD;i++) {
final Thread[] threads = new Thread[numThreads];
for(int i=0;i<numThreads;i++) {
threads[i] = new Thread() {
@Override
public void run() {
@ -800,7 +800,7 @@ public class TestIndexWriterReader extends LuceneTestCase {
lastCount = count;
}
for(int i=0;i<NUM_THREAD;i++) {
for(int i=0;i<numThreads;i++) {
threads[i].join();
}
// final check
@ -840,14 +840,13 @@ public class TestIndexWriterReader extends LuceneTestCase {
IndexReader r = writer.getReader();
final int NUM_THREAD = 5;
final float SECONDS = 0.5f;
final long endTime = (long) (System.currentTimeMillis() + 1000.*SECONDS);
final List<Throwable> excs = Collections.synchronizedList(new ArrayList<Throwable>());
final Thread[] threads = new Thread[NUM_THREAD];
for(int i=0;i<NUM_THREAD;i++) {
final Thread[] threads = new Thread[numThreads];
for(int i=0;i<numThreads;i++) {
threads[i] = new Thread() {
final Random r = new Random(random.nextLong());
@ -889,7 +888,7 @@ public class TestIndexWriterReader extends LuceneTestCase {
searcher.close();
}
for(int i=0;i<NUM_THREAD;i++) {
for(int i=0;i<numThreads;i++) {
threads[i].join();
}
// at least search once

View File

@ -108,8 +108,8 @@ public class TestIndexWriterWithThreads extends LuceneTestCase {
public void testImmediateDiskFullWithThreads() throws Exception {
int NUM_THREADS = 3;
for(int iter=0;iter<10;iter++) {
final int numIterations = TEST_NIGHTLY ? 10 : 3;
for(int iter=0;iter<numIterations;iter++) {
if (VERBOSE) {
System.out.println("\nTEST: iter=" + iter);
}
@ -155,8 +155,8 @@ public class TestIndexWriterWithThreads extends LuceneTestCase {
// still want to be robust to this case:
public void testCloseWithThreads() throws Exception {
int NUM_THREADS = 3;
for(int iter=0;iter<7;iter++) {
int numIterations = TEST_NIGHTLY ? 7 : 3;
for(int iter=0;iter<numIterations;iter++) {
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(