You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2010/10/23 14:55:19 UTC

svn commit: r1026614 - /lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestSizeBoundedOptimize.java

Author: shaie
Date: Sat Oct 23 12:55:19 2010
New Revision: 1026614

URL: http://svn.apache.org/viewvc?rev=1026614&view=rev
Log:
LUCENE-2721: Random Failure TestSizeBoundedOptimize#testFirstSegmentTooLarge

Modified:
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestSizeBoundedOptimize.java

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestSizeBoundedOptimize.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestSizeBoundedOptimize.java?rev=1026614&r1=1026613&r2=1026614&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestSizeBoundedOptimize.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestSizeBoundedOptimize.java Sat Oct 23 12:55:19 2010
@@ -34,14 +34,21 @@ public class TestSizeBoundedOptimize ext
     writer.commit();
   }
   
+  private static IndexWriterConfig newWriterConfig() throws IOException {
+    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
+    conf.setMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH);
+    conf.setRAMBufferSizeMB(IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB);
+    // prevent any merges by default.
+    conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
+    return conf;
+  }
+  
   public void testByteSizeLimit() throws Exception {
     // tests that the max merge size constraint is applied during optimize.
     Directory dir = new RAMDirectory();
 
     // Prepare an index w/ several small segments and a large one.
-    IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, null);
-    // prevent any merges from happening.
-    conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
+    IndexWriterConfig conf = newWriterConfig();
     IndexWriter writer = new IndexWriter(dir, conf);
     final int numSegments = 15;
     for (int i = 0; i < numSegments; i++) {
@@ -54,7 +61,7 @@ public class TestSizeBoundedOptimize ext
     sis.read(dir);
     double min = sis.info(0).sizeInBytes();
     
-    conf = new IndexWriterConfig(TEST_VERSION_CURRENT, null);
+    conf = newWriterConfig();
     LogByteSizeMergePolicy lmp = new LogByteSizeMergePolicy();
     lmp.setMaxMergeMB((min + 1) / (1 << 20));
     conf.setMergePolicy(lmp);
@@ -74,9 +81,7 @@ public class TestSizeBoundedOptimize ext
     Directory dir = new RAMDirectory();
 
     // Prepare an index w/ several small segments and a large one.
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
-    // prevent any merges from happening.
-    conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
+    IndexWriterConfig conf = newWriterConfig();
     IndexWriter writer = new IndexWriter(dir, conf);
 
     addDocs(writer, 3);
@@ -89,7 +94,7 @@ public class TestSizeBoundedOptimize ext
     
     writer.close();
 
-    conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
+    conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
     lmp.setMaxMergeDocs(3);
     conf.setMergePolicy(lmp);
@@ -107,8 +112,7 @@ public class TestSizeBoundedOptimize ext
   public void testLastSegmentTooLarge() throws Exception {
     Directory dir = new RAMDirectory();
 
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
-    conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
+    IndexWriterConfig conf = newWriterConfig();
     IndexWriter writer = new IndexWriter(dir, conf);
 
     addDocs(writer, 3);
@@ -118,7 +122,7 @@ public class TestSizeBoundedOptimize ext
     
     writer.close();
 
-    conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
+    conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
     lmp.setMaxMergeDocs(3);
     conf.setMergePolicy(lmp);
@@ -135,8 +139,7 @@ public class TestSizeBoundedOptimize ext
   public void testFirstSegmentTooLarge() throws Exception {
     Directory dir = new RAMDirectory();
     
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
-    conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
+    IndexWriterConfig conf = newWriterConfig();
     IndexWriter writer = new IndexWriter(dir, conf);
     
     addDocs(writer, 5);
@@ -146,7 +149,7 @@ public class TestSizeBoundedOptimize ext
     
     writer.close();
     
-    conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
+    conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
     lmp.setMaxMergeDocs(3);
     conf.setMergePolicy(lmp);
@@ -163,8 +166,7 @@ public class TestSizeBoundedOptimize ext
   public void testAllSegmentsSmall() throws Exception {
     Directory dir = new RAMDirectory();
     
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
-    conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
+    IndexWriterConfig conf = newWriterConfig();
     IndexWriter writer = new IndexWriter(dir, conf);
     
     addDocs(writer, 3);
@@ -174,7 +176,7 @@ public class TestSizeBoundedOptimize ext
     
     writer.close();
     
-    conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
+    conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
     lmp.setMaxMergeDocs(3);
     conf.setMergePolicy(lmp);
@@ -191,8 +193,7 @@ public class TestSizeBoundedOptimize ext
   public void testAllSegmentsLarge() throws Exception {
     Directory dir = new RAMDirectory();
     
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
-    conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
+    IndexWriterConfig conf = newWriterConfig();
     IndexWriter writer = new IndexWriter(dir, conf);
     
     addDocs(writer, 3);
@@ -201,7 +202,7 @@ public class TestSizeBoundedOptimize ext
     
     writer.close();
     
-    conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
+    conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
     lmp.setMaxMergeDocs(2);
     conf.setMergePolicy(lmp);
@@ -218,8 +219,7 @@ public class TestSizeBoundedOptimize ext
   public void testOneLargeOneSmall() throws Exception {
     Directory dir = new RAMDirectory();
     
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
-    conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
+    IndexWriterConfig conf = newWriterConfig();
     IndexWriter writer = new IndexWriter(dir, conf);
     
     addDocs(writer, 3);
@@ -229,7 +229,7 @@ public class TestSizeBoundedOptimize ext
     
     writer.close();
     
-    conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
+    conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
     lmp.setMaxMergeDocs(3);
     conf.setMergePolicy(lmp);
@@ -246,8 +246,7 @@ public class TestSizeBoundedOptimize ext
   public void testMergeFactor() throws Exception {
     Directory dir = new RAMDirectory();
     
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
-    conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
+    IndexWriterConfig conf = newWriterConfig();
     IndexWriter writer = new IndexWriter(dir, conf);
     
     addDocs(writer, 3);
@@ -260,7 +259,7 @@ public class TestSizeBoundedOptimize ext
     
     writer.close();
     
-    conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
+    conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
     lmp.setMaxMergeDocs(3);
     lmp.setMergeFactor(2);
@@ -280,8 +279,7 @@ public class TestSizeBoundedOptimize ext
   public void testSingleNonOptimizedSegment() throws Exception {
     Directory dir = new RAMDirectory();
     
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
-    conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
+    IndexWriterConfig conf = newWriterConfig();
     IndexWriter writer = new IndexWriter(dir, conf);
     
     addDocs(writer, 3);
@@ -295,7 +293,7 @@ public class TestSizeBoundedOptimize ext
     r.deleteDocument(r.numDocs() - 1);
     r.close();
     
-    conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
+    conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
     lmp.setMaxMergeDocs(3);
     conf.setMergePolicy(lmp);
@@ -314,15 +312,14 @@ public class TestSizeBoundedOptimize ext
   public void testSingleOptimizedSegment() throws Exception {
     Directory dir = new RAMDirectory();
     
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
-    conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
+    IndexWriterConfig conf = newWriterConfig();
     IndexWriter writer = new IndexWriter(dir, conf);
     
     addDocs(writer, 3);
     
     writer.close();
     
-    conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
+    conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
     lmp.setMaxMergeDocs(3);
     conf.setMergePolicy(lmp);
@@ -340,8 +337,7 @@ public class TestSizeBoundedOptimize ext
   public void testSingleNonOptimizedTooLargeSegment() throws Exception {
     Directory dir = new RAMDirectory();
     
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
-    conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
+    IndexWriterConfig conf = newWriterConfig();
     IndexWriter writer = new IndexWriter(dir, conf);
     
     addDocs(writer, 5);
@@ -353,7 +349,7 @@ public class TestSizeBoundedOptimize ext
     r.deleteDocument(r.numDocs() - 1);
     r.close();
     
-    conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
+    conf = newWriterConfig();
     LogMergePolicy lmp = new LogDocMergePolicy();
     lmp.setMaxMergeDocs(2);
     conf.setMergePolicy(lmp);