From 618c6198c94998367d1d09e974d205ee3ee197d9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 20 Apr 2023 20:14:16 +0000 Subject: [PATCH] Fix LocalTranslogTests.testWithRandomException test scenario (#6748) * fix #6625 Signed-off-by: Valentin Mitrofanov * fix #6625 - reverse assertEquals params Signed-off-by: Valentin Mitrofanov --------- Signed-off-by: Valentin Mitrofanov (cherry picked from commit 4afc914f1dbb50df3fc7316b0bc1e808458f48e6) Signed-off-by: github-actions[bot] --- .../opensearch/index/translog/LocalTranslogTests.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 8eb70753e04c8..31c39f80d6d13 100644 --- a/server/src/test/java/org/opensearch/index/translog/LocalTranslogTests.java +++ b/server/src/test/java/org/opensearch/index/translog/LocalTranslogTests.java @@ -2908,7 +2908,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); } @@ -3230,13 +3232,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()) {