Skip to content

Commit

Permalink
Fix flaky test testFlushThrowsFlushFailedExceptionOnCorruption. (#10671)
Browse files Browse the repository at this point in the history
This test is flaky in two ways, one it may hit a case where a merge occurs and the hardcoded segment does not exist to delete.
Two with certain mock filesystems a corruption exception won't be thrown here, only a NoSuchFile - This doesn't change our
handling in the engine, but the test should conditionally handle if the store is marked corrupted on close.

Signed-off-by: Marc Handalian <[email protected]>
  • Loading branch information
mch2 authored Oct 17, 2023
1 parent a36ab39 commit 8b04521
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,18 @@ public void testFlushThrowsFlushFailedExceptionOnCorruption() throws Exception {
indexOperations(nrtEngine, operations);
// wipe the nrt directory initially so we can sync with primary.
cleanAndCopySegmentsFromPrimary(nrtEngine);
nrtEngineStore.directory().deleteFile("_0.si");
final Optional<String> toDelete = Set.of(nrtEngineStore.directory().listAll()).stream().filter(f -> f.endsWith(".si")).findAny();
assertTrue(toDelete.isPresent());
nrtEngineStore.directory().deleteFile(toDelete.get());
assertThrows(FlushFailedEngineException.class, nrtEngine::flush);
assertTrue(nrtEngineStore.isMarkedCorrupted());
// store will throw when eventually closed, not handled here.
assertThrows(RuntimeException.class, nrtEngineStore::close);
nrtEngine.close();
if (nrtEngineStore.isMarkedCorrupted()) {
assertThrows(RuntimeException.class, nrtEngineStore::close);
} else {
// With certain mock directories a NoSuchFileException is thrown which is not treated as a
// corruption Exception. In these cases we don't expect any issue on store close.
nrtEngineStore.close();
}
}

private void copySegments(Collection<String> latestPrimaryFiles, Engine nrtEngine) throws IOException {
Expand Down

0 comments on commit 8b04521

Please sign in to comment.