Skip to content

Commit

Permalink
Fix testSeqNoCollision (#52588)
Browse files Browse the repository at this point in the history
Adjusts the assertion as we trim translog more eagerly since #52556.

Relates #52556
Closes #52148
  • Loading branch information
dnhatn committed Feb 20, 2020
1 parent f05b831 commit d46d931
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit d46d931

Please sign in to comment.