You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2012/10/02 13:58:42 UTC
svn commit: r1392867 -
/lucene/dev/branches/lucene4456/lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
Author: mikemccand
Date: Tue Oct 2 11:58:42 2012
New Revision: 1392867
URL: http://svn.apache.org/viewvc?rev=1392867&view=rev
Log:
LUCENE-4456: TestSnapshotDeletionPolicy creates leftover files
Modified:
lucene/dev/branches/lucene4456/lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
Modified: lucene/dev/branches/lucene4456/lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4456/lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java?rev=1392867&r1=1392866&r2=1392867&view=diff
==============================================================================
--- lucene/dev/branches/lucene4456/lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java (original)
+++ lucene/dev/branches/lucene4456/lucene/core/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java Tue Oct 2 11:58:42 2012
@@ -17,17 +17,18 @@ package org.apache.lucene.index;
* limitations under the License.
*/
+import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Random;
-import java.io.IOException;
+import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.TextField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IndexInput;
-import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.ThreadInterruptedException;
import org.junit.Test;
@@ -313,6 +314,12 @@ public class TestSnapshotDeletionPolicy
public void testRollbackToOldSnapshot() throws Exception {
int numSnapshots = 2;
Directory dir = newDirectory();
+
+ if (dir instanceof MockDirectoryWrapper) {
+ // We create leftover files:
+ ((MockDirectoryWrapper) dir).setAssertNoUnrefencedFilesOnClose(false);
+ }
+
SnapshotDeletionPolicy sdp = getDeletionPolicy();
IndexWriter writer = new IndexWriter(dir, getConfig(random(), sdp));
prepareIndexAndSnapshots(sdp, writer, numSnapshots, "snapshot");
@@ -325,10 +332,11 @@ public class TestSnapshotDeletionPolicy
writer.deleteUnusedFiles();
assertSnapshotExists(dir, sdp, numSnapshots - 1);
writer.close();
-
+
// but 'snapshot1' files will still exist (need to release snapshot before they can be deleted).
String segFileName = sdp.getSnapshot("snapshot1").getSegmentsFileName();
assertTrue("snapshot files should exist in the directory: " + segFileName, dir.fileExists(segFileName));
+
dir.close();
}
@@ -367,6 +375,10 @@ public class TestSnapshotDeletionPolicy
// asserts that those snapshots/commit points are protected.
int numSnapshots = 3;
Directory dir = newDirectory();
+ if (dir instanceof MockDirectoryWrapper) {
+ // We create leftover files:
+ ((MockDirectoryWrapper) dir).setAssertNoUnrefencedFilesOnClose(false);
+ }
SnapshotDeletionPolicy sdp = getDeletionPolicy();
IndexWriter writer = new IndexWriter(dir, getConfig(random(), sdp));
prepareIndexAndSnapshots(sdp, writer, numSnapshots, "snapshot");
@@ -385,6 +397,11 @@ public class TestSnapshotDeletionPolicy
@Test
public void testSnapshotLastCommitTwice() throws Exception {
Directory dir = newDirectory();
+ if (dir instanceof MockDirectoryWrapper) {
+ // We create leftover files:
+ ((MockDirectoryWrapper) dir).setAssertNoUnrefencedFilesOnClose(false);
+ }
+
SnapshotDeletionPolicy sdp = getDeletionPolicy();
IndexWriter writer = new IndexWriter(dir, getConfig(random(), sdp));
writer.addDocument(new Document());