Skip to content

Commit

Permalink
adapt testWaitForPendingSeqNo to stricter operation recovery range
Browse files Browse the repository at this point in the history
Before we use to ship anything in the translog above a certain point. #27580 changed to have a strict upper bound.
  • Loading branch information
bleskes committed Dec 3, 2017
1 parent eb50d22 commit 736703a
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@
import java.util.concurrent.atomic.AtomicReference;

import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.both;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.hamcrest.Matchers.not;

public class RecoveryDuringReplicationTests extends ESIndexLevelReplicationTestCase {
Expand Down Expand Up @@ -390,7 +392,8 @@ public long indexTranslogOperations(List<Translog.Operation> operations, int tot
recoveryStart.await();

// index some more
docs += shards.indexDocs(randomInt(5));
final int indexedDuringRecovery = shards.indexDocs(randomInt(5));
docs += indexedDuringRecovery;

assertFalse("recovery should wait on pending docs", opsSent.get());

Expand All @@ -401,7 +404,9 @@ public long indexTranslogOperations(List<Translog.Operation> operations, int tot
recoveryFuture.get();

assertThat(newReplica.recoveryState().getIndex().fileDetails(), empty());
assertThat(newReplica.recoveryState().getTranslog().recoveredOperations(), equalTo(docs));
assertThat(newReplica.recoveryState().getTranslog().recoveredOperations(),
// we don't know which of the inflight operations made it into the translog range we re-play
both(greaterThanOrEqualTo(docs-indexedDuringRecovery)).and(lessThanOrEqualTo(docs)));

shards.assertAllEqual(docs);
} finally {
Expand Down

0 comments on commit 736703a

Please sign in to comment.