From 48b9faeb92c43e31bd70ff5de10b7fbeb53ae686 Mon Sep 17 00:00:00 2001 From: Niels Bauman <33722607+nielsbauman@users.noreply.github.com> Date: Fri, 10 Jan 2025 08:59:42 +1000 Subject: [PATCH] Fix trappy timeouts in `GetAliasesRequest` (#119817) Removes the use of the trappy default master node timeout and configures a sensible default instead. --- .../datastreams/DataStreamIT.java | 28 +-- .../datastreams/DataStreamsSnapshotsIT.java | 35 +++- .../ValidateIndicesAliasesRequestIT.java | 9 +- .../create/AutoCreateSystemIndexIT.java | 2 +- .../indices/create/CreateSystemIndicesIT.java | 6 +- .../admin/indices/rollover/RolloverIT.java | 2 +- .../elasticsearch/aliases/IndexAliasesIT.java | 89 ++++---- .../aliases/NetNewSystemIndexAliasIT.java | 2 +- .../aliases/SystemIndexAliasIT.java | 2 +- .../elasticsearch/index/HiddenIndexIT.java | 14 +- .../indices/IndicesOptionsIntegrationIT.java | 30 ++- .../template/SimpleIndexTemplateIT.java | 8 +- .../snapshots/RestoreSnapshotIT.java | 20 +- .../indices/alias/get/GetAliasesRequest.java | 11 - .../alias/get/GetAliasesRequestBuilder.java | 5 +- .../client/internal/IndicesAdminClient.java | 5 +- .../get/TransportGetAliasesActionTests.java | 24 +-- .../cluster/metadata/MetadataTests.java | 24 +-- .../elasticsearch/xpack/ccr/CcrAliasesIT.java | 11 +- .../xpack/ccr/IndexFollowingIT.java | 2 +- .../xpack/enrich/EnrichPolicyRunner.java | 2 +- .../EnrichPolicyMaintenanceServiceTests.java | 5 +- .../search/SearchApplicationIndexService.java | 6 - .../SearchApplicationIndexServiceTests.java | 6 +- .../MlInitializationServiceIT.java | 2 +- .../ml/integration/AnnotationIndexIT.java | 2 + .../xpack/ml/integration/IndexLayoutIT.java | 2 +- .../ml/integration/JobResultsProviderIT.java | 5 +- .../xpack/ml/MlInitializationService.java | 5 +- .../ml/job/persistence/JobDataDeleter.java | 7 +- .../xpack/ql/index/IndexResolver.java | 3 +- .../FrozenSearchableSnapshotsIntegTests.java | 8 +- .../SearchableSnapshotsIntegTests.java | 8 +- .../security/authz/IndexAliasesTests.java | 191 +++++++++++++----- .../authz/IndicesAndAliasesResolverTests.java | 60 +++--- .../AbstractWatcherIntegrationTestCase.java | 7 +- 36 files changed, 394 insertions(+), 254 deletions(-) diff --git a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java index 0e03045a090f8..dd0c93bfc6dfc 100644 --- a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java +++ b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java @@ -588,7 +588,11 @@ public void testResolvabilityOfDataStreamsInAPIs() throws Exception { verifyResolvability(dataStreamName, indicesAdmin().prepareForceMerge(dataStreamName), false); verifyResolvability(dataStreamName, indicesAdmin().prepareValidateQuery(dataStreamName), false); verifyResolvability(dataStreamName, indicesAdmin().prepareRecoveries(dataStreamName), false); - verifyResolvability(dataStreamName, indicesAdmin().prepareGetAliases("dummy").setIndices(dataStreamName), false); + verifyResolvability( + dataStreamName, + indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "dummy").setIndices(dataStreamName), + false + ); verifyResolvability(dataStreamName, indicesAdmin().prepareGetFieldMappings(dataStreamName), false); verifyResolvability(dataStreamName, indicesAdmin().preparePutMapping(dataStreamName).setSource(""" {"_doc":{"properties": {"my_field":{"type":"keyword"}}}}""", XContentType.JSON), false); @@ -635,7 +639,7 @@ public void testResolvabilityOfDataStreamsInAPIs() throws Exception { verifyResolvability(wildcardExpression, indicesAdmin().prepareForceMerge(wildcardExpression), false); verifyResolvability(wildcardExpression, indicesAdmin().prepareValidateQuery(wildcardExpression), false); verifyResolvability(wildcardExpression, indicesAdmin().prepareRecoveries(wildcardExpression), false); - verifyResolvability(wildcardExpression, indicesAdmin().prepareGetAliases(wildcardExpression), false); + verifyResolvability(wildcardExpression, indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, wildcardExpression), false); verifyResolvability(wildcardExpression, indicesAdmin().prepareGetFieldMappings(wildcardExpression), false); verifyResolvability(wildcardExpression, indicesAdmin().preparePutMapping(wildcardExpression).setSource(""" {"_doc":{"properties": {"my_field":{"type":"keyword"}}}}""", XContentType.JSON), false); @@ -738,7 +742,7 @@ public void testAliasActionsOnDataStreams() throws Exception { IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest(); aliasesAddRequest.addAliasAction(addAction); assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet()); - GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet(); + GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT)).actionGet(); assertThat( response.getDataStreamAliases(), equalTo(Map.of("metrics-foo", List.of(new DataStreamAlias("foo", List.of("metrics-foo"), null, null)))) @@ -764,7 +768,7 @@ public void testDataSteamAliasWithFilter() throws Exception { IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest(); aliasesAddRequest.addAliasAction(addAction); assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet()); - GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet(); + GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT)).actionGet(); assertThat( response.getDataStreamAliases(), equalTo( @@ -794,7 +798,7 @@ public void testDataSteamAliasWithFilter() throws Exception { aliasesAddRequest = new IndicesAliasesRequest(); aliasesAddRequest.addAliasAction(addAction); assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet()); - response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet(); + response = indicesAdmin().getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT)).actionGet(); assertThat( response.getDataStreamAliases(), equalTo( @@ -840,7 +844,7 @@ public void testSearchFilteredAndUnfilteredAlias() throws Exception { aliasesAddRequest.addAliasAction(addFilteredAliasAction); aliasesAddRequest.addAliasAction(addUnfilteredAliasAction); assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet()); - GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet(); + GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT)).actionGet(); assertThat(response.getDataStreamAliases(), hasKey("logs-foobar")); assertThat( response.getDataStreamAliases().get("logs-foobar"), @@ -884,7 +888,7 @@ public void testRandomDataSteamAliasesUpdate() throws Exception { addAction = new AliasActions(AliasActions.Type.ADD).aliases(alias).indices(dataStreams[0]).filter(indexFilters).writeIndex(true); assertAcked(indicesAdmin().aliases(new IndicesAliasesRequest().addAliasAction(addAction)).actionGet()); - GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet(); + GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT)).actionGet(); assertThat(response.getDataStreamAliases().size(), equalTo(dataStreams.length)); List result = response.getDataStreamAliases() .values() @@ -933,7 +937,7 @@ public void testDataSteamAliasWithMalformedFilter() throws Exception { indicesAdmin().aliases(new IndicesAliasesRequest().addAliasAction(addAction)) ); assertThat(e.getMessage(), equalTo("failed to parse filter for alias [" + alias + "]")); - GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet(); + GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT)).actionGet(); assertThat(response.getDataStreamAliases(), anEmptyMap()); } @@ -998,7 +1002,7 @@ public void testRemoveDataStreamAliasesMixedExpression() throws Exception { aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("metrics-foo").aliases("my-alias1")); aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.ADD).index("metrics-myindex").aliases("my-alias2")); assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet()); - GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet(); + GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT)).actionGet(); assertThat( response.getDataStreamAliases(), equalTo(Map.of("metrics-foo", List.of(new DataStreamAlias("my-alias1", List.of("metrics-foo"), null, null)))) @@ -1013,7 +1017,7 @@ public void testRemoveDataStreamAliasesMixedExpression() throws Exception { aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.REMOVE).index("_all").aliases("my-*")); } assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet()); - response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet(); + response = indicesAdmin().getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT)).actionGet(); assertThat(response.getDataStreamAliases(), anEmptyMap()); assertThat(response.getAliases().get("metrics-myindex").size(), equalTo(0)); assertThat(response.getAliases().size(), equalTo(1)); @@ -1034,7 +1038,7 @@ public void testUpdateDataStreamsWithWildcards() throws Exception { new AliasActions(AliasActions.Type.ADD).index("metrics-foo").aliases("my-alias1", "my-alias2") ); assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet()); - GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet(); + GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT)).actionGet(); assertThat(response.getDataStreamAliases().keySet(), containsInAnyOrder("metrics-foo")); assertThat( response.getDataStreamAliases().get("metrics-foo"), @@ -1060,7 +1064,7 @@ public void testUpdateDataStreamsWithWildcards() throws Exception { aliasesAddRequest.addAliasAction(new AliasActions(AliasActions.Type.REMOVE).index("_all").aliases("_all")); } assertAcked(indicesAdmin().aliases(aliasesAddRequest).actionGet()); - GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest()).actionGet(); + GetAliasesResponse response = indicesAdmin().getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT)).actionGet(); assertThat(response.getDataStreamAliases(), anEmptyMap()); assertThat(response.getAliases().size(), equalTo(0)); } diff --git a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java index ac828630b0463..f6c703b96888c 100644 --- a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java +++ b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java @@ -213,7 +213,10 @@ public void testSnapshotAndRestore() throws Exception { assertEquals(1, ds.get(0).getDataStream().getIndices().size()); assertEquals(dsBackingIndexName, ds.get(0).getDataStream().getIndices().get(0).getName()); - GetAliasesResponse getAliasesResponse = client.admin().indices().getAliases(new GetAliasesRequest("my-alias")).actionGet(); + GetAliasesResponse getAliasesResponse = client.admin() + .indices() + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "my-alias")) + .actionGet(); assertThat(getAliasesResponse.getDataStreamAliases().keySet(), containsInAnyOrder("ds", "other-ds")); assertThat(getAliasesResponse.getDataStreamAliases().get("ds").size(), equalTo(1)); assertThat(getAliasesResponse.getDataStreamAliases().get("ds").get(0).getName(), equalTo("my-alias")); @@ -462,7 +465,10 @@ public void testSnapshotAndRestoreAllIncludeSpecificDataStream() throws Exceptio assertEquals(1, dataStreamInfos.get(0).getDataStream().getIndices().size()); assertEquals(backingIndexName, dataStreamInfos.get(0).getDataStream().getIndices().get(0).getName()); - GetAliasesResponse getAliasesResponse = client.admin().indices().getAliases(new GetAliasesRequest("my-alias")).actionGet(); + GetAliasesResponse getAliasesResponse = client.admin() + .indices() + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "my-alias")) + .actionGet(); assertThat(getAliasesResponse.getDataStreamAliases().keySet(), contains(dataStreamToSnapshot)); assertThat( getAliasesResponse.getDataStreamAliases().get(dataStreamToSnapshot), @@ -520,7 +526,10 @@ public void testSnapshotAndRestoreReplaceAll() throws Exception { containsInAnyOrder("ds", "other-ds", "with-fs") ); - GetAliasesResponse getAliasesResponse = client.admin().indices().getAliases(new GetAliasesRequest("my-alias")).actionGet(); + GetAliasesResponse getAliasesResponse = client.admin() + .indices() + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "my-alias")) + .actionGet(); assertThat(getAliasesResponse.getDataStreamAliases().keySet(), containsInAnyOrder("ds", "other-ds")); assertThat(getAliasesResponse.getDataStreamAliases().get("ds").size(), equalTo(1)); assertThat(getAliasesResponse.getDataStreamAliases().get("ds").get(0).getName(), equalTo("my-alias")); @@ -581,7 +590,10 @@ public void testSnapshotAndRestoreAll() throws Exception { assertEquals(1, dataStreamInfos.get(2).getDataStream().getFailureIndices().getIndices().size()); assertEquals(fsFailureIndexName, dataStreamInfos.get(2).getDataStream().getFailureIndices().getIndices().get(0).getName()); - GetAliasesResponse getAliasesResponse = client.admin().indices().getAliases(new GetAliasesRequest("my-alias")).actionGet(); + GetAliasesResponse getAliasesResponse = client.admin() + .indices() + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "my-alias")) + .actionGet(); assertThat(getAliasesResponse.getDataStreamAliases().keySet(), containsInAnyOrder("ds", "other-ds")); assertThat(getAliasesResponse.getDataStreamAliases().get("ds").size(), equalTo(1)); @@ -649,7 +661,10 @@ public void testSnapshotAndRestoreIncludeAliasesFalse() throws Exception { assertEquals(1, dataStreamInfos.get(2).getDataStream().getIndices().size()); assertEquals(fsFailureIndexName, dataStreamInfos.get(2).getDataStream().getFailureIndices().getIndices().get(0).getName()); - GetAliasesResponse getAliasesResponse = client.admin().indices().getAliases(new GetAliasesRequest("*")).actionGet(); + GetAliasesResponse getAliasesResponse = client.admin() + .indices() + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "*")) + .actionGet(); assertThat(getAliasesResponse.getDataStreamAliases(), anEmptyMap()); assertAcked( client().execute( @@ -699,7 +714,10 @@ public void testRename() throws Exception { ); assertEquals(DOCUMENT_SOURCE, client.prepareGet(ds2BackingIndexName, id).get().getSourceAsMap()); - GetAliasesResponse getAliasesResponse = client.admin().indices().getAliases(new GetAliasesRequest("my-alias")).actionGet(); + GetAliasesResponse getAliasesResponse = client.admin() + .indices() + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "my-alias")) + .actionGet(); assertThat(getAliasesResponse.getDataStreamAliases().keySet(), containsInAnyOrder("ds", "ds2", "other-ds")); assertThat(getAliasesResponse.getDataStreamAliases().get("ds2").size(), equalTo(1)); assertThat(getAliasesResponse.getDataStreamAliases().get("ds2").get(0).getName(), equalTo("my-alias")); @@ -749,7 +767,10 @@ public void testRenameWriteDataStream() throws Exception { assertEquals(1, dataStreamInfos.get(0).getDataStream().getIndices().size()); assertEquals(otherDs2BackingIndexName, dataStreamInfos.get(0).getDataStream().getIndices().get(0).getName()); - GetAliasesResponse getAliasesResponse = client.admin().indices().getAliases(new GetAliasesRequest("my-alias")).actionGet(); + GetAliasesResponse getAliasesResponse = client.admin() + .indices() + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "my-alias")) + .actionGet(); assertThat(getAliasesResponse.getDataStreamAliases().keySet(), containsInAnyOrder("ds", "other-ds", "other-ds2")); assertThat(getAliasesResponse.getDataStreamAliases().get("other-ds2").size(), equalTo(1)); assertThat(getAliasesResponse.getDataStreamAliases().get("other-ds2").get(0).getName(), equalTo("my-alias")); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/alias/ValidateIndicesAliasesRequestIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/alias/ValidateIndicesAliasesRequestIT.java index 5a49322666768..b742661a32c1a 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/alias/ValidateIndicesAliasesRequestIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/alias/ValidateIndicesAliasesRequestIT.java @@ -81,7 +81,10 @@ public void testAllowed() { final IndicesAliasesRequest request = new IndicesAliasesRequest().origin("allowed"); request.addAliasAction(IndicesAliasesRequest.AliasActions.add().index("index").alias("alias")); assertAcked(client().admin().indices().aliases(request).actionGet()); - final GetAliasesResponse response = client().admin().indices().getAliases(new GetAliasesRequest("alias")).actionGet(); + final GetAliasesResponse response = client().admin() + .indices() + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "alias")) + .actionGet(); assertThat(response.getAliases().keySet().size(), equalTo(1)); assertThat(response.getAliases().keySet().iterator().next(), equalTo("index")); final List aliasMetadata = response.getAliases().get("index"); @@ -117,6 +120,8 @@ public void testSomeAllowed() { final Exception e = expectThrows(IllegalStateException.class, client().admin().indices().aliases(request)); final String index = "foo_allowed".equals(origin) ? "bar" : "foo"; assertThat(e, hasToString(containsString("origin [" + origin + "] not allowed for index [" + index + "]"))); - assertTrue(client().admin().indices().getAliases(new GetAliasesRequest("alias")).actionGet().getAliases().isEmpty()); + assertTrue( + client().admin().indices().getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "alias")).actionGet().getAliases().isEmpty() + ); } } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/AutoCreateSystemIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/AutoCreateSystemIndexIT.java index b10e17b3f4e0f..ea7cec710e31e 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/AutoCreateSystemIndexIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/AutoCreateSystemIndexIT.java @@ -273,7 +273,7 @@ public void testAutoCreateSystemAliasViaComposableTemplateAllowsTemplates() thro private void assertAliasesHidden(String nonPrimaryIndex, Set aliasNames, int aliasCount) throws InterruptedException, ExecutionException { final GetAliasesResponse getAliasesResponse = indicesAdmin().getAliases( - new GetAliasesRequest().indicesOptions(IndicesOptions.strictExpandHidden()) + new GetAliasesRequest(TEST_REQUEST_TIMEOUT).indicesOptions(IndicesOptions.strictExpandHidden()) ).get(); assertThat(getAliasesResponse.getAliases().size(), equalTo(1)); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateSystemIndicesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateSystemIndicesIT.java index 112ed994385ef..867ca89f9e7f3 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateSystemIndicesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateSystemIndicesIT.java @@ -115,7 +115,7 @@ public void testNonPrimarySystemIndexIsAutoCreatedViaConcreteName() throws Excep // Check that a non-primary system index is not assigned as the write index for the alias final GetAliasesResponse getAliasesResponse = indicesAdmin().getAliases( - new GetAliasesRequest().indicesOptions(IndicesOptions.strictExpandHidden()) + new GetAliasesRequest(TEST_REQUEST_TIMEOUT).indicesOptions(IndicesOptions.strictExpandHidden()) ).actionGet(); assertThat(getAliasesResponse.getAliases().size(), equalTo(1)); @@ -322,7 +322,7 @@ public void onFailure(Exception e) { */ private void assertAliases(String concreteIndex) { final GetAliasesResponse getAliasesResponse = indicesAdmin().getAliases( - new GetAliasesRequest().indicesOptions(IndicesOptions.strictExpandHidden()) + new GetAliasesRequest(TEST_REQUEST_TIMEOUT).indicesOptions(IndicesOptions.strictExpandHidden()) ).actionGet(); assertThat(getAliasesResponse.getAliases().size(), equalTo(1)); @@ -334,7 +334,7 @@ private void assertAliases(String concreteIndex) { private void assertHasAliases(Set aliasNames, String name, String primaryName, int aliasCount) throws InterruptedException, java.util.concurrent.ExecutionException { final GetAliasesResponse getAliasesResponse = indicesAdmin().getAliases( - new GetAliasesRequest().indicesOptions(IndicesOptions.strictExpandHidden()) + new GetAliasesRequest(TEST_REQUEST_TIMEOUT).indicesOptions(IndicesOptions.strictExpandHidden()) ).get(); assertThat(getAliasesResponse.getAliases().size(), equalTo(1)); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/rollover/RolloverIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/rollover/RolloverIT.java index 1dc5e24639c97..746f35992e721 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/rollover/RolloverIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/rollover/RolloverIT.java @@ -866,7 +866,7 @@ public void testRolloverConcurrently() throws Exception { for (int i = 0; i < numOfThreads; i++) { var aliasName = "test-" + i; - var response = indicesAdmin().getAliases(new GetAliasesRequest(aliasName)).get(); + var response = indicesAdmin().getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT, aliasName)).get(); List>> actual = response.getAliases().entrySet().stream().toList(); List>> expected = new ArrayList<>(numberOfRolloversPerThread); int numOfIndices = numberOfRolloversPerThread + 1; diff --git a/server/src/internalClusterTest/java/org/elasticsearch/aliases/IndexAliasesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/aliases/IndexAliasesIT.java index 5d2ae93d919b0..ad17d8dbaa4ad 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/aliases/IndexAliasesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/aliases/IndexAliasesIT.java @@ -611,7 +611,7 @@ public void testDeleteAliases() throws Exception { assertAliasesVersionIncreases(indices, () -> indicesAdmin().prepareAliases().removeAlias(indices, aliases).get()); for (String alias : aliases) { - assertTrue(indicesAdmin().prepareGetAliases(alias).get().getAliases().isEmpty()); + assertTrue(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, alias).get().getAliases().isEmpty()); } logger.info("--> creating index [foo_foo] and [bar_bar]"); @@ -627,9 +627,9 @@ public void testDeleteAliases() throws Exception { () -> assertAcked(indicesAdmin().prepareAliases().addAliasAction(AliasActions.remove().index("foo*").alias("foo"))) ); - assertFalse(indicesAdmin().prepareGetAliases("foo").get().getAliases().isEmpty()); - assertTrue(indicesAdmin().prepareGetAliases("foo").setIndices("foo_foo").get().getAliases().isEmpty()); - assertFalse(indicesAdmin().prepareGetAliases("foo").setIndices("bar_bar").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foo").get().getAliases().isEmpty()); + assertTrue(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foo").setIndices("foo_foo").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foo").setIndices("bar_bar").get().getAliases().isEmpty()); IllegalArgumentException iae = expectThrows( IllegalArgumentException.class, indicesAdmin().prepareAliases().addAliasAction(AliasActions.remove().index("foo").alias("foo")) @@ -783,7 +783,7 @@ public void testIndicesGetAliases() throws Exception { ); logger.info("--> getting alias1"); - GetAliasesResponse getResponse = indicesAdmin().prepareGetAliases("alias1").get(); + GetAliasesResponse getResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias1").get(); assertThat(getResponse, notNullValue()); assertThat(getResponse.getAliases().size(), equalTo(1)); assertThat(getResponse.getAliases().get("foobar").size(), equalTo(1)); @@ -792,10 +792,10 @@ public void testIndicesGetAliases() throws Exception { assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue()); - assertFalse(indicesAdmin().prepareGetAliases("alias1").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias1").get().getAliases().isEmpty()); logger.info("--> getting all aliases that start with alias*"); - getResponse = indicesAdmin().prepareGetAliases("alias*").get(); + getResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias*").get(); assertThat(getResponse, notNullValue()); assertThat(getResponse.getAliases().size(), equalTo(1)); assertThat(getResponse.getAliases().get("foobar").size(), equalTo(2)); @@ -809,7 +809,7 @@ public void testIndicesGetAliases() throws Exception { assertThat(getResponse.getAliases().get("foobar").get(1).getFilter(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(1).getIndexRouting(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(1).getSearchRouting(), nullValue()); - assertFalse(indicesAdmin().prepareGetAliases("alias*").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias*").get().getAliases().isEmpty()); logger.info("--> creating aliases [bar, baz, foo]"); assertAliasesVersionIncreases( @@ -830,7 +830,7 @@ public void testIndicesGetAliases() throws Exception { ); logger.info("--> getting bar and baz for index bazbar"); - getResponse = indicesAdmin().prepareGetAliases("bar", "bac").setIndices("bazbar").get(); + getResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "bar", "bac").setIndices("bazbar").get(); assertThat(getResponse, notNullValue()); assertThat(getResponse.getAliases().size(), equalTo(1)); assertThat(getResponse.getAliases().get("bazbar").size(), equalTo(2)); @@ -846,13 +846,13 @@ public void testIndicesGetAliases() throws Exception { assertThat(getResponse.getAliases().get("bazbar").get(1).getFilter(), nullValue()); assertThat(getResponse.getAliases().get("bazbar").get(1).getIndexRouting(), nullValue()); assertThat(getResponse.getAliases().get("bazbar").get(1).getSearchRouting(), nullValue()); - assertFalse(indicesAdmin().prepareGetAliases("bar").get().getAliases().isEmpty()); - assertFalse(indicesAdmin().prepareGetAliases("bac").get().getAliases().isEmpty()); - assertFalse(indicesAdmin().prepareGetAliases("bar").setIndices("bazbar").get().getAliases().isEmpty()); - assertFalse(indicesAdmin().prepareGetAliases("bac").setIndices("bazbar").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "bar").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "bac").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "bar").setIndices("bazbar").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "bac").setIndices("bazbar").get().getAliases().isEmpty()); logger.info("--> getting *b* for index baz*"); - getResponse = indicesAdmin().prepareGetAliases("*b*").setIndices("baz*").get(); + getResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "*b*").setIndices("baz*").get(); assertThat(getResponse, notNullValue()); assertThat(getResponse.getAliases().size(), equalTo(1)); assertThat(getResponse.getAliases().get("bazbar").size(), equalTo(2)); @@ -868,10 +868,10 @@ public void testIndicesGetAliases() throws Exception { assertThat(getResponse.getAliases().get("bazbar").get(1).getFilter(), nullValue()); assertThat(getResponse.getAliases().get("bazbar").get(1).getIndexRouting(), nullValue()); assertThat(getResponse.getAliases().get("bazbar").get(1).getSearchRouting(), nullValue()); - assertFalse(indicesAdmin().prepareGetAliases("*b*").setIndices("baz*").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "*b*").setIndices("baz*").get().getAliases().isEmpty()); logger.info("--> getting *b* for index *bar"); - getResponse = indicesAdmin().prepareGetAliases("b*").setIndices("*bar").get(); + getResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "b*").setIndices("*bar").get(); assertThat(getResponse, notNullValue()); assertThat(getResponse.getAliases().size(), equalTo(2)); assertThat(getResponse.getAliases().get("bazbar").size(), equalTo(2)); @@ -892,10 +892,10 @@ public void testIndicesGetAliases() throws Exception { assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), equalTo("bla")); assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), equalTo("bla")); - assertFalse(indicesAdmin().prepareGetAliases("b*").setIndices("*bar").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "b*").setIndices("*bar").get().getAliases().isEmpty()); logger.info("--> getting f* for index *bar"); - getResponse = indicesAdmin().prepareGetAliases("f*").setIndices("*bar").get(); + getResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "f*").setIndices("*bar").get(); assertThat(getResponse, notNullValue()); assertThat(getResponse.getAliases().size(), equalTo(1)); assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue()); @@ -903,11 +903,11 @@ public void testIndicesGetAliases() throws Exception { assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue()); - assertFalse(indicesAdmin().prepareGetAliases("f*").setIndices("*bar").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "f*").setIndices("*bar").get().getAliases().isEmpty()); // alias at work logger.info("--> getting f* for index *bac"); - getResponse = indicesAdmin().prepareGetAliases("foo").setIndices("*bac").get(); + getResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foo").setIndices("*bac").get(); assertThat(getResponse, notNullValue()); assertThat(getResponse.getAliases().size(), equalTo(1)); assertThat(getResponse.getAliases().get("foobar").size(), equalTo(1)); @@ -916,10 +916,10 @@ public void testIndicesGetAliases() throws Exception { assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue()); - assertFalse(indicesAdmin().prepareGetAliases("foo").setIndices("*bac").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foo").setIndices("*bac").get().getAliases().isEmpty()); logger.info("--> getting foo for index foobar"); - getResponse = indicesAdmin().prepareGetAliases("foo").setIndices("foobar").get(); + getResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foo").setIndices("foobar").get(); assertThat(getResponse, notNullValue()); assertThat(getResponse.getAliases().size(), equalTo(1)); assertThat(getResponse.getAliases().get("foobar").get(0), notNullValue()); @@ -927,13 +927,13 @@ public void testIndicesGetAliases() throws Exception { assertThat(getResponse.getAliases().get("foobar").get(0).getFilter(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(0).getIndexRouting(), nullValue()); assertThat(getResponse.getAliases().get("foobar").get(0).getSearchRouting(), nullValue()); - assertFalse(indicesAdmin().prepareGetAliases("foo").setIndices("foobar").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foo").setIndices("foobar").get().getAliases().isEmpty()); for (String aliasName : new String[] { null, "_all", "*" }) { logger.info("--> getting {} alias for index foobar", aliasName); getResponse = aliasName != null - ? indicesAdmin().prepareGetAliases(aliasName).setIndices("foobar").get() - : indicesAdmin().prepareGetAliases().setIndices("foobar").get(); + ? indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, aliasName).setIndices("foobar").get() + : indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT).setIndices("foobar").get(); assertThat(getResponse, notNullValue()); assertThat(getResponse.getAliases().size(), equalTo(1)); assertThat(getResponse.getAliases().get("foobar").size(), equalTo(4)); @@ -945,20 +945,20 @@ public void testIndicesGetAliases() throws Exception { // alias at work again logger.info("--> getting * for index *bac"); - getResponse = indicesAdmin().prepareGetAliases("*").setIndices("*bac").get(); + getResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "*").setIndices("*bac").get(); assertThat(getResponse, notNullValue()); assertThat(getResponse.getAliases().size(), equalTo(2)); assertThat(getResponse.getAliases().get("foobar").size(), equalTo(4)); assertThat(getResponse.getAliases().get("bazbar").size(), equalTo(2)); - assertFalse(indicesAdmin().prepareGetAliases("*").setIndices("*bac").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "*").setIndices("*bac").get().getAliases().isEmpty()); assertAcked(indicesAdmin().prepareAliases().removeAlias("foobar", "foo")); - getResponse = indicesAdmin().prepareGetAliases("foo").setIndices("foobar").get(); + getResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foo").setIndices("foobar").get(); for (final Map.Entry> entry : getResponse.getAliases().entrySet()) { assertTrue(entry.getValue().isEmpty()); } - assertTrue(indicesAdmin().prepareGetAliases("foo").setIndices("foobar").get().getAliases().isEmpty()); + assertTrue(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foo").setIndices("foobar").get().getAliases().isEmpty()); } public void testGetAllAliasesWorks() { @@ -970,7 +970,7 @@ public void testGetAllAliasesWorks() { () -> assertAcked(indicesAdmin().prepareAliases().addAlias("index1", "alias1").addAlias("index2", "alias2")) ); - GetAliasesResponse response = indicesAdmin().prepareGetAliases().get(); + GetAliasesResponse response = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT).get(); assertThat(response.getAliases(), hasKey("index1")); assertThat(response.getAliases(), hasKey("index1")); } @@ -1114,8 +1114,11 @@ public void testAliasesWithBlocks() { () -> assertAcked(indicesAdmin().prepareAliases().addAlias("test", "alias1").addAlias("test", "alias2")) ); assertAliasesVersionIncreases("test", () -> assertAcked(indicesAdmin().prepareAliases().removeAlias("test", "alias1"))); - assertThat(indicesAdmin().prepareGetAliases("alias2").get().getAliases().get("test").size(), equalTo(1)); - assertFalse(indicesAdmin().prepareGetAliases("alias2").get().getAliases().isEmpty()); + assertThat( + indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias2").get().getAliases().get("test").size(), + equalTo(1) + ); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias2").get().getAliases().isEmpty()); } finally { disableIndexBlock("test", block); } @@ -1132,8 +1135,8 @@ public void testAliasesWithBlocks() { "test", () -> assertBlocked(indicesAdmin().prepareAliases().removeAlias("test", "alias2"), INDEX_READ_ONLY_BLOCK) ); - assertThat(indicesAdmin().prepareGetAliases("alias2").get().getAliases().get("test").size(), equalTo(1)); - assertFalse(indicesAdmin().prepareGetAliases("alias2").get().getAliases().isEmpty()); + assertThat(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias2").get().getAliases().get("test").size(), equalTo(1)); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias2").get().getAliases().isEmpty()); } finally { disableIndexBlock("test", SETTING_READ_ONLY); @@ -1150,8 +1153,8 @@ public void testAliasesWithBlocks() { "test", () -> assertBlocked(indicesAdmin().prepareAliases().removeAlias("test", "alias2"), INDEX_METADATA_BLOCK) ); - assertBlocked(indicesAdmin().prepareGetAliases("alias2"), INDEX_METADATA_BLOCK); - assertBlocked(indicesAdmin().prepareGetAliases("alias2"), INDEX_METADATA_BLOCK); + assertBlocked(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias2"), INDEX_METADATA_BLOCK); + assertBlocked(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias2"), INDEX_METADATA_BLOCK); } finally { disableIndexBlock("test", SETTING_BLOCKS_METADATA); @@ -1176,12 +1179,12 @@ public void testAliasActionRemoveIndex() { assertAcked(indicesAdmin().prepareAliases().removeIndex("foo*")); assertFalse(indexExists("foo_foo")); - assertFalse(indicesAdmin().prepareGetAliases("foo").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foo").get().getAliases().isEmpty()); assertTrue(indexExists("bar_bar")); - assertFalse(indicesAdmin().prepareGetAliases("foo").setIndices("bar_bar").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foo").setIndices("bar_bar").get().getAliases().isEmpty()); assertAcked(indicesAdmin().prepareAliases().removeIndex("bar_bar")); - assertTrue(indicesAdmin().prepareGetAliases("foo").get().getAliases().isEmpty()); + assertTrue(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foo").get().getAliases().isEmpty()); assertFalse(indexExists("bar_bar")); } @@ -1320,7 +1323,7 @@ public void testGetAliasAndAliasExistsForHiddenAliases() { } private void checkAliases() { - GetAliasesResponse getAliasesResponse = indicesAdmin().prepareGetAliases("alias1").get(); + GetAliasesResponse getAliasesResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias1").get(); assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1)); AliasMetadata aliasMetadata = getAliasesResponse.getAliases().get("test").get(0); assertThat(aliasMetadata.alias(), equalTo("alias1")); @@ -1329,7 +1332,7 @@ private void checkAliases() { assertThat(aliasMetadata.searchRouting(), nullValue()); assertThat(aliasMetadata.isHidden(), nullValue()); - getAliasesResponse = indicesAdmin().prepareGetAliases("alias2").get(); + getAliasesResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias2").get(); assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1)); aliasMetadata = getAliasesResponse.getAliases().get("test").get(0); assertThat(aliasMetadata.alias(), equalTo("alias2")); @@ -1338,7 +1341,7 @@ private void checkAliases() { assertThat(aliasMetadata.searchRouting(), nullValue()); assertThat(aliasMetadata.isHidden(), nullValue()); - getAliasesResponse = indicesAdmin().prepareGetAliases("alias3").get(); + getAliasesResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias3").get(); assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1)); aliasMetadata = getAliasesResponse.getAliases().get("test").get(0); assertThat(aliasMetadata.alias(), equalTo("alias3")); @@ -1347,7 +1350,7 @@ private void checkAliases() { assertThat(aliasMetadata.searchRouting(), equalTo("search")); assertThat(aliasMetadata.isHidden(), nullValue()); - getAliasesResponse = indicesAdmin().prepareGetAliases("alias4").get(); + getAliasesResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias4").get(); assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(1)); aliasMetadata = getAliasesResponse.getAliases().get("test").get(0); assertThat(aliasMetadata.alias(), equalTo("alias4")); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/aliases/NetNewSystemIndexAliasIT.java b/server/src/internalClusterTest/java/org/elasticsearch/aliases/NetNewSystemIndexAliasIT.java index cf54bc50398c4..f0ee06336b493 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/aliases/NetNewSystemIndexAliasIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/aliases/NetNewSystemIndexAliasIT.java @@ -49,7 +49,7 @@ public void testGetAliasWithNetNewSystemIndices() throws Exception { } ensureGreen(); - GetAliasesRequest getAliasesRequest = new GetAliasesRequest(); + GetAliasesRequest getAliasesRequest = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); GetAliasesResponse aliasResponse = indicesAdmin().getAliases(getAliasesRequest).get(); assertThat(aliasResponse.getAliases().size(), is(0)); } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/aliases/SystemIndexAliasIT.java b/server/src/internalClusterTest/java/org/elasticsearch/aliases/SystemIndexAliasIT.java index fbade0ac2c871..38696d75b93da 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/aliases/SystemIndexAliasIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/aliases/SystemIndexAliasIT.java @@ -41,7 +41,7 @@ public void testCreateAliasForSystemIndex() throws Exception { assertAcked(indicesAdmin().prepareAliases().addAlias(PRIMARY_INDEX_NAME, INDEX_NAME + "-system-alias")); final GetAliasesResponse getAliasesResponse = indicesAdmin().getAliases( - new GetAliasesRequest().indicesOptions(IndicesOptions.strictExpandHidden()) + new GetAliasesRequest(TEST_REQUEST_TIMEOUT).indicesOptions(IndicesOptions.strictExpandHidden()) ).get(); assertThat(getAliasesResponse.getAliases().size(), equalTo(1)); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/HiddenIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/HiddenIndexIT.java index d116c091fbe4a..802ba04375c48 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/index/HiddenIndexIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/index/HiddenIndexIT.java @@ -150,13 +150,13 @@ public void testAliasesForHiddenIndices() { ); // The index should be returned here when queried by name or by wildcard because the alias is visible - final GetAliasesRequestBuilder req = indicesAdmin().prepareGetAliases(visibleAlias); + final GetAliasesRequestBuilder req = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, visibleAlias); GetAliasesResponse response = req.get(); assertThat(response.getAliases().get(hiddenIndex), hasSize(1)); assertThat(response.getAliases().get(hiddenIndex).get(0).alias(), equalTo(visibleAlias)); assertThat(response.getAliases().get(hiddenIndex).get(0).isHidden(), nullValue()); - response = indicesAdmin().prepareGetAliases("alias*").get(); + response = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias*").get(); assertThat(response.getAliases().get(hiddenIndex), hasSize(1)); assertThat(response.getAliases().get(hiddenIndex).get(0).alias(), equalTo(visibleAlias)); assertThat(response.getAliases().get(hiddenIndex).get(0).isHidden(), nullValue()); @@ -169,19 +169,21 @@ public void testAliasesForHiddenIndices() { ); // Querying by name directly should get the right result - response = indicesAdmin().prepareGetAliases(hiddenAlias).get(); + response = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, hiddenAlias).get(); assertThat(response.getAliases().get(hiddenIndex), hasSize(1)); assertThat(response.getAliases().get(hiddenIndex).get(0).alias(), equalTo(hiddenAlias)); assertThat(response.getAliases().get(hiddenIndex).get(0).isHidden(), equalTo(true)); // querying by wildcard should get the right result because the indices options include hidden by default - response = indicesAdmin().prepareGetAliases("alias*").get(); + response = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias*").get(); assertThat(response.getAliases().get(hiddenIndex), hasSize(1)); assertThat(response.getAliases().get(hiddenIndex).get(0).alias(), equalTo(hiddenAlias)); assertThat(response.getAliases().get(hiddenIndex).get(0).isHidden(), equalTo(true)); // But we should get no results if we specify indices options that don't include hidden - response = indicesAdmin().prepareGetAliases("alias*").setIndicesOptions(IndicesOptions.strictExpandOpen()).get(); + response = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias*") + .setIndicesOptions(IndicesOptions.strictExpandOpen()) + .get(); assertThat(response.getAliases().get(hiddenIndex), nullValue()); // Now try with a hidden alias that starts with a dot @@ -192,7 +194,7 @@ public void testAliasesForHiddenIndices() { ); // Check that querying by dot-prefixed pattern returns the alias - response = indicesAdmin().prepareGetAliases(".alias*").get(); + response = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, ".alias*").get(); assertThat(response.getAliases().get(hiddenIndex), hasSize(1)); assertThat(response.getAliases().get(hiddenIndex).get(0).alias(), equalTo(dotHiddenAlias)); assertThat(response.getAliases().get(hiddenIndex).get(0).isHidden(), equalTo(true)); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java index 545ed83bb79c8..652f4e02ffbce 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java @@ -497,7 +497,9 @@ public void testDeleteIndexWildcard() throws Exception { public void testPutAlias() throws Exception { createIndex("foobar"); verify(indicesAdmin().prepareAliases().addAlias("foobar", "foobar_alias"), false); - assertFalse(indicesAdmin().prepareGetAliases("foobar_alias").setIndices("foobar").get().getAliases().isEmpty()); + assertFalse( + indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foobar_alias").setIndices("foobar").get().getAliases().isEmpty() + ); } @@ -505,16 +507,24 @@ public void testPutAliasWildcard() throws Exception { createIndex("foo", "foobar", "bar", "barbaz"); verify(indicesAdmin().prepareAliases().addAlias("foo*", "foobar_alias"), false); - assertFalse(indicesAdmin().prepareGetAliases("foobar_alias").setIndices("foo").get().getAliases().isEmpty()); - assertFalse(indicesAdmin().prepareGetAliases("foobar_alias").setIndices("foobar").get().getAliases().isEmpty()); - assertTrue(indicesAdmin().prepareGetAliases("foobar_alias").setIndices("bar").get().getAliases().isEmpty()); - assertTrue(indicesAdmin().prepareGetAliases("foobar_alias").setIndices("barbaz").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foobar_alias").setIndices("foo").get().getAliases().isEmpty()); + assertFalse( + indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foobar_alias").setIndices("foobar").get().getAliases().isEmpty() + ); + assertTrue(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foobar_alias").setIndices("bar").get().getAliases().isEmpty()); + assertTrue( + indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foobar_alias").setIndices("barbaz").get().getAliases().isEmpty() + ); verify(indicesAdmin().prepareAliases().addAlias("*", "foobar_alias"), false); - assertFalse(indicesAdmin().prepareGetAliases("foobar_alias").setIndices("foo").get().getAliases().isEmpty()); - assertFalse(indicesAdmin().prepareGetAliases("foobar_alias").setIndices("foobar").get().getAliases().isEmpty()); - assertFalse(indicesAdmin().prepareGetAliases("foobar_alias").setIndices("bar").get().getAliases().isEmpty()); - assertFalse(indicesAdmin().prepareGetAliases("foobar_alias").setIndices("barbaz").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foobar_alias").setIndices("foo").get().getAliases().isEmpty()); + assertFalse( + indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foobar_alias").setIndices("foobar").get().getAliases().isEmpty() + ); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foobar_alias").setIndices("bar").get().getAliases().isEmpty()); + assertFalse( + indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "foobar_alias").setIndices("barbaz").get().getAliases().isEmpty() + ); } @@ -646,7 +656,7 @@ static ValidateQueryRequestBuilder validateQuery(String... indices) { } static GetAliasesRequestBuilder getAliases(String... indices) { - return indicesAdmin().prepareGetAliases("dummy").setIndices(indices); + return indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "dummy").setIndices(indices); } static GetFieldMappingsRequestBuilder getFieldMapping(String... indices) { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java index 8496180e85d4e..e63da56c39c11 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java @@ -494,7 +494,7 @@ public void testIndexTemplateWithAliases() throws Exception { prepareIndex("test_index").setId("4").setSource("type", "typeY", "field", "D value").get(); prepareIndex("test_index").setId("5").setSource("type", "typeZ", "field", "E value").get(); - GetAliasesResponse getAliasesResponse = indicesAdmin().prepareGetAliases().setIndices("test_index").get(); + GetAliasesResponse getAliasesResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT).setIndices("test_index").get(); assertThat(getAliasesResponse.getAliases().size(), equalTo(1)); assertThat(getAliasesResponse.getAliases().get("test_index").size(), equalTo(4)); @@ -538,7 +538,7 @@ public void testIndexTemplateWithAliasesInSource() { assertAcked(prepareCreate("test_index")); ensureGreen(); - GetAliasesResponse getAliasesResponse = indicesAdmin().prepareGetAliases().setIndices("test_index").get(); + GetAliasesResponse getAliasesResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT).setIndices("test_index").get(); assertThat(getAliasesResponse.getAliases().size(), equalTo(1)); assertThat(getAliasesResponse.getAliases().get("test_index").size(), equalTo(1)); @@ -574,7 +574,7 @@ public void testIndexTemplateWithAliasesSource() { assertAcked(prepareCreate("test_index")); ensureGreen(); - GetAliasesResponse getAliasesResponse = indicesAdmin().prepareGetAliases().setIndices("test_index").get(); + GetAliasesResponse getAliasesResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT).setIndices("test_index").get(); assertThat(getAliasesResponse.getAliases().size(), equalTo(1)); assertThat(getAliasesResponse.getAliases().get("test_index").size(), equalTo(3)); @@ -685,7 +685,7 @@ public void testMultipleAliasesPrecedence() throws Exception { ensureGreen(); - GetAliasesResponse getAliasesResponse = indicesAdmin().prepareGetAliases().setIndices("test").get(); + GetAliasesResponse getAliasesResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT).setIndices("test").get(); assertThat(getAliasesResponse.getAliases().get("test").size(), equalTo(4)); for (AliasMetadata aliasMetadata : getAliasesResponse.getAliases().get("test")) { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RestoreSnapshotIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RestoreSnapshotIT.java index 4ba06a34ca3a7..f84948afe97ad 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RestoreSnapshotIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RestoreSnapshotIT.java @@ -340,14 +340,14 @@ public void testRestoreAliases() throws Exception { .addAlias("test-idx-1", "alias-1") ); - assertFalse(indicesAdmin().prepareGetAliases("alias-123").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias-123").get().getAliases().isEmpty()); createSnapshot("test-repo", "test-snap", Collections.emptyList()); logger.info("--> delete all indices"); cluster().wipeIndices("test-idx-1", "test-idx-2", "test-idx-3"); - assertTrue(indicesAdmin().prepareGetAliases("alias-123").get().getAliases().isEmpty()); - assertTrue(indicesAdmin().prepareGetAliases("alias-1").get().getAliases().isEmpty()); + assertTrue(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias-123").get().getAliases().isEmpty()); + assertTrue(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias-1").get().getAliases().isEmpty()); logger.info("--> restore snapshot with aliases"); RestoreSnapshotResponse restoreSnapshotResponse = clusterAdmin().prepareRestoreSnapshot( @@ -362,8 +362,8 @@ public void testRestoreAliases() throws Exception { ); logger.info("--> check that aliases are restored"); - assertFalse(indicesAdmin().prepareGetAliases("alias-123").get().getAliases().isEmpty()); - assertFalse(indicesAdmin().prepareGetAliases("alias-1").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias-123").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias-1").get().getAliases().isEmpty()); logger.info("--> update aliases"); assertAcked(indicesAdmin().prepareAliases().removeAlias("test-idx-3", "alias-123")); @@ -372,8 +372,8 @@ public void testRestoreAliases() throws Exception { logger.info("--> delete and close indices"); cluster().wipeIndices("test-idx-1", "test-idx-2"); assertAcked(indicesAdmin().prepareClose("test-idx-3")); - assertTrue(indicesAdmin().prepareGetAliases("alias-123").get().getAliases().isEmpty()); - assertTrue(indicesAdmin().prepareGetAliases("alias-1").get().getAliases().isEmpty()); + assertTrue(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias-123").get().getAliases().isEmpty()); + assertTrue(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias-1").get().getAliases().isEmpty()); logger.info("--> restore snapshot without aliases"); restoreSnapshotResponse = clusterAdmin().prepareRestoreSnapshot(TEST_REQUEST_TIMEOUT, "test-repo", "test-snap") @@ -388,9 +388,9 @@ public void testRestoreAliases() throws Exception { ); logger.info("--> check that aliases are not restored and existing aliases still exist"); - assertTrue(indicesAdmin().prepareGetAliases("alias-123").get().getAliases().isEmpty()); - assertTrue(indicesAdmin().prepareGetAliases("alias-1").get().getAliases().isEmpty()); - assertFalse(indicesAdmin().prepareGetAliases("alias-3").get().getAliases().isEmpty()); + assertTrue(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias-123").get().getAliases().isEmpty()); + assertTrue(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias-1").get().getAliases().isEmpty()); + assertFalse(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias-3").get().getAliases().isEmpty()); } public void testRestoreTemplates() throws Exception { diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequest.java index fff8f5f587f70..0950e16229a2b 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequest.java @@ -12,7 +12,6 @@ import org.elasticsearch.action.AliasesRequest; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.local.LocalClusterStateRequest; -import org.elasticsearch.action.support.master.MasterNodeRequest; import org.elasticsearch.common.Strings; import org.elasticsearch.core.TimeValue; import org.elasticsearch.tasks.CancellableTask; @@ -30,16 +29,6 @@ public class GetAliasesRequest extends LocalClusterStateRequest implements Alias private String[] indices = Strings.EMPTY_ARRAY; private IndicesOptions indicesOptions = DEFAULT_INDICES_OPTIONS; - @Deprecated - public GetAliasesRequest(String... aliases) { - this(MasterNodeRequest.TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT, aliases); - } - - @Deprecated - public GetAliasesRequest() { - this(Strings.EMPTY_ARRAY); - } - public GetAliasesRequest(TimeValue masterTimeout, String... aliases) { super(masterTimeout); this.aliases = aliases; diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequestBuilder.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequestBuilder.java index 80fb7d794c32f..dc6374fed21fd 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequestBuilder.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequestBuilder.java @@ -12,10 +12,11 @@ import org.elasticsearch.action.ActionRequestBuilder; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.internal.ElasticsearchClient; +import org.elasticsearch.core.TimeValue; public class GetAliasesRequestBuilder extends ActionRequestBuilder { - public GetAliasesRequestBuilder(ElasticsearchClient client, String... aliases) { - super(client, GetAliasesAction.INSTANCE, new GetAliasesRequest(aliases)); + public GetAliasesRequestBuilder(ElasticsearchClient client, TimeValue masterTimeout, String... aliases) { + super(client, GetAliasesAction.INSTANCE, new GetAliasesRequest(masterTimeout, aliases)); } public GetAliasesRequestBuilder setAliases(String... aliases) { diff --git a/server/src/main/java/org/elasticsearch/client/internal/IndicesAdminClient.java b/server/src/main/java/org/elasticsearch/client/internal/IndicesAdminClient.java index 7a5e027a850fe..00557bc4f05ef 100644 --- a/server/src/main/java/org/elasticsearch/client/internal/IndicesAdminClient.java +++ b/server/src/main/java/org/elasticsearch/client/internal/IndicesAdminClient.java @@ -115,6 +115,7 @@ import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.cluster.metadata.IndexMetadata.APIBlock; import org.elasticsearch.core.Nullable; +import org.elasticsearch.core.TimeValue; import org.elasticsearch.threadpool.ThreadPool; /** @@ -336,8 +337,8 @@ public void getAliases(GetAliasesRequest request, ActionListener getIndex(GetIndexRequest request) { diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesActionTests.java index ec5f0b489d6ef..31c22422ec538 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesActionTests.java @@ -44,7 +44,7 @@ public void testPostProcess() { metadata.put(IndexMetadata.builder("c").settings(settings(IndexVersion.current())).numberOfShards(1).numberOfReplicas(0)); ClusterState clusterState = ClusterState.builder(ClusterState.EMPTY_STATE).metadata(metadata).build(); - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); Map> aliases = Map.of("b", Collections.singletonList(new AliasMetadata.Builder("y").build())); Map> result = TransportGetAliasesAction.postProcess( request, @@ -60,7 +60,7 @@ public void testPostProcess() { assertThat(result.get("b").size(), equalTo(1)); assertThat(result.get("c").size(), equalTo(0)); - request = new GetAliasesRequest(); + request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.replaceAliases("y", "z"); aliases = Map.of("b", Collections.singletonList(new AliasMetadata.Builder("y").build())); result = TransportGetAliasesAction.postProcess( @@ -77,7 +77,7 @@ public void testPostProcess() { assertThat(result.get("b").size(), equalTo(1)); assertThat(result.get("c").size(), equalTo(0)); - request = new GetAliasesRequest("y", "z"); + request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "y", "z"); aliases = Map.of("b", Collections.singletonList(new AliasMetadata.Builder("y").build())); result = TransportGetAliasesAction.postProcess( request, @@ -95,7 +95,7 @@ public void testPostProcess() { public void testDeprecationWarningEmittedForTotalWildcard() { ClusterState state = systemIndexTestClusterState(); - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); Map> aliases = Map.of( ".b", Collections.singletonList(new AliasMetadata.Builder(".y").build()), @@ -130,7 +130,7 @@ public void testDeprecationWarningEmittedForTotalWildcard() { public void testDeprecationWarningEmittedWhenSystemIndexIsRequested() { ClusterState state = systemIndexTestClusterState(); - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indices(".b"); Map> aliases = Map.of(".b", Collections.singletonList(new AliasMetadata.Builder(".y").build())); final String[] concreteIndices = { ".b" }; @@ -159,7 +159,7 @@ public void testDeprecationWarningEmittedWhenSystemIndexIsRequested() { public void testDeprecationWarningEmittedWhenSystemIndexIsRequestedByAlias() { ClusterState state = systemIndexTestClusterState(); - GetAliasesRequest request = new GetAliasesRequest(".y"); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, ".y"); Map> aliases = Map.of(".b", Collections.singletonList(new AliasMetadata.Builder(".y").build())); final String[] concreteIndices = { "a", ".b", "c" }; assertEquals(state.metadata().findAliases(request.aliases(), concreteIndices), aliases); @@ -187,7 +187,7 @@ public void testDeprecationWarningEmittedWhenSystemIndexIsRequestedByAlias() { public void testDeprecationWarningNotEmittedWhenSystemAccessAllowed() { ClusterState state = systemIndexTestClusterState(); - GetAliasesRequest request = new GetAliasesRequest(".y"); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, ".y"); Map> aliases = Map.of(".b", Collections.singletonList(new AliasMetadata.Builder(".y").build())); final String[] concreteIndices = { "a", ".b", "c" }; assertEquals(state.metadata().findAliases(request.aliases(), concreteIndices), aliases); @@ -210,7 +210,7 @@ public void testDeprecationWarningNotEmittedWhenSystemAccessAllowed() { public void testDeprecationWarningNotEmittedWhenOnlyNonsystemIndexRequested() { ClusterState state = systemIndexTestClusterState(); - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indices("c"); Map> aliases = Map.of("c", Collections.singletonList(new AliasMetadata.Builder("d").build())); final String[] concreteIndices = { "c" }; @@ -239,7 +239,7 @@ public void testPostProcessDataStreamAliases() { clusterState = ClusterState.builder(clusterState).metadata(builder).build(); // return all all data streams with aliases - var getAliasesRequest = new GetAliasesRequest(); + var getAliasesRequest = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); var result = TransportGetAliasesAction.postProcess(resolver, getAliasesRequest, clusterState); assertThat(result.keySet(), containsInAnyOrder("logs-foo", "logs-bar")); assertThat(result.get("logs-foo"), contains(new DataStreamAlias("logs", List.of("logs-bar", "logs-foo"), null, null))); @@ -252,20 +252,20 @@ public void testPostProcessDataStreamAliases() { ); // filter by alias name - getAliasesRequest = new GetAliasesRequest("secret"); + getAliasesRequest = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "secret"); result = TransportGetAliasesAction.postProcess(resolver, getAliasesRequest, clusterState); assertThat(result.keySet(), containsInAnyOrder("logs-bar")); assertThat(result.get("logs-bar"), contains(new DataStreamAlias("secret", List.of("logs-bar"), null, null))); // filter by data stream: - getAliasesRequest = new GetAliasesRequest().indices("logs-foo"); + getAliasesRequest = new GetAliasesRequest(TEST_REQUEST_TIMEOUT).indices("logs-foo"); result = TransportGetAliasesAction.postProcess(resolver, getAliasesRequest, clusterState); assertThat(result.keySet(), containsInAnyOrder("logs-foo")); assertThat(result.get("logs-foo"), contains(new DataStreamAlias("logs", List.of("logs-bar", "logs-foo"), null, null))); } public void testNetNewSystemIndicesDontErrorWhenNotRequested() { - GetAliasesRequest aliasesRequest = new GetAliasesRequest(); + GetAliasesRequest aliasesRequest = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); // `.b` will be the "net new" system index this test case ClusterState clusterState = systemIndexTestClusterState(); String[] concreteIndices; diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java index fc46afd10c18d..8f9c1826e97de 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java @@ -123,16 +123,16 @@ public void testFindAliases() { .build(); { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); Map> aliases = metadata.findAliases(request.aliases(), Strings.EMPTY_ARRAY); assertThat(aliases, anEmptyMap()); } { final GetAliasesRequest request; if (randomBoolean()) { - request = new GetAliasesRequest(); + request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); } else { - request = new GetAliasesRequest(randomFrom("alias1", "alias2")); + request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, randomFrom("alias1", "alias2")); // replacing with empty aliases behaves as if aliases were unspecified at request building request.replaceAliases(Strings.EMPTY_ARRAY); } @@ -142,7 +142,7 @@ public void testFindAliases() { assertThat(aliasMetadataList, transformedItemsMatch(AliasMetadata::alias, contains("alias1", "alias2"))); } { - GetAliasesRequest request = new GetAliasesRequest("alias*"); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "alias*"); Map> aliases = metadata.findAliases(request.aliases(), new String[] { "index", "index2" }); assertThat(aliases, aMapWithSize(2)); List indexAliasMetadataList = aliases.get("index"); @@ -151,7 +151,7 @@ public void testFindAliases() { assertThat(index2AliasMetadataList, transformedItemsMatch(AliasMetadata::alias, contains("alias2", "alias3"))); } { - GetAliasesRequest request = new GetAliasesRequest("alias1"); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "alias1"); Map> aliases = metadata.findAliases(request.aliases(), new String[] { "index" }); assertThat(aliases, aMapWithSize(1)); List aliasMetadataList = aliases.get("index"); @@ -184,19 +184,19 @@ public void testFindDataStreamAliases() { Metadata metadata = builder.build(); { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); Map> aliases = metadata.findDataStreamAliases(request.aliases(), Strings.EMPTY_ARRAY); assertThat(aliases, anEmptyMap()); } { - GetAliasesRequest request = new GetAliasesRequest().aliases("alias1"); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT).aliases("alias1"); Map> aliases = metadata.findDataStreamAliases(request.aliases(), new String[] { "index" }); assertThat(aliases, anEmptyMap()); } { - GetAliasesRequest request = new GetAliasesRequest().aliases("alias1"); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT).aliases("alias1"); Map> aliases = metadata.findDataStreamAliases( request.aliases(), new String[] { "index", "d1", "d2" } @@ -207,7 +207,7 @@ public void testFindDataStreamAliases() { } { - GetAliasesRequest request = new GetAliasesRequest().aliases("ali*"); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT).aliases("ali*"); Map> aliases = metadata.findDataStreamAliases(request.aliases(), new String[] { "index", "d2" }); assertEquals(1, aliases.size()); List found = aliases.get("d2"); @@ -216,7 +216,7 @@ public void testFindDataStreamAliases() { // test exclusion { - GetAliasesRequest request = new GetAliasesRequest().aliases("*"); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT).aliases("*"); Map> aliases = metadata.findDataStreamAliases( request.aliases(), new String[] { "index", "d1", "d2", "d3", "d4" } @@ -277,7 +277,7 @@ public void testFindAliasWithExclusion() { .putAlias(AliasMetadata.builder("alias3").build()) ) .build(); - GetAliasesRequest request = new GetAliasesRequest().aliases("*", "-alias1"); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT).aliases("*", "-alias1"); Map> aliases = metadata.findAliases(request.aliases(), new String[] { "index", "index2" }); assertThat(aliases.get("index"), transformedItemsMatch(AliasMetadata::alias, contains("alias2"))); assertThat(aliases.get("index2"), transformedItemsMatch(AliasMetadata::alias, contains("alias3"))); @@ -312,7 +312,7 @@ public void testFindAliasWithExclusionAndOverride() { .putAlias(AliasMetadata.builder("bb").build()) ) .build(); - GetAliasesRequest request = new GetAliasesRequest().aliases("a*", "-*b", "b*"); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT).aliases("a*", "-*b", "b*"); List aliases = metadata.findAliases(request.aliases(), new String[] { "index" }).get("index"); assertThat(aliases, transformedItemsMatch(AliasMetadata::alias, contains("aa", "bb"))); } diff --git a/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/CcrAliasesIT.java b/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/CcrAliasesIT.java index 45aac762c616a..c389e84ed592a 100644 --- a/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/CcrAliasesIT.java +++ b/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/CcrAliasesIT.java @@ -306,7 +306,10 @@ public void testStress() throws Exception { } private String[] getAliasesOnLeader() throws InterruptedException, ExecutionException { - final GetAliasesResponse response = leaderClient().admin().indices().getAliases(new GetAliasesRequest().indices("leader")).get(); + final GetAliasesResponse response = leaderClient().admin() + .indices() + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT).indices("leader")) + .get(); return response.getAliases().get("leader").stream().map(AliasMetadata::alias).toArray(String[]::new); } @@ -328,7 +331,7 @@ private void assertAliasesExist( assertBusy(() -> { final GetAliasesResponse followerResponse = followerClient().admin() .indices() - .getAliases(new GetAliasesRequest().indices(followerIndex)) + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT).indices(followerIndex)) .get(); assertThat( "expected follower to have [" + aliases.length + "] aliases, but was " + followerResponse.getAliases().toString(), @@ -340,7 +343,7 @@ private void assertAliasesExist( final GetAliasesResponse leaderResponse = leaderClient().admin() .indices() - .getAliases(new GetAliasesRequest().indices(leaderIndex).aliases(alias)) + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT).indices(leaderIndex).aliases(alias)) .get(); final AliasMetadata leaderAliasMetadata = getAliasMetadata(leaderResponse, leaderIndex, alias); @@ -374,7 +377,7 @@ private void assertAliasExistence(final String alias, final boolean exists) thro // we must check serially because aliases exist will return true if any but not necessarily all of the requested aliases exist final GetAliasesResponse response = followerClient().admin() .indices() - .getAliases(new GetAliasesRequest().indices("follower").aliases(alias)) + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT).indices("follower").aliases(alias)) .get(); if (exists) { assertFalse("alias [" + alias + "] did not exist", response.getAliases().isEmpty()); diff --git a/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java b/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java index 21b6c9db668ac..7556d02ddb1cf 100644 --- a/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java +++ b/x-pack/plugin/ccr/src/internalClusterTest/java/org/elasticsearch/xpack/ccr/IndexFollowingIT.java @@ -485,7 +485,7 @@ public void testAddAliasAfterUnfollow() throws Exception { assertAcked(followerClient().admin().indices().aliases(request).actionGet()); final GetAliasesResponse response = followerClient().admin() .indices() - .getAliases(new GetAliasesRequest("follower_alias")) + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "follower_alias")) .actionGet(); assertThat(response.getAliases().keySet().size(), equalTo(1)); assertThat(response.getAliases().keySet().iterator().next(), equalTo("follower")); diff --git a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunner.java b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunner.java index 69bc54457785c..37498bb9d54ab 100644 --- a/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunner.java +++ b/x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPolicyRunner.java @@ -748,7 +748,7 @@ private void validateIndexBeforePromotion(String destinationIndexName, ClusterSt private void updateEnrichPolicyAlias(ActionListener listener) { String enrichIndexBase = EnrichPolicy.getBaseName(policyName); logger.debug("Policy [{}]: Promoting new enrich index [{}] to alias [{}]", policyName, enrichIndexName, enrichIndexBase); - GetAliasesRequest aliasRequest = new GetAliasesRequest(enrichIndexBase); + GetAliasesRequest aliasRequest = new GetAliasesRequest(ENRICH_MASTER_REQUEST_TIMEOUT, enrichIndexBase); ClusterState clusterState = clusterService.state(); validateIndexBeforePromotion(enrichIndexName, clusterState); String[] concreteIndices = indexNameExpressionResolver.concreteIndexNamesWithSystemIndexAccess(clusterState, aliasRequest); diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyMaintenanceServiceTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyMaintenanceServiceTests.java index 34df040205496..0c19c2867a489 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyMaintenanceServiceTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyMaintenanceServiceTests.java @@ -203,7 +203,10 @@ private String fakeRunPolicy(String forPolicy) throws IOException { private void promoteFakePolicyIndex(String indexName, String forPolicy) { String enrichIndexBase = EnrichPolicy.getBaseName(forPolicy); - GetAliasesResponse getAliasesResponse = client().admin().indices().getAliases(new GetAliasesRequest(enrichIndexBase)).actionGet(); + GetAliasesResponse getAliasesResponse = client().admin() + .indices() + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT, enrichIndexBase)) + .actionGet(); IndicesAliasesRequest aliasToggleRequest = new IndicesAliasesRequest(); String[] indices = getAliasesResponse.getAliases().keySet().toArray(new String[0]); if (indices.length > 0) { diff --git a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/search/SearchApplicationIndexService.java b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/search/SearchApplicationIndexService.java index 2219a2bebbd25..60aacd03de1f3 100644 --- a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/search/SearchApplicationIndexService.java +++ b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/search/SearchApplicationIndexService.java @@ -19,8 +19,6 @@ import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; -import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest; -import org.elasticsearch.action.admin.indices.alias.get.GetAliasesResponse; import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.delete.DeleteResponse; import org.elasticsearch.action.get.GetRequest; @@ -321,10 +319,6 @@ private void deleteSearchApplication(String resourceName, ActionListener listener) { IndicesAliasesRequest aliasesRequest = new IndicesAliasesRequest().addAliasAction( IndicesAliasesRequest.AliasActions.remove().aliases(searchAliasName).indices("*") diff --git a/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/search/SearchApplicationIndexServiceTests.java b/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/search/SearchApplicationIndexServiceTests.java index 6e9d33b45041b..0c4202666d60a 100644 --- a/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/search/SearchApplicationIndexServiceTests.java +++ b/x-pack/plugin/ent-search/src/test/java/org/elasticsearch/xpack/application/search/SearchApplicationIndexServiceTests.java @@ -10,6 +10,7 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.DocWriteResponse; +import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesResponse; import org.elasticsearch.action.delete.DeleteResponse; import org.elasticsearch.cluster.metadata.Metadata; @@ -246,7 +247,10 @@ public void testDeleteSearchApplication() throws Exception { DeleteResponse resp = awaitDeleteSearchApplication("my_search_app_4"); assertThat(resp.status(), equalTo(RestStatus.OK)); expectThrows(ResourceNotFoundException.class, () -> awaitGetSearchApplication("my_search_app_4")); - GetAliasesResponse response = searchAppService.getAlias("my_search_app_4"); + GetAliasesResponse response = client().admin() + .indices() + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "my_search_app_4")) + .actionGet(); assertTrue(response.getAliases().isEmpty()); { diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/MlInitializationServiceIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/MlInitializationServiceIT.java index 1d67639f712a0..46510be620216 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/MlInitializationServiceIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/MlInitializationServiceIT.java @@ -214,7 +214,7 @@ private static Map getIndexToSettingsMap(List indexNam } private static Map> getIndexToAliasesMap(List indexNames) { - GetAliasesResponse getAliasesResponse = indicesAdmin().prepareGetAliases() + GetAliasesResponse getAliasesResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT) .setIndices(indexNames.toArray(String[]::new)) .setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN) .get(); diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/AnnotationIndexIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/AnnotationIndexIT.java index 6572a6c286519..6f5fa72a2b2f6 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/AnnotationIndexIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/AnnotationIndexIT.java @@ -250,6 +250,7 @@ public void testAliasesMovedFromOldToNew() throws Exception { assertBusy(() -> { assertTrue(annotationsIndexExists(AnnotationIndex.LATEST_INDEX_NAME)); Map> aliases = indicesAdmin().prepareGetAliases( + TEST_REQUEST_TIMEOUT, AnnotationIndex.READ_ALIAS_NAME, AnnotationIndex.WRITE_ALIAS_NAME ).setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN).get().getAliases(); @@ -330,6 +331,7 @@ private boolean annotationsIndexExists(String expectedName) { private int numberOfAnnotationsAliases() { int count = 0; Map> aliases = indicesAdmin().prepareGetAliases( + TEST_REQUEST_TIMEOUT, AnnotationIndex.READ_ALIAS_NAME, AnnotationIndex.WRITE_ALIAS_NAME, AnnotationIndex.LATEST_INDEX_NAME diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/IndexLayoutIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/IndexLayoutIT.java index 99052c771fb49..ec95b979fdd6d 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/IndexLayoutIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/IndexLayoutIT.java @@ -66,7 +66,7 @@ public void testCrudOnTwoJobsInSharedIndex() throws Exception { assertThat( client.admin() .indices() - .prepareGetAliases(AnomalyDetectorsIndex.jobStateIndexPattern()) + .prepareGetAliases(TEST_REQUEST_TIMEOUT, AnomalyDetectorsIndex.jobStateIndexPattern()) .get() .getAliases() .get(".ml-state-000001") diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobResultsProviderIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobResultsProviderIT.java index 997476143dff8..ff6c3c8444783 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobResultsProviderIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/JobResultsProviderIT.java @@ -530,7 +530,10 @@ private Map getIndexMappingProperties(String index) { } private Set getAliases(String index) { - GetAliasesResponse getAliasesResponse = client().admin().indices().getAliases(new GetAliasesRequest().indices(index)).actionGet(); + GetAliasesResponse getAliasesResponse = client().admin() + .indices() + .getAliases(new GetAliasesRequest(TEST_REQUEST_TIMEOUT).indices(index)) + .actionGet(); Map> aliases = getAliasesResponse.getAliases(); assertThat(aliases.containsKey(index), is(true)); List aliasMetadataList = aliases.get(index); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlInitializationService.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlInitializationService.java index 45a71a80de077..99df16bcd3dc2 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlInitializationService.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MlInitializationService.java @@ -221,8 +221,9 @@ private void makeMlInternalIndicesHidden() { logger.warn("One or more of the ML internal indices could not be made hidden."); return; } - GetAliasesRequest getAliasesRequest = new GetAliasesRequest().indices(mlHiddenIndexPatterns) - .indicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN); + GetAliasesRequest getAliasesRequest = new GetAliasesRequest(MasterNodeRequest.INFINITE_MASTER_NODE_TIMEOUT).indices( + mlHiddenIndexPatterns + ).indicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN); executeAsyncWithOrigin(client, ML_ORIGIN, GetAliasesAction.INSTANCE, getAliasesRequest, getAliasesResponseListener); }, finalListener::onFailure); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobDataDeleter.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobDataDeleter.java index 0f3abe3ab8c20..a61f78e856b50 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobDataDeleter.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/persistence/JobDataDeleter.java @@ -25,6 +25,7 @@ import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.broadcast.BroadcastResponse; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.action.support.master.MasterNodeRequest; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; @@ -475,8 +476,10 @@ private void deleteAliases(@SuppressWarnings("HiddenField") String jobId, Action final String writeAliasName = AnomalyDetectorsIndex.resultsWriteAlias(jobId); // first find the concrete indices associated with the aliases - GetAliasesRequest aliasesRequest = new GetAliasesRequest().aliases(readAliasName, writeAliasName) - .indicesOptions(IndicesOptions.lenientExpandOpenHidden()); + GetAliasesRequest aliasesRequest = new GetAliasesRequest(MasterNodeRequest.INFINITE_MASTER_NODE_TIMEOUT).aliases( + readAliasName, + writeAliasName + ).indicesOptions(IndicesOptions.lenientExpandOpenHidden()); executeAsyncWithOrigin( client.threadPool().getThreadContext(), ML_ORIGIN, diff --git a/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/index/IndexResolver.java b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/index/IndexResolver.java index 7a85bf4c7349b..b50ca4d928040 100644 --- a/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/index/IndexResolver.java +++ b/x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/index/IndexResolver.java @@ -16,6 +16,7 @@ import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse; import org.elasticsearch.action.support.IndicesOptions; +import org.elasticsearch.action.support.master.MasterNodeRequest; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.metadata.AliasMetadata; import org.elasticsearch.common.Strings; @@ -694,7 +695,7 @@ public void resolveAsSeparateMappings( } private static GetAliasesRequest createGetAliasesRequest(FieldCapabilitiesResponse response, boolean includeFrozen) { - return new GetAliasesRequest().aliases("*") + return new GetAliasesRequest(MasterNodeRequest.INFINITE_MASTER_NODE_TIMEOUT).aliases("*") .indices(response.getIndices()) .indicesOptions(includeFrozen ? FIELD_CAPS_FROZEN_INDICES_OPTIONS : FIELD_CAPS_INDICES_OPTIONS); } diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/FrozenSearchableSnapshotsIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/FrozenSearchableSnapshotsIntegTests.java index 2797202e5f24e..da60f9a84c3ba 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/FrozenSearchableSnapshotsIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/FrozenSearchableSnapshotsIntegTests.java @@ -318,17 +318,17 @@ public void testCreateAndRestorePartialSearchableSnapshot() throws Exception { ); if (deletedBeforeMount) { - assertThat(indicesAdmin().prepareGetAliases(aliasName).get().getAliases().size(), equalTo(0)); + assertThat(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, aliasName).get().getAliases().size(), equalTo(0)); assertAcked(indicesAdmin().prepareAliases().addAlias(restoredIndexName, aliasName)); } else if (indexName.equals(restoredIndexName) == false) { - assertThat(indicesAdmin().prepareGetAliases(aliasName).get().getAliases().size(), equalTo(1)); + assertThat(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, aliasName).get().getAliases().size(), equalTo(1)); assertAcked( indicesAdmin().prepareAliases() .addAliasAction(IndicesAliasesRequest.AliasActions.remove().index(indexName).alias(aliasName).mustExist(true)) .addAlias(restoredIndexName, aliasName) ); } - assertThat(indicesAdmin().prepareGetAliases(aliasName).get().getAliases().size(), equalTo(1)); + assertThat(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, aliasName).get().getAliases().size(), equalTo(1)); assertTotalHits(aliasName, originalAllHits, originalBarHits); final var request = new ClusterAllocationExplainRequest(TEST_REQUEST_TIMEOUT).setIndex(restoredIndexName) @@ -422,7 +422,7 @@ public void testCreateAndRestorePartialSearchableSnapshot() throws Exception { assertFalse(clonedIndexSettings.hasValue(IndexModule.INDEX_RECOVERY_TYPE_SETTING.getKey())); assertAcked(indicesAdmin().prepareDelete(restoredIndexName)); - assertThat(indicesAdmin().prepareGetAliases(aliasName).get().getAliases().size(), equalTo(0)); + assertThat(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, aliasName).get().getAliases().size(), equalTo(0)); assertAcked(indicesAdmin().prepareAliases().addAlias(clonedIndexName, aliasName)); assertTotalHits(aliasName, originalAllHits, originalBarHits); } diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsIntegTests.java index 84a632a419ead..25617028fe544 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsIntegTests.java @@ -264,17 +264,17 @@ public void testCreateAndRestoreSearchableSnapshot() throws Exception { assertThat(indexMetadata.getEventIngestedRange(), sameInstance(IndexLongFieldRange.UNKNOWN)); if (deletedBeforeMount) { - assertThat(indicesAdmin().prepareGetAliases(aliasName).get().getAliases().size(), equalTo(0)); + assertThat(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, aliasName).get().getAliases().size(), equalTo(0)); assertAcked(indicesAdmin().prepareAliases().addAlias(restoredIndexName, aliasName)); } else if (indexName.equals(restoredIndexName) == false) { - assertThat(indicesAdmin().prepareGetAliases(aliasName).get().getAliases().size(), equalTo(1)); + assertThat(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, aliasName).get().getAliases().size(), equalTo(1)); assertAcked( indicesAdmin().prepareAliases() .addAliasAction(IndicesAliasesRequest.AliasActions.remove().index(indexName).alias(aliasName).mustExist(true)) .addAlias(restoredIndexName, aliasName) ); } - assertThat(indicesAdmin().prepareGetAliases(aliasName).get().getAliases().size(), equalTo(1)); + assertThat(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, aliasName).get().getAliases().size(), equalTo(1)); assertTotalHits(aliasName, originalAllHits, originalBarHits); internalCluster().fullRestart(); @@ -347,7 +347,7 @@ public void testCreateAndRestoreSearchableSnapshot() throws Exception { assertFalse(clonedIndexSettings.hasValue(IndexModule.INDEX_RECOVERY_TYPE_SETTING.getKey())); assertAcked(indicesAdmin().prepareDelete(restoredIndexName)); - assertThat(indicesAdmin().prepareGetAliases(aliasName).get().getAliases().size(), equalTo(0)); + assertThat(indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, aliasName).get().getAliases().size(), equalTo(0)); assertAcked(indicesAdmin().prepareAliases().addAlias(clonedIndexName, aliasName)); assertTotalHits(aliasName, originalAllHits, originalBarHits); } diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/IndexAliasesTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/IndexAliasesTests.java index 0a9995761cc42..c1dbb004196ac 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/IndexAliasesTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/IndexAliasesTests.java @@ -195,19 +195,31 @@ public void testGetAliasesCreateOnlyPermissionStrict() { final Client client = client().filterWithHeader(headers); assertThrowsAuthorizationException( - client.admin().indices().prepareGetAliases("test_1").setIndices("test_1").setIndicesOptions(IndicesOptions.strictExpand())::get, + client.admin() + .indices() + .prepareGetAliases(TEST_REQUEST_TIMEOUT, "test_1") + .setIndices("test_1") + .setIndicesOptions(IndicesOptions.strictExpand())::get, GetAliasesAction.NAME, "create_only" ); assertThrowsAuthorizationException( - client.admin().indices().prepareGetAliases("_all").setIndices("test_1").setIndicesOptions(IndicesOptions.strictExpand())::get, + client.admin() + .indices() + .prepareGetAliases(TEST_REQUEST_TIMEOUT, "_all") + .setIndices("test_1") + .setIndicesOptions(IndicesOptions.strictExpand())::get, GetAliasesAction.NAME, "create_only" ); assertThrowsAuthorizationException( - client.admin().indices().prepareGetAliases().setIndices("test_1").setIndicesOptions(IndicesOptions.strictExpand())::get, + client.admin() + .indices() + .prepareGetAliases(TEST_REQUEST_TIMEOUT) + .setIndices("test_1") + .setIndicesOptions(IndicesOptions.strictExpand())::get, GetAliasesAction.NAME, "create_only" ); @@ -215,7 +227,7 @@ public void testGetAliasesCreateOnlyPermissionStrict() { assertThrowsAuthorizationException( client.admin() .indices() - .prepareGetAliases("test_alias") + .prepareGetAliases(TEST_REQUEST_TIMEOUT, "test_alias") .setIndices("test_*") .setIndicesOptions(IndicesOptions.strictExpand())::get, GetAliasesAction.NAME, @@ -224,7 +236,11 @@ public void testGetAliasesCreateOnlyPermissionStrict() { // this throws exception no matter what the indices options are because the aliases part cannot be resolved to any alias // and there is no way to "allow_no_aliases" like we can do with indices. - assertThrowsAuthorizationException(client.admin().indices().prepareGetAliases()::get, GetAliasesAction.NAME, "create_only"); + assertThrowsAuthorizationException( + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT)::get, + GetAliasesAction.NAME, + "create_only" + ); } public void testGetAliasesCreateOnlyPermissionIgnoreUnavailable() { @@ -238,7 +254,7 @@ public void testGetAliasesCreateOnlyPermissionIgnoreUnavailable() { assertThrowsAuthorizationException( client.admin() .indices() - .prepareGetAliases("test_1") + .prepareGetAliases(TEST_REQUEST_TIMEOUT, "test_1") .setIndices("test_1") .setIndicesOptions(IndicesOptions.lenientExpandOpen())::get, GetAliasesAction.NAME, @@ -248,17 +264,25 @@ public void testGetAliasesCreateOnlyPermissionIgnoreUnavailable() { assertThrowsAuthorizationException( client.admin() .indices() - .prepareGetAliases("_all") + .prepareGetAliases(TEST_REQUEST_TIMEOUT, "_all") .setIndices("test_1") .setIndicesOptions(IndicesOptions.lenientExpandOpen())::get, GetAliasesAction.NAME, "create_only" ); - assertThrowsAuthorizationException(client.admin().indices().prepareGetAliases("alias*")::get, GetAliasesAction.NAME, "create_only"); + assertThrowsAuthorizationException( + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias*")::get, + GetAliasesAction.NAME, + "create_only" + ); assertThrowsAuthorizationException( - client.admin().indices().prepareGetAliases().setIndices("test_1").setIndicesOptions(IndicesOptions.lenientExpandOpen())::get, + client.admin() + .indices() + .prepareGetAliases(TEST_REQUEST_TIMEOUT) + .setIndices("test_1") + .setIndicesOptions(IndicesOptions.lenientExpandOpen())::get, GetAliasesAction.NAME, "create_only" ); @@ -266,7 +290,7 @@ public void testGetAliasesCreateOnlyPermissionIgnoreUnavailable() { assertThrowsAuthorizationException( client.admin() .indices() - .prepareGetAliases("test_alias") + .prepareGetAliases(TEST_REQUEST_TIMEOUT, "test_alias") .setIndices("test_*") .setIndicesOptions(IndicesOptions.lenientExpandOpen())::get, GetAliasesAction.NAME, @@ -274,7 +298,11 @@ public void testGetAliasesCreateOnlyPermissionIgnoreUnavailable() { ); assertThrowsAuthorizationException( - client.admin().indices().prepareGetAliases().setIndices("test_*").setIndicesOptions(IndicesOptions.lenientExpandOpen())::get, + client.admin() + .indices() + .prepareGetAliases(TEST_REQUEST_TIMEOUT) + .setIndices("test_*") + .setIndicesOptions(IndicesOptions.lenientExpandOpen())::get, GetAliasesAction.NAME, "create_only" ); @@ -282,7 +310,7 @@ public void testGetAliasesCreateOnlyPermissionIgnoreUnavailable() { // this throws exception no matter what the indices options are because the aliases part cannot be resolved to any alias // and there is no way to "allow_no_aliases" like we can do with indices. assertThrowsAuthorizationException( - client.admin().indices().prepareGetAliases().setIndicesOptions(IndicesOptions.lenientExpandOpen())::get, + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setIndicesOptions(IndicesOptions.lenientExpandOpen())::get, GetAliasesAction.NAME, "create_only" ); @@ -415,43 +443,63 @@ public void testGetAliasesCreateAndAliasesPermission() { assertAcked(client.admin().indices().prepareCreate("test_1").addAlias(new Alias("test_alias")).get()); // ok: user has manage_aliases on test_* - assertAliases(client.admin().indices().prepareGetAliases().setAliases("test_alias").setIndices("test_1"), "test_1", "test_alias"); + assertAliases( + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("test_alias").setIndices("test_1"), + "test_1", + "test_alias" + ); // ok: user has manage_aliases on test_*, test_* gets resolved to test_1 - assertAliases(client.admin().indices().prepareGetAliases().setAliases("test_alias").setIndices("test_*"), "test_1", "test_alias"); + assertAliases( + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("test_alias").setIndices("test_*"), + "test_1", + "test_alias" + ); // ok: user has manage_aliases on test_*, empty indices gets resolved to _all indices (thus test_1) - assertAliases(client.admin().indices().prepareGetAliases().setAliases("test_alias"), "test_1", "test_alias"); + assertAliases(client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("test_alias"), "test_1", "test_alias"); // ok: user has manage_aliases on test_*, _all aliases gets resolved to test_alias and empty indices gets resolved to _all // indices (thus test_1) - assertAliases(client.admin().indices().prepareGetAliases().setAliases("_all").setIndices("test_1"), "test_1", "test_alias"); + assertAliases( + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("_all").setIndices("test_1"), + "test_1", + "test_alias" + ); // ok: user has manage_aliases on test_*, empty aliases gets resolved to test_alias and empty indices gets resolved to _all // indices (thus test_1) - assertAliases(client.admin().indices().prepareGetAliases().setIndices("test_1"), "test_1", "test_alias"); + assertAliases(client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setIndices("test_1"), "test_1", "test_alias"); // ok: user has manage_aliases on test_*, test_* aliases gets resolved to test_alias and empty indices gets resolved to _all // indices (thus test_1) - assertAliases(client.admin().indices().prepareGetAliases().setAliases("test_*").setIndices("test_1"), "test_1", "test_alias"); + assertAliases( + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("test_*").setIndices("test_1"), + "test_1", + "test_alias" + ); // ok: user has manage_aliases on test_*, _all aliases gets resolved to test_alias and _all indices becomes test_1 - assertAliases(client.admin().indices().prepareGetAliases().setAliases("_all").setIndices("_all"), "test_1", "test_alias"); + assertAliases( + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("_all").setIndices("_all"), + "test_1", + "test_alias" + ); // ok: user has manage_aliases on test_*, empty aliases gets resolved to test_alias and empty indices becomes test_1 - assertAliases(client.admin().indices().prepareGetAliases(), "test_1", "test_alias"); + assertAliases(client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT), "test_1", "test_alias"); // fails: user has manage_aliases on test_*, although _all aliases and empty indices can be resolved, the explicit non // authorized alias (alias_1) causes the request to fail assertThrowsAuthorizationException( - client.admin().indices().prepareGetAliases().setAliases("_all", "alias_1")::get, + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("_all", "alias_1")::get, GetAliasesAction.NAME, "create_test_aliases_test" ); // fails: user doesn't have manage_aliases on alias_1 assertThrowsAuthorizationException( - client.admin().indices().prepareGetAliases().setAliases("alias_1")::get, + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("alias_1")::get, GetAliasesAction.NAME, "create_test_aliases_test" ); @@ -542,7 +590,7 @@ public void testGetAliasesCreateAndAliasesPermission2() { // fails: user doesn't have manage_aliases aliases on test_1, nor test_alias assertThrowsAuthorizationException( - client.admin().indices().prepareGetAliases().setAliases("test_alias").setIndices("test_1")::get, + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("test_alias").setIndices("test_1")::get, GetAliasesAction.NAME, "create_test_aliases_alias" ); @@ -550,20 +598,20 @@ public void testGetAliasesCreateAndAliasesPermission2() { // user doesn't have manage_aliases aliases on test_*, no matching indices to replace wildcards GetAliasesResponse getAliasesResponse = client.admin() .indices() - .prepareGetAliases() + .prepareGetAliases(TEST_REQUEST_TIMEOUT) .setIndices("test_*") .setAliases("test_alias") .get(); assertEquals(0, getAliasesResponse.getAliases().size()); // no existing indices to replace empty indices (thus _all) - getAliasesResponse = client.admin().indices().prepareGetAliases().setAliases("test_alias").get(); + getAliasesResponse = client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("test_alias").get(); assertEquals(0, getAliasesResponse.getAliases().size()); { // fails: no existing aliases to replace wildcards assertThrowsAuthorizationException( - client.admin().indices().prepareGetAliases().setIndices("test_1").setAliases("test_*")::get, + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setIndices("test_1").setAliases("test_*")::get, GetAliasesAction.NAME, "create_test_aliases_alias" ); @@ -571,7 +619,7 @@ public void testGetAliasesCreateAndAliasesPermission2() { { // fails: no existing aliases to replace _all assertThrowsAuthorizationException( - client.admin().indices().prepareGetAliases().setIndices("test_1").setAliases("_all")::get, + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setIndices("test_1").setAliases("_all")::get, GetAliasesAction.NAME, "create_test_aliases_alias" ); @@ -579,14 +627,14 @@ public void testGetAliasesCreateAndAliasesPermission2() { { // fails: no existing aliases to replace empty aliases assertThrowsAuthorizationException( - client.admin().indices().prepareGetAliases().setIndices("test_1")::get, + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setIndices("test_1")::get, GetAliasesAction.NAME, "create_test_aliases_alias" ); } { // fails: no existing aliases to replace empty aliases - GetAliasesResponse response = client.admin().indices().prepareGetAliases().get(); + GetAliasesResponse response = client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).get(); assertThat(response.getAliases().size(), equalTo(0)); } } @@ -668,28 +716,58 @@ public void testGetAliasesCreateAndAliasesPermission3() { // user has create permission on test_* and manage_aliases permission on test_*,alias_*. All good. assertAcked(client.admin().indices().prepareCreate("test_1").addAlias(new Alias("test_alias")).addAlias(new Alias("alias_1"))); - assertAliases(client.admin().indices().prepareGetAliases().setAliases("test_alias").setIndices("test_1"), "test_1", "test_alias"); + assertAliases( + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("test_alias").setIndices("test_1"), + "test_1", + "test_alias" + ); - assertAliases(client.admin().indices().prepareGetAliases().setAliases("alias_1").setIndices("test_1"), "test_1", "alias_1"); + assertAliases( + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("alias_1").setIndices("test_1"), + "test_1", + "alias_1" + ); - assertAliases(client.admin().indices().prepareGetAliases().setAliases("alias_1").setIndices("test_*"), "test_1", "alias_1"); + assertAliases( + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("alias_1").setIndices("test_*"), + "test_1", + "alias_1" + ); - assertAliases(client.admin().indices().prepareGetAliases().setAliases("test_*").setIndices("test_1"), "test_1", "test_alias"); + assertAliases( + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("test_*").setIndices("test_1"), + "test_1", + "test_alias" + ); assertAliases( - client.admin().indices().prepareGetAliases().setAliases("_all").setIndices("test_1"), + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("_all").setIndices("test_1"), "test_1", "alias_1", "test_alias" ); - assertAliases(client.admin().indices().prepareGetAliases().setAliases("_all"), "test_1", "alias_1", "test_alias"); + assertAliases( + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("_all"), + "test_1", + "alias_1", + "test_alias" + ); - assertAliases(client.admin().indices().prepareGetAliases().setIndices("test_1"), "test_1", "alias_1", "test_alias"); + assertAliases( + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setIndices("test_1"), + "test_1", + "alias_1", + "test_alias" + ); - assertAliases(client.admin().indices().prepareGetAliases(), "test_1", "alias_1", "test_alias"); + assertAliases(client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT), "test_1", "alias_1", "test_alias"); - assertAliases(client.admin().indices().prepareGetAliases().setAliases("alias_*").setIndices("test_*"), "test_1", "alias_1"); + assertAliases( + client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("alias_*").setIndices("test_*"), + "test_1", + "alias_1" + ); } public void testCreateIndexAliasesOnlyPermission() { @@ -718,7 +796,7 @@ public void testGetAliasesAliasesOnlyPermissionStrict() { IndexNotFoundException.class, client.admin() .indices() - .prepareGetAliases("alias_1") + .prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias_1") .setIndices("test_1") .setIndicesOptions(IndicesOptions.strictExpandOpen())::get ); @@ -728,7 +806,7 @@ public void testGetAliasesAliasesOnlyPermissionStrict() { assertThrowsAuthorizationException( client.admin() .indices() - .prepareGetAliases("non_authorized") + .prepareGetAliases(TEST_REQUEST_TIMEOUT, "non_authorized") .setIndices("test_1") .setIndicesOptions(IndicesOptions.strictExpandOpen())::get, GetAliasesAction.NAME, @@ -739,7 +817,7 @@ public void testGetAliasesAliasesOnlyPermissionStrict() { assertThrowsAuthorizationException( client.admin() .indices() - .prepareGetAliases("alias_1") + .prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias_1") .setIndices("non_authorized") .setIndicesOptions(IndicesOptions.strictExpandOpen())::get, GetAliasesAction.NAME, @@ -758,7 +836,7 @@ public void testGetAliasesAliasesOnlyPermissionIgnoreUnavailable() { // ok: manage_aliases on both test_* and alias_* GetAliasesResponse getAliasesResponse = client.admin() .indices() - .prepareGetAliases("alias_1") + .prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias_1") .setIndices("test_1") .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .get(); @@ -768,7 +846,7 @@ public void testGetAliasesAliasesOnlyPermissionIgnoreUnavailable() { assertThrowsAuthorizationException( client.admin() .indices() - .prepareGetAliases("non_authorized") + .prepareGetAliases(TEST_REQUEST_TIMEOUT, "non_authorized") .setIndices("test_1") .setIndicesOptions(IndicesOptions.lenientExpandOpen())::get, GetAliasesAction.NAME, @@ -778,7 +856,7 @@ public void testGetAliasesAliasesOnlyPermissionIgnoreUnavailable() { // no manage_aliases privilege on non_authorized index getAliasesResponse = client.admin() .indices() - .prepareGetAliases("alias_1") + .prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias_1") .setIndices("non_authorized") .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .get(); @@ -796,13 +874,18 @@ public void testRemoveIndex() { assertAcked(client.admin().indices().prepareCreate("test_1").addAlias(new Alias("test_alias_1"))); assertAcked(client.admin().indices().prepareAliases().removeIndex("test_delete_*").get()); - assertAliases(client.admin().indices().prepareGetAliases().setAliases("*"), "test_1", "test_alias_1"); + assertAliases(client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("*"), "test_1", "test_alias_1"); // test that the remove index wildcard expacnds only to authorized indices assertAcked(client.admin().indices().prepareAliases().removeIndex("*").get()); - GetAliasesResponse getAliasesResponse = client.admin().indices().prepareGetAliases().setAliases("*").get(); + GetAliasesResponse getAliasesResponse = client.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("*").get(); assertThat(getAliasesResponse.getAliases().size(), equalTo(0)); - assertAliases(indicesAdmin().prepareGetAliases().setAliases("*"), "bogus_index_1", "bogus_alias_1", "bogus_alias_2"); + assertAliases( + indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT).setAliases("*"), + "bogus_index_1", + "bogus_alias_1", + "bogus_alias_2" + ); } public void testAliasesForHiddenIndices() { @@ -834,13 +917,13 @@ public void testAliasesForHiddenIndices() { ); // The index should be returned here when queried by name or by wildcard because the alias is visible - final GetAliasesRequestBuilder req = aliasesClient.admin().indices().prepareGetAliases(visibleAlias); + final GetAliasesRequestBuilder req = aliasesClient.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT, visibleAlias); GetAliasesResponse response = req.get(); assertThat(response.getAliases().get(hiddenIndex), hasSize(1)); assertThat(response.getAliases().get(hiddenIndex).get(0).alias(), Matchers.equalTo(visibleAlias)); assertThat(response.getAliases().get(hiddenIndex).get(0).isHidden(), nullValue()); - response = indicesAdmin().prepareGetAliases("alias*").get(); + response = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias*").get(); assertThat(response.getAliases().get(hiddenIndex), hasSize(1)); assertThat(response.getAliases().get(hiddenIndex).get(0).alias(), Matchers.equalTo(visibleAlias)); assertThat(response.getAliases().get(hiddenIndex).get(0).isHidden(), nullValue()); @@ -855,19 +938,23 @@ public void testAliasesForHiddenIndices() { ); // Querying by name directly should get the right result - response = aliasesClient.admin().indices().prepareGetAliases(hiddenAlias).get(); + response = aliasesClient.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT, hiddenAlias).get(); assertThat(response.getAliases().get(hiddenIndex), hasSize(1)); assertThat(response.getAliases().get(hiddenIndex).get(0).alias(), Matchers.equalTo(hiddenAlias)); assertThat(response.getAliases().get(hiddenIndex).get(0).isHidden(), Matchers.equalTo(true)); // querying by wildcard should get the right result because the indices options include hidden by default - response = aliasesClient.admin().indices().prepareGetAliases("alias*").get(); + response = aliasesClient.admin().indices().prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias*").get(); assertThat(response.getAliases().get(hiddenIndex), hasSize(1)); assertThat(response.getAliases().get(hiddenIndex).get(0).alias(), Matchers.equalTo(hiddenAlias)); assertThat(response.getAliases().get(hiddenIndex).get(0).isHidden(), Matchers.equalTo(true)); // But we should get no results if we specify indices options that don't include hidden - response = aliasesClient.admin().indices().prepareGetAliases("alias*").setIndicesOptions(IndicesOptions.strictExpandOpen()).get(); + response = aliasesClient.admin() + .indices() + .prepareGetAliases(TEST_REQUEST_TIMEOUT, "alias*") + .setIndicesOptions(IndicesOptions.strictExpandOpen()) + .get(); assertThat(response.getAliases().get(hiddenIndex), nullValue()); } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java index 52081771d1e93..b62d895db7f1d 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java @@ -1224,7 +1224,7 @@ public void testResolveWildcardsIndicesAliasesRequestAddAndDeleteActions() { } public void testResolveGetAliasesRequestStrict() { - GetAliasesRequest request = new GetAliasesRequest("alias1").indices("foo", "foofoo"); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "alias1").indices("foo", "foofoo"); request.indicesOptions(IndicesOptions.fromOptions(false, randomBoolean(), randomBoolean(), randomBoolean())); final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, GetAliasesAction.NAME); List indices = resolveIndices(request, authorizedIndices).getLocal(); @@ -1237,7 +1237,7 @@ public void testResolveGetAliasesRequestStrict() { } public void testResolveGetAliasesRequestIgnoreUnavailable() { - GetAliasesRequest request = new GetAliasesRequest("alias1").indices("foo", "foofoo"); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "alias1").indices("foo", "foofoo"); request.indicesOptions(IndicesOptions.fromOptions(true, randomBoolean(), randomBoolean(), randomBoolean())); final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, GetAliasesAction.NAME); List indices = resolveIndices(request, authorizedIndices).getLocal(); @@ -1249,7 +1249,7 @@ public void testResolveGetAliasesRequestIgnoreUnavailable() { } public void testResolveGetAliasesRequestMissingIndexStrict() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indicesOptions(IndicesOptions.fromOptions(false, randomBoolean(), true, randomBoolean())); request.indices("missing"); request.aliases("alias2"); @@ -1268,7 +1268,7 @@ public void testResolveGetAliasesRequestMissingIndexStrict() { } public void testGetAliasesRequestMissingIndexIgnoreUnavailableDisallowNoIndices() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indicesOptions(IndicesOptions.fromOptions(true, false, randomBoolean(), randomBoolean())); request.indices("missing"); request.aliases("alias2"); @@ -1286,7 +1286,7 @@ public void testGetAliasesRequestMissingIndexIgnoreUnavailableDisallowNoIndices( } public void testGetAliasesRequestMissingIndexIgnoreUnavailableAllowNoIndices() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indicesOptions(IndicesOptions.fromOptions(true, true, randomBoolean(), randomBoolean())); request.indices("missing"); request.aliases("alias2"); @@ -1300,7 +1300,7 @@ public void testGetAliasesRequestMissingIndexIgnoreUnavailableAllowNoIndices() { } public void testGetAliasesRequestMissingIndexStrict() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indicesOptions(IndicesOptions.fromOptions(false, randomBoolean(), randomBoolean(), randomBoolean())); request.indices("missing"); request.aliases("alias2"); @@ -1314,7 +1314,7 @@ public void testGetAliasesRequestMissingIndexStrict() { } public void testResolveWildcardsGetAliasesRequestStrictExpand() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indicesOptions(IndicesOptions.fromOptions(false, randomBoolean(), true, true)); request.aliases("alias1"); request.indices("foo*"); @@ -1330,7 +1330,7 @@ public void testResolveWildcardsGetAliasesRequestStrictExpand() { } public void testResolveWildcardsGetAliasesRequestStrictExpandOpen() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indicesOptions(IndicesOptions.fromOptions(false, randomBoolean(), true, false)); request.aliases("alias1"); request.indices("foo*"); @@ -1346,7 +1346,7 @@ public void testResolveWildcardsGetAliasesRequestStrictExpandOpen() { } public void testResolveWildcardsGetAliasesRequestLenientExpandOpen() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indicesOptions(IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), true, false)); request.aliases("alias1"); request.indices("foo*", "bar", "missing"); @@ -1360,7 +1360,7 @@ public void testResolveWildcardsGetAliasesRequestLenientExpandOpen() { } public void testWildcardsGetAliasesRequestNoMatchingIndicesDisallowNoIndices() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indicesOptions(IndicesOptions.fromOptions(randomBoolean(), false, true, randomBoolean())); request.aliases("alias3"); request.indices("non_matching_*"); @@ -1372,7 +1372,7 @@ public void testWildcardsGetAliasesRequestNoMatchingIndicesDisallowNoIndices() { } public void testWildcardsGetAliasesRequestNoMatchingIndicesAllowNoIndices() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indicesOptions(IndicesOptions.fromOptions(randomBoolean(), true, true, randomBoolean())); request.aliases("alias3"); request.indices("non_matching_*"); @@ -1380,7 +1380,7 @@ public void testWildcardsGetAliasesRequestNoMatchingIndicesAllowNoIndices() { } public void testResolveAllGetAliasesRequest() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); // even if not set, empty means _all if (randomBoolean()) { request.indices("_all"); @@ -1423,7 +1423,7 @@ public void testResolveAllGetAliasesRequest() { } public void testResolveAllGetAliasesRequestExpandWildcardsOpenOnly() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); // set indices options to have wildcards resolved to open indices only (default is open and closed) request.indicesOptions(IndicesOptions.fromOptions(true, false, true, false)); // even if not set, empty means _all @@ -1444,7 +1444,7 @@ public void testResolveAllGetAliasesRequestExpandWildcardsOpenOnly() { } public void testAllGetAliasesRequestNoAuthorizedIndicesAllowNoIndices() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indicesOptions(IndicesOptions.fromOptions(randomBoolean(), true, true, randomBoolean())); request.aliases("alias1"); request.indices("_all"); @@ -1452,7 +1452,7 @@ public void testAllGetAliasesRequestNoAuthorizedIndicesAllowNoIndices() { } public void testAllGetAliasesRequestNoAuthorizedIndicesDisallowNoIndices() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indicesOptions(IndicesOptions.fromOptions(randomBoolean(), false, true, randomBoolean())); request.aliases("alias1"); request.indices("_all"); @@ -1464,7 +1464,7 @@ public void testAllGetAliasesRequestNoAuthorizedIndicesDisallowNoIndices() { } public void testWildcardsGetAliasesRequestNoAuthorizedIndicesAllowNoIndices() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.aliases("alias1"); request.indices("foo*"); request.indicesOptions(IndicesOptions.fromOptions(randomBoolean(), true, true, randomBoolean())); @@ -1472,7 +1472,7 @@ public void testWildcardsGetAliasesRequestNoAuthorizedIndicesAllowNoIndices() { } public void testWildcardsGetAliasesRequestNoAuthorizedIndicesDisallowNoIndices() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indicesOptions(IndicesOptions.fromOptions(randomBoolean(), false, true, randomBoolean())); request.aliases("alias1"); request.indices("foo*"); @@ -1485,7 +1485,7 @@ public void testWildcardsGetAliasesRequestNoAuthorizedIndicesDisallowNoIndices() } public void testResolveAllAliasesGetAliasesRequest() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); if (randomBoolean()) { request.aliases("_all"); } @@ -1515,7 +1515,7 @@ public void testResolveAllAliasesGetAliasesRequest() { } public void testResolveAllAndExplicitAliasesGetAliasesRequest() { - GetAliasesRequest request = new GetAliasesRequest(new String[] { "_all", "explicit" }); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, new String[] { "_all", "explicit" }); if (randomBoolean()) { request.indices("_all"); } @@ -1560,7 +1560,7 @@ public void testResolveAllAndExplicitAliasesGetAliasesRequest() { } public void testResolveAllAndWildcardsAliasesGetAliasesRequest() { - GetAliasesRequest request = new GetAliasesRequest(new String[] { "_all", "foo*", "non_matching_*" }); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, new String[] { "_all", "foo*", "non_matching_*" }); if (randomBoolean()) { request.indices("_all"); } @@ -1587,7 +1587,7 @@ public void testResolveAllAndWildcardsAliasesGetAliasesRequest() { } public void testResolveAliasesWildcardsGetAliasesRequest() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.indices("*bar"); request.aliases("foo*"); final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, GetAliasesAction.NAME); @@ -1603,7 +1603,7 @@ public void testResolveAliasesWildcardsGetAliasesRequest() { } public void testResolveAliasesWildcardsGetAliasesRequestNoAuthorizedIndices() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); // no authorized aliases match bar*, hence aliases are replaced with the no-aliases-expression request.aliases("bar*"); request.indices("*bar"); @@ -1612,7 +1612,7 @@ public void testResolveAliasesWildcardsGetAliasesRequestNoAuthorizedIndices() { } public void testResolveAliasesExclusionWildcardsGetAliasesRequest() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); request.aliases("foo*", "-foobar*"); final AuthorizedIndices authorizedIndices = buildAuthorizedIndices(user, GetAliasesAction.NAME); List indices = resolveIndices(request, authorizedIndices).getLocal(); @@ -1656,7 +1656,7 @@ public void testResolveAliasesExclusionWildcardsGetAliasesRequest() { } public void testResolveAliasesAllGetAliasesRequestNoAuthorizedIndices() { - GetAliasesRequest request = new GetAliasesRequest(); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT); if (randomBoolean()) { request.aliases("_all"); } @@ -1916,7 +1916,7 @@ public void testAliasDateMathExpressionNotSupported() { null ) ); - GetAliasesRequest request = new GetAliasesRequest("").indices("foo", "foofoo"); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "").indices("foo", "foofoo"); List indices = resolveIndices(request, buildAuthorizedIndices(user, GetAliasesAction.NAME)).getLocal(); // the union of all indices and aliases gets returned String[] expectedIndices = new String[] { "", "foo", "foofoo" }; @@ -2220,7 +2220,7 @@ public void testDataStreamResolution() { public void testDataStreamsAreNotVisibleWhenNotIncludedByRequestWithWildcard() { final User user = new User("data-stream-tester2", "data_stream_test2"); - GetAliasesRequest request = new GetAliasesRequest("*"); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, "*"); assertThat(request, instanceOf(IndicesRequest.Replaceable.class)); assertThat(request.includeDataStreams(), is(true)); @@ -2261,7 +2261,7 @@ public void testDataStreamsAreNotVisibleWhenNotIncludedByRequestWithWildcard() { public void testDataStreamsAreNotVisibleWhenNotIncludedByRequestWithoutWildcard() { final User user = new User("data-stream-tester2", "data_stream_test2"); String dataStreamName = "logs-foobar"; - GetAliasesRequest request = new GetAliasesRequest(dataStreamName); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, dataStreamName); assertThat(request, instanceOf(IndicesRequest.Replaceable.class)); assertThat(request.includeDataStreams(), is(true)); @@ -2409,7 +2409,7 @@ public void testBackingIndicesAreVisibleWhenIncludedByRequestWithWildcard() { public void testBackingIndicesAreNotVisibleWhenNotIncludedByRequestWithoutWildcard() { final User user = new User("data-stream-tester2", "data_stream_test2"); String dataStreamName = "logs-foobar"; - GetAliasesRequest request = new GetAliasesRequest(dataStreamName); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, dataStreamName); assertThat(request, instanceOf(IndicesRequest.Replaceable.class)); assertThat(request.includeDataStreams(), is(true)); @@ -2521,7 +2521,7 @@ public void testDataStreamNotAuthorizedWhenBackingIndicesAreAuthorizedViaWildcar final User user = new User("data-stream-tester2", "backing_index_test_wildcards"); boolean failureStore = randomBoolean(); String indexName = failureStore ? ".fs-logs-foobar-*" : ".ds-logs-foobar-*"; - GetAliasesRequest request = new GetAliasesRequest(indexName); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, indexName); assertThat(request, instanceOf(IndicesRequest.Replaceable.class)); assertThat(request.includeDataStreams(), is(true)); @@ -2561,7 +2561,7 @@ public void testDataStreamNotAuthorizedWhenBackingIndicesAreAuthorizedViaNameAnd final User user = new User("data-stream-tester2", "backing_index_test_name"); boolean failureStore = randomBoolean(); String indexName = failureStore ? ".fs-logs-foobar-*" : ".ds-logs-foobar-*"; - GetAliasesRequest request = new GetAliasesRequest(indexName); + GetAliasesRequest request = new GetAliasesRequest(TEST_REQUEST_TIMEOUT, indexName); assertThat(request, instanceOf(IndicesRequest.Replaceable.class)); assertThat(request.includeDataStreams(), is(true)); diff --git a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java index 5eaf27e7b2670..808cd5e0b22b6 100644 --- a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -280,9 +280,12 @@ public void replaceWatcherIndexWithRandomlyNamedIndex(String originalIndexOrAlia ensureGreen(to); AtomicReference originalIndex = new AtomicReference<>(originalIndexOrAlias); - boolean watchesIsAlias = indicesAdmin().prepareGetAliases(originalIndexOrAlias).get().getAliases().isEmpty() == false; + boolean watchesIsAlias = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, originalIndexOrAlias) + .get() + .getAliases() + .isEmpty() == false; if (watchesIsAlias) { - GetAliasesResponse aliasesResponse = indicesAdmin().prepareGetAliases(originalIndexOrAlias).get(); + GetAliasesResponse aliasesResponse = indicesAdmin().prepareGetAliases(TEST_REQUEST_TIMEOUT, originalIndexOrAlias).get(); assertEquals(1, aliasesResponse.getAliases().size()); aliasesResponse.getAliases().entrySet().forEach((aliasRecord) -> { assertEquals(1, aliasRecord.getValue().size());