mirror of https://github.com/apache/lucene.git
LUCENE-7422: fix bugs in test's retry loop
This commit is contained in:
parent
2fcccc037d
commit
e3b08517c5
|
@ -28,6 +28,8 @@ import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.IOContext;
|
import org.apache.lucene.store.IOContext;
|
||||||
import org.apache.lucene.store.IndexInput;
|
import org.apache.lucene.store.IndexInput;
|
||||||
import org.apache.lucene.store.IndexOutput;
|
import org.apache.lucene.store.IndexOutput;
|
||||||
|
import org.apache.lucene.store.MockDirectoryWrapper;
|
||||||
|
import org.apache.lucene.store.RAMDirectory;
|
||||||
import org.apache.lucene.util.LineFileDocs;
|
import org.apache.lucene.util.LineFileDocs;
|
||||||
import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
|
import org.apache.lucene.util.LuceneTestCase.SuppressFileSystems;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
|
@ -84,7 +86,8 @@ public class TestAllFilesCheckIndexHeader extends LuceneTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkOneFile(Directory dir, String victim) throws IOException {
|
private void checkOneFile(Directory dir, String victim) throws IOException {
|
||||||
try (BaseDirectoryWrapper dirCopy = newDirectory()) {
|
// use ramdir explicit, as we do evil things like try to generate broken files, deletes must work.
|
||||||
|
try (BaseDirectoryWrapper dirCopy = new MockDirectoryWrapper(random(), new RAMDirectory())) {
|
||||||
dirCopy.setCheckIndexOnClose(false);
|
dirCopy.setCheckIndexOnClose(false);
|
||||||
|
|
||||||
long victimLength = dir.fileLength(victim);
|
long victimLength = dir.fileLength(victim);
|
||||||
|
@ -117,6 +120,8 @@ public class TestAllFilesCheckIndexHeader extends LuceneTestCase {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// we have to try again, delete the first attempt and retry the loop
|
||||||
|
dirCopy.deleteFile(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dirCopy.sync(Collections.singleton(name));
|
dirCopy.sync(Collections.singleton(name));
|
||||||
|
|
Loading…
Reference in New Issue