Skip to content

Commit

Permalink
make sure every copy has established PRRL
Browse files Browse the repository at this point in the history
  • Loading branch information
dnhatn committed Dec 19, 2019
1 parent 36d2dd9 commit 6071abd
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.core.internal.io.IOUtils;
import org.elasticsearch.index.seqno.ReplicationTracker;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.snapshots.SnapshotState;
import org.elasticsearch.test.ESTestCase;
Expand Down Expand Up @@ -87,12 +88,15 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import static java.util.Collections.sort;
import static java.util.Collections.unmodifiableList;
import static org.hamcrest.Matchers.anEmptyMap;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.everyItem;
import static org.hamcrest.Matchers.in;

/**
* Superclass for tests that interact with an external test cluster using Elasticsearch's {@link RestClient}.
Expand Down Expand Up @@ -1148,6 +1152,15 @@ public void ensurePeerRecoveryRetentionLeasesRenewedAndSynced(String index, bool
assertThat(retentionLease.get("retaining_seq_no"), equalTo(globalCheckpoint + 1));
}
}
if (alwaysExists) {
List<String> existingLeaseIds = retentionLeases.stream().map(lease -> (String) lease.get("id"))
.collect(Collectors.toList());
List<String> expectedLeaseIds = shard.stream()
.map(shr -> (String) XContentMapValues.extractValue("routing.node", shr))
.map(ReplicationTracker::getPeerRecoveryRetentionLeaseId)
.collect(Collectors.toList());
assertThat("not every active copy has established its PPRL", expectedLeaseIds, everyItem(in(existingLeaseIds)));
}
}
}
}, 60, TimeUnit.SECONDS);
Expand Down

0 comments on commit 6071abd

Please sign in to comment.