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 public void testAddIndexOnDiskFull() throws IOException
{ {
int START_COUNT = 57; int START_COUNT = 57;
int NUM_DIR = 50; int NUM_DIR = TEST_NIGHTLY ? 50 : 5;
int END_COUNT = START_COUNT + NUM_DIR*25; int END_COUNT = START_COUNT + NUM_DIR* (TEST_NIGHTLY ? 25 : 5);
// Build up a bunch of dirs that have indexes which we // Build up a bunch of dirs that have indexes which we
// will then merge together by calling addIndexes(*): // will then merge together by calling addIndexes(*):

View File

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

View File

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