You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2011/06/28 15:59:24 UTC

svn commit: r1140626 - /lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java

Author: simonw
Date: Tue Jun 28 13:59:24 2011
New Revision: 1140626

URL: http://svn.apache.org/viewvc?rev=1140626&view=rev
Log:
speed up testcase if TESTS_NIGHTLY=false

Modified:
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java?rev=1140626&r1=1140625&r2=1140626&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java (original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java Tue Jun 28 13:59:24 2011
@@ -50,12 +50,12 @@ public class TestFlushByRamOrCountsPolic
 
   public void testFlushByRam() throws CorruptIndexException,
       LockObtainFailedException, IOException, InterruptedException {
-    int[] numThreads = new int[] { 3 + random.nextInt(12), 1 };
+    int[] numThreads = new int[] { 2 + atLeast(1), 1 };
     for (int i = 0; i < numThreads.length; i++) {
-      runFlushByRam(numThreads[i],
-          1 + random.nextInt(10) + random.nextDouble(), false);
+      final double ramBuffer = (TEST_NIGHTLY ? 1 : 10) + atLeast(2) + random.nextDouble();
+      runFlushByRam(numThreads[i], ramBuffer
+         , false);
     }
-
     for (int i = 0; i < numThreads.length; i++) {
       // with a 256 mb ram buffer we should never stall
       runFlushByRam(numThreads[i], 256.d, true);
@@ -65,13 +65,13 @@ public class TestFlushByRamOrCountsPolic
   protected void runFlushByRam(int numThreads, double maxRamMB,
       boolean ensureNotStalled) throws IOException, CorruptIndexException,
       LockObtainFailedException, InterruptedException {
-    final int numDocumentsToIndex = 50 + random.nextInt(150);
+    final int numDocumentsToIndex = 10 + atLeast(30);
     AtomicInteger numDocs = new AtomicInteger(numDocumentsToIndex);
     Directory dir = newDirectory();
     MockDefaultFlushPolicy flushPolicy = new MockDefaultFlushPolicy();
     IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT,
         new MockAnalyzer(random)).setFlushPolicy(flushPolicy);
-    final int numDWPT = 1 + random.nextInt(8);
+    final int numDWPT = 1 + atLeast(2);
     DocumentsWriterPerThreadPool threadPool = new ThreadAffinityDocumentsWriterThreadPool(
         numDWPT);
     iwc.setIndexerThreadPool(threadPool);
@@ -118,21 +118,21 @@ public class TestFlushByRamOrCountsPolic
 
   public void testFlushDocCount() throws CorruptIndexException,
       LockObtainFailedException, IOException, InterruptedException {
-    int[] numThreads = new int[] { 3 + random.nextInt(12), 1 };
+    int[] numThreads = new int[] { 2 + atLeast(1), 1 };
     for (int i = 0; i < numThreads.length; i++) {
 
-      final int numDocumentsToIndex = 50 + random.nextInt(150);
+      final int numDocumentsToIndex =  50 + atLeast(30);
       AtomicInteger numDocs = new AtomicInteger(numDocumentsToIndex);
       Directory dir = newDirectory();
       MockDefaultFlushPolicy flushPolicy = new MockDefaultFlushPolicy();
       IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT,
           new MockAnalyzer(random)).setFlushPolicy(flushPolicy);
 
-      final int numDWPT = 1 + random.nextInt(8);
+      final int numDWPT = 1 + atLeast(2);
       DocumentsWriterPerThreadPool threadPool = new ThreadAffinityDocumentsWriterThreadPool(
           numDWPT);
       iwc.setIndexerThreadPool(threadPool);
-      iwc.setMaxBufferedDocs(2 + random.nextInt(50));
+      iwc.setMaxBufferedDocs(2 + atLeast(10));
       iwc.setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH);
       iwc.setMaxBufferedDeleteTerms(IndexWriterConfig.DISABLE_AUTO_FLUSH);
       IndexWriter writer = new IndexWriter(dir, iwc);
@@ -170,7 +170,7 @@ public class TestFlushByRamOrCountsPolic
 
   public void testRandom() throws IOException, InterruptedException {
     final int numThreads = 1 + random.nextInt(8);
-    final int numDocumentsToIndex = 100 + random.nextInt(300);
+    final int numDocumentsToIndex = 50 + atLeast(70);
     AtomicInteger numDocs = new AtomicInteger(numDocumentsToIndex);
     Directory dir = newDirectory();
     IndexWriterConfig iwc = newIndexWriterConfig(TEST_VERSION_CURRENT,
@@ -317,11 +317,7 @@ public class TestFlushByRamOrCountsPolic
             ramSize = newRamSize;
           }
           if (doRandomCommit) {
-            int commit;
-            synchronized (random) {
-              commit = random.nextInt(20);
-            }
-            if (commit == 0) {
+            if (rarely()) {
               writer.commit();
             }
           }