Skip to content

Commit 6071abd

Browse files
committed
make sure every copy has established PRRL
1 parent 36d2dd9 commit 6071abd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.elasticsearch.common.xcontent.json.JsonXContent;
5353
import org.elasticsearch.common.xcontent.support.XContentMapValues;
5454
import org.elasticsearch.core.internal.io.IOUtils;
55+
import org.elasticsearch.index.seqno.ReplicationTracker;
5556
import org.elasticsearch.rest.RestStatus;
5657
import org.elasticsearch.snapshots.SnapshotState;
5758
import org.elasticsearch.test.ESTestCase;
@@ -87,12 +88,15 @@
8788
import java.util.concurrent.atomic.AtomicReference;
8889
import java.util.function.Consumer;
8990
import java.util.function.Predicate;
91+
import java.util.stream.Collectors;
9092

9193
import static java.util.Collections.sort;
9294
import static java.util.Collections.unmodifiableList;
9395
import static org.hamcrest.Matchers.anEmptyMap;
9496
import static org.hamcrest.Matchers.anyOf;
9597
import static org.hamcrest.Matchers.equalTo;
98+
import static org.hamcrest.Matchers.everyItem;
99+
import static org.hamcrest.Matchers.in;
96100

97101
/**
98102
* 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
11481152
assertThat(retentionLease.get("retaining_seq_no"), equalTo(globalCheckpoint + 1));
11491153
}
11501154
}
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+
}
11511164
}
11521165
}
11531166
}, 60, TimeUnit.SECONDS);

0 commit comments

Comments
 (0)