lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1629400 - in /lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index: TestAddIndexes.java TestIndexFileDeleter.java TestIndexWriter.java TestIndexWriterExceptions.java
Date Sat, 04 Oct 2014 14:42:41 GMT
Author: rmuir
Date: Sat Oct  4 14:42:41 2014
New Revision: 1629400

URL: http://svn.apache.org/r1629400
Log:
LUCENE-5969: fix false fails from tests that look for exact file names

Modified:
    lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
    lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
    lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
    lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java

Modified: lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java?rev=1629400&r1=1629399&r2=1629400&view=diff
==============================================================================
--- lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
(original)
+++ lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
Sat Oct  4 14:42:41 2014
@@ -1116,7 +1116,10 @@ public class TestAddIndexes extends Luce
     w3.close();
     // we should now see segments_X,
     // _Y.cfs,_Y.cfe, _Z.si
-    assertEquals("Only one compound segment should exist, but got: " + Arrays.toString(dir.listAll()),
4, dir.listAll().length);
+    SegmentInfos sis = new SegmentInfos();
+    sis.read(dir);
+    assertEquals("Only one compound segment should exist", 1, sis.size());
+    assertTrue(sis.info(0).info.getUseCompoundFile());
     dir.close();
   }
   

Modified: lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java?rev=1629400&r1=1629399&r2=1629400&view=diff
==============================================================================
--- lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
(original)
+++ lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexFileDeleter.java
Sat Oct  4 14:42:41 2014
@@ -22,7 +22,6 @@ import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.codecs.Codec;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
@@ -84,6 +83,13 @@ public class TestIndexFileDeleter extend
     Term searchTerm = new Term("id", "7");
     writer.deleteDocuments(searchTerm);
     writer.close();
+    
+    // read in index to try to not depend on codec-specific filenames so much
+    SegmentInfos sis = new SegmentInfos();
+    sis.read(dir);
+    SegmentInfo si0 = sis.info(0).info;
+    SegmentInfo si1 = sis.info(1).info;
+    SegmentInfo si3 = sis.info(3).info;
 
     // Now, artificially create an extra .del file & extra
     // .s0 file:
@@ -110,11 +116,13 @@ public class TestIndexFileDeleter extend
     // non-existent segment:
     copyFile(dir, "_0_1" + ext, "_188_1" + ext);
 
+    String cfsFiles0[] = si0.getCodec().compoundFormat().files(si0);
+    
     // Create a bogus segment file:
-    copyFile(dir, "_0.cfs", "_188.cfs");
+    copyFile(dir, cfsFiles0[0], "_188.cfs");
 
     // Create a bogus fnm file when the CFS already exists:
-    copyFile(dir, "_0.cfs", "_0.fnm");
+    copyFile(dir, cfsFiles0[0], "_0.fnm");
     
     // Create some old segments file:
     copyFile(dir, "segments_2", "segments");
@@ -124,8 +132,14 @@ public class TestIndexFileDeleter extend
     
     // TODO: assert is bogus (relies upon codec-specific filenames)
     assertTrue(slowFileExists(dir, "_3.fdt") || slowFileExists(dir, "_3.fld"));
-    assertTrue(!slowFileExists(dir, "_3.cfs"));
-    copyFile(dir, "_1.cfs", "_3.cfs");
+    
+    String cfsFiles3[] = si3.getCodec().compoundFormat().files(si3);
+    for (String f : cfsFiles3) {
+      assertTrue(!slowFileExists(dir, f));
+    }
+    
+    String cfsFiles1[] = si1.getCodec().compoundFormat().files(si1);
+    copyFile(dir, cfsFiles1[0], "_3.cfs");
     
     String[] filesPre = dir.listAll();
 

Modified: lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1629400&r1=1629399&r2=1629400&view=diff
==============================================================================
--- lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
(original)
+++ lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
Sat Oct  4 14:42:41 2014
@@ -1326,6 +1326,7 @@ public class TestIndexWriter extends Luc
 
 
   public void testDeleteUnusedFiles() throws Exception {
+    assumeFalse("test relies on exact filenames", Codec.getDefault() instanceof SimpleTextCodec);
     for(int iter=0;iter<2;iter++) {
       MockDirectoryWrapper dir = newMockDirectory(); // relies on windows semantics
       dir.setEnableVirusScanner(false); // but ensures files are actually deleted

Modified: lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=1629400&r1=1629399&r2=1629400&view=diff
==============================================================================
--- lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
(original)
+++ lucene/dev/branches/lucene5969/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
Sat Oct  4 14:42:41 2014
@@ -1231,17 +1231,19 @@ public class TestIndexWriterExceptions e
 
     long gen = SegmentInfos.getLastCommitGeneration(dir);
     assertTrue("segment generation should be > 0 but got " + gen, gen > 0);
-
-    String[] files = dir.listAll();
+    
     boolean corrupted = false;
-    for(int i=0;i<files.length;i++) {
-      if (files[i].endsWith(".cfs")) {
-        dir.deleteFile(files[i]);
-        corrupted = true;
-        break;
-      }
+    SegmentInfos sis = new SegmentInfos();
+    sis.read(dir);
+    for (SegmentCommitInfo si : sis) {
+      assertTrue(si.info.getUseCompoundFile());
+      String cfsFiles[] = si.info.getCodec().compoundFormat().files(si.info);
+      dir.deleteFile(cfsFiles[0]);
+      corrupted = true;
+      break;
     }
-    assertTrue("failed to find cfs file to remove", corrupted);
+
+    assertTrue("failed to find cfs file to remove: ", corrupted);
 
     IndexReader reader = null;
     try {



Mime
View raw message