lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r1721127 [2/2] - in /lucene/dev/branches/lucene6835/lucene: analysis/common/src/java/org/apache/lucene/analysis/hunspell/ analysis/common/src/test/org/apache/lucene/analysis/hunspell/ backward-codecs/src/test/org/apache/lucene/index/ core/s...
Date Mon, 21 Dec 2015 11:15:57 GMT
Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java Mon Dec 21 11:15:56 2015
@@ -949,7 +949,7 @@ public class TestIndexWriterExceptions e
     for (FailOnlyInCommit failure : failures) {
       MockDirectoryWrapper dir = newMockDirectory();
       dir.setFailOnCreateOutput(false);
-      dir.setEnableVirusScanner(false); // we check for specific list of files
+      assumeFalse("we check for specific list of files", TestUtil.hasVirusChecker(dir));
       int fileCount = dir.listAll().length;
       IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
       Document doc = new Document();
@@ -1177,10 +1177,7 @@ public class TestIndexWriterExceptions e
   public void testSimulatedCorruptIndex1() throws IOException {
       BaseDirectoryWrapper dir = newDirectory();
       dir.setCheckIndexOnClose(false); // we are corrupting it!
-      if (dir instanceof MockDirectoryWrapper) {
-        // we want to ensure our corruption always succeeds!
-        ((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
-      }
+      assumeFalse("we want to ensure our corruption always succeeds!", TestUtil.hasVirusChecker(dir));
 
       IndexWriter writer = null;
 
@@ -1229,10 +1226,7 @@ public class TestIndexWriterExceptions e
   public void testSimulatedCorruptIndex2() throws IOException {
     BaseDirectoryWrapper dir = newDirectory();
     dir.setCheckIndexOnClose(false); // we are corrupting it!
-    if (dir instanceof MockDirectoryWrapper) {
-      // we want to ensure our corruption always succeeds!
-      ((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
-    }
+    assumeFalse("we want to ensure our corruption always succeeds!", TestUtil.hasVirusChecker(dir));
     IndexWriter writer = null;
 
     writer  = new IndexWriter(

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterForceMerge.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterForceMerge.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterForceMerge.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterForceMerge.java Mon Dec 21 11:15:56 2015
@@ -126,7 +126,7 @@ public class TestIndexWriterForceMerge e
   public void testForceMergeTempSpaceUsage() throws IOException {
 
     final MockDirectoryWrapper dir = newMockDirectory();
-    dir.setEnableVirusScanner(false);
+    assumeFalse("deletes must succeed else too much disk is used", TestUtil.hasVirusChecker(dir));
     // don't use MockAnalyzer, variable length payloads can cause merge to make things bigger,
     // since things are optimized for fixed length case. this is a problem for MemoryPF's encoding.
     // (it might have other problems too)

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterFromReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterFromReader.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterFromReader.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterFromReader.java Mon Dec 21 11:15:56 2015
@@ -17,6 +17,10 @@ package org.apache.lucene.index;
  * limitations under the License.
  */
 
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.store.AlreadyClosedException;
@@ -24,10 +28,7 @@ import org.apache.lucene.store.Directory
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LuceneTestCase;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import org.apache.lucene.util.TestUtil;
 
 public class TestIndexWriterFromReader extends LuceneTestCase {
 
@@ -111,10 +112,7 @@ public class TestIndexWriterFromReader e
   // Pull NRT reader after writer has committed and then indexed another doc:
   public void testAfterCommitThenIndex() throws Exception {
     Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      // We only hit exc if stale segments file was deleted:
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
+    assumeFalse("We only hit exc if stale segments file was deleted", TestUtil.hasVirusChecker(dir));
     IndexWriter w = new IndexWriter(dir, newIndexWriterConfig());
     w.addDocument(new Document());
     w.commit();
@@ -140,10 +138,7 @@ public class TestIndexWriterFromReader e
   // NRT rollback: pull NRT reader after writer has committed and then before indexing another doc
   public void testNRTRollback() throws Exception {
     Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      // We only hit exc if stale segments file was deleted:
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
+    assumeFalse("We only hit exc if stale segments file was deleted", TestUtil.hasVirusChecker(dir));
     IndexWriter w = new IndexWriter(dir, newIndexWriterConfig());
     w.addDocument(new Document());
     w.commit();

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterOnDiskFull.java Mon Dec 21 11:15:56 2015
@@ -63,7 +63,7 @@ public class TestIndexWriterOnDiskFull e
           System.out.println("TEST: cycle: diskFree=" + diskFree);
         }
         MockDirectoryWrapper dir = new MockDirectoryWrapper(random(), new RAMDirectory());
-        dir.setEnableVirusScanner(false); // currently uses the IW unreferenced files method, unaware of retries
+        assumeFalse("currently uses the IW unreferenced files method, unaware of retries", TestUtil.hasVirusChecker(dir));
         dir.setMaxSizeInBytes(diskFree);
         IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random())));
         MergeScheduler ms = writer.getConfig().getMergeScheduler();

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestNRTReaderCleanup.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestNRTReaderCleanup.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestNRTReaderCleanup.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestNRTReaderCleanup.java Mon Dec 21 11:15:56 2015
@@ -28,6 +28,7 @@ import org.apache.lucene.store.MockDirec
 import org.apache.lucene.util.Constants;
 import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
 
 /** LUCENE-5574 */
 @SuppressFileSystems("WindowsFS") // the bug doesn't happen on windows.
@@ -41,11 +42,7 @@ public class TestNRTReaderCleanup extend
 
     MockDirectoryWrapper dir = newMockDirectory();
     
-    // don't act like windows either, or the test won't simulate the condition
-    dir.setEnableVirusScanner(false);
-
-    // Allow deletion of still open files:
-    dir.setNoDeleteOpenFile(false);
+    assumeFalse("don't act like windows either, or the test won't simulate the condition", TestUtil.hasVirusChecker(dir));
 
     // Allow writing to same file more than once:
     dir.setPreventDoubleWrite(false);

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestNeverDelete.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestNeverDelete.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestNeverDelete.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestNeverDelete.java Mon Dec 21 11:15:56 2015
@@ -39,12 +39,6 @@ public class TestNeverDelete extends Luc
     final Path tmpDir = createTempDir("TestNeverDelete");
     final BaseDirectoryWrapper d = newFSDirectory(tmpDir);
 
-    // We want to "see" files removed if Lucene removed
-    // them.  This is still worth running on Windows since
-    // some files the IR opens and closes.
-    if (d instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper)d).setNoDeleteOpenFile(false);
-    }
     final RandomIndexWriter w = new RandomIndexWriter(random(),
                                                       d,
                                                       newIndexWriterConfig(new MockAnalyzer(random()))

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestNumericDocValuesUpdates.java Mon Dec 21 11:15:56 2015
@@ -1182,10 +1182,7 @@ public class TestNumericDocValuesUpdates
   @Test
   public void testDeleteUnusedUpdatesFiles() throws Exception {
     Directory dir = newDirectory();
-    // test explicitly needs files to always be actually deleted
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
-    }
+    assumeFalse("test explicitly needs files to always be actually deleted", TestUtil.hasVirusChecker(dir));
     IndexWriterConfig conf = newIndexWriterConfig(new MockAnalyzer(random()));
     IndexWriter writer = new IndexWriter(dir, conf);
     

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java Mon Dec 21 11:15:56 2015
@@ -189,10 +189,8 @@ public class TestOmitPositions extends L
   // Verifies no *.prx exists when all fields omit term positions:
   public void testNoPrxFile() throws Throwable {
     Directory ram = newDirectory();
-    if (ram instanceof MockDirectoryWrapper) {
-      // we verify some files get deleted
-      ((MockDirectoryWrapper)ram).setEnableVirusScanner(false);
-    }
+    assumeFalse("we verify some files get deleted", TestUtil.hasVirusChecker(ram));
+
     Analyzer analyzer = new MockAnalyzer(random());
     IndexWriter writer = new IndexWriter(ram, newIndexWriterConfig(analyzer)
                                                 .setMaxBufferedDocs(3)

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java Mon Dec 21 11:15:56 2015
@@ -40,6 +40,7 @@ import org.apache.lucene.store.Directory
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
 
 
 public class TestOmitTf extends LuceneTestCase {
@@ -219,10 +220,7 @@ public class TestOmitTf extends LuceneTe
   // Verifies no *.prx exists when all fields omit term freq:
   public void testNoPrxFile() throws Throwable {
     Directory ram = newDirectory();
-    if (ram instanceof MockDirectoryWrapper) {
-      // we verify some files get deleted
-      ((MockDirectoryWrapper)ram).setEnableVirusScanner(false);
-    }
+    assumeFalse("we verify some files get deleted", TestUtil.hasVirusChecker(ram));
     Analyzer analyzer = new MockAnalyzer(random());
     IndexWriter writer = new IndexWriter(ram, newIndexWriterConfig(analyzer)
                                                 .setMaxBufferedDocs(3)

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestPersistentSnapshotDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestPersistentSnapshotDeletionPolicy.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestPersistentSnapshotDeletionPolicy.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestPersistentSnapshotDeletionPolicy.java Mon Dec 21 11:15:56 2015
@@ -23,6 +23,7 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.util.TestUtil;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -50,7 +51,7 @@ public class TestPersistentSnapshotDelet
   public void testExistingSnapshots() throws Exception {
     int numSnapshots = 3;
     MockDirectoryWrapper dir = newMockDirectory();
-    dir.setEnableVirusScanner(false); // test relies on files actually being deleted
+    assumeFalse("test relies on files actually being deleted", TestUtil.hasVirusChecker(dir));
     IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy(dir)));
     PersistentSnapshotDeletionPolicy psdp = (PersistentSnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     assertNull(psdp.getLastSaveFile());

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestRollingUpdates.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestRollingUpdates.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestRollingUpdates.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestRollingUpdates.java Mon Dec 21 11:15:56 2015
@@ -39,10 +39,7 @@ public class TestRollingUpdates extends
   public void testRollingUpdates() throws Exception {
     Random random = new Random(random().nextLong());
     final BaseDirectoryWrapper dir = newDirectory();
-    // test checks for no unref'ed files with the IW helper method, which isn't aware of "tried to delete files"
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
-    }
+    assumeFalse("test checks for no unref'ed files with the IW helper method, which isn't aware of 'tried to delete files'", TestUtil.hasVirusChecker(dir));
     
     final LineFileDocs docs = new LineFileDocs(random, true);
 

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java Mon Dec 21 11:15:56 2015
@@ -32,6 +32,7 @@ import org.apache.lucene.store.Directory
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
 import org.apache.lucene.util.ThreadInterruptedException;
 import org.junit.Test;
 
@@ -103,10 +104,7 @@ public class TestSnapshotDeletionPolicy
   }
 
   private void runTest(Random random, Directory dir) throws Exception {
-    // we use the IW unref'ed files check which is unaware of retries:
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
-    }
+    assumeFalse("we use the IW unref'ed files check which is unaware of retries:", TestUtil.hasVirusChecker(dir));
     // Run for ~1 seconds
     final long stopTime = System.currentTimeMillis() + 1000;
 
@@ -257,10 +255,7 @@ public class TestSnapshotDeletionPolicy
     
     // Create 3 snapshots: snapshot0, snapshot1, snapshot2
     Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      // we verify some files get deleted
-      ((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
-    }
+    assumeFalse("we verify some files get deleted", TestUtil.hasVirusChecker(dir));
     IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
     SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     prepareIndexAndSnapshots(sdp, writer, numSnapshots);
@@ -285,10 +280,8 @@ public class TestSnapshotDeletionPolicy
   @Test
   public void testMultiThreadedSnapshotting() throws Exception {
     Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      // test relies on files actually being deleted
-      ((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
-    }
+    assumeFalse("test relies on files actually being deleted", TestUtil.hasVirusChecker(dir));
+
     final IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
     final SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
 
@@ -364,10 +357,7 @@ public class TestSnapshotDeletionPolicy
   @Test
   public void testReleaseSnapshot() throws Exception {
     Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      // we rely upon existence of files
-      ((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
-    }
+    assumeFalse("we rely upon existence of files", TestUtil.hasVirusChecker(dir));
     IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
     SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     prepareIndexAndSnapshots(sdp, writer, 1);
@@ -417,10 +407,7 @@ public class TestSnapshotDeletionPolicy
     // Tests the behavior of SDP when commits that are given at ctor are missing
     // on onInit().
     Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      // we rely upon existence of files
-      ((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
-    }
+    assumeFalse("we rely upon existence of files", TestUtil.hasVirusChecker(dir));
     IndexWriter writer = new IndexWriter(dir, getConfig(random(), getDeletionPolicy()));
     SnapshotDeletionPolicy sdp = (SnapshotDeletionPolicy) writer.getConfig().getIndexDeletionPolicy();
     writer.addDocument(new Document());

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/util/TestOfflineSorter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/util/TestOfflineSorter.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/util/TestOfflineSorter.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/util/TestOfflineSorter.java Mon Dec 21 11:15:56 2015
@@ -30,6 +30,7 @@ import org.apache.lucene.store.IOContext
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.store.IndexOutput;
 import org.apache.lucene.store.MockDirectoryWrapper;
+import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
 import org.apache.lucene.util.OfflineSorter.BufferSize;
 import org.apache.lucene.util.OfflineSorter.ByteSequencesWriter;
 import org.apache.lucene.util.OfflineSorter.SortInfo;
@@ -37,6 +38,7 @@ import org.apache.lucene.util.OfflineSor
 /**
  * Tests for on-disk merge sorting.
  */
+@SuppressFileSystems("VirusCheckingFS")
 public class TestOfflineSorter extends LuceneTestCase {
   private Path tempDir;
 
@@ -54,30 +56,14 @@ public class TestOfflineSorter extends L
     super.tearDown();
   }
 
-  private static Directory newDirectoryNoVirusScanner() {
-    Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
-    return dir;
-  }
-
-  private static Directory newFSDirectoryNoVirusScanner() {
-    Directory dir = newFSDirectory(createTempDir());
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
-    return dir;
-  }
-
   public void testEmpty() throws Exception {
-    try (Directory dir = newDirectoryNoVirusScanner()) {
+    try (Directory dir = newDirectory()) {
         checkSort(dir, new OfflineSorter(dir, "foo"), new byte [][] {});
     }
   }
 
   public void testSingleLine() throws Exception {
-    try (Directory dir = newDirectoryNoVirusScanner()) {
+    try (Directory dir = newDirectory()) {
       checkSort(dir, new OfflineSorter(dir, "foo"), new byte [][] {
           "Single line only.".getBytes(StandardCharsets.UTF_8)
         });
@@ -86,7 +72,7 @@ public class TestOfflineSorter extends L
 
   public void testIntermediateMerges() throws Exception {
     // Sort 20 mb worth of data with 1mb buffer, binary merging.
-    try (Directory dir = newDirectoryNoVirusScanner()) {
+    try (Directory dir = newDirectory()) {
       SortInfo info = checkSort(dir, new OfflineSorter(dir, "foo", OfflineSorter.DEFAULT_COMPARATOR, BufferSize.megabytes(1), 2), 
           generateRandom((int)OfflineSorter.MB * 20));
       assertTrue(info.mergeRounds > 10);
@@ -95,7 +81,7 @@ public class TestOfflineSorter extends L
 
   public void testSmallRandom() throws Exception {
     // Sort 20 mb worth of data with 1mb buffer.
-    try (Directory dir = newDirectoryNoVirusScanner()) {
+    try (Directory dir = newDirectory()) {
       SortInfo sortInfo = checkSort(dir, new OfflineSorter(dir, "foo", OfflineSorter.DEFAULT_COMPARATOR, BufferSize.megabytes(1), OfflineSorter.MAX_TEMPFILES),
                                     generateRandom((int)OfflineSorter.MB * 20));
       assertEquals(1, sortInfo.mergeRounds);
@@ -105,7 +91,7 @@ public class TestOfflineSorter extends L
   @Nightly
   public void testLargerRandom() throws Exception {
     // Sort 100MB worth of data with 15mb buffer.
-    try (Directory dir = newFSDirectoryNoVirusScanner()) {
+    try (Directory dir = newFSDirectory(createTempDir())) {
       checkSort(dir, new OfflineSorter(dir, "foo", OfflineSorter.DEFAULT_COMPARATOR, BufferSize.megabytes(16), OfflineSorter.MAX_TEMPFILES), 
                 generateRandom((int)OfflineSorter.MB * 100));
     }
@@ -223,7 +209,7 @@ public class TestOfflineSorter extends L
     Thread[] threads = new Thread[TestUtil.nextInt(random(), 4, 10)];
     final AtomicBoolean failed = new AtomicBoolean();
     final int iters = atLeast(1000);
-    try (Directory dir = newDirectoryNoVirusScanner()) {
+    try (Directory dir = newDirectory()) {
       for(int i=0;i<threads.length;i++) {
         final int threadID = i;
         threads[i] = new Thread() {

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java Mon Dec 21 11:15:56 2015
@@ -66,10 +66,11 @@ import org.apache.lucene.util.IntsRefBui
 import org.apache.lucene.util.LineFileDocs;
 import org.apache.lucene.util.LuceneTestCase.Slow;
 import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
+import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
-import org.apache.lucene.util.automaton.CompiledAutomaton;
 import org.apache.lucene.util.automaton.Automaton;
+import org.apache.lucene.util.automaton.CompiledAutomaton;
 import org.apache.lucene.util.automaton.RegExp;
 import org.apache.lucene.util.fst.BytesRefFSTEnum.InputOutput;
 import org.apache.lucene.util.fst.FST.Arc;
@@ -83,6 +84,7 @@ import static org.apache.lucene.util.fst
 import static org.apache.lucene.util.fst.FSTTester.toIntsRef;
 
 @SuppressCodecs({ "SimpleText", "Memory", "Direct" })
+@SuppressFileSystems({ "VirusCheckingFS" })
 @Slow
 public class TestFSTs extends LuceneTestCase {
 
@@ -93,7 +95,6 @@ public class TestFSTs extends LuceneTest
     super.setUp();
     dir = newMockDirectory();
     dir.setPreventDoubleWrite(false);
-    dir.setEnableVirusScanner(false);
   }
 
   @Override

Modified: lucene/dev/branches/lucene6835/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeWriter.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeWriter.java (original)
+++ lucene/dev/branches/lucene6835/lucene/sandbox/src/java/org/apache/lucene/bkdtree/BKDTreeWriter.java Mon Dec 21 11:15:56 2015
@@ -19,6 +19,7 @@ package org.apache.lucene.bkdtree;
 
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Comparator;
 
 import org.apache.lucene.store.ByteArrayDataInput;
@@ -32,8 +33,8 @@ import org.apache.lucene.util.BytesRefBu
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.InPlaceMergeSorter;
 import org.apache.lucene.util.LongBitSet;
-import org.apache.lucene.util.OfflineSorter;
 import org.apache.lucene.util.OfflineSorter.ByteSequencesWriter;
+import org.apache.lucene.util.OfflineSorter;
 import org.apache.lucene.util.RamUsageEstimator;
 
 // TODO
@@ -343,7 +344,7 @@ class BKDTreeWriter {
         return writer;
       } finally {
         if (success) {
-          tempDir.deleteFile(sortedFileName);
+          tempDir.deleteFiles(Collections.singleton(sortedFileName));
         } else {
           IOUtils.deleteFilesIgnoringExceptions(tempDir, sortedFileName);
         }
@@ -415,7 +416,7 @@ class BKDTreeWriter {
         latSortedWriter.destroy();
         lonSortedWriter.destroy();
         if (tempInput != null) {
-          tempDir.deleteFile(tempInput.getName());
+          tempDir.deleteFiles(Collections.singleton(tempInput.getName()));
         }
       } else {
         try {

Modified: lucene/dev/branches/lucene6835/lucene/sandbox/src/java/org/apache/lucene/bkdtree/OfflineLatLonWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/sandbox/src/java/org/apache/lucene/bkdtree/OfflineLatLonWriter.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/sandbox/src/java/org/apache/lucene/bkdtree/OfflineLatLonWriter.java (original)
+++ lucene/dev/branches/lucene6835/lucene/sandbox/src/java/org/apache/lucene/bkdtree/OfflineLatLonWriter.java Mon Dec 21 11:15:56 2015
@@ -18,6 +18,7 @@ package org.apache.lucene.bkdtree;
  */
 
 import java.io.IOException;
+import java.util.Collections;
 
 import org.apache.lucene.store.ByteArrayDataOutput;
 import org.apache.lucene.store.Directory;
@@ -66,7 +67,7 @@ final class OfflineLatLonWriter implemen
 
   @Override
   public void destroy() throws IOException {
-    tempDir.deleteFile(out.getName());
+    tempDir.deleteFiles(Collections.singleton(out.getName()));
   }
 
   @Override

Modified: lucene/dev/branches/lucene6835/lucene/sandbox/src/java/org/apache/lucene/rangetree/OfflineSliceWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/sandbox/src/java/org/apache/lucene/rangetree/OfflineSliceWriter.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/sandbox/src/java/org/apache/lucene/rangetree/OfflineSliceWriter.java (original)
+++ lucene/dev/branches/lucene6835/lucene/sandbox/src/java/org/apache/lucene/rangetree/OfflineSliceWriter.java Mon Dec 21 11:15:56 2015
@@ -65,7 +65,7 @@ final class OfflineSliceWriter implement
 
   @Override
   public void destroy() throws IOException {
-    tempDir.deleteFile(tempFile.getName());
+    tempDir.deleteFiles(Collections.singleton(tempFile.getName()));
   }
 
   @Override

Modified: lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java (original)
+++ lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java Mon Dec 21 11:15:56 2015
@@ -183,11 +183,6 @@ public abstract class BaseCompoundFormat
   // Just tests that we can open all files returned by listAll
   public void testListAll() throws Exception {
     Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      // test lists files manually and tries to verify every .cfs it finds,
-      // but a virus scanner could leave some trash.
-      ((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
-    }
     // riw should sometimes create docvalues fields, etc
     RandomIndexWriter riw = new RandomIndexWriter(random(), dir);
     Document doc = new Document();

Modified: lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/index/BaseIndexFileFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/index/BaseIndexFileFormatTestCase.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/index/BaseIndexFileFormatTestCase.java (original)
+++ lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/index/BaseIndexFileFormatTestCase.java Mon Dec 21 11:15:56 2015
@@ -196,11 +196,7 @@ abstract class BaseIndexFileFormatTestCa
   /** The purpose of this test is to make sure that bulk merge doesn't accumulate useless data over runs. */
   public void testMergeStability() throws Exception {
     Directory dir = newDirectory();
-    if (dir instanceof MockDirectoryWrapper) {
-      // Else, the virus checker may prevent deletion of files and cause
-      // us to see too many bytes used by extension in the end:
-      ((MockDirectoryWrapper) dir).setEnableVirusScanner(false);
-    }
+
     // do not use newMergePolicy that might return a MockMergePolicy that ignores the no-CFS ratio
     // do not use RIW which will change things up!
     MergePolicy mp = newTieredMergePolicy();
@@ -219,11 +215,6 @@ abstract class BaseIndexFileFormatTestCa
     DirectoryReader reader = DirectoryReader.open(dir);
 
     Directory dir2 = newDirectory();
-    if (dir2 instanceof MockDirectoryWrapper) {
-      // Else, the virus checker may prevent deletion of files and cause
-      // us to see too many bytes used by extension in the end:
-      ((MockDirectoryWrapper) dir2).setEnableVirusScanner(false);
-    }
     mp = newTieredMergePolicy();
     mp.setNoCFSRatio(0);
     cfg = new IndexWriterConfig(new MockAnalyzer(random())).setUseCompoundFile(false).setMergePolicy(mp);

Added: lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/mockfile/VirusCheckingFS.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/mockfile/VirusCheckingFS.java?rev=1721127&view=auto
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/mockfile/VirusCheckingFS.java (added)
+++ lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/mockfile/VirusCheckingFS.java Mon Dec 21 11:15:56 2015
@@ -0,0 +1,52 @@
+package org.apache.lucene.mockfile;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.nio.file.AccessDeniedException;
+import java.nio.file.FileSystem;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Random;
+
+/** 
+ * Acts like Windows, where random programs may open the files you just wrote in an unfriendly
+ * way preventing deletion (e.g. not passing FILE_SHARE_DELETE) or renaming or overwriting etc.
+ */
+public class VirusCheckingFS extends FilterFileSystemProvider {
+
+  final Random random;
+
+  /** 
+   * Create a new instance, wrapping {@code delegate}.
+   */
+  public VirusCheckingFS(FileSystem delegate, Random random) {
+    super("viruschecking://", delegate);
+    this.random = random;
+  }
+
+  @Override
+  public void delete(Path path) throws IOException {
+    if (random.nextInt(5) == 1) {
+      throw new AccessDeniedException("VirusCheckingFS is randomly refusing to delete file \"" + path + "\"");
+    }
+    super.delete(path);
+  }
+
+  // TODO: rename?  createOutput?  deleteIfExists?
+}

Modified: lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java (original)
+++ lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/store/BaseDirectoryTestCase.java Mon Dec 21 11:15:56 2015
@@ -1183,7 +1183,7 @@ public abstract class BaseDirectoryTestC
       in.close();
     }
     Set<String> files = new HashSet<String>(Arrays.asList(dir.listAll()));
-    // In case ExtraFS struck:
+    // In case ExtrasFS struck:
     files.remove("extra0");
     assertEquals(new HashSet<String>(names), files);
     dir.close();

Modified: lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java (original)
+++ lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/store/MockDirectoryWrapper.java Mon Dec 21 11:15:56 2015
@@ -72,12 +72,10 @@ public class MockDirectoryWrapper extend
   double randomIOExceptionRate;
   double randomIOExceptionRateOnOpen;
   Random randomState;
-  boolean noDeleteOpenFile = true;
   boolean assertNoDeleteOpenFile = false;
   boolean preventDoubleWrite = true;
   boolean trackDiskUsage = false;
   boolean useSlowOpenClosers = LuceneTestCase.TEST_NIGHTLY;
-  boolean enableVirusScanner = true;
   boolean allowRandomFileNotFoundException = true;
   boolean allowReadingFilesStillOpenForWrite = false;
   private Set<String> unSyncedFiles;
@@ -104,15 +102,10 @@ public class MockDirectoryWrapper extend
   // is made to delete an open file, we enroll it here.
   private Set<String> openFilesDeleted;
   
-  // only tracked if virus scanner is enabled:
-  // set of files it prevented deletion for
-  private Set<String> triedToDelete;
-
   private synchronized void init() {
     if (openFiles == null) {
       openFiles = new HashMap<>();
       openFilesDeleted = new HashSet<>();
-      triedToDelete = new HashSet<>();
     }
 
     if (createdFiles == null)
@@ -170,18 +163,6 @@ public class MockDirectoryWrapper extend
     allowReadingFilesStillOpenForWrite = value;
   }
   
-  /** Returns true if the virus scanner is enabled */
-  public boolean getEnableVirusScanner() {
-    return enableVirusScanner;
-  }
-  
-  /** If set to true (the default), deleteFile sometimes
-   *  fails because a virus scanner is open.
-   */
-  public void setEnableVirusScanner(boolean value) {
-    this.enableVirusScanner = value;
-  }
-
   /**
    * Enum for controlling hard disk throttling.
    * Set via {@link MockDirectoryWrapper #setThrottling(Throttling)}
@@ -236,12 +217,8 @@ public class MockDirectoryWrapper extend
       throw new IOException("cannot rename after crash");
     }
     
-    if (openFiles.containsKey(source)) {
-      if (assertNoDeleteOpenFile) {
-        throw (AssertionError) fillOpenTrace(new AssertionError("MockDirectoryWrapper: file \"" + source + "\" is still open: cannot rename"), source, true);
-      } else if (noDeleteOpenFile) {
-        throw (IOException) fillOpenTrace(new IOException("MockDirectoryWrapper: file \"" + source + "\" is still open: cannot rename"), source, true);
-      }
+    if (assertNoDeleteOpenFile && openFiles.containsKey(source)) {
+      throw (AssertionError) fillOpenTrace(new AssertionError("MockDirectoryWrapper: file \"" + source + "\" is still open: cannot rename"), source, true);
     }
 
     boolean success = false;
@@ -280,7 +257,6 @@ public class MockDirectoryWrapper extend
   /** Simulates a crash of OS or machine by overwriting
    *  unsynced files. */
   public synchronized void crash() throws IOException {
-    crashed = true;
     openFiles = new HashMap<>();
     openFilesForWrite = new HashSet<>();
     openFilesDeleted = new HashSet<>();
@@ -302,7 +278,7 @@ public class MockDirectoryWrapper extend
 
       if (damage == 0) {
         action = "deleted";
-        deleteFiles(Collections.singleton(name), true);
+        deleteFiles(Collections.singleton(name));
       } else if (damage == 1) {
         action = "zeroed";
         // Zero out file entirely
@@ -336,21 +312,21 @@ public class MockDirectoryWrapper extend
         ii.close();
 
         // Delete original and copy bytes back:
-        deleteFiles(Collections.singleton(name), true);
+        deleteFiles(Collections.singleton(name));
         
         final IndexOutput out = in.createOutput(name, LuceneTestCase.newIOContext(randomState));
         ii = in.openInput(tempFileName, LuceneTestCase.newIOContext(randomState));
         out.copyBytes(ii, ii.length());
         out.close();
         ii.close();
-        deleteFiles(Collections.singleton(tempFileName), true);
+        deleteFiles(Collections.singleton(tempFileName));
       } else if (damage == 3) {
         // The file survived intact:
         action = "didn't change";
       } else {
         action = "fully truncated";
         // Totally truncate the file to zero bytes
-        deleteFiles(Collections.singleton(name), true);
+        deleteFiles(Collections.singleton(name));
         IndexOutput out = in.createOutput(name, LuceneTestCase.newIOContext(randomState));
         out.close();
       }
@@ -358,6 +334,7 @@ public class MockDirectoryWrapper extend
         System.out.println("MockDirectoryWrapper: " + action + " unsynced file: " + name);
       }
     }
+    crashed = true;
   }
 
   public synchronized void clearCrash() {
@@ -384,18 +361,6 @@ public class MockDirectoryWrapper extend
   }
 
   /**
-   * Emulate windows whereby deleting an open file is not
-   * allowed (raise IOException).
-  */
-  public void setNoDeleteOpenFile(boolean value) {
-    this.noDeleteOpenFile = value;
-  }
-  
-  public boolean getNoDeleteOpenFile() {
-    return noDeleteOpenFile;
-  }
-  
-  /**
    * Trip a test assert if there is an attempt
    * to delete an open file.
   */
@@ -468,7 +433,26 @@ public class MockDirectoryWrapper extend
   @Override
   public synchronized void deleteFiles(Collection<String> names) throws IOException {
     maybeYield();
-    deleteFiles(names, false);
+
+    maybeThrowDeterministicException();
+
+    if (crashed) {
+      throw new IOException("cannot delete after crash");
+    }
+
+    for(String name : names) {
+      if (openFiles.containsKey(name)) {
+        openFilesDeleted.add(name);
+        if (assertNoDeleteOpenFile) {
+          throw (IOException) fillOpenTrace(new IOException("MockDirectoryWrapper: file \"" + name + "\" is still open: cannot delete"), name, true);
+        }
+      } else {
+        openFilesDeleted.remove(name);
+      }
+    }
+
+    unSyncedFiles.removeAll(names);
+    in.deleteFiles(names);
   }
 
   // sets the cause of the incoming ioe to be the stack
@@ -492,59 +476,6 @@ public class MockDirectoryWrapper extend
     }
   }
 
-  private synchronized void deleteFiles(Collection<String> names, boolean forced) throws IOException {
-    maybeYield();
-
-    maybeThrowDeterministicException();
-
-    if (crashed && !forced)
-      throw new IOException("cannot delete after crash");
-
-    for(String name : names) {
-      if (unSyncedFiles.contains(name)) {
-        unSyncedFiles.remove(name);
-      }
-      triedToDelete.remove(name);
-    }
-
-    in.deleteFiles(names);
-
-    // nocommit how to get virus checker back!!!  must move down to MockFS?
-
-    /*
-    if (unSyncedFiles.contains(name))
-      unSyncedFiles.remove(name);
-    if (!forced && (noDeleteOpenFile || assertNoDeleteOpenFile)) {
-      if (openFiles.containsKey(name)) {
-        openFilesDeleted.add(name);
-
-        if (!assertNoDeleteOpenFile) {
-          throw (IOException) fillOpenTrace(new IOException("MockDirectoryWrapper: file \"" + name + "\" is still open: cannot delete"), name, true);
-        } else {
-          throw (AssertionError) fillOpenTrace(new AssertionError("MockDirectoryWrapper: file \"" + name + "\" is still open: cannot delete"), name, true);
-        }
-      } else {
-        openFilesDeleted.remove(name);
-      }
-    }
-    if (!forced && enableVirusScanner && (randomState.nextInt(4) == 0)) {
-      triedToDelete.add(name);
-      if (LuceneTestCase.VERBOSE) {
-        System.out.println("MDW: now refuse to delete file: " + name);
-      }
-      throw new IOException("cannot delete file: " + name + ", a virus scanner has it open");
-    }
-    triedToDelete.remove(name);
-    in.deleteFile(name);
-    */
-  }
-
-  /** Returns true if {@link #deleteFiles} was called with this
-   *  fileName, but the virus checker prevented the deletion. */
-  public boolean didTryToDelete(String fileName) {
-    return triedToDelete.contains(fileName);
-  }
-
   public synchronized Set<String> getOpenDeletedFiles() {
     return new HashSet<>(openFilesDeleted);
   }
@@ -572,12 +503,8 @@ public class MockDirectoryWrapper extend
         throw new IOException("file \"" + name + "\" was already written to");
       }
     }
-    if ((noDeleteOpenFile || assertNoDeleteOpenFile) && openFiles.containsKey(name)) {
-      if (!assertNoDeleteOpenFile) {
-        throw new IOException("MockDirectoryWrapper: file \"" + name + "\" is still open: cannot overwrite");
-      } else {
-        throw new AssertionError("MockDirectoryWrapper: file \"" + name + "\" is still open: cannot overwrite");
-      }
+    if (assertNoDeleteOpenFile && openFiles.containsKey(name)) {
+      throw new AssertionError("MockDirectoryWrapper: file \"" + name + "\" is still open: cannot overwrite");
     }
     
     if (crashed) {
@@ -728,9 +655,6 @@ public class MockDirectoryWrapper extend
       // files that we tried to delete, but couldn't because readers were open.
       // all that matters is that we tried! (they will eventually go away)
       //   still open when we tried to delete
-      Set<String> pendingDeletions = new HashSet<>(openFilesDeleted);
-      //   virus scanner when we tried to delete
-      pendingDeletions.addAll(triedToDelete);
       maybeYield();
       if (openFiles == null) {
         openFiles = new HashMap<>();
@@ -759,6 +683,8 @@ public class MockDirectoryWrapper extend
       if (getCheckIndexOnClose()) {
         randomIOExceptionRate = 0.0;
         randomIOExceptionRateOnOpen = 0.0;
+
+        // nocommit we should also confirm all prior segments_N are intact?
         if (DirectoryReader.indexExists(this)) {
           if (LuceneTestCase.VERBOSE) {
             System.out.println("\nNOTE: MockDirectoryWrapper: now crush");
@@ -773,7 +699,6 @@ public class MockDirectoryWrapper extend
           if (assertNoUnreferencedFilesOnClose) {
             // now look for unreferenced files: discount ones that we tried to delete but could not
             Set<String> allFiles = new HashSet<>(Arrays.asList(listAll()));
-            allFiles.removeAll(pendingDeletions);
             String[] startFiles = allFiles.toArray(new String[0]);
             IndexWriterConfig iwc = new IndexWriterConfig(null);
             iwc.setIndexDeletionPolicy(NoDeletionPolicy.INSTANCE);
@@ -783,51 +708,6 @@ public class MockDirectoryWrapper extend
             Set<String> startSet = new TreeSet<>(Arrays.asList(startFiles));
             Set<String> endSet = new TreeSet<>(Arrays.asList(endFiles));
             
-            if (pendingDeletions.contains("segments.gen") && endSet.contains("segments.gen")) {
-              // this is possible if we hit an exception while writing segments.gen, we try to delete it
-              // and it ends out in pendingDeletions (but IFD wont remove this).
-              startSet.add("segments.gen");
-              if (LuceneTestCase.VERBOSE) {
-                System.out.println("MDW: Unreferenced check: Ignoring segments.gen that we could not delete.");
-              }
-            }
-            
-            // it's possible we cannot delete the segments_N on windows if someone has it open and
-            // maybe other files too, depending on timing. normally someone on windows wouldnt have
-            // an issue (IFD would nuke this stuff eventually), but we pass NoDeletionPolicy...
-            for (String file : pendingDeletions) {
-              if (file.startsWith("segments") && !file.equals("segments.gen") && endSet.contains(file)) {
-                startSet.add(file);
-                if (LuceneTestCase.VERBOSE) {
-                  System.out.println("MDW: Unreferenced check: Ignoring segments file: " + file + " that we could not delete.");
-                }
-                SegmentInfos sis;
-                try {
-                  sis = SegmentInfos.readCommit(in, file);
-                } catch (IOException ioe) {
-                  // OK: likely some of the .si files were deleted
-                  sis = new SegmentInfos();
-                }
-                
-                try {
-                  Set<String> ghosts = new HashSet<>(sis.files(false));
-                  for (String s : ghosts) {
-                    if (endSet.contains(s) && !startSet.contains(s)) {
-                      assert pendingDeletions.contains(s);
-                      if (LuceneTestCase.VERBOSE) {
-                        System.out.println("MDW: Unreferenced check: Ignoring referenced file: " + s + " " +
-                            "from " + file + " that we could not delete.");
-                      }
-                      startSet.add(s);
-                    }
-                  }
-                } catch (Throwable t) {
-                  System.err.println("ERROR processing leftover segments file " + file + ":");
-                  t.printStackTrace();
-                }
-              }
-            }
-            
             startFiles = startSet.toArray(new String[0]);
             endFiles = endSet.toArray(new String[0]);
             
@@ -857,10 +737,6 @@ public class MockDirectoryWrapper extend
                 extras += "\n\nThese files were added (waaaaaaaaaat!): " + added;
               }
               
-              if (pendingDeletions.size() != 0) {
-                extras += "\n\nThese files we had previously tried to delete, but couldn't: " + pendingDeletions;
-              }
-              
               throw new RuntimeException("unreferenced files: before delete:\n    " + Arrays.toString(startFiles) + "\n  after delete:\n    " + Arrays.toString(endFiles) + extras);
             }
             

Modified: lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java (original)
+++ lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/util/TestRuleTemporaryFilesCleanup.java Mon Dec 21 11:15:56 2015
@@ -39,6 +39,7 @@ import org.apache.lucene.mockfile.Handle
 import org.apache.lucene.mockfile.LeakFS;
 import org.apache.lucene.mockfile.ShuffleFS;
 import org.apache.lucene.mockfile.VerboseFS;
+import org.apache.lucene.mockfile.VirusCheckingFS;
 import org.apache.lucene.mockfile.WindowsFS;
 import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
 import org.apache.lucene.util.LuceneTestCase.SuppressFsync;
@@ -174,6 +175,11 @@ final class TestRuleTemporaryFilesCleanu
       if (allowed(avoid, ExtrasFS.class)) {
         fs = new ExtrasFS(fs, random.nextInt(4) == 0, random.nextBoolean()).getFileSystem(null);
       }
+      // nocommit
+      if (false && allowed(avoid, VirusCheckingFS.class) && (true || random.nextInt(10) == 1)) {
+        // 10% of the time we swap in virus checking (acts-like-windows) FS:
+        fs = new VirusCheckingFS(fs, random).getFileSystem(null);
+      }
     }
     if (LuceneTestCase.VERBOSE) {
       System.out.println("filesystem: " + fs.provider());

Modified: lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java (original)
+++ lucene/dev/branches/lucene6835/lucene/test-framework/src/java/org/apache/lucene/util/TestUtil.java Mon Dec 21 11:15:56 2015
@@ -45,9 +45,6 @@ import java.util.regex.PatternSyntaxExce
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
-import com.carrotsearch.randomizedtesting.generators.RandomInts;
-import com.carrotsearch.randomizedtesting.generators.RandomPicks;
-
 import org.apache.lucene.codecs.Codec;
 import org.apache.lucene.codecs.DocValuesFormat;
 import org.apache.lucene.codecs.PostingsFormat;
@@ -70,13 +67,13 @@ import org.apache.lucene.document.LongFi
 import org.apache.lucene.document.NumericDocValuesField;
 import org.apache.lucene.document.SortedDocValuesField;
 import org.apache.lucene.index.CheckIndex;
+import org.apache.lucene.index.CodecReader;
 import org.apache.lucene.index.ConcurrentMergeScheduler;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.DocValuesType;
 import org.apache.lucene.index.FieldInfo;
-import org.apache.lucene.index.IndexFileNames;
-import org.apache.lucene.index.PostingsEnum;
 import org.apache.lucene.index.FilterLeafReader;
+import org.apache.lucene.index.IndexFileNames;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexableField;
@@ -85,8 +82,8 @@ import org.apache.lucene.index.LeafReade
 import org.apache.lucene.index.LogMergePolicy;
 import org.apache.lucene.index.MergePolicy;
 import org.apache.lucene.index.MergeScheduler;
-import org.apache.lucene.index.CodecReader;
 import org.apache.lucene.index.MultiFields;
+import org.apache.lucene.index.PostingsEnum;
 import org.apache.lucene.index.SegmentReader;
 import org.apache.lucene.index.SlowCodecReaderWrapper;
 import org.apache.lucene.index.Terms;
@@ -96,11 +93,16 @@ import org.apache.lucene.search.FieldDoc
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.store.FilterDirectory;
 import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.NoLockFactory;
 import org.apache.lucene.store.RAMDirectory;
 import org.junit.Assert;
 
+import com.carrotsearch.randomizedtesting.generators.RandomInts;
+import com.carrotsearch.randomizedtesting.generators.RandomPicks;
+
 
 /**
  * General utility methods for Lucene unit tests. 
@@ -1275,4 +1277,16 @@ public final class TestUtil {
     }
     return ram;
   }
+
+  public static boolean hasVirusChecker(Directory dir) {
+    dir = FilterDirectory.unwrap(dir);
+    if (dir instanceof FSDirectory) {
+      Path path = ((FSDirectory) dir).getDirectory();
+      System.out.println("HERE: " + path.toString());
+      // nocommit doesn't work?
+      return path.getFileSystem().toString().contains("VirusCheckingFS");
+    } else {
+      return false;
+    }
+  }
 }

Modified: lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java (original)
+++ lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/codecs/compressing/TestCompressingStoredFieldsFormat.java Mon Dec 21 11:15:56 2015
@@ -56,10 +56,6 @@ public class TestCompressingStoredFields
 
   public void testDeletePartiallyWrittenFilesIfAbort() throws IOException {
     Directory dir = newDirectory();
-    // test explicitly needs files to always be actually deleted
-    if (dir instanceof MockDirectoryWrapper) {
-      ((MockDirectoryWrapper)dir).setEnableVirusScanner(false);
-    }
     IndexWriterConfig iwConf = newIndexWriterConfig(new MockAnalyzer(random()));
     iwConf.setMaxBufferedDocs(RandomInts.randomIntBetween(random(), 2, 30));
     iwConf.setCodec(CompressingCodec.randomInstance(random()));

Added: lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestVirusCheckingFS.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestVirusCheckingFS.java?rev=1721127&view=auto
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestVirusCheckingFS.java (added)
+++ lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestVirusCheckingFS.java Mon Dec 21 11:15:56 2015
@@ -0,0 +1,62 @@
+package org.apache.lucene.mockfile;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URI;
+import java.nio.file.AccessDeniedException;
+import java.nio.file.FileSystem;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+/** Basic tests for VirusCheckingFS */
+public class TestVirusCheckingFS extends MockFileSystemTestCase {
+  
+  @Override
+  protected Path wrap(Path path) {
+    FileSystem fs = new VirusCheckingFS(path.getFileSystem(), random()).getFileSystem(URI.create("file:///"));
+    return new FilterPath(path, fs);
+  }
+  
+  /** Test Files.delete fails if a file has an open inputstream against it */
+  public void testDeleteSometimesFails() throws IOException {
+    Path dir = wrap(createTempDir());
+
+    int counter = 0;
+    while (true) {
+      Path path = dir.resolve("file" + counter);
+      counter++;
+
+      OutputStream file = Files.newOutputStream(path);
+      file.write(5);
+      file.close();
+
+      // File is now closed, we attempt delete:
+      try {
+        Files.delete(path);
+      } catch (AccessDeniedException ade) {
+        // expected (sometimes)
+        assertTrue(ade.getMessage().contains("VirusCheckingFS is randomly refusing to delete file "));
+        break;
+      }
+
+      assertFalse(Files.exists(path));
+    }
+  }
+}

Modified: lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestWindowsFS.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestWindowsFS.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestWindowsFS.java (original)
+++ lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/mockfile/TestWindowsFS.java Mon Dec 21 11:15:56 2015
@@ -41,10 +41,10 @@ import org.apache.lucene.util.Constants;
 /** Basic tests for WindowsFS */
 public class TestWindowsFS extends MockFileSystemTestCase {
   
-  // currently we don't emulate windows well enough to work on windows!
   @Override
   public void setUp() throws Exception {
     super.setUp();
+    // irony: currently we don't emulate windows well enough to work on windows!
     assumeFalse("windows is not supported", Constants.WINDOWS);
   }
 

Modified: lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/store/TestMockDirectoryWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/store/TestMockDirectoryWrapper.java?rev=1721127&r1=1721126&r2=1721127&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/store/TestMockDirectoryWrapper.java (original)
+++ lucene/dev/branches/lucene6835/lucene/test-framework/src/test/org/apache/lucene/store/TestMockDirectoryWrapper.java Mon Dec 21 11:15:56 2015
@@ -37,7 +37,6 @@ public class TestMockDirectoryWrapper ex
     } else {
       dir = newMockFSDirectory(path);
     }
-    dir.setEnableVirusScanner(false); // test manipulates filesystem directly
     return dir;
   }
   



Mime
View raw message