From 5376be6a18717db47caf5cf41475d50a7ef72286 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Thu, 20 Feb 2020 13:05:43 -0500 Subject: [PATCH] Fix testSeqNoCollision --- .../index/replication/IndexLevelReplicationTests.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/index/replication/IndexLevelReplicationTests.java b/server/src/test/java/org/elasticsearch/index/replication/IndexLevelReplicationTests.java index a2ecdf7809089..bdb2d114997c5 100644 --- a/server/src/test/java/org/elasticsearch/index/replication/IndexLevelReplicationTests.java +++ b/server/src/test/java/org/elasticsearch/index/replication/IndexLevelReplicationTests.java @@ -536,7 +536,6 @@ public void testRequestFailureReplication() throws Exception { } } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/52148") public void testSeqNoCollision() throws Exception { try (ReplicationGroup shards = createGroup(2)) { shards.startAll(); @@ -567,19 +566,15 @@ public void testSeqNoCollision() throws Exception { } logger.info("--> Promote replica1 as the primary"); shards.promoteReplicaToPrimary(replica1).get(); // wait until resync completed. - // We roll a new translog generation and trim operations that are above the global checkpoint during primary-replica resync. - // If the `initOperations` is empty, then the stale operation on the replica2 will be discarded as it is the only operation - // in a translog file. Otherwise, the stale op will be retained along with initOperations but will be skipped in snapshot. - int staleOps = initOperations.isEmpty() ? 0 : 1; shards.index(new IndexRequest(index.getName()).id("d2").source("{}", XContentType.JSON)); final Translog.Operation op2; try (Translog.Snapshot snapshot = getTranslog(replica2).newSnapshot()) { - assertThat(snapshot.totalOperations(), equalTo(initDocs + 1 + staleOps)); + assertThat(snapshot.totalOperations(), equalTo(1)); op2 = snapshot.next(); assertThat(op2.seqNo(), equalTo(op1.seqNo())); assertThat(op2.primaryTerm(), greaterThan(op1.primaryTerm())); - assertThat("Remaining of snapshot should contain init operations", snapshot, containsOperationsInAnyOrder(initOperations)); - assertThat(snapshot.skippedOperations(), equalTo(staleOps)); + assertNull(snapshot.next()); + assertThat(snapshot.skippedOperations(), equalTo(0)); } // Make sure that peer-recovery transfers all but non-overridden operations.