adapt testWaitForPendingSeqNo to stricter operation recovery range
Before we use to ship anything in the translog above a certain point. changed to have a strict upper bound.
@@ -58,10 +58,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
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 {
@@ -390,7 +392,8 @@ public class RecoveryDuringReplicationTests extends ESIndexLevelReplicationTestC
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());
@@ -401,7 +404,9 @@ public class RecoveryDuringReplicationTests extends ESIndexLevelReplicationTestC
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 {
