mirror of https://github.com/apache/lucene.git
LUCENE-5330: add test
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1539317 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e10ca44c82
commit
f165031574
|
@ -1099,4 +1099,23 @@ public class TestIndexWriterReader extends LuceneTestCase {
|
|||
dir.close();
|
||||
}
|
||||
|
||||
/** Make sure if all we do is open NRT reader against
|
||||
* writer, we don't see merge starvation. */
|
||||
public void testTooManySegments() throws Exception {
|
||||
Directory dir = newDirectory();
|
||||
IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
|
||||
IndexWriter w = new IndexWriter(dir, iwc);
|
||||
// Create 500 segments:
|
||||
for(int i=0;i<500;i++) {
|
||||
Document doc = new Document();
|
||||
doc.add(newStringField("id", ""+i, Field.Store.NO));
|
||||
w.addDocument(doc);
|
||||
IndexReader r = DirectoryReader.open(w, true);
|
||||
// Make sure segment count never exceeds 100:
|
||||
assertTrue(r.leaves().size() < 100);
|
||||
r.close();
|
||||
}
|
||||
w.close();
|
||||
dir.close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue