Skip to content

Commit 2900e3f

Browse files
committed
adapt testWaitForPendingSeqNo to stricter operation recovery range
Before we use to ship anything in the translog above a certain point. #27580 changed to have a strict upper bound.
1 parent f58a3d0 commit 2900e3f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

core/src/test/java/org/elasticsearch/index/replication/RecoveryDuringReplicationTests.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@
5858
import java.util.concurrent.atomic.AtomicReference;
5959

6060
import static org.hamcrest.Matchers.anyOf;
61+
import static org.hamcrest.Matchers.both;
6162
import static org.hamcrest.Matchers.empty;
6263
import static org.hamcrest.Matchers.equalTo;
6364
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
6465
import static org.hamcrest.Matchers.lessThan;
66+
import static org.hamcrest.Matchers.lessThanOrEqualTo;
6567
import static org.hamcrest.Matchers.not;
6668

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

392394
// index some more
393-
docs += shards.indexDocs(randomInt(5));
395+
final int indexedDuringRecovery = shards.indexDocs(randomInt(5));
396+
docs += indexedDuringRecovery;
394397

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

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

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

406411
shards.assertAllEqual(docs);
407412
} finally {

0 commit comments

Comments
 (0)