LUCENE-3829: fix test to use DV API correctly

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1294882 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2012-02-28 22:56:39 +00:00
parent 7a8db2fcff
commit a1fbc36305
1 changed files with 15 additions and 7 deletions

View File

@ -872,10 +872,6 @@ public class TestDocValuesIndexing extends LuceneTestCase {
final AtomicReader sr = getOnlySegmentReader(r); final AtomicReader sr = getOnlySegmentReader(r);
final DocValues dv = sr.docValues("stringdv"); final DocValues dv = sr.docValues("stringdv");
final DocValues.Source stringDVSource = dv.getSource();
assertNotNull(stringDVSource);
final DocValues.Source stringDVDirectSource = dv.getDirectSource();
assertNotNull(stringDVDirectSource);
assertNotNull(dv); assertNotNull(dv);
final long END_TIME = System.currentTimeMillis() + (TEST_NIGHTLY ? 30 : 1); final long END_TIME = System.currentTimeMillis() + (TEST_NIGHTLY ? 30 : 1);
@ -888,11 +884,19 @@ public class TestDocValuesIndexing extends LuceneTestCase {
threads[thread] = new Thread() { threads[thread] = new Thread() {
@Override @Override
public void run() { public void run() {
final DocValues.Source stringDVSource;
final DocValues.Source stringDVDirectSource;
try {
stringDVSource = dv.getSource();
assertNotNull(stringDVSource);
stringDVDirectSource = dv.getDirectSource();
assertNotNull(stringDVDirectSource);
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
while(System.currentTimeMillis() < END_TIME) { while(System.currentTimeMillis() < END_TIME) {
final DocValues.Source source; final DocValues.Source source;
// LUCENE-3829: remove this 'true ||' below if (random.nextBoolean()) {
// once we fix thread safety of DirectSource
if (true || random.nextBoolean()) {
source = stringDVSource; source = stringDVSource;
} else { } else {
source = stringDVDirectSource; source = stringDVDirectSource;
@ -914,6 +918,10 @@ public class TestDocValuesIndexing extends LuceneTestCase {
threads[thread].start(); threads[thread].start();
} }
for(Thread thread : threads) {
thread.join();
}
r.close(); r.close();
dir.close(); dir.close();
} }