Skip to content

Commit 3481a1a

Browse files
committed
Detect multi-project in REST tests
This PR makes ESRestTestCase to detect whether multi-project is enabled and issue requests accordingly.
1 parent 7560e2e commit 3481a1a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ public static boolean hasXPack() {
258258
*/
259259
private static RestClient cleanupClient;
260260

261+
private static boolean multiProjectEnabled;
262+
261263
public enum ProductFeature {
262264
XPACK,
263265
ILM,
@@ -397,6 +399,9 @@ public void initClient() throws IOException {
397399
if (moduleName.startsWith("serverless-")) {
398400
serverless = true;
399401
}
402+
if (moduleName.contains("multi-project")) {
403+
multiProjectEnabled = true;
404+
}
400405
}
401406
if (serverless) {
402407
availableFeatures.removeAll(
@@ -1269,6 +1274,9 @@ protected void wipeSearchableSnapshotsIndices() throws IOException {
12691274
// retrieves all indices with a type of store equals to "snapshot"
12701275
final Request request = new Request("GET", "_cluster/state/metadata");
12711276
request.addParameter("filter_path", "metadata.indices.*.settings.index.store.snapshot");
1277+
if (multiProjectEnabled) {
1278+
request.addParameter("multi_project", "true");
1279+
}
12721280

12731281
final Response response = cleanupClient().performRequest(request);
12741282
@SuppressWarnings("unchecked")
@@ -1838,7 +1846,11 @@ public static void ensureHealth(RestClient restClient, String index, Consumer<Re
18381846
} catch (ResponseException e) {
18391847
if (e.getResponse().getStatusLine().getStatusCode() == HttpStatus.SC_REQUEST_TIMEOUT) {
18401848
try {
1841-
final Response clusterStateResponse = restClient.performRequest(new Request("GET", "/_cluster/state?pretty"));
1849+
final Request clusterStateRequest = new Request("GET", "/_cluster/state?pretty");
1850+
if (multiProjectEnabled) {
1851+
clusterStateRequest.addParameter("multi_project", "true");
1852+
}
1853+
final Response clusterStateResponse = restClient.performRequest(clusterStateRequest);
18421854
fail(
18431855
"timed out waiting for green state for index ["
18441856
+ index
@@ -2376,6 +2388,9 @@ public void ensurePeerRecoveryRetentionLeasesRenewedAndSynced(String index) thro
23762388
protected static Map<String, Set<String>> getClusterStateFeatures(RestClient adminClient) throws IOException {
23772389
final Request request = new Request("GET", "_cluster/state");
23782390
request.addParameter("filter_path", "nodes_features");
2391+
if (multiProjectEnabled) {
2392+
request.addParameter("multi_project", "true");
2393+
}
23792394

23802395
final Response response = adminClient.performRequest(request);
23812396

0 commit comments

Comments
 (0)