mirror of https://github.com/apache/lucene.git
don't allow random FNFE/NSFE from MDW for this test
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1580615 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
af26e13463
commit
f18af4252a
|
@ -524,6 +524,7 @@ public class TestIndexWriterDelete extends LuceneTestCase {
|
|||
}
|
||||
MockDirectoryWrapper dir = new MockDirectoryWrapper(random(), new RAMDirectory(startDir, newIOContext(random())));
|
||||
dir.setPreventDoubleWrite(false);
|
||||
dir.setAllowRandomFileNotFoundException(false);
|
||||
IndexWriter modifier = new IndexWriter(dir,
|
||||
newIndexWriterConfig(
|
||||
TEST_VERSION_CURRENT, new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false))
|
||||
|
|
|
@ -74,6 +74,7 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
|
|||
boolean preventDoubleWrite = true;
|
||||
boolean trackDiskUsage = false;
|
||||
boolean wrapLockFactory = true;
|
||||
boolean allowRandomFileNotFoundException = true;
|
||||
private Set<String> unSyncedFiles;
|
||||
private Set<String> createdFiles;
|
||||
private Set<String> openFilesForWrite = new HashSet<>();
|
||||
|
@ -137,7 +138,15 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
|
|||
public void setPreventDoubleWrite(boolean value) {
|
||||
preventDoubleWrite = value;
|
||||
}
|
||||
|
||||
|
||||
/** If set to true (the default), when we throw random
|
||||
* IOException on openInput or createOutput, we may
|
||||
* sometimes throw FileNotFoundException or
|
||||
* NoSuchFileException. */
|
||||
public void setAllowRandomFileNotFoundException(boolean value) {
|
||||
allowRandomFileNotFoundException = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum for controlling hard disk throttling.
|
||||
* Set via {@link MockDirectoryWrapper #setThrottling(Throttling)}
|
||||
|
@ -379,7 +388,7 @@ public class MockDirectoryWrapper extends BaseDirectoryWrapper {
|
|||
System.out.println(Thread.currentThread().getName() + ": MockDirectoryWrapper: now throw random exception during open file=" + name);
|
||||
new Throwable().printStackTrace(System.out);
|
||||
}
|
||||
if (randomState.nextBoolean()) {
|
||||
if (allowRandomFileNotFoundException == false || randomState.nextBoolean()) {
|
||||
throw new IOException("a random IOException (" + name + ")");
|
||||
} else {
|
||||
throw randomState.nextBoolean() ? new FileNotFoundException("a random IOException (" + name + ")") : new NoSuchFileException("a random IOException (" + name + ")");
|
||||
|
|
Loading…
Reference in New Issue