diff --git a/server/src/test/java/org/opensearch/index/translog/LocalTranslogTests.java b/server/src/test/java/org/opensearch/index/translog/LocalTranslogTests.java index 6c1741d68cb05..9443417d80885 100644 --- a/server/src/test/java/org/opensearch/index/translog/LocalTranslogTests.java +++ b/server/src/test/java/org/opensearch/index/translog/LocalTranslogTests.java @@ -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); } @@ -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()) {