From f1650315749335e2eb3d9f750212369d04a5089b Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Wed, 6 Nov 2013 11:46:56 +0000 Subject: [PATCH] LUCENE-5330: add test git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1539317 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/index/TestIndexWriterReader.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java index 0cee0ea96d2..f468a6da31a 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java @@ -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(); + } }