mirror of https://github.com/apache/lucene.git
LUCENE-5969: fix false fails from tests that look for exact file names
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5969@1629400 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
799a2875e1
commit
acf361084b
|
@ -1116,7 +1116,10 @@ public class TestAddIndexes extends LuceneTestCase {
|
||||||
w3.close();
|
w3.close();
|
||||||
// we should now see segments_X,
|
// we should now see segments_X,
|
||||||
// _Y.cfs,_Y.cfe, _Z.si
|
// _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();
|
dir.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.apache.lucene.analysis.MockAnalyzer;
|
import org.apache.lucene.analysis.MockAnalyzer;
|
||||||
import org.apache.lucene.codecs.Codec;
|
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
import org.apache.lucene.document.Field;
|
import org.apache.lucene.document.Field;
|
||||||
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
||||||
|
@ -84,6 +83,13 @@ public class TestIndexFileDeleter extends LuceneTestCase {
|
||||||
Term searchTerm = new Term("id", "7");
|
Term searchTerm = new Term("id", "7");
|
||||||
writer.deleteDocuments(searchTerm);
|
writer.deleteDocuments(searchTerm);
|
||||||
writer.close();
|
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
|
// Now, artificially create an extra .del file & extra
|
||||||
// .s0 file:
|
// .s0 file:
|
||||||
|
@ -110,11 +116,13 @@ public class TestIndexFileDeleter extends LuceneTestCase {
|
||||||
// non-existent segment:
|
// non-existent segment:
|
||||||
copyFile(dir, "_0_1" + ext, "_188_1" + ext);
|
copyFile(dir, "_0_1" + ext, "_188_1" + ext);
|
||||||
|
|
||||||
|
String cfsFiles0[] = si0.getCodec().compoundFormat().files(si0);
|
||||||
|
|
||||||
// Create a bogus segment file:
|
// 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:
|
// 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:
|
// Create some old segments file:
|
||||||
copyFile(dir, "segments_2", "segments");
|
copyFile(dir, "segments_2", "segments");
|
||||||
|
@ -124,8 +132,14 @@ public class TestIndexFileDeleter extends LuceneTestCase {
|
||||||
|
|
||||||
// TODO: assert is bogus (relies upon codec-specific filenames)
|
// TODO: assert is bogus (relies upon codec-specific filenames)
|
||||||
assertTrue(slowFileExists(dir, "_3.fdt") || slowFileExists(dir, "_3.fld"));
|
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();
|
String[] filesPre = dir.listAll();
|
||||||
|
|
||||||
|
|
|
@ -1326,6 +1326,7 @@ public class TestIndexWriter extends LuceneTestCase {
|
||||||
|
|
||||||
|
|
||||||
public void testDeleteUnusedFiles() throws Exception {
|
public void testDeleteUnusedFiles() throws Exception {
|
||||||
|
assumeFalse("test relies on exact filenames", Codec.getDefault() instanceof SimpleTextCodec);
|
||||||
for(int iter=0;iter<2;iter++) {
|
for(int iter=0;iter<2;iter++) {
|
||||||
MockDirectoryWrapper dir = newMockDirectory(); // relies on windows semantics
|
MockDirectoryWrapper dir = newMockDirectory(); // relies on windows semantics
|
||||||
dir.setEnableVirusScanner(false); // but ensures files are actually deleted
|
dir.setEnableVirusScanner(false); // but ensures files are actually deleted
|
||||||
|
|
|
@ -1231,17 +1231,19 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
|
||||||
|
|
||||||
long gen = SegmentInfos.getLastCommitGeneration(dir);
|
long gen = SegmentInfos.getLastCommitGeneration(dir);
|
||||||
assertTrue("segment generation should be > 0 but got " + gen, gen > 0);
|
assertTrue("segment generation should be > 0 but got " + gen, gen > 0);
|
||||||
|
|
||||||
String[] files = dir.listAll();
|
|
||||||
boolean corrupted = false;
|
boolean corrupted = false;
|
||||||
for(int i=0;i<files.length;i++) {
|
SegmentInfos sis = new SegmentInfos();
|
||||||
if (files[i].endsWith(".cfs")) {
|
sis.read(dir);
|
||||||
dir.deleteFile(files[i]);
|
for (SegmentCommitInfo si : sis) {
|
||||||
corrupted = true;
|
assertTrue(si.info.getUseCompoundFile());
|
||||||
break;
|
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;
|
IndexReader reader = null;
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue