From c72fc5528305fa7eb81b163e523e52272813a16c Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Sat, 22 Jul 2017 08:46:21 +0200 Subject: [PATCH] adapt testDoubleDeliveryReplicaAppendingOnly to #25827 --- .../index/engine/InternalEngineTests.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index b659f7dbae2..ef8d71968de 100644 --- a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -3177,16 +3177,19 @@ public class InternalEngineTests extends ESTestCase { public void testDoubleDeliveryReplicaAppendingOnly() throws IOException { final ParsedDocument doc = testParsedDocument("1", null, testDocumentWithTextField(), new BytesArray("{}".getBytes(Charset.defaultCharset())), null); - Engine.Index operation = appendOnlyReplica(doc, false, 1, randomIntBetween(0, 20)); - Engine.Index retry = appendOnlyReplica(doc, true, 1, operation.seqNo()); + Engine.Index operation = appendOnlyReplica(doc, false, 1, randomIntBetween(0, 5)); + Engine.Index retry = appendOnlyReplica(doc, true, 1, randomIntBetween(0, 5)); + // operations with a seq# equal or lower to the local checkpoint are not indexed to lucene + // and the version lookup is skipped + final boolean belowLckp = operation.seqNo() == 0 && retry.seqNo() == 0; if (randomBoolean()) { Engine.IndexResult indexResult = engine.index(operation); assertFalse(engine.indexWriterHasDeletions()); assertEquals(0, engine.getNumVersionLookups()); assertNotNull(indexResult.getTranslogLocation()); Engine.IndexResult retryResult = engine.index(retry); - assertFalse(engine.indexWriterHasDeletions()); - assertEquals(1, engine.getNumVersionLookups()); + assertEquals(retry.seqNo() > operation.seqNo(), engine.indexWriterHasDeletions()); + assertEquals(belowLckp ? 0 : 1, engine.getNumVersionLookups()); assertNotNull(retryResult.getTranslogLocation()); assertTrue(retryResult.getTranslogLocation().compareTo(indexResult.getTranslogLocation()) > 0); } else { @@ -3195,8 +3198,8 @@ public class InternalEngineTests extends ESTestCase { assertEquals(1, engine.getNumVersionLookups()); assertNotNull(retryResult.getTranslogLocation()); Engine.IndexResult indexResult = engine.index(operation); - assertFalse(engine.indexWriterHasDeletions()); - assertEquals(2, engine.getNumVersionLookups()); + assertEquals(operation.seqNo() > retry.seqNo(), engine.indexWriterHasDeletions()); + assertEquals(belowLckp ? 1 : 2, engine.getNumVersionLookups()); assertNotNull(retryResult.getTranslogLocation()); assertTrue(retryResult.getTranslogLocation().compareTo(indexResult.getTranslogLocation()) < 0); }