You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2015/04/18 21:36:17 UTC

svn commit: r1674575 - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/test-framework/ lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java

Author: rmuir
Date: Sat Apr 18 19:36:16 2015
New Revision: 1674575

URL: http://svn.apache.org/r1674575
Log:
LUCENE-6436: add SuppressFsync annotation and reduce the number of fsyncs in tests

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/lucene/   (props changed)
    lucene/dev/branches/branch_5x/lucene/test-framework/   (props changed)
    lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
    lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java

Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1674575&r1=1674574&r2=1674575&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java Sat Apr 18 19:36:16 2015
@@ -314,6 +314,18 @@ public abstract class LuceneTestCase ext
   }
   
   /**
+   * Annotation for test classes that should avoid always omit
+   * actual fsync calls from reaching the filesystem.
+   * <p>
+   * This can be useful, e.g. if they make many lucene commits.
+   */
+  @Documented
+  @Inherited
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target(ElementType.TYPE)
+  public @interface SuppressFsync {}
+  
+  /**
    * Marks any suites which are known not to close all the temporary
    * files. This may prevent temp. files and folders from being cleaned
    * up after the suite is completed.

Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java?rev=1674575&r1=1674574&r2=1674575&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java (original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java Sat Apr 18 19:36:16 2015
@@ -23,6 +23,7 @@ import org.apache.lucene.mockfile.LeakFS
 import org.apache.lucene.mockfile.VerboseFS;
 import org.apache.lucene.mockfile.WindowsFS;
 import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
+import org.apache.lucene.util.LuceneTestCase.SuppressFsync;
 import org.apache.lucene.util.LuceneTestCase.SuppressTempFileChecks;
 
 import com.carrotsearch.randomizedtesting.RandomizedContext;
@@ -138,11 +139,17 @@ final class TestRuleTemporaryFilesCleanu
     }
     
     Random random = RandomizedContext.current().getRandom();
-    // sometimes just use a bare filesystem
-    if (random.nextInt(10) > 0) {
+    
+    // speed up tests by omitting actual fsync calls to the hardware most of the time.
+    if (targetClass.isAnnotationPresent(SuppressFsync.class) || random.nextInt(100) > 0) {
       if (allowed(avoid, DisableFsyncFS.class)) {
         fs = new DisableFsyncFS(fs).getFileSystem(null);
       }
+    }
+    
+    // otherwise, wrap with mockfilesystems for additional checks. some 
+    // of these have side effects (e.g. concurrency) so it doesn't always happen.
+    if (random.nextInt(10) > 0) {
       if (allowed(avoid, LeakFS.class)) {
         fs = new LeakFS(fs).getFileSystem(null);
       }