Fix testPrepareIndexForPeerRecovery (#52245)

Since #51905, we skip translog recovery if the local checkpoint of the
safe commit equals to the global checkpoint. This change adjusts the
test not to create a new snapshot in that case.

Closes #52221
Relates #51905
This commit is contained in:
Nhat Nguyen 2020-02-12 11:08:48 -05:00
parent 82ab1bc1ff
commit d7fe135d90
1 changed files with 7 additions and 5 deletions

View File

@ -177,11 +177,13 @@ public class PeerRecoveryTargetServiceTests extends IndexShardTestCase {
Optional<SequenceNumbers.CommitInfo> safeCommit = shard.store().findSafeIndexCommit(globalCheckpoint);
assertTrue(safeCommit.isPresent());
int expectedTotalLocal = 0;
try (Translog.Snapshot snapshot = getTranslog(shard).newSnapshot(safeCommit.get().localCheckpoint + 1, globalCheckpoint)) {
Translog.Operation op;
while ((op = snapshot.next()) != null) {
if (op.seqNo() <= globalCheckpoint) {
expectedTotalLocal++;
if (safeCommit.get().localCheckpoint < globalCheckpoint) {
try (Translog.Snapshot snapshot = getTranslog(shard).newSnapshot(safeCommit.get().localCheckpoint + 1, globalCheckpoint)) {
Translog.Operation op;
while ((op = snapshot.next()) != null) {
if (op.seqNo() <= globalCheckpoint) {
expectedTotalLocal++;
}
}
}
}