test and start of node stress tests

This commit is contained in:
kimchy 2010-05-17 23:56:42 +03:00
parent eef6c02bf7
commit 34103c6b7f
1 changed files with 11 additions and 0 deletions

View File

@ -33,6 +33,7 @@ import org.testng.annotations.Test;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.List; import java.util.List;
import static org.elasticsearch.util.lucene.DocumentBuilder.*; import static org.elasticsearch.util.lucene.DocumentBuilder.*;
@ -139,12 +140,22 @@ public class SimpleLuceneTests {
} }
reader.close(); reader.close();
// verify that all readers are closed // verify that all readers are closed
// also, SADLY, verifies that new readers are always created, meaning that caching based on index reader are useless
IdentityHashMap<IndexReader, Boolean> identityReaders = new IdentityHashMap<IndexReader, Boolean>();
for (IndexReader reader1 : readers) { for (IndexReader reader1 : readers) {
assertThat(reader1.getRefCount(), equalTo(0)); assertThat(reader1.getRefCount(), equalTo(0));
assertThat(identityReaders.containsKey(reader1), equalTo(false));
identityReaders.put(reader1, Boolean.TRUE);
if (reader1.getSequentialSubReaders() != null) { if (reader1.getSequentialSubReaders() != null) {
for (IndexReader reader2 : reader1.getSequentialSubReaders()) { for (IndexReader reader2 : reader1.getSequentialSubReaders()) {
assertThat(reader2.getRefCount(), equalTo(0)); assertThat(reader2.getRefCount(), equalTo(0));
assertThat(reader2.getSequentialSubReaders(), nullValue());
assertThat(identityReaders.containsKey(reader2), equalTo(false));
identityReaders.put(reader2, Boolean.TRUE);
} }
} }
} }