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/20 15:59:20 UTC

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

Author: shaie
Date: Wed Oct 20 13:59:19 2010
New Revision: 1025586

URL: http://svn.apache.org/viewvc?rev=1025586&view=rev
Log:
fixing the test to get away w/ random testing

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=1025586&r1=1025585&r2=1025586&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 Wed Oct 20 13:59:19 2010
@@ -39,21 +39,24 @@ 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);
+    IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, null);
     // prevent any merges from happening.
     conf.setMergePolicy(NoMergePolicy.COMPOUND_FILES);
     IndexWriter writer = new IndexWriter(dir, conf);
     final int numSegments = 15;
     for (int i = 0; i < numSegments; i++) {
-      int numDocs = i == 7 ? 10 : 1;
+      int numDocs = i == 7 ? 30 : 1;
       addDocs(writer, numDocs);
     }
-    
     writer.close();
-
-    conf = newIndexWriterConfig(TEST_VERSION_CURRENT, null);
+    
+    SegmentInfos sis = new SegmentInfos();
+    sis.read(dir);
+    double min = sis.info(0).sizeInBytes();
+    
+    conf = new IndexWriterConfig(TEST_VERSION_CURRENT, null);
     LogByteSizeMergePolicy lmp = new LogByteSizeMergePolicy();
-    lmp.setMaxMergeMB(200.0 / (1 << 20)); // ~100 bytes tops
+    lmp.setMaxMergeMB((min + 1) / (1 << 20));
     conf.setMergePolicy(lmp);
     
     writer = new IndexWriter(dir, conf);
@@ -61,7 +64,7 @@ public class TestSizeBoundedOptimize ext
     writer.close();
 
     // Should only be 3 segments in the index, because one of them exceeds the size limit
-    SegmentInfos sis = new SegmentInfos();
+    sis = new SegmentInfos();
     sis.read(dir);
     assertEquals(3, sis.size());
   }