mirror of https://github.com/apache/lucene.git
fix false test failure
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1044257 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cdf6350cd6
commit
14f4e0475d
|
@ -48,6 +48,7 @@ import static org.junit.Assume.*;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// - mix in optimize, addIndexes
|
// - mix in optimize, addIndexes
|
||||||
|
// - randomoly mix in non-congruent docs
|
||||||
|
|
||||||
public class TestNRTThreads extends LuceneTestCase {
|
public class TestNRTThreads extends LuceneTestCase {
|
||||||
|
|
||||||
|
@ -216,71 +217,79 @@ public class TestNRTThreads extends LuceneTestCase {
|
||||||
|
|
||||||
smokeTestReader(r);
|
smokeTestReader(r);
|
||||||
|
|
||||||
final IndexSearcher s = new IndexSearcher(r);
|
if (r.numDocs() > 0) {
|
||||||
|
|
||||||
// run search threads
|
final IndexSearcher s = new IndexSearcher(r);
|
||||||
final long searchStopTime = System.currentTimeMillis() + 500;
|
|
||||||
final Thread[] searchThreads = new Thread[NUM_SEARCH_THREADS];
|
// run search threads
|
||||||
final AtomicInteger totHits = new AtomicInteger();
|
final long searchStopTime = System.currentTimeMillis() + 500;
|
||||||
for(int thread=0;thread<NUM_SEARCH_THREADS;thread++) {
|
final Thread[] searchThreads = new Thread[NUM_SEARCH_THREADS];
|
||||||
searchThreads[thread] = new Thread() {
|
final AtomicInteger totHits = new AtomicInteger();
|
||||||
@Override
|
for(int thread=0;thread<NUM_SEARCH_THREADS;thread++) {
|
||||||
public void run() {
|
searchThreads[thread] = new Thread() {
|
||||||
try {
|
@Override
|
||||||
TermsEnum termsEnum = MultiFields.getTerms(s.getIndexReader(), "body").iterator();
|
public void run() {
|
||||||
int seenTermCount = 0;
|
try {
|
||||||
int shift;
|
TermsEnum termsEnum = MultiFields.getTerms(s.getIndexReader(), "body").iterator();
|
||||||
int trigger;
|
int seenTermCount = 0;
|
||||||
if (totTermCount.get() == 0) {
|
int shift;
|
||||||
shift = 0;
|
int trigger;
|
||||||
trigger = 1;
|
if (totTermCount.get() == 0) {
|
||||||
} else {
|
shift = 0;
|
||||||
shift = random.nextInt(totTermCount.get()/10);
|
trigger = 1;
|
||||||
trigger = totTermCount.get()/10;
|
} else {
|
||||||
}
|
shift = random.nextInt(totTermCount.get()/10);
|
||||||
while(System.currentTimeMillis() < searchStopTime) {
|
trigger = totTermCount.get()/10;
|
||||||
BytesRef term = termsEnum.next();
|
}
|
||||||
if (term == null) {
|
while(System.currentTimeMillis() < searchStopTime) {
|
||||||
totTermCount.set(seenTermCount);
|
BytesRef term = termsEnum.next();
|
||||||
seenTermCount = 0;
|
if (term == null) {
|
||||||
trigger = totTermCount.get()/10;
|
if (seenTermCount == 0) {
|
||||||
//System.out.println("trigger " + trigger);
|
break;
|
||||||
shift = random.nextInt(totTermCount.get()/10);
|
}
|
||||||
termsEnum.seek(new BytesRef(""));
|
totTermCount.set(seenTermCount);
|
||||||
continue;
|
seenTermCount = 0;
|
||||||
}
|
trigger = totTermCount.get()/10;
|
||||||
seenTermCount++;
|
//System.out.println("trigger " + trigger);
|
||||||
// search 10 terms
|
shift = random.nextInt(totTermCount.get()/10);
|
||||||
if (trigger == 0) {
|
termsEnum.seek(new BytesRef(""));
|
||||||
trigger = 1;
|
continue;
|
||||||
}
|
}
|
||||||
if ((seenTermCount + shift) % trigger == 0) {
|
seenTermCount++;
|
||||||
//if (VERBOSE) {
|
// search 10 terms
|
||||||
//System.out.println(Thread.currentThread().getName() + " now search body:" + term.utf8ToString());
|
if (trigger == 0) {
|
||||||
//}
|
trigger = 1;
|
||||||
totHits.addAndGet(runQuery(s, new TermQuery(new Term("body", term))));
|
}
|
||||||
|
if ((seenTermCount + shift) % trigger == 0) {
|
||||||
|
//if (VERBOSE) {
|
||||||
|
//System.out.println(Thread.currentThread().getName() + " now search body:" + term.utf8ToString());
|
||||||
|
//}
|
||||||
|
totHits.addAndGet(runQuery(s, new TermQuery(new Term("body", term))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (VERBOSE) {
|
||||||
|
System.out.println(Thread.currentThread().getName() + ": search done");
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
failed.set(true);
|
||||||
|
t.printStackTrace(System.out);
|
||||||
|
throw new RuntimeException(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (VERBOSE) {
|
};
|
||||||
System.out.println(Thread.currentThread().getName() + ": search done");
|
searchThreads[thread].setDaemon(true);
|
||||||
}
|
searchThreads[thread].start();
|
||||||
} catch (Throwable t) {
|
}
|
||||||
failed.set(true);
|
|
||||||
t.printStackTrace(System.out);
|
|
||||||
throw new RuntimeException(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
searchThreads[thread].setDaemon(true);
|
|
||||||
searchThreads[thread].start();
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int thread=0;thread<NUM_SEARCH_THREADS;thread++) {
|
for(int thread=0;thread<NUM_SEARCH_THREADS;thread++) {
|
||||||
searchThreads[thread].join();
|
searchThreads[thread].join();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VERBOSE) {
|
if (VERBOSE) {
|
||||||
System.out.println("TEST: DONE search: totHits=" + totHits);
|
System.out.println("TEST: DONE search: totHits=" + totHits);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue