From d9bbb89b2611c8edcba7c81bde67578241af6136 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Wed, 12 Sep 2018 08:24:11 -0400 Subject: [PATCH] TEST: Adjust rollback condition when shard is empty If a shard is empty, it won't rollback its engine on promotion. This commit adjusts the expectation in the rollback test. Relates #33473 --- .../java/org/elasticsearch/index/shard/IndexShardTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java index d6b80a6f6d7a3..0c5d9b1613f32 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java @@ -963,7 +963,8 @@ public void testRollbackReplicaEngineOnPromotion() throws IOException, Interrupt Set docsBelowGlobalCheckpoint = getShardDocUIDs(indexShard).stream() .filter(id -> Long.parseLong(id) <= Math.max(globalCheckpointOnReplica, globalCheckpoint)).collect(Collectors.toSet()); final CountDownLatch latch = new CountDownLatch(1); - final boolean shouldRollback = Math.max(globalCheckpoint, globalCheckpointOnReplica) < indexShard.seqNoStats().getMaxSeqNo(); + final boolean shouldRollback = Math.max(globalCheckpoint, globalCheckpointOnReplica) < indexShard.seqNoStats().getMaxSeqNo() + && indexShard.seqNoStats().getMaxSeqNo() != SequenceNumbers.NO_OPS_PERFORMED; final Engine beforeRollbackEngine = indexShard.getEngine(); indexShard.acquireReplicaOperationPermit( indexShard.pendingPrimaryTerm + 1,