Apache Solr open-source search software
LUCENE-5644: i moved this test over to new class
Michael McCandlessba888c09870b
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.javaindex 68acb07e368..f6baf888a0b 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java@@ -2788,66 +2788,4 @@ public class TestIndexWriter extends LuceneTestCase {r.close();dir.close();}-- // LUCENE-5644- public void testSegmentCountOnFlush() throws Exception {- Directory dir = newDirectory();- final IndexWriter w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())));- final CountDownLatch startingGun = new CountDownLatch(1);- final CountDownLatch startDone = new CountDownLatch(2);- final CountDownLatch middleGun = new CountDownLatch(1);- final CountDownLatch finalGun = new CountDownLatch(1);- Thread[] threads = new Thread[2];- for(int i=0;i<threads.length;i++) {- final int threadID = i;- threads[i] = new Thread() {- @Override- public void run() {- try {- startingGun.await();- Document doc = new Document();- doc.add(newTextField("field", "here is some text", Field.Store.NO));- w.addDocument(doc);- startDone.countDown();-- middleGun.await();- if (threadID == 0) {- w.addDocument(doc);- } else {- finalGun.await();- w.addDocument(doc);- }- } catch (Exception e) {- throw new RuntimeException(e);- }- }- };- threads[i].start();- }-- startingGun.countDown();- startDone.await();-- IndexReader r = DirectoryReader.open(w, true);- assertEquals(2, r.numDocs());- int numSegments = r.leaves().size();- // 1 segment if the threads ran sequentially, else 2:- assertTrue(numSegments <= 2);- r.close();-- middleGun.countDown();- threads[0].join();-- finalGun.countDown();- threads[1].join();-- r = DirectoryReader.open(w, true);- assertEquals(4, r.numDocs());- // Both threads should have shared a single thread state since they did not try to index concurrently:- assertEquals(1+numSegments, r.leaves().size());- r.close();-- w.close();- dir.close();- }}