|
52 | 52 | import org.elasticsearch.common.xcontent.json.JsonXContent; |
53 | 53 | import org.elasticsearch.common.xcontent.support.XContentMapValues; |
54 | 54 | import org.elasticsearch.core.internal.io.IOUtils; |
| 55 | +import org.elasticsearch.index.seqno.ReplicationTracker; |
55 | 56 | import org.elasticsearch.rest.RestStatus; |
56 | 57 | import org.elasticsearch.snapshots.SnapshotState; |
57 | 58 | import org.elasticsearch.test.ESTestCase; |
|
87 | 88 | import java.util.concurrent.atomic.AtomicReference; |
88 | 89 | import java.util.function.Consumer; |
89 | 90 | import java.util.function.Predicate; |
| 91 | +import java.util.stream.Collectors; |
90 | 92 |
|
91 | 93 | import static java.util.Collections.sort; |
92 | 94 | import static java.util.Collections.unmodifiableList; |
93 | 95 | import static org.hamcrest.Matchers.anEmptyMap; |
94 | 96 | import static org.hamcrest.Matchers.anyOf; |
95 | 97 | import static org.hamcrest.Matchers.equalTo; |
| 98 | +import static org.hamcrest.Matchers.everyItem; |
| 99 | +import static org.hamcrest.Matchers.in; |
96 | 100 |
|
97 | 101 | /** |
98 | 102 | * Superclass for tests that interact with an external test cluster using Elasticsearch's {@link RestClient}. |
@@ -1148,6 +1152,15 @@ public void ensurePeerRecoveryRetentionLeasesRenewedAndSynced(String index, bool |
1148 | 1152 | assertThat(retentionLease.get("retaining_seq_no"), equalTo(globalCheckpoint + 1)); |
1149 | 1153 | } |
1150 | 1154 | } |
| 1155 | + if (alwaysExists) { |
| 1156 | + List<String> existingLeaseIds = retentionLeases.stream().map(lease -> (String) lease.get("id")) |
| 1157 | + .collect(Collectors.toList()); |
| 1158 | + List<String> expectedLeaseIds = shard.stream() |
| 1159 | + .map(shr -> (String) XContentMapValues.extractValue("routing.node", shr)) |
| 1160 | + .map(ReplicationTracker::getPeerRecoveryRetentionLeaseId) |
| 1161 | + .collect(Collectors.toList()); |
| 1162 | + assertThat("not every active copy has established its PPRL", expectedLeaseIds, everyItem(in(existingLeaseIds))); |
| 1163 | + } |
1151 | 1164 | } |
1152 | 1165 | } |
1153 | 1166 | }, 60, TimeUnit.SECONDS); |
|
0 commit comments