diff --git a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java index 5b586524d0bfc..ca7971f744e1d 100644 --- a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java @@ -1822,8 +1822,8 @@ public void testForceMergeWithSoftDeletesRetentionAndRecoverySource() throws Exc ) ) { int numDocs = scaledRandomIntBetween(10, 100); + boolean useRecoverySource = randomBoolean() || omitSourceAllTheTime; for (int i = 0; i < numDocs; i++) { - boolean useRecoverySource = randomBoolean() || omitSourceAllTheTime; ParsedDocument doc = testParsedDocument(Integer.toString(i), null, testDocument(), B_1, null, useRecoverySource); engine.index(indexForDoc(doc)); liveDocs.add(doc.id()); @@ -1832,14 +1832,14 @@ public void testForceMergeWithSoftDeletesRetentionAndRecoverySource() throws Exc } } for (int i = 0; i < numDocs; i++) { - boolean useRecoverySource = randomBoolean() || omitSourceAllTheTime; ParsedDocument doc = testParsedDocument(Integer.toString(i), null, testDocument(), B_1, null, useRecoverySource); - if (randomBoolean()) { + boolean isDeleted = randomBoolean(); + if (isDeleted) { engine.delete(new Engine.Delete(doc.id(), newUid(doc.id()), primaryTerm.get())); liveDocs.remove(doc.id()); liveDocsWithSource.remove(doc.id()); } - if (randomBoolean()) { + if (isDeleted) { engine.index(indexForDoc(doc)); liveDocs.add(doc.id()); if (useRecoverySource == false) { @@ -1896,7 +1896,6 @@ public void testForceMergeWithSoftDeletesRetentionAndRecoverySource() throws Exc numSegments = searcher.getDirectoryReader().leaves().size(); } if (numSegments == 1) { - boolean useRecoverySource = randomBoolean() || omitSourceAllTheTime; ParsedDocument doc = testParsedDocument("dummy", null, testDocument(), B_1, null, useRecoverySource); engine.index(indexForDoc(doc)); if (useRecoverySource == false) {