diff --git a/modules/aggregations/src/internalClusterTest/java/org/elasticsearch/aggregations/bucket/TimeSeriesTsidHashCardinalityIT.java b/modules/aggregations/src/internalClusterTest/java/org/elasticsearch/aggregations/bucket/TimeSeriesTsidHashCardinalityIT.java index eb78101c6181..9380610d730b 100644 --- a/modules/aggregations/src/internalClusterTest/java/org/elasticsearch/aggregations/bucket/TimeSeriesTsidHashCardinalityIT.java +++ b/modules/aggregations/src/internalClusterTest/java/org/elasticsearch/aggregations/bucket/TimeSeriesTsidHashCardinalityIT.java @@ -99,17 +99,12 @@ public void setUp() throws Exception { .setSettings( settings.put(IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(), IndexVersions.NEW_INDEXVERSION_FORMAT).build() ) - .setMapping(mapping) - .get() - ); - - assertAcked( + .setMapping(mapping), indicesAdmin().prepareCreate(afterIndex) .setSettings( settings.put(IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(), IndexVersions.TIME_SERIES_ID_HASHING).build() ) .setMapping(mapping) - .get() ); final TimeSeriesDataset timeSeriesDataset = new TimeSeriesDataset(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java index f5860cedcd98..420f6427a55e 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/IndicesRequestIT.java @@ -15,6 +15,7 @@ import org.elasticsearch.action.admin.indices.cache.clear.TransportClearIndicesCacheAction; import org.elasticsearch.action.admin.indices.close.CloseIndexRequest; import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction; +import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; import org.elasticsearch.action.admin.indices.delete.TransportDeleteIndexAction; import org.elasticsearch.action.admin.indices.flush.FlushRequest; @@ -157,9 +158,11 @@ public void setup() { for (int i = 0; i < numIndices; i++) { indices.add("test" + i); } - for (String index : indices) { - assertAcked(prepareCreate(index).addAlias(new Alias(index + "-alias"))); - } + assertAcked( + indices.stream() + .map(index -> prepareCreate(index).addAlias(new Alias(index + "-alias"))) + .toArray(CreateIndexRequestBuilder[]::new) + ); ensureGreen(); } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java index e8160a311bed..4c25b3262d55 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/indices/create/CreateIndexIT.java @@ -158,8 +158,7 @@ public void testEmptyMappings() throws Exception { } public void testTwoEmptyEqualMappings() throws Exception { - assertAcked(prepareCreate("test1")); - assertAcked(prepareCreate("test2").setMapping(XContentFactory.jsonBuilder().startObject().endObject())); + assertAcked(prepareCreate("test1"), prepareCreate("test2").setMapping(XContentFactory.jsonBuilder().startObject().endObject())); FieldCapabilitiesRequest fieldCapsReq1 = new FieldCapabilitiesRequest(); fieldCapsReq1.indices("test1"); fieldCapsReq1.fields("*"); 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 46b4675adc8a..1dc5e24639c9 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 @@ -649,9 +649,11 @@ public void testRolloverWithClosedIndexInAlias() { final String openNonwriteIndex = "open-index-nonwrite"; final String closedIndex = "closed-index-nonwrite"; final String writeIndexPrefix = "write-index-"; - assertAcked(prepareCreate(openNonwriteIndex).addAlias(new Alias(aliasName)).get()); - assertAcked(prepareCreate(closedIndex).addAlias(new Alias(aliasName)).get()); - assertAcked(prepareCreate(writeIndexPrefix + "000001").addAlias(new Alias(aliasName).writeIndex(true)).get()); + assertAcked( + prepareCreate(openNonwriteIndex).addAlias(new Alias(aliasName)), + prepareCreate(closedIndex).addAlias(new Alias(aliasName)), + prepareCreate(writeIndexPrefix + "000001").addAlias(new Alias(aliasName).writeIndex(true)) + ); ensureGreen(); index(closedIndex, null, "{\"foo\": \"bar\"}"); @@ -674,17 +676,18 @@ public void testRolloverWithClosedWriteIndex() throws Exception { final String openNonwriteIndex = "open-index-nonwrite"; final String closedIndex = "closed-index-nonwrite"; final String writeIndexPrefix = "write-index-"; - assertAcked(prepareCreate(openNonwriteIndex).addAlias(new Alias(aliasName)).get()); - assertAcked(prepareCreate(closedIndex).addAlias(new Alias(aliasName)).get()); - assertAcked(prepareCreate(writeIndexPrefix + "000001").addAlias(new Alias(aliasName).writeIndex(true)).get()); + assertAcked( + prepareCreate(openNonwriteIndex).addAlias(new Alias(aliasName)), + prepareCreate(closedIndex).addAlias(new Alias(aliasName)), + prepareCreate(writeIndexPrefix + "000001").addAlias(new Alias(aliasName).writeIndex(true)) + ); ensureGreen(openNonwriteIndex, closedIndex, writeIndexPrefix + "000001"); index(closedIndex, null, "{\"foo\": \"bar\"}"); index(aliasName, null, "{\"foo\": \"bar\"}"); index(aliasName, null, "{\"foo\": \"bar\"}"); refresh(aliasName); - assertAcked(indicesAdmin().prepareClose(closedIndex).get()); - assertAcked(indicesAdmin().prepareClose(writeIndexPrefix + "000001").get()); + assertAcked(indicesAdmin().prepareClose(closedIndex, writeIndexPrefix + "000001").get()); ensureGreen(aliasName); RolloverResponse rolloverResponse = indicesAdmin().prepareRolloverIndex(aliasName) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/search/TransportSearchIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/search/TransportSearchIT.java index 67576059de1e..5db2651c703d 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/search/TransportSearchIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/search/TransportSearchIT.java @@ -307,11 +307,15 @@ public void testFinalReduce() throws ExecutionException, InterruptedException { public void testWaitForRefreshIndexValidation() throws Exception { int numberOfShards = randomIntBetween(3, 10); - assertAcked(prepareCreate("test1").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards))); - assertAcked(prepareCreate("test2").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards))); - assertAcked(prepareCreate("test3").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards))); - indicesAdmin().prepareAliases().addAlias("test1", "testAlias").get(); - indicesAdmin().prepareAliases().addAlias(new String[] { "test2", "test3" }, "testFailedAlias").get(); + assertAcked( + prepareCreate("test1").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards)), + prepareCreate("test2").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards)), + prepareCreate("test3").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards)) + ); + assertAcked( + indicesAdmin().prepareAliases().addAlias("test1", "testAlias"), + indicesAdmin().prepareAliases().addAlias(new String[] { "test2", "test3" }, "testFailedAlias") + ); long[] validCheckpoints = new long[numberOfShards]; Arrays.fill(validCheckpoints, SequenceNumbers.UNASSIGNED_SEQ_NO); @@ -376,8 +380,10 @@ public void testShardCountLimit() throws Exception { try { final int numPrimaries1 = randomIntBetween(2, 10); final int numPrimaries2 = randomIntBetween(1, 10); - assertAcked(prepareCreate("test1").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numPrimaries1))); - assertAcked(prepareCreate("test2").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numPrimaries2))); + assertAcked( + prepareCreate("test1").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numPrimaries1)), + prepareCreate("test2").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numPrimaries2)) + ); // no exception prepareSearch("test1").get().decRef(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java index cba1d9362c91..d16fbf929855 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java @@ -531,8 +531,10 @@ private void checkBrownFoxTermVector(Fields fields, String fieldName, boolean wi public void testDuelWithAndWithoutTermVectors() throws IOException, ExecutionException, InterruptedException { // setup indices String[] indexNames = new String[] { "with_tv", "without_tv" }; - assertAcked(prepareCreate(indexNames[0]).setMapping("field1", "type=text,term_vector=with_positions_offsets,analyzer=keyword")); - assertAcked(prepareCreate(indexNames[1]).setMapping("field1", "type=text,term_vector=no,analyzer=keyword")); + assertAcked( + prepareCreate(indexNames[1]).setMapping("field1", "type=text,term_vector=no,analyzer=keyword"), + prepareCreate(indexNames[0]).setMapping("field1", "type=text,term_vector=with_positions_offsets,analyzer=keyword") + ); ensureGreen(); // index documents with and without term vectors @@ -1074,9 +1076,7 @@ public void testWithKeywordAndNormalizer() throws IOException, ExecutionExceptio "type=text,term_vector=with_positions_offsets,analyzer=my_analyzer", "field2", "type=text,term_vector=with_positions_offsets,analyzer=keyword" - ) - ); - assertAcked( + ), prepareCreate(indexNames[1]).setSettings(builder.build()) .setMapping("field1", "type=keyword,normalizer=my_normalizer", "field2", "type=keyword") ); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/aliases/IndexAliasesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/aliases/IndexAliasesIT.java index 309bf69f00be..5d2ae93d919b 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/aliases/IndexAliasesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/aliases/IndexAliasesIT.java @@ -323,10 +323,8 @@ public void testSearchingFilteringAliasesSingleIndex() throws Exception { } public void testSearchingFilteringAliasesTwoIndices() throws Exception { - logger.info("--> creating index [test1]"); - assertAcked(prepareCreate("test1").setMapping("name", "type=text")); - logger.info("--> creating index [test2]"); - assertAcked(prepareCreate("test2").setMapping("name", "type=text")); + logger.info("--> creating indices [test1, test2]"); + assertAcked(prepareCreate("test1").setMapping("name", "type=text"), prepareCreate("test2").setMapping("name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -525,8 +523,7 @@ public void testSearchingFilteringAliasesMultipleIndices() throws Exception { public void testDeletingByQueryFilteringAliases() throws Exception { logger.info("--> creating index [test1] and [test2"); - assertAcked(prepareCreate("test1").setMapping("name", "type=text")); - assertAcked(prepareCreate("test2").setMapping("name", "type=text")); + assertAcked(prepareCreate("test1").setMapping("name", "type=text"), prepareCreate("test2").setMapping("name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -580,8 +577,7 @@ public void testDeletingByQueryFilteringAliases() throws Exception { public void testDeleteAliases() throws Exception { logger.info("--> creating index [test1] and [test2]"); - assertAcked(prepareCreate("test1").setMapping("name", "type=text")); - assertAcked(prepareCreate("test2").setMapping("name", "type=text")); + assertAcked(prepareCreate("test1").setMapping("name", "type=text"), prepareCreate("test2").setMapping("name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -619,8 +615,7 @@ public void testDeleteAliases() throws Exception { } logger.info("--> creating index [foo_foo] and [bar_bar]"); - assertAcked(prepareCreate("foo_foo")); - assertAcked(prepareCreate("bar_bar")); + assertAcked(prepareCreate("foo_foo"), prepareCreate("bar_bar")); ensureGreen(); logger.info("--> adding [foo] alias to [foo_foo] and [bar_bar]"); @@ -1163,13 +1158,15 @@ public void testAliasesWithBlocks() { } } - public void testAliasActionRemoveIndex() throws InterruptedException, ExecutionException { - assertAcked(prepareCreate("foo_foo")); - assertAcked(prepareCreate("bar_bar")); - assertAliasesVersionIncreases(new String[] { "foo_foo", "bar_bar" }, () -> { - assertAcked(indicesAdmin().prepareAliases().addAlias("foo_foo", "foo")); - assertAcked(indicesAdmin().prepareAliases().addAlias("bar_bar", "foo")); - }); + public void testAliasActionRemoveIndex() { + assertAcked(prepareCreate("foo_foo"), prepareCreate("bar_bar")); + assertAliasesVersionIncreases( + new String[] { "foo_foo", "bar_bar" }, + () -> assertAcked( + indicesAdmin().prepareAliases().addAlias("bar_bar", "foo"), + indicesAdmin().prepareAliases().addAlias("foo_foo", "foo") + ) + ); IllegalArgumentException iae = expectThrows(IllegalArgumentException.class, indicesAdmin().prepareAliases().removeIndex("foo")); assertEquals( diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/UpdateShardAllocationSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/UpdateShardAllocationSettingsIT.java index 198e27a70c0b..7fb763b5b91a 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/UpdateShardAllocationSettingsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/UpdateShardAllocationSettingsIT.java @@ -39,8 +39,10 @@ public void testEnableRebalance() { // we test with 2 shards since otherwise it's pretty fragile if there are difference in the num or shards such that // all shards are relocated to the second node which is not what we want here. It's solely a test for the settings to take effect final int numShards = 2; - assertAcked(prepareCreate("test").setSettings(indexSettings(numShards, 0))); - assertAcked(prepareCreate("test_1").setSettings(indexSettings(numShards, 0))); + assertAcked( + prepareCreate("test").setSettings(indexSettings(numShards, 0)), + prepareCreate("test_1").setSettings(indexSettings(numShards, 0)) + ); ensureGreen(); assertAllShardsOnNodes("test", firstNode); assertAllShardsOnNodes("test_1", firstNode); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesRequestCacheIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesRequestCacheIT.java index 52492ba7ce65..03fb3d43793c 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesRequestCacheIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesRequestCacheIT.java @@ -321,9 +321,11 @@ public void testQueryRewriteDates() throws Exception { public void testQueryRewriteDatesWithNow() throws Exception { Client client = client(); Settings settings = indexSettings(1, 0).put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true).build(); - assertAcked(indicesAdmin().prepareCreate("index-1").setMapping("d", "type=date").setSettings(settings).get()); - assertAcked(indicesAdmin().prepareCreate("index-2").setMapping("d", "type=date").setSettings(settings).get()); - assertAcked(indicesAdmin().prepareCreate("index-3").setMapping("d", "type=date").setSettings(settings).get()); + assertAcked( + indicesAdmin().prepareCreate("index-1").setMapping("d", "type=date").setSettings(settings), + indicesAdmin().prepareCreate("index-2").setMapping("d", "type=date").setSettings(settings), + indicesAdmin().prepareCreate("index-3").setMapping("d", "type=date").setSettings(settings) + ); ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC); DateFormatter formatter = DateFormatter.forPattern("strict_date_optional_time"); indexRandom( diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetFieldMappingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetFieldMappingsIT.java index e6927aefbc5c..71fcb25c2e0b 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetFieldMappingsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/SimpleGetFieldMappingsIT.java @@ -81,9 +81,10 @@ private XContentBuilder getMappingForType() throws IOException { } public void testGetFieldMappings() throws Exception { - - assertAcked(prepareCreate("indexa").setMapping(getMappingForType())); - assertAcked(indicesAdmin().prepareCreate("indexb").setMapping(getMappingForType())); + assertAcked( + prepareCreate("indexa").setMapping(getMappingForType()), + indicesAdmin().prepareCreate("indexb").setMapping(getMappingForType()) + ); // Get mappings by full name GetFieldMappingsResponse response = indicesAdmin().prepareGetFieldMappings("indexa").setFields("field1", "obj.subfield").get(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/monitor/metrics/NodeIndexingMetricsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/monitor/metrics/NodeIndexingMetricsIT.java index e4d44212f285..1635a08e1768 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/monitor/metrics/NodeIndexingMetricsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/monitor/metrics/NodeIndexingMetricsIT.java @@ -336,8 +336,10 @@ public void testPrimaryDocumentRejectionMetricsArePublishing() { plugin.resetMeter(); final int numberOfShards = randomIntBetween(1, 5); - assertAcked(prepareCreate("test-one", Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards)).get()); - assertAcked(prepareCreate("test-two", Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)).get()); + assertAcked( + prepareCreate("test-one", Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards)), + prepareCreate("test-two", Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) + ); final BulkRequest bulkRequestOne = new BulkRequest(); final int batchCountOne = randomIntBetween(50, 100); @@ -397,8 +399,10 @@ public void testPrimaryDocumentRejectionMetricsFluctuatingOverTime() throws Exce ensureStableCluster(2); // for simplicity do not mix small and big documents in single index/shard - assertAcked(prepareCreate("test-index-one", Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)).get()); - assertAcked(prepareCreate("test-index-two", Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)).get()); + assertAcked( + prepareCreate("test-index-one", Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)), + prepareCreate("test-index-two", Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) + ); final TestTelemetryPlugin plugin = internalCluster().getInstance(PluginsService.class, dataNode) .filterPlugins(TestTelemetryPlugin.class) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java index 80c47d6180db..affa371d92aa 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/metrics/TopHitsIT.java @@ -119,10 +119,10 @@ public static String randomExecutionHint() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("idx").setMapping(TERMS_AGGS_FIELD, "type=keyword", "text", "type=text,store=true")); - assertAcked(prepareCreate("field-collapsing").setMapping("group", "type=keyword")); - createIndex("empty"); assertAcked( + prepareCreate("idx").setMapping(TERMS_AGGS_FIELD, "type=keyword", "text", "type=text,store=true"), + prepareCreate("field-collapsing").setMapping("group", "type=keyword"), + prepareCreate("empty"), prepareCreate("articles").setMapping( jsonBuilder().startObject() .startObject("_doc") diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/QueryRewriteContextIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/QueryRewriteContextIT.java index f4aa34c9b47b..965fd0d8011c 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/QueryRewriteContextIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/QueryRewriteContextIT.java @@ -154,8 +154,10 @@ public void testResolvedIndices_TransportSearchAction() { public void testResolvedIndices_TransportExplainAction() { final String[] indices = { "test1", "test2" }; createIndex(indices); - assertAcked(indicesAdmin().prepareAliases().addAlias("test1", "alias1")); - assertAcked(indicesAdmin().prepareAliases().addAlias(indices, "alias2")); + assertAcked( + indicesAdmin().prepareAliases().addAlias("test1", "alias1"), + indicesAdmin().prepareAliases().addAlias(indices, "alias2") + ); assertResolvedIndices(client().prepareExplain("test1", "1"), Set.of("test1"), Set.of("test1"), r -> {}); assertResolvedIndices(client().prepareExplain("alias1", "1"), Set.of("alias1"), Set.of("test1"), r -> {}); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java index 6cca07bfacc9..fe49ce57d040 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/fieldcaps/FieldCapabilitiesIT.java @@ -15,6 +15,7 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.admin.cluster.reroute.ClusterRerouteUtils; import org.elasticsearch.action.admin.indices.close.CloseIndexRequest; +import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.fieldcaps.FieldCapabilities; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesFailure; import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest; @@ -380,8 +381,10 @@ public void testTwoIndicesOneClosedIgnoreUnavailable() { } public void testWithIndexFilter() throws InterruptedException { - assertAcked(prepareCreate("index-1").setMapping("timestamp", "type=date", "field1", "type=keyword")); - assertAcked(prepareCreate("index-2").setMapping("timestamp", "type=date", "field1", "type=long")); + assertAcked( + prepareCreate("index-1").setMapping("timestamp", "type=date", "field1", "type=keyword"), + prepareCreate("index-2").setMapping("timestamp", "type=date", "field1", "type=long") + ); List reqs = new ArrayList<>(); reqs.add(prepareIndex("index-1").setSource("timestamp", "2015-07-08")); @@ -474,8 +477,7 @@ public void testFieldMetricsAndDimensions() { public void testFailures() throws InterruptedException { // in addition to the existing "old_index" and "new_index", create two where the test query throws an error on rewrite - assertAcked(prepareCreate("index1-error")); - assertAcked(prepareCreate("index2-error")); + assertAcked(prepareCreate("index1-error"), prepareCreate("index2-error")); ensureGreen("index1-error", "index2-error"); FieldCapabilitiesResponse response = client().prepareFieldCaps() .setFields("*") @@ -503,9 +505,7 @@ private void populateTimeRangeIndices() throws Exception { internalCluster().ensureAtLeastNumDataNodes(2); assertAcked( prepareCreate("log-index-1").setSettings(indexSettings(between(1, 5), 1)) - .setMapping("timestamp", "type=date", "field1", "type=keyword") - ); - assertAcked( + .setMapping("timestamp", "type=date", "field1", "type=keyword"), prepareCreate("log-index-2").setSettings(indexSettings(between(1, 5), 1)) .setMapping("timestamp", "type=date", "field1", "type=long") ); @@ -666,9 +666,11 @@ public void testManyIndicesWithSameMapping() { } """; String[] indices = IntStream.range(0, between(1, 9)).mapToObj(n -> "test_many_index_" + n).toArray(String[]::new); - for (String index : indices) { - assertAcked(indicesAdmin().prepareCreate(index).setMapping(mapping).get()); - } + assertAcked( + Arrays.stream(indices) + .map(index -> indicesAdmin().prepareCreate(index).setMapping(mapping)) + .toArray(CreateIndexRequestBuilder[]::new) + ); FieldCapabilitiesRequest request = new FieldCapabilitiesRequest(); request.indices("test_many_index_*"); request.fields("*"); @@ -787,9 +789,11 @@ public void testIndexMode() throws Exception { Settings settings = Settings.builder().put("mode", "time_series").putList("routing_path", List.of("hostname")).build(); int numIndices = between(1, 5); for (int i = 0; i < numIndices; i++) { - assertAcked(indicesAdmin().prepareCreate("test_metrics_" + i).setSettings(settings).setMapping(metricsMapping).get()); + assertAcked( + indicesAdmin().prepareCreate("test_metrics_" + i).setSettings(settings).setMapping(metricsMapping), + indicesAdmin().prepareCreate("test_old_metrics_" + i).setMapping(metricsMapping) + ); indexModes.put("test_metrics_" + i, IndexMode.TIME_SERIES); - assertAcked(indicesAdmin().prepareCreate("test_old_metrics_" + i).setMapping(metricsMapping).get()); indexModes.put("test_old_metrics_" + i, IndexMode.STANDARD); } } @@ -808,9 +812,11 @@ public void testIndexMode() throws Exception { Settings settings = Settings.builder().put("mode", "logsdb").build(); int numIndices = between(1, 5); for (int i = 0; i < numIndices; i++) { - assertAcked(indicesAdmin().prepareCreate("test_logs_" + i).setSettings(settings).setMapping(logsMapping).get()); + assertAcked( + indicesAdmin().prepareCreate("test_logs_" + i).setSettings(settings).setMapping(logsMapping), + indicesAdmin().prepareCreate("test_old_logs_" + i).setMapping(logsMapping) + ); indexModes.put("test_logs_" + i, IndexMode.LOGSDB); - assertAcked(indicesAdmin().prepareCreate("test_old_logs_" + i).setMapping(logsMapping).get()); indexModes.put("test_old_logs_" + i, IndexMode.STANDARD); } } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/sort/FieldSortIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/sort/FieldSortIT.java index bf7a315040ca..f407c14c48c5 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/sort/FieldSortIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/sort/FieldSortIT.java @@ -2003,10 +2003,12 @@ public void testLongSortOptimizationCorrectResults() { } public void testSortMixedFieldTypes() { - assertAcked(prepareCreate("index_long").setMapping("foo", "type=long").get()); - assertAcked(prepareCreate("index_integer").setMapping("foo", "type=integer").get()); - assertAcked(prepareCreate("index_double").setMapping("foo", "type=double").get()); - assertAcked(prepareCreate("index_keyword").setMapping("foo", "type=keyword").get()); + assertAcked( + prepareCreate("index_long").setMapping("foo", "type=long"), + prepareCreate("index_integer").setMapping("foo", "type=integer"), + prepareCreate("index_double").setMapping("foo", "type=double"), + prepareCreate("index_keyword").setMapping("foo", "type=keyword") + ); prepareIndex("index_long").setId("1").setSource("foo", "123").get(); prepareIndex("index_integer").setId("1").setSource("foo", "123").get(); @@ -2038,9 +2040,11 @@ public void testSortMixedFieldTypes() { } public void testSortMixedFieldTypesWithNoDocsForOneType() { - assertAcked(prepareCreate("index_long").setMapping("foo", "type=long").get()); - assertAcked(prepareCreate("index_other").setMapping("bar", "type=keyword").get()); - assertAcked(prepareCreate("index_double").setMapping("foo", "type=double").get()); + assertAcked( + prepareCreate("index_long").setMapping("foo", "type=long"), + prepareCreate("index_other").setMapping("bar", "type=keyword"), + prepareCreate("index_double").setMapping("foo", "type=double") + ); prepareIndex("index_long").setId("1").setSource("foo", "123").get(); prepareIndex("index_long").setId("2").setSource("foo", "124").get(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/CloneSnapshotIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/CloneSnapshotIT.java index 209195301a65..caf7f852cc15 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/CloneSnapshotIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/CloneSnapshotIT.java @@ -565,9 +565,7 @@ public void testSnapshotQueuedAfterCloneFromBrokenSourceSnapshot() throws Except assertSuccessful(sn1); assertSuccessful(sn2); assertSuccessful(sn3); - assertAcked(clone1.get()); - assertAcked(clone2.get()); - assertAcked(clone3.get()); + assertAcked(clone1, clone2, clone3); } public void testStartSnapshotWithSuccessfulShardClonePendingFinalization() throws Exception { @@ -624,8 +622,7 @@ public void testStartCloneWithSuccessfulShardClonePendingFinalization() throws E unblockNode(repoName, masterName); awaitNoMoreRunningOperations(masterName); awaitMasterFinishRepoOperations(); - assertAcked(blockedClone.get()); - assertAcked(otherClone.get()); + assertAcked(blockedClone, otherClone); assertEquals(getSnapshot(repoName, cloneName).state(), SnapshotState.SUCCESS); assertEquals(getSnapshot(repoName, otherCloneName).state(), SnapshotState.SUCCESS); } @@ -732,8 +729,7 @@ public void testManyConcurrentClonesStartOutOfOrder() throws Exception { awaitClusterState(state -> SnapshotsInProgress.get(state).forRepo(repoName).stream().anyMatch(entry -> entry.state().completed())); repo.unblock(); - assertAcked(clone1.get()); - assertAcked(clone2.get()); + assertAcked(clone1, clone2); } public void testRemoveFailedCloneFromCSWithoutIO() throws Exception { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java index de62c0152817..da798269f557 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java @@ -478,8 +478,7 @@ public void testCascadedAborts() throws Exception { assertThat(thirdSnapshotResponse.get().getSnapshotInfo().state(), is(SnapshotState.FAILED)); logger.info("--> verify both deletes have completed"); - assertAcked(deleteSnapshotsResponse.get()); - assertAcked(allDeletedResponse.get()); + assertAcked(deleteSnapshotsResponse, allDeletedResponse); logger.info("--> verify that all snapshots are gone"); assertThat(clusterAdmin().prepareGetSnapshots(TEST_REQUEST_TIMEOUT, repoName).get().getSnapshots(), empty()); @@ -715,8 +714,7 @@ public void testQueuedOperationsOnMasterDisconnect() throws Exception { networkDisruption.stopDisrupting(); logger.info("--> make sure all failing requests get a response"); - assertAcked(firstDeleteFuture.get()); - assertAcked(secondDeleteFuture.get()); + assertAcked(firstDeleteFuture, secondDeleteFuture); expectThrows(SnapshotException.class, createSnapshot); awaitNoMoreRunningOperations(); } @@ -1014,8 +1012,7 @@ public void testBackToBackQueuedDeletes() throws Exception { awaitNDeletionsInProgress(2); unblockNode(repoName, masterName); - assertAcked(deleteSnapshotOne.get()); - assertAcked(deleteSnapshotTwo.get()); + assertAcked(deleteSnapshotOne, deleteSnapshotTwo); final RepositoryData repositoryData = getRepositoryData(repoName); assertThat(repositoryData.getSnapshotIds(), empty()); @@ -1890,8 +1887,7 @@ public void testIndexDeletedWhileSnapshotAndCloneQueuedAfterClone() throws Excep assertSuccessful(snapshot3); unblockNode(repository, master); - assertAcked(cloneSnapshot.get()); - assertAcked(cloneSnapshot2.get()); + assertAcked(cloneSnapshot, cloneSnapshot2); assertAcked(startDeleteSnapshot(repository, cloneTarget).get()); assertThat( @@ -2031,8 +2027,7 @@ public void testCloneQueuedAfterMissingShard() throws Exception { awaitNumberOfSnapshotsInProgress(2); unblockNode(repository, master); - assertAcked(deleteFuture.get()); - assertAcked(cloneFuture.get()); + assertAcked(deleteFuture, cloneFuture); awaitNoMoreRunningOperations(); assertThat(snapshot1.get().getSnapshotInfo().state(), is(SnapshotState.PARTIAL)); } @@ -2109,8 +2104,7 @@ public void testSnapshotAndCloneQueuedAfterMissingShard() throws Exception { awaitNumberOfSnapshotsInProgress(3); unblockNode(repository, master); - assertAcked(deleteFuture.get()); - assertAcked(cloneFuture.get()); + assertAcked(deleteFuture, cloneFuture); awaitNoMoreRunningOperations(); assertThat(snapshot1.get().getSnapshotInfo().state(), is(SnapshotState.PARTIAL)); assertThat(snapshot2.get().getSnapshotInfo().state(), is(SnapshotState.PARTIAL)); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java index 588753f570c9..0d359300bbdc 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/DedicatedClusterSnapshotRestoreIT.java @@ -664,8 +664,7 @@ public void testRestoreShrinkIndex() throws Exception { createSnapshot(repo, snapshot, Collections.singletonList(shrunkIdx)); logger.info("--> delete index and stop the data node"); - assertAcked(indicesAdmin().prepareDelete(sourceIdx).get()); - assertAcked(indicesAdmin().prepareDelete(shrunkIdx).get()); + assertAcked(indicesAdmin().prepareDelete(sourceIdx), indicesAdmin().prepareDelete(shrunkIdx)); internalCluster().stopRandomDataNode(); clusterAdmin().prepareHealth(TEST_REQUEST_TIMEOUT).setTimeout(TimeValue.timeValueSeconds(30)).setWaitForNodes("1"); diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexStateServiceBatchingTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexStateServiceBatchingTests.java index 272fad595971..e07fc038949c 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexStateServiceBatchingTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexStateServiceBatchingTests.java @@ -80,8 +80,7 @@ public void testBatchOpenIndices() throws Exception { block1.run(); // release block // assert that the requests were acknowledged - assertAcked(future1.get()); - assertAcked(future2.get()); + assertAcked(future1, future2); // and assert that all the indices are open for (String index : List.of("test-1", "test-2", "test-3")) { diff --git a/test/framework/src/main/java/org/elasticsearch/search/aggregations/metrics/AbstractGeoTestCase.java b/test/framework/src/main/java/org/elasticsearch/search/aggregations/metrics/AbstractGeoTestCase.java index 29112b4bd8f5..ee11530ab44b 100644 --- a/test/framework/src/main/java/org/elasticsearch/search/aggregations/metrics/AbstractGeoTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/search/aggregations/metrics/AbstractGeoTestCase.java @@ -143,9 +143,8 @@ public void setupSuiteScopeCluster() throws Exception { } singleCentroid = computeCentroid(allSingleVal); multiCentroid = computeCentroid(allMultiVal); - assertAcked(prepareCreate(EMPTY_IDX_NAME).setMapping(SINGLE_VALUED_FIELD_NAME, "type=" + fieldTypeName())); - assertAcked( + prepareCreate(EMPTY_IDX_NAME).setMapping(SINGLE_VALUED_FIELD_NAME, "type=" + fieldTypeName()), prepareCreate(DATELINE_IDX_NAME).setMapping( SINGLE_VALUED_FIELD_NAME, "type=" + fieldTypeName(), diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index b9a097b4e76f..c70664940bac 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -759,24 +759,10 @@ public Settings indexSettings() { } /** - * Creates one or more indices and asserts that the indices are acknowledged. If one of the indices - * already exists this method will fail and wipe all the indices created so far. + * Creates one or more indices and asserts that the indices are acknowledged. */ public final void createIndex(String... names) { - - List created = new ArrayList<>(); - for (String name : names) { - boolean success = false; - try { - assertAcked(prepareCreate(name)); - created.add(name); - success = true; - } finally { - if (success == false && created.isEmpty() == false) { - cluster().wipeIndices(created.toArray(new String[created.size()])); - } - } - } + assertAcked(Arrays.stream(names).map(this::prepareCreate).toArray(CreateIndexRequestBuilder[]::new)); } /** diff --git a/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java b/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java index 6c501898d5fe..40aee8eed423 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java +++ b/test/framework/src/main/java/org/elasticsearch/test/hamcrest/ElasticsearchAssertions.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.RequestBuilder; import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequestBuilder; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; +import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; import org.elasticsearch.action.bulk.BulkResponse; @@ -107,8 +108,42 @@ public static void assertAcked(RequestBuilder future) { - assertAcked(future.actionGet()); + @SafeVarargs + public static void assertAcked(RequestBuilder... builders) { + final List> futures = new ArrayList<>(builders.length); + for (RequestBuilder response : builders) { + futures.add(response.execute()); + } + Throwable tr = null; + for (var future : futures) { + try { + assertAcked(future.get()); + } catch (Throwable t) { + tr = ExceptionsHelper.useOrSuppress(tr, t); + } + } + if (tr != null) { + throw new AssertionError(tr); + } + } + + @SafeVarargs + public static void assertAcked(ActionFuture... futures) { + if (futures.length == 1) { + assertAcked(futures[0].actionGet()); + return; + } + Throwable tr = null; + for (var future : futures) { + try { + assertAcked(future.get()); + } catch (Throwable t) { + tr = ExceptionsHelper.useOrSuppress(tr, t); + } + } + if (tr != null) { + throw new AssertionError(tr); + } } public static void assertAcked(RequestBuilder builder, TimeValue timeValue) { @@ -131,6 +166,28 @@ public static void assertAcked(IsAcknowledgedSupplier response) { * Assert that an index creation was fully acknowledged, meaning that both the index creation cluster * state update was successful and that the requisite number of shard copies were started before returning. */ + public static void assertAcked(CreateIndexRequestBuilder... requests) { + if (requests.length == 1) { + assertAcked(requests[0]); + return; + } + final List> futures = new ArrayList<>(requests.length); + for (CreateIndexRequestBuilder response : requests) { + futures.add(response.execute()); + } + Throwable tr = null; + for (Future future : futures) { + try { + assertAcked(future.get()); + } catch (Throwable t) { + tr = ExceptionsHelper.useOrSuppress(tr, t); + } + } + if (tr != null) { + throw new AssertionError(tr); + } + } + public static void assertAcked(CreateIndexResponse response) { assertThat(response.getClass().getSimpleName() + " failed - not acked", response.isAcknowledged(), is(true)); assertThat( 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 e8940b2f4175..21b6c9db668a 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 @@ -605,8 +605,8 @@ public void testUnfollowNonExistingIndex() { public void testFollowNonExistentIndex() throws Exception { String indexSettings = getIndexSettings(1, 0); - assertAcked(leaderClient().admin().indices().prepareCreate("test-leader").setSource(indexSettings, XContentType.JSON).get()); assertAcked( + leaderClient().admin().indices().prepareCreate("test-leader").setSource(indexSettings, XContentType.JSON), followerClient().admin() .indices() .prepareCreate("test-follower")