Skip to content

Commit

Permalink
Fix LocalTranslogTests.testWithRandomException test scenario (opensea…
Browse files Browse the repository at this point in the history
…rch-project#6748)

* fix opensearch-project#6625

Signed-off-by: Valentin Mitrofanov <mitrofmep@gmail.com>

* fix opensearch-project#6625 - reverse assertEquals params

Signed-off-by: Valentin Mitrofanov <mitrofmep@gmail.com>

---------

Signed-off-by: Valentin Mitrofanov <mitrofmep@gmail.com>
  • Loading branch information
mitrofmep authored and austintlee committed Apr 28, 2023
1 parent f6e560f commit 6bbec8f
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2904,7 +2904,9 @@ ChannelFactory getChannelFactory() {
void deleteReaderFiles(TranslogReader reader) {
if (fail.fail()) {
// simulate going OOM and dying just at the wrong moment.
throw new RuntimeException("simulated");
RuntimeException e = new RuntimeException("simulated");
tragedy.setTragicException(e);
throw e;
} else {
super.deleteReaderFiles(reader);
}
Expand Down Expand Up @@ -3226,13 +3228,13 @@ public void testWithRandomException() throws IOException {
syncedDocs.addAll(unsynced);
unsynced.clear();
} catch (TranslogException | MockDirectoryWrapper.FakeIOException ex) {
assertEquals(failableTLog.getTragicException(), ex);
assertEquals(ex, failableTLog.getTragicException());
} catch (IOException ex) {
assertEquals(ex.getMessage(), "__FAKE__ no space left on device");
assertEquals(failableTLog.getTragicException(), ex);
assertEquals(ex, failableTLog.getTragicException());
} catch (RuntimeException ex) {
assertEquals(ex.getMessage(), "simulated");
assertEquals(failableTLog.getTragicException(), ex);
assertEquals(ex, failableTLog.getTragicException());
} finally {
Checkpoint checkpoint = Translog.readCheckpoint(config.getTranslogPath());
if (checkpoint.numOps == unsynced.size() + syncedDocs.size()) {
Expand Down

0 comments on commit 6bbec8f

Please sign in to comment.