LUCENE-7690: also handle expected CorruptIndexException in this test

This commit is contained in:
Mike McCandless 2017-02-13 10:29:38 -05:00
parent 563f522643
commit f1c5cd5784
1 changed files with 19 additions and 22 deletions

View File

@ -40,6 +40,7 @@ import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.NumericUtils;
import org.apache.lucene.util.Rethrow;
import org.apache.lucene.util.StringHelper;
import org.apache.lucene.util.TestUtil;
@ -232,16 +233,7 @@ public abstract class BasePointsFormatTestCase extends BaseIndexFileFormatTestCa
dir.setRandomIOExceptionRateOnOpen(0.05);
verify(dir, docValues, null, numDims, numBytesPerDim, true);
} catch (IllegalStateException ise) {
if (ise.getMessage().contains("this writer hit an unrecoverable error")) {
Throwable cause = ise.getCause();
if (cause != null && cause.getMessage().contains("a random IOException")) {
done = true;
} else {
throw ise;
}
} else {
throw ise;
}
done = handlePossiblyFakeException(ise);
} catch (AssertionError ae) {
if (ae.getMessage() != null && ae.getMessage().contains("does not exist; files=")) {
// OK: likely we threw the random IOExc when IW was asserting the commit files exist
@ -253,21 +245,26 @@ public abstract class BasePointsFormatTestCase extends BaseIndexFileFormatTestCa
// This just means we got a too-small maxMB for the maxPointsInLeafNode; just retry w/ more heap
assertTrue(iae.getMessage().contains("either increase maxMBSortInHeap or decrease maxPointsInLeafNode"));
} catch (IOException ioe) {
Throwable ex = ioe;
done = handlePossiblyFakeException(ioe);
}
}
}
}
// TODO: merge w/ BaseIndexFileFormatTestCase.handleFakeIOException
private boolean handlePossiblyFakeException(Exception e) {
Throwable ex = e;
while (ex != null) {
String message = ex.getMessage();
if (message != null && (message.contains("a random IOException") || message.contains("background merge hit exception"))) {
done = true;
break;
return true;
}
ex = ex.getCause();
}
if (done == false) {
throw ioe;
}
}
}
}
Rethrow.rethrow(e);
// dead code yet javac disagrees:
return false;
}
public void testMultiValued() throws Exception {