diff --git a/benchmarks/src/main/java/org/opensearch/benchmark/routing/allocation/Allocators.java b/benchmarks/src/main/java/org/opensearch/benchmark/routing/allocation/Allocators.java index 7c00fa5abb53f..d700b9dab2cf3 100644 --- a/benchmarks/src/main/java/org/opensearch/benchmark/routing/allocation/Allocators.java +++ b/benchmarks/src/main/java/org/opensearch/benchmark/routing/allocation/Allocators.java @@ -111,7 +111,7 @@ public static DiscoveryNode newNode(String nodeId, Map attribute nodeId, new TransportAddress(TransportAddress.META_ADDRESS, portGenerator.incrementAndGet()), attributes, - Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE), + Sets.newHashSet(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE), Version.CURRENT ); } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index ff79cc5df0df0..5925d1a4d8164 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -115,7 +115,7 @@ dependencies { api 'de.thetaphi:forbiddenapis:3.2' api 'com.avast.gradle:gradle-docker-compose-plugin:0.14.12' api 'org.apache.maven:maven-model:3.6.2' - api 'com.networknt:json-schema-validator:1.0.36' + api 'com.networknt:json-schema-validator:1.0.67' api "com.fasterxml.jackson.core:jackson-databind:${props.getProperty('jackson')}" testFixturesApi "junit:junit:${props.getProperty('junit')}" diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy index c97791f3c2c66..edc3b883dddb3 100644 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/opensearch/gradle/test/ClusterFormationTasks.groovy @@ -153,7 +153,8 @@ class ClusterFormationTasks { } boolean supportsInitialClusterManagerNodes = hasBwcNodes == false || config.bwcVersion.onOrAfter("7.0.0") if (esConfig['discovery.type'] == null && config.getAutoSetClusterManagerNodes() && supportsInitialClusterManagerNodes) { - esConfig['cluster.initial_master_nodes'] = nodes.stream().map({ n -> + // To promote inclusive language, the old setting name is deprecated in 2.0.0 + esConfig[node.nodeVersion.onOrAfter("2.0.0") ? 'cluster.initial_cluster_manager_nodes' : 'cluster.initial_master_nodes'] = nodes.stream().map({ n -> if (n.config.settings['node.name'] == null) { return "node-" + n.nodeNum } else { diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java index a94ebacd460a5..ef52adab6377a 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java @@ -361,7 +361,12 @@ private void commonNodeConfig(OpenSearchNode node, String nodeNames, OpenSearchN .collect(Collectors.toList()) .forEach(node.defaultConfig::remove); if (nodeNames != null && node.settings.getOrDefault("discovery.type", "anything").equals("single-node") == false) { - node.defaultConfig.put("cluster.initial_master_nodes", "[" + nodeNames + "]"); + // To promote inclusive language, the old setting name is deprecated n 2.0.0 + if (node.getVersion().onOrAfter("2.0.0")) { + node.defaultConfig.put("cluster.initial_cluster_manager_nodes", "[" + nodeNames + "]"); + } else { + node.defaultConfig.put("cluster.initial_master_nodes", "[" + nodeNames + "]"); + } } node.defaultConfig.put("discovery.seed_providers", "file"); node.defaultConfig.put("discovery.seed_hosts", "[]"); diff --git a/buildSrc/version.properties b/buildSrc/version.properties index 5202b60cbdc20..1486ce4b6e44c 100644 --- a/buildSrc/version.properties +++ b/buildSrc/version.properties @@ -11,7 +11,7 @@ spatial4j = 0.7 jts = 1.15.0 jackson = 2.12.6 snakeyaml = 1.26 -icu4j = 68.2 +icu4j = 70.1 supercsv = 2.4.0 log4j = 2.17.1 slf4j = 1.6.2 diff --git a/client/rest/src/main/java/org/opensearch/client/Node.java b/client/rest/src/main/java/org/opensearch/client/Node.java index bcf78b763f048..952823cf29d6c 100644 --- a/client/rest/src/main/java/org/opensearch/client/Node.java +++ b/client/rest/src/main/java/org/opensearch/client/Node.java @@ -210,21 +210,21 @@ public Roles(final Set roles) { } /** - * Returns whether or not the node could be elected cluster_manager. + * Returns whether or not the node could be elected cluster-manager. */ public boolean isMasterEligible() { - return roles.contains("master"); + return roles.contains("master") || roles.contains("cluster_manager"); } /** - * Teturns whether or not the node stores data. + * Returns whether or not the node stores data. */ public boolean isData() { return roles.contains("data"); } /** - * Teturns whether or not the node runs ingest pipelines. + * Returns whether or not the node runs ingest pipelines. */ public boolean isIngest() { return roles.contains("ingest"); diff --git a/distribution/docker/docker-compose.yml b/distribution/docker/docker-compose.yml index f648a514e1db4..5ed2b159ffe2b 100644 --- a/distribution/docker/docker-compose.yml +++ b/distribution/docker/docker-compose.yml @@ -5,7 +5,7 @@ services: image: opensearch:test environment: - node.name=opensearch-1 - - cluster.initial_master_nodes=opensearch-1,opensearch-2 + - cluster.initial_cluster_manager_nodes=opensearch-1,opensearch-2 - discovery.seed_hosts=opensearch-2:9300 - cluster.name=opensearch - bootstrap.memory_lock=true @@ -29,7 +29,7 @@ services: image: opensearch:test environment: - node.name=opensearch-2 - - cluster.initial_master_nodes=opensearch-1,opensearch-2 + - cluster.initial_cluster_manager_nodes=opensearch-1,opensearch-2 - discovery.seed_hosts=opensearch-1:9300 - cluster.name=opensearch - bootstrap.memory_lock=true diff --git a/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml b/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml index af1ed146c41aa..95ea022696942 100644 --- a/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml +++ b/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml @@ -1,13 +1,31 @@ +--- +"Test cat nodes output - before 2.0.0": + - skip: + version: "2.0.0 - " + reason: "master is replaced by cluster_manager in 2.0.0" + + - do: + cat.nodes: + v: true + + - match: + $body: | + /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n + ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + --- "Test cat nodes output": + - skip: + version: " - 1.4.99" + reason: "cluster_manager is introduced in 2.0.0" - do: cat.nodes: {} - match: $body: | - / #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name - ^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + / #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role cluster_manager name + ^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ - do: cat.nodes: @@ -15,8 +33,8 @@ - match: $body: | - /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n - ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ cluster_manager \s+ name \n + ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ - do: cat.nodes: diff --git a/distribution/src/config/opensearch.yml b/distribution/src/config/opensearch.yml index accc920e6aa17..2188fbe600cbf 100644 --- a/distribution/src/config/opensearch.yml +++ b/distribution/src/config/opensearch.yml @@ -67,9 +67,9 @@ ${path.logs} # #discovery.seed_hosts: ["host1", "host2"] # -# Bootstrap the cluster using an initial set of master-eligible nodes: +# Bootstrap the cluster using an initial set of cluster-manager-eligible nodes: # -#cluster.initial_master_nodes: ["node-1", "node-2"] +#cluster.initial_cluster_manager_nodes: ["node-1", "node-2"] # # For more information, consult the discovery and cluster formation module documentation. # diff --git a/modules/analysis-common/src/internalClusterTest/java/org/opensearch/analysis/common/QueryStringWithAnalyzersIT.java b/modules/analysis-common/src/internalClusterTest/java/org/opensearch/analysis/common/QueryStringWithAnalyzersIT.java index 02c3bdfd70ec2..8c2f83bf83d85 100644 --- a/modules/analysis-common/src/internalClusterTest/java/org/opensearch/analysis/common/QueryStringWithAnalyzersIT.java +++ b/modules/analysis-common/src/internalClusterTest/java/org/opensearch/analysis/common/QueryStringWithAnalyzersIT.java @@ -73,7 +73,7 @@ public void testCustomWordDelimiterQueryString() { .put("analysis.filter.custom_word_delimiter.split_on_numerics", "false") .put("analysis.filter.custom_word_delimiter.stem_english_possessive", "false") ) - .addMapping("type1", "field1", "type=text,analyzer=my_analyzer", "field2", "type=text,analyzer=my_analyzer") + .setMapping("field1", "type=text,analyzer=my_analyzer", "field2", "type=text,analyzer=my_analyzer") ); client().prepareIndex("test").setId("1").setSource("field1", "foo bar baz", "field2", "not needed").get(); diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java index a8dd2d2578541..57c959a4f0b65 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HighlighterWithAnalyzersTests.java @@ -149,8 +149,7 @@ public void testMultiPhraseCutoff() throws IOException { * query. We cut off and extract terms if there are more than 16 terms in the query */ assertAcked( - prepareCreate("test").addMapping( - "test", + prepareCreate("test").setMapping( "body", "type=text,analyzer=custom_analyzer," + "search_analyzer=custom_analyzer,term_vector=with_positions_offsets" ) @@ -225,8 +224,7 @@ public void testSynonyms() throws IOException { assertAcked( prepareCreate("test").setSettings(builder.build()) - .addMapping( - "type1", + .setMapping( "field1", "type=text,term_vector=with_positions_offsets,search_analyzer=synonym," + "analyzer=standard,index_options=offsets" ) @@ -335,8 +333,7 @@ public void testPhrasePrefix() throws IOException { assertAcked( prepareCreate("second_test_index").setSettings(builder.build()) - .addMapping( - "doc", + .setMapping( "field4", "type=text,term_vector=with_positions_offsets,analyzer=synonym", "field3", diff --git a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/AppendProcessorTests.java b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/AppendProcessorTests.java index 9a507338df332..7caa63792f347 100644 --- a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/AppendProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/AppendProcessorTests.java @@ -147,7 +147,7 @@ public void testConvertScalarToList() throws Exception { public void testAppendMetadataExceptVersion() throws Exception { // here any metadata field value becomes a list, which won't make sense in most of the cases, // but support for append is streamlined like for set so we test it - Metadata randomMetadata = randomFrom(Metadata.INDEX, Metadata.TYPE, Metadata.ID, Metadata.ROUTING); + Metadata randomMetadata = randomFrom(Metadata.INDEX, Metadata.ID, Metadata.ROUTING); List values = new ArrayList<>(); Processor appendProcessor; if (randomBoolean()) { diff --git a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/SetProcessorTests.java b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/SetProcessorTests.java index 0e7ba5556fbf8..923757b605108 100644 --- a/modules/ingest-common/src/test/java/org/opensearch/ingest/common/SetProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/opensearch/ingest/common/SetProcessorTests.java @@ -116,7 +116,7 @@ public void testSetExistingNullFieldWithOverrideDisabled() throws Exception { } public void testSetMetadataExceptVersion() throws Exception { - Metadata randomMetadata = randomFrom(Metadata.INDEX, Metadata.TYPE, Metadata.ID, Metadata.ROUTING); + Metadata randomMetadata = randomFrom(Metadata.INDEX, Metadata.ID, Metadata.ROUTING); Processor processor = createSetProcessor(randomMetadata.getFieldName(), "_value", true, false); IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random()); processor.execute(ingestDocument); diff --git a/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java b/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java index 450e70c3c8938..952b00dda608c 100644 --- a/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java +++ b/modules/lang-expression/src/internalClusterTest/java/org/opensearch/script/expression/MoreExpressionIT.java @@ -158,7 +158,7 @@ public void testScore() throws Exception { } public void testDateMethods() throws Exception { - OpenSearchAssertions.assertAcked(prepareCreate("test").addMapping("doc", "date0", "type=date", "date1", "type=date")); + OpenSearchAssertions.assertAcked(prepareCreate("test").setMapping("date0", "type=date", "date1", "type=date")); ensureGreen("test"); indexRandom( true, @@ -188,7 +188,7 @@ public void testDateMethods() throws Exception { } public void testDateObjectMethods() throws Exception { - OpenSearchAssertions.assertAcked(prepareCreate("test").addMapping("doc", "date0", "type=date", "date1", "type=date")); + OpenSearchAssertions.assertAcked(prepareCreate("test").setMapping("date0", "type=date", "date1", "type=date")); ensureGreen("test"); indexRandom( true, @@ -219,7 +219,7 @@ public void testDateObjectMethods() throws Exception { public void testMultiValueMethods() throws Exception { OpenSearchAssertions.assertAcked( - prepareCreate("test").addMapping("doc", "double0", "type=double", "double1", "type=double", "double2", "type=double") + prepareCreate("test").setMapping("double0", "type=double", "double1", "type=double", "double2", "type=double") ); ensureGreen("test"); @@ -322,7 +322,7 @@ public void testMultiValueMethods() throws Exception { } public void testInvalidDateMethodCall() throws Exception { - OpenSearchAssertions.assertAcked(prepareCreate("test").addMapping("doc", "double", "type=double")); + OpenSearchAssertions.assertAcked(prepareCreate("test").setMapping("double", "type=double")); ensureGreen("test"); indexRandom(true, client().prepareIndex("test").setId("1").setSource("double", "178000000.0")); try { @@ -343,7 +343,7 @@ public void testInvalidDateMethodCall() throws Exception { } public void testSparseField() throws Exception { - OpenSearchAssertions.assertAcked(prepareCreate("test").addMapping("doc", "x", "type=long", "y", "type=long")); + OpenSearchAssertions.assertAcked(prepareCreate("test").setMapping("x", "type=long", "y", "type=long")); ensureGreen("test"); indexRandom( true, @@ -528,7 +528,7 @@ public void testSpecialValueVariable() throws Exception { public void testStringSpecialValueVariable() throws Exception { // i.e. expression script for term aggregations, which is not allowed - assertAcked(client().admin().indices().prepareCreate("test").addMapping("doc", "text", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("text", "type=keyword").get()); ensureGreen("test"); indexRandom( true, diff --git a/modules/mapper-extras/src/test/java/org/opensearch/index/query/RankFeatureQueryBuilderTests.java b/modules/mapper-extras/src/test/java/org/opensearch/index/query/RankFeatureQueryBuilderTests.java index b0d7bb9d2e14e..e183ba6f6735c 100644 --- a/modules/mapper-extras/src/test/java/org/opensearch/index/query/RankFeatureQueryBuilderTests.java +++ b/modules/mapper-extras/src/test/java/org/opensearch/index/query/RankFeatureQueryBuilderTests.java @@ -62,7 +62,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws "_doc", new CompressedXContent( Strings.toString( - PutMappingRequest.buildFromSimplifiedDef( + PutMappingRequest.simpleMapping( "my_feature_field", "type=rank_feature", "my_negative_feature_field", diff --git a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java index 1cb5d81136de1..8d3c37bc9b039 100644 --- a/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java +++ b/modules/percolator/src/internalClusterTest/java/org/opensearch/percolator/PercolatorQuerySearchIT.java @@ -101,7 +101,7 @@ public void testPercolatorQuery() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator") ); client().prepareIndex("test") @@ -183,8 +183,7 @@ public void testPercolatorRangeQueries() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping( - "type", + .setMapping( "field1", "type=long", "field2", @@ -315,17 +314,7 @@ public void testPercolatorGeoQueries() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping( - "type", - "id", - "type=keyword", - "field1", - "type=geo_point", - "field2", - "type=geo_shape", - "query", - "type=percolator" - ) + .setMapping("id", "type=keyword", "field1", "type=geo_point", "field2", "type=geo_shape", "query", "type=percolator") ); client().prepareIndex("test") @@ -380,7 +369,7 @@ public void testPercolatorQueryExistingDocument() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", "type=keyword", "field2", "type=keyword", "query", "type=percolator") ); client().prepareIndex("test") @@ -408,14 +397,14 @@ public void testPercolatorQueryExistingDocument() throws Exception { logger.info("percolating empty doc"); SearchResponse response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("query", "test", "type", "1", null, null, null)) + .setQuery(new PercolateQueryBuilder("query", "test", "1", null, null, null)) .get(); assertHitCount(response, 1); assertThat(response.getHits().getAt(0).getId(), equalTo("1")); logger.info("percolating doc with 1 field"); response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("query", "test", "type", "5", null, null, null)) + .setQuery(new PercolateQueryBuilder("query", "test", "5", null, null, null)) .addSort("id", SortOrder.ASC) .get(); assertHitCount(response, 2); @@ -424,7 +413,7 @@ public void testPercolatorQueryExistingDocument() throws Exception { logger.info("percolating doc with 2 fields"); response = client().prepareSearch() - .setQuery(new PercolateQueryBuilder("query", "test", "type", "6", null, null, null)) + .setQuery(new PercolateQueryBuilder("query", "test", "6", null, null, null)) .addSort("id", SortOrder.ASC) .get(); assertHitCount(response, 3); @@ -438,7 +427,7 @@ public void testPercolatorQueryExistingDocumentSourceDisabled() throws Exception client().admin() .indices() .prepareCreate("test") - .addMapping("type", "_source", "enabled=false", "field1", "type=keyword", "query", "type=percolator") + .setMapping("_source", "enabled=false", "field1", "type=keyword", "query", "type=percolator") ); client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("query", matchAllQuery()).endObject()).get(); @@ -449,7 +438,7 @@ public void testPercolatorQueryExistingDocumentSourceDisabled() throws Exception logger.info("percolating empty doc with source disabled"); IllegalArgumentException e = expectThrows( IllegalArgumentException.class, - () -> { client().prepareSearch().setQuery(new PercolateQueryBuilder("query", "test", "type", "1", null, null, null)).get(); } + () -> { client().prepareSearch().setQuery(new PercolateQueryBuilder("query", "test", "1", null, null, null)).get(); } ); assertThat(e.getMessage(), containsString("source disabled")); } @@ -459,7 +448,7 @@ public void testPercolatorSpecificQueries() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "id", "type=keyword", "field1", "type=text", "field2", "type=text", "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", "type=text", "field2", "type=text", "query", "type=percolator") ); client().prepareIndex("test") @@ -565,7 +554,7 @@ public void testPercolatorQueryWithHighlighting() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "id", "type=keyword", "field1", fieldMapping, "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", fieldMapping.toString(), "query", "type=percolator") ); client().prepareIndex("test") .setId("1") @@ -810,7 +799,7 @@ public void testTakePositionOffsetGapIntoAccount() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type", "field", "type=text,position_increment_gap=5", "query", "type=percolator") + .setMapping("field", "type=text,position_increment_gap=5", "query", "type=percolator") ); client().prepareIndex("test") .setId("1") @@ -832,13 +821,13 @@ public void testTakePositionOffsetGapIntoAccount() throws Exception { public void testManyPercolatorFields() throws Exception { String queryFieldName = randomAlphaOfLength(8); assertAcked( - client().admin().indices().prepareCreate("test1").addMapping("type", queryFieldName, "type=percolator", "field", "type=keyword") + client().admin().indices().prepareCreate("test1").setMapping(queryFieldName, "type=percolator", "field", "type=keyword") ); assertAcked( client().admin() .indices() .prepareCreate("test2") - .addMapping("type", queryFieldName, "type=percolator", "second_query_field", "type=percolator", "field", "type=keyword") + .setMapping(queryFieldName, "type=percolator", "second_query_field", "type=percolator", "field", "type=keyword") ); assertAcked( client().admin() @@ -867,7 +856,7 @@ public void testManyPercolatorFields() throws Exception { public void testWithMultiplePercolatorFields() throws Exception { String queryFieldName = randomAlphaOfLength(8); assertAcked( - client().admin().indices().prepareCreate("test1").addMapping("type", queryFieldName, "type=percolator", "field", "type=keyword") + client().admin().indices().prepareCreate("test1").setMapping(queryFieldName, "type=percolator", "field", "type=keyword") ); assertAcked( client().admin() @@ -1130,7 +1119,7 @@ public void testPercolateQueryWithNestedDocuments() throws Exception { } public void testPercolatorQueryViaMultiSearch() throws Exception { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type", "field1", "type=text", "query", "type=percolator")); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field1", "type=text", "query", "type=percolator")); client().prepareIndex("test") .setId("1") @@ -1204,10 +1193,10 @@ public void testPercolatorQueryViaMultiSearch() throws Exception { ) ) ) - .add(client().prepareSearch("test").setQuery(new PercolateQueryBuilder("query", "test", "type", "5", null, null, null))) + .add(client().prepareSearch("test").setQuery(new PercolateQueryBuilder("query", "test", "5", null, null, null))) .add( client().prepareSearch("test") // non existing doc, so error element - .setQuery(new PercolateQueryBuilder("query", "test", "type", "6", null, null, null)) + .setQuery(new PercolateQueryBuilder("query", "test", "6", null, null, null)) ) .get(); @@ -1239,7 +1228,7 @@ public void testPercolatorQueryViaMultiSearch() throws Exception { item = response.getResponses()[5]; assertThat(item.getResponse(), nullValue()); assertThat(item.getFailureMessage(), notNullValue()); - assertThat(item.getFailureMessage(), containsString("[test/type/6] couldn't be found")); + assertThat(item.getFailureMessage(), containsString("[test/6] couldn't be found")); } public void testDisallowExpensiveQueries() throws IOException { @@ -1248,7 +1237,7 @@ public void testDisallowExpensiveQueries() throws IOException { client().admin() .indices() .prepareCreate("test") - .addMapping("_doc", "id", "type=keyword", "field1", "type=keyword", "query", "type=percolator") + .setMapping("id", "type=keyword", "field1", "type=keyword", "query", "type=percolator") ); client().prepareIndex("test") @@ -1298,7 +1287,7 @@ public void testDisallowExpensiveQueries() throws IOException { public void testWrappedWithConstantScore() throws Exception { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("_doc", "d", "type=date", "q", "type=percolator")); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("d", "type=date", "q", "type=percolator")); client().prepareIndex("test") .setId("1") diff --git a/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java b/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java index 87f08e2ff50fc..b2130eca3bb02 100644 --- a/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java +++ b/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java @@ -67,7 +67,6 @@ import org.opensearch.common.io.stream.NamedWriteableRegistry; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; -import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.xcontent.ConstructingObjectParser; import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.NamedXContentRegistry; @@ -111,19 +110,11 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder { public static final String NAME = "percolate"; - private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(ParseField.class); - static final String DOCUMENT_TYPE_DEPRECATION_MESSAGE = "[types removal] Types are deprecated in [percolate] queries. " - + "The [document_type] should no longer be specified."; - static final String TYPE_DEPRECATION_MESSAGE = "[types removal] Types are deprecated in [percolate] queries. " - + "The [type] of the indexed document should no longer be specified."; - static final ParseField DOCUMENT_FIELD = new ParseField("document"); static final ParseField DOCUMENTS_FIELD = new ParseField("documents"); private static final ParseField NAME_FIELD = new ParseField("name"); private static final ParseField QUERY_FIELD = new ParseField("field"); - private static final ParseField DOCUMENT_TYPE_FIELD = new ParseField("document_type"); private static final ParseField INDEXED_DOCUMENT_FIELD_INDEX = new ParseField("index"); - private static final ParseField INDEXED_DOCUMENT_FIELD_TYPE = new ParseField("type"); private static final ParseField INDEXED_DOCUMENT_FIELD_ID = new ParseField("id"); private static final ParseField INDEXED_DOCUMENT_FIELD_ROUTING = new ParseField("routing"); private static final ParseField INDEXED_DOCUMENT_FIELD_PREFERENCE = new ParseField("preference"); @@ -131,29 +122,16 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder documents; private final XContentType documentXContentType; private final String indexedDocumentIndex; - @Deprecated - private final String indexedDocumentType; private final String indexedDocumentId; private final String indexedDocumentRouting; private final String indexedDocumentPreference; private final Long indexedDocumentVersion; private final Supplier documentSupplier; - /** - * @deprecated use {@link #PercolateQueryBuilder(String, BytesReference, XContentType)} with the document content - * type to avoid autodetection. - */ - @Deprecated - public PercolateQueryBuilder(String field, String documentType, BytesReference document) { - this(field, documentType, Collections.singletonList(document), XContentHelper.xContentType(document)); - } - /** * Creates a percolator query builder instance for percolating a provided document. * @@ -162,7 +140,7 @@ public PercolateQueryBuilder(String field, String documentType, BytesReference d * @param documentXContentType The content type of the binary blob containing the document to percolate */ public PercolateQueryBuilder(String field, BytesReference document, XContentType documentXContentType) { - this(field, null, Collections.singletonList(document), documentXContentType); + this(field, Collections.singletonList(document), documentXContentType); } /** @@ -173,11 +151,6 @@ public PercolateQueryBuilder(String field, BytesReference document, XContentType * @param documentXContentType The content type of the binary blob containing the document to percolate */ public PercolateQueryBuilder(String field, List documents, XContentType documentXContentType) { - this(field, null, documents, documentXContentType); - } - - @Deprecated - public PercolateQueryBuilder(String field, String documentType, List documents, XContentType documentXContentType) { if (field == null) { throw new IllegalArgumentException("[field] is a required argument"); } @@ -185,11 +158,9 @@ public PercolateQueryBuilder(String field, String documentType, List documentSupplier) { - if (field == null) { - throw new IllegalArgumentException("[field] is a required argument"); - } - this.field = field; - this.documentType = documentType; - this.documents = Collections.emptyList(); - this.documentXContentType = null; - this.documentSupplier = documentSupplier; - indexedDocumentIndex = null; - indexedDocumentType = null; - indexedDocumentId = null; - indexedDocumentRouting = null; - indexedDocumentPreference = null; - indexedDocumentVersion = null; - } - /** * Creates a percolator query builder instance for percolating a document in a remote index. * * @param field The field that contains the percolator query * @param indexedDocumentIndex The index containing the document to percolate - * @param indexedDocumentType The type containing the document to percolate * @param indexedDocumentId The id of the document to percolate * @param indexedDocumentRouting The routing value for the document to percolate * @param indexedDocumentPreference The preference to use when fetching the document to percolate @@ -228,30 +181,6 @@ protected PercolateQueryBuilder(String field, String documentType, Supplier documentSupplier) { + if (field == null) { + throw new IllegalArgumentException("[field] is a required argument"); + } + this.field = field; + this.documents = Collections.emptyList(); + this.documentXContentType = null; + this.documentSupplier = documentSupplier; + indexedDocumentIndex = null; + indexedDocumentId = null; + indexedDocumentRouting = null; + indexedDocumentPreference = null; + indexedDocumentVersion = null; + } + /** * Read from a stream. */ @@ -286,9 +228,20 @@ public PercolateQueryBuilder( super(in); field = in.readString(); name = in.readOptionalString(); - documentType = in.readOptionalString(); + if (in.getVersion().before(Version.V_2_0_0)) { + String documentType = in.readOptionalString(); + if (documentType != null) { + throw new IllegalStateException("documentType must be null"); + } + } indexedDocumentIndex = in.readOptionalString(); - indexedDocumentType = in.readOptionalString(); + if (in.getVersion().before(Version.V_2_0_0)) { + String indexedDocumentType = in.readOptionalString(); + if (indexedDocumentType != null) { + throw new IllegalStateException("indexedDocumentType must be null"); + } + } + indexedDocumentId = in.readOptionalString(); indexedDocumentRouting = in.readOptionalString(); indexedDocumentPreference = in.readOptionalString(); @@ -322,9 +275,15 @@ protected void doWriteTo(StreamOutput out) throws IOException { } out.writeString(field); out.writeOptionalString(name); - out.writeOptionalString(documentType); + if (out.getVersion().before(Version.V_2_0_0)) { + // In 7x, typeless percolate queries are represented by null documentType values + out.writeOptionalString(null); + } out.writeOptionalString(indexedDocumentIndex); - out.writeOptionalString(indexedDocumentType); + if (out.getVersion().before(Version.V_2_0_0)) { + // In 7x, typeless percolate queries are represented by null indexedDocumentType values + out.writeOptionalString(null); + } out.writeOptionalString(indexedDocumentId); out.writeOptionalString(indexedDocumentRouting); out.writeOptionalString(indexedDocumentPreference); @@ -346,7 +305,6 @@ protected void doWriteTo(StreamOutput out) throws IOException { @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(NAME); - builder.field(DOCUMENT_TYPE_FIELD.getPreferredName(), documentType); builder.field(QUERY_FIELD.getPreferredName(), field); if (name != null) { builder.field(NAME_FIELD.getPreferredName(), name); @@ -367,13 +325,10 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep } builder.endArray(); } - if (indexedDocumentIndex != null || indexedDocumentType != null || indexedDocumentId != null) { + if (indexedDocumentIndex != null || indexedDocumentId != null) { if (indexedDocumentIndex != null) { builder.field(INDEXED_DOCUMENT_FIELD_INDEX.getPreferredName(), indexedDocumentIndex); } - if (indexedDocumentType != null) { - builder.field(INDEXED_DOCUMENT_FIELD_TYPE.getPreferredName(), indexedDocumentType); - } if (indexedDocumentId != null) { builder.field(INDEXED_DOCUMENT_FIELD_ID.getPreferredName(), indexedDocumentId); } @@ -401,23 +356,12 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep String indexDocRouting = (String) args[5]; String indexDocPreference = (String) args[6]; Long indexedDocVersion = (Long) args[7]; - String indexedDocType = (String) args[8]; - String docType = (String) args[9]; if (indexedDocId != null) { - return new PercolateQueryBuilder( - field, - docType, - indexedDocIndex, - indexedDocType, - indexedDocId, - indexDocRouting, - indexDocPreference, - indexedDocVersion - ); + return new PercolateQueryBuilder(field, indexedDocIndex, indexedDocId, indexDocRouting, indexDocPreference, indexedDocVersion); } else if (document != null) { - return new PercolateQueryBuilder(field, docType, Collections.singletonList(document), XContentType.JSON); + return new PercolateQueryBuilder(field, Collections.singletonList(document), XContentType.JSON); } else { - return new PercolateQueryBuilder(field, docType, documents, XContentType.JSON); + return new PercolateQueryBuilder(field, documents, XContentType.JSON); } }); static { @@ -429,8 +373,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep PARSER.declareString(optionalConstructorArg(), INDEXED_DOCUMENT_FIELD_ROUTING); PARSER.declareString(optionalConstructorArg(), INDEXED_DOCUMENT_FIELD_PREFERENCE); PARSER.declareLong(optionalConstructorArg(), INDEXED_DOCUMENT_FIELD_VERSION); - PARSER.declareStringOrNull(optionalConstructorArg(), INDEXED_DOCUMENT_FIELD_TYPE); - PARSER.declareStringOrNull(optionalConstructorArg(), DOCUMENT_TYPE_FIELD); PARSER.declareString(PercolateQueryBuilder::setName, NAME_FIELD); PARSER.declareString(PercolateQueryBuilder::queryName, AbstractQueryBuilder.NAME_FIELD); PARSER.declareFloat(PercolateQueryBuilder::boost, BOOST_FIELD); @@ -461,10 +403,8 @@ public static PercolateQueryBuilder fromXContent(XContentParser parser) throws I @Override protected boolean doEquals(PercolateQueryBuilder other) { return Objects.equals(field, other.field) - && Objects.equals(documentType, other.documentType) && Objects.equals(documents, other.documents) && Objects.equals(indexedDocumentIndex, other.indexedDocumentIndex) - && Objects.equals(indexedDocumentType, other.indexedDocumentType) && Objects.equals(documentSupplier, other.documentSupplier) && Objects.equals(indexedDocumentId, other.indexedDocumentId); @@ -472,7 +412,7 @@ protected boolean doEquals(PercolateQueryBuilder other) { @Override protected int doHashCode() { - return Objects.hash(field, documentType, documents, indexedDocumentIndex, indexedDocumentType, indexedDocumentId, documentSupplier); + return Objects.hash(field, documents, indexedDocumentIndex, indexedDocumentId, documentSupplier); } @Override @@ -491,7 +431,6 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) { } else { PercolateQueryBuilder rewritten = new PercolateQueryBuilder( field, - documentType, Collections.singletonList(source), XContentHelper.xContentType(source) ); @@ -513,20 +452,14 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) { client.get(getRequest, ActionListener.wrap(getResponse -> { if (getResponse.isExists() == false) { throw new ResourceNotFoundException( - "indexed document [{}{}/{}] couldn't be found", + "indexed document [{}/{}] couldn't be found", indexedDocumentIndex, - indexedDocumentType == null ? "" : "/" + indexedDocumentType, indexedDocumentId ); } if (getResponse.isSourceEmpty()) { throw new IllegalArgumentException( - "indexed document [" - + indexedDocumentIndex - + (indexedDocumentType == null ? "" : "/" + indexedDocumentType) - + "/" - + indexedDocumentId - + "] source disabled" + "indexed document [" + indexedDocumentIndex + "/" + indexedDocumentId + "] source disabled" ); } documentSupplier.set(getResponse.getSourceAsBytesRef()); @@ -534,7 +467,7 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryShardContext) { }, listener::onFailure)); }); - PercolateQueryBuilder rewritten = new PercolateQueryBuilder(field, documentType, documentSupplier::get); + PercolateQueryBuilder rewritten = new PercolateQueryBuilder(field, documentSupplier::get); if (name != null) { rewritten.setName(name); } @@ -576,14 +509,6 @@ protected Query doToQuery(QueryShardContext context) throws IOException { final DocumentMapper docMapper; final MapperService mapperService = context.getMapperService(); String type = mapperService.documentMapper().type(); - if (documentType != null) { - deprecationLogger.deprecate("percolate_with_document_type", DOCUMENT_TYPE_DEPRECATION_MESSAGE); - if (documentType.equals(type) == false) { - throw new IllegalArgumentException( - "specified document_type [" + documentType + "] is not equal to the actual type [" + type + "]" - ); - } - } docMapper = mapperService.documentMapper(); for (BytesReference document : documents) { docs.add(docMapper.parse(new SourceToParse(context.index().getName(), "_temp_id", document, documentXContentType))); @@ -631,10 +556,6 @@ public String getField() { return field; } - public String getDocumentType() { - return documentType; - } - public List getDocuments() { return documents; } diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java index 12be15552652c..87aa28a3346bc 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateQueryBuilderTests.java @@ -110,14 +110,14 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws docType, new CompressedXContent( Strings.toString( - PutMappingRequest.buildFromSimplifiedDef(queryField, "type=percolator", aliasField, "type=alias,path=" + queryField) + PutMappingRequest.simpleMapping(queryField, "type=percolator", aliasField, "type=alias,path=" + queryField) ) ), MapperService.MergeReason.MAPPING_UPDATE ); mapperService.merge( docType, - new CompressedXContent(Strings.toString(PutMappingRequest.buildFromSimplifiedDef(TEXT_FIELD_NAME, "type=text"))), + new CompressedXContent(Strings.toString(PutMappingRequest.simpleMapping(TEXT_FIELD_NAME, "type=text"))), MapperService.MergeReason.MAPPING_UPDATE ); } @@ -148,16 +148,14 @@ private PercolateQueryBuilder doCreateTestQueryBuilder(boolean indexedDocument) indexedDocumentVersion = (long) randomIntBetween(0, Integer.MAX_VALUE); queryBuilder = new PercolateQueryBuilder( queryField, - null, indexedDocumentIndex, - null, indexedDocumentId, indexedDocumentRouting, indexedDocumentPreference, indexedDocumentVersion ); } else { - queryBuilder = new PercolateQueryBuilder(queryField, null, documentSource, XContentType.JSON); + queryBuilder = new PercolateQueryBuilder(queryField, documentSource, XContentType.JSON); } if (randomBoolean()) { queryBuilder.setName(randomAlphaOfLength(4)); @@ -217,7 +215,6 @@ protected GetResponse executeGet(GetRequest getRequest) { protected void doAssertLuceneQuery(PercolateQueryBuilder queryBuilder, Query query, QueryShardContext context) throws IOException { assertThat(query, Matchers.instanceOf(PercolateQuery.class)); PercolateQuery percolateQuery = (PercolateQuery) query; - assertNull(queryBuilder.getDocumentType()); assertThat(percolateQuery.getDocuments(), Matchers.equalTo(documentSource)); } @@ -227,12 +224,7 @@ public void testMustRewrite() throws IOException { IllegalStateException e = expectThrows(IllegalStateException.class, () -> pqb.toQuery(createShardContext())); assertThat(e.getMessage(), equalTo("query builder must be rewritten first")); QueryBuilder rewrite = rewriteAndFetch(pqb, createShardContext()); - PercolateQueryBuilder geoShapeQueryBuilder = new PercolateQueryBuilder( - pqb.getField(), - pqb.getDocumentType(), - documentSource, - XContentType.JSON - ); + PercolateQueryBuilder geoShapeQueryBuilder = new PercolateQueryBuilder(pqb.getField(), documentSource, XContentType.JSON); assertEquals(geoShapeQueryBuilder, rewrite); } @@ -259,25 +251,19 @@ public void testRequiredParameters() { ); assertThat(e.getMessage(), equalTo("[field] is a required argument")); - e = expectThrows(IllegalArgumentException.class, () -> new PercolateQueryBuilder("_field", "_document_type", null, null)); - assertThat(e.getMessage(), equalTo("[document] is a required argument")); - e = expectThrows( IllegalArgumentException.class, - () -> { new PercolateQueryBuilder(null, null, "_index", "_type", "_id", null, null, null); } + () -> new PercolateQueryBuilder("_field", (List) null, XContentType.JSON) ); + assertThat(e.getMessage(), equalTo("[document] is a required argument")); + + e = expectThrows(IllegalArgumentException.class, () -> { new PercolateQueryBuilder(null, "_index", "_id", null, null, null); }); assertThat(e.getMessage(), equalTo("[field] is a required argument")); - e = expectThrows( - IllegalArgumentException.class, - () -> { new PercolateQueryBuilder("_field", "_document_type", null, "_type", "_id", null, null, null); } - ); + e = expectThrows(IllegalArgumentException.class, () -> { new PercolateQueryBuilder("_field", null, "_id", null, null, null); }); assertThat(e.getMessage(), equalTo("[index] is a required argument")); - e = expectThrows( - IllegalArgumentException.class, - () -> { new PercolateQueryBuilder("_field", "_document_type", "_index", "_type", null, null, null, null); } - ); + e = expectThrows(IllegalArgumentException.class, () -> { new PercolateQueryBuilder("_field", "_index", null, null, null, null); }); assertThat(e.getMessage(), equalTo("[id] is a required argument")); } @@ -287,15 +273,6 @@ public void testFromJsonNoDocumentType() throws IOException { queryBuilder.toQuery(queryShardContext); } - public void testFromJsonWithDocumentType() throws IOException { - QueryShardContext queryShardContext = createShardContext(); - QueryBuilder queryBuilder = parseQuery( - "{\"percolate\" : { \"document\": {}, \"document_type\":\"" + docType + "\", \"field\":\"" + queryField + "\"}}" - ); - queryBuilder.toQuery(queryShardContext); - assertWarnings(PercolateQueryBuilder.DOCUMENT_TYPE_DEPRECATION_MESSAGE); - } - public void testFromJsonNoType() throws IOException { indexedDocumentIndex = randomAlphaOfLength(4); indexedDocumentId = randomAlphaOfLength(4); @@ -315,25 +292,6 @@ public void testFromJsonNoType() throws IOException { rewriteAndFetch(queryBuilder, queryShardContext).toQuery(queryShardContext); } - public void testFromJsonWithType() throws IOException { - indexedDocumentIndex = randomAlphaOfLength(4); - indexedDocumentId = randomAlphaOfLength(4); - indexedDocumentVersion = Versions.MATCH_ANY; - documentSource = Collections.singletonList(randomSource(new HashSet<>())); - - QueryShardContext queryShardContext = createShardContext(); - QueryBuilder queryBuilder = parseQuery( - "{\"percolate\" : { \"index\": \"" - + indexedDocumentIndex - + "\", \"type\": \"_doc\", \"id\": \"" - + indexedDocumentId - + "\", \"field\":\"" - + queryField - + "\"}}" - ); - rewriteAndFetch(queryBuilder, queryShardContext).toQuery(queryShardContext); - } - public void testBothDocumentAndDocumentsSpecified() { IllegalArgumentException e = expectThrows( IllegalArgumentException.class, @@ -426,7 +384,7 @@ public void testSettingNameWhileRewritingWhenDocumentSupplierAndSourceNotNull() Supplier supplier = () -> new BytesArray("{\"test\": \"test\"}"); String testName = "name1"; QueryShardContext shardContext = createShardContext(); - PercolateQueryBuilder percolateQueryBuilder = new PercolateQueryBuilder(queryField, null, supplier); + PercolateQueryBuilder percolateQueryBuilder = new PercolateQueryBuilder(queryField, supplier); percolateQueryBuilder.setName(testName); QueryBuilder rewrittenQueryBuilder = percolateQueryBuilder.doRewrite(shardContext); diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateWithNestedQueryBuilderTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateWithNestedQueryBuilderTests.java index 5038e72e9be5e..0ab9eff731bff 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolateWithNestedQueryBuilderTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolateWithNestedQueryBuilderTests.java @@ -50,7 +50,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws super.initializeAdditionalMappings(mapperService); mapperService.merge( "_doc", - new CompressedXContent(Strings.toString(PutMappingRequest.buildFromSimplifiedDef("some_nested_object", "type=nested"))), + new CompressedXContent(Strings.toString(PutMappingRequest.simpleMapping("some_nested_object", "type=nested"))), MapperService.MergeReason.MAPPING_UPDATE ); } diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java index d3da99ffbc102..1d77c9d472864 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorQuerySearchTests.java @@ -96,7 +96,7 @@ protected Map, Object>> pluginScripts() { } public void testPercolateScriptQuery() throws IOException { - client().admin().indices().prepareCreate("index").addMapping("type", "query", "type=percolator").get(); + client().admin().indices().prepareCreate("index").setMapping("query", "type=percolator").get(); client().prepareIndex("index") .setId("1") .setSource( diff --git a/plugins/analysis-icu/licenses/icu4j-68.2.jar.sha1 b/plugins/analysis-icu/licenses/icu4j-68.2.jar.sha1 deleted file mode 100644 index fcb3d79075099..0000000000000 --- a/plugins/analysis-icu/licenses/icu4j-68.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -76893e6000401ace133a65262254be0ebe556d46 \ No newline at end of file diff --git a/plugins/analysis-icu/licenses/icu4j-70.1.jar.sha1 b/plugins/analysis-icu/licenses/icu4j-70.1.jar.sha1 new file mode 100644 index 0000000000000..6fad735235417 --- /dev/null +++ b/plugins/analysis-icu/licenses/icu4j-70.1.jar.sha1 @@ -0,0 +1 @@ +dfa3a1fbc55bf5db8c6e79fc0935ac7ab1202950 \ No newline at end of file diff --git a/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java b/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java index 375222cd2af44..3a430331167f6 100644 --- a/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java +++ b/plugins/mapper-size/src/internalClusterTest/java/org/opensearch/index/mapper/size/SizeMappingIT.java @@ -36,7 +36,6 @@ import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentType; -import org.opensearch.index.mapper.MapperService; import org.opensearch.plugin.mapper.MapperSizePlugin; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchIntegTestCase; @@ -122,7 +121,7 @@ private void assertSizeMappingEnabled(String index, boolean enabled) throws IOEx } public void testBasic() throws Exception { - assertAcked(prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME, "_size", "enabled=true")); + assertAcked(prepareCreate("test").setMapping("_size", "enabled=true")); final String source = "{\"f\":10}"; indexRandom(true, client().prepareIndex("test").setId("1").setSource(source, XContentType.JSON)); GetResponse getResponse = client().prepareGet("test", "1").setStoredFields("_size").get(); diff --git a/qa/remote-clusters/docker-compose.yml b/qa/remote-clusters/docker-compose.yml index 74aaa9e2a5271..cf6aefcf5c1a3 100644 --- a/qa/remote-clusters/docker-compose.yml +++ b/qa/remote-clusters/docker-compose.yml @@ -5,7 +5,7 @@ services: image: opensearch:test environment: - node.name=opensearch-1 - - cluster.initial_master_nodes=opensearch-1 + - cluster.initial_cluster_manager_nodes=opensearch-1 - cluster.name=opensearch-1 - bootstrap.memory_lock=true - network.publish_host=127.0.0.1 @@ -39,7 +39,7 @@ services: image: opensearch:test environment: - node.name=opensearch-2 - - cluster.initial_master_nodes=opensearch-2 + - cluster.initial_cluster_manager_nodes=opensearch-2 - cluster.name=opensearch-2 - bootstrap.memory_lock=true - network.publish_host=127.0.0.1 diff --git a/release-notes/opensearch.release-notes-1.3.0.md b/release-notes/opensearch.release-notes-1.3.0.md new file mode 100644 index 0000000000000..62c5be8413943 --- /dev/null +++ b/release-notes/opensearch.release-notes-1.3.0.md @@ -0,0 +1,1299 @@ +## Version 1.3.0 Release Notes + +* __MapperService has to be passed in as null for EnginePlugins CodecService constructor (#2177) (#2413)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Wed, 9 Mar 2022 10:17:33 -0500 + + efs/remotes/os_or/1.3 + * MapperService has to be passed in as null for EnginePlugins CodecService + constructor + + * Addressing code review comments + + * Delayed CodecService instantiation up to the shard initialization + + * Added logger (associated with shard) to CodecServiceConfig + + * Refactored the EngineConfigFactory / IndexShard instantiation of the + CodecService + (cherry picked from commit 9c679cbbfcf685e3865d2cf06b8f4e10c3082d49) + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Replace exclusionary words whitelist and blacklist in the places that… (#2365)__ + + [aponb](mailto:apre@gmx.at) - Mon, 7 Mar 2022 15:14:36 -0800 + + * Replace the exclusionary word whitelist with allowlist, and blacklist with + denylist, in code commet and internal variable/method/class/package name. + + Signed-off-by: Andreas <apre@gmx.at> + + +* __Install plugin command help (#2193) (#2264)__ + + [Joshua Palis](mailto:jpalis@amazon.com) - Mon, 7 Mar 2022 15:24:56 -0500 + * edited opensearch-plugin install help output to include plugin URL + * fixed unit test for plugin install help output by correctly identifying the + beginning og the non-option argument list + * added comments to install plugins help non option argument ouput unit test + * fixed format violation + * added additional details on valid plugin ids and how to use plugin URLs + * added additional information to plugin install help output + (cherry picked from commit b251d2b565b918708a1612ec16d1916122c7805d) Signed-off-by: Joshua Palis <jpalis@amazon.com> + + Signed-off-by: Joshua Palis <jpalis@amazon.com> + + +* __Add valuesField in PercentilesAggregationBuilder streamInput constructor (#2308) (#2389)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Mon, 7 Mar 2022 13:07:41 -0500 + + Signed-off-by: Subhobrata Dey <sbcd90@gmail.com> + (cherry picked from commit e1fd4b75b4f888d8d486baceeb9fd6fe7df44416) + Co-authored-by: Subhobrata Dey <sbcd90@gmail.com> + + +* __Updated the url for docker distribution (#2325) (#2360)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Mon, 7 Mar 2022 11:52:46 -0500 + + Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> + (cherry picked from commit 9224537704bb12980a129afb1e7b6ba6ab93680e) + Co-authored-by: Owais Kazi <owaiskazi19@gmail.com> + + +* __Reintroduce negative epoch_millis #1991 (#2232) (#2380)__ + + [Breno Faria](mailto:breno.faria@intrafind.com) - Mon, 7 Mar 2022 11:46:54 -0500 + + * Reintroduce negative epoch_millis #1991 + Fixes a regression introduced with Elasticsearch 7 regarding the date + field + type that removed support for negative timestamps with sub-second + granularity. Thanks to Ryan Kophs (https://github.com/rkophs) for allowing me to use + his previous work. + Signed-off-by: Breno Faria <breno.faria@intrafind.de> + + * applying spotless fix + Signed-off-by: Breno Faria <breno.faria@intrafind.de> + + * more conservative implementation of isSupportedBy + Signed-off-by: Breno Faria <breno.faria@intrafind.de> + + * adding braces to control flow statement + Signed-off-by: Breno Faria <breno.faria@intrafind.de> + + * spotless fix... + Signed-off-by: Breno Faria <breno.faria@intrafind.de> + Co-authored-by: Breno Faria <breno.faria@intrafind.de> + Co-authored-by: Breno Faria <breno.faria@intrafind.de> + + +* __Add 'key' field to 'function_score' query function definition in explanation response (#1711) (#2346)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Mon, 7 Mar 2022 11:42:03 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Fix java-version-checker source/target compatibility settings (#2354)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Fri, 4 Mar 2022 15:21:54 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + +* __Fixing the --release flag usage for javac (#2343)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Fri, 4 Mar 2022 13:49:01 -0500 + + * Fixing the --release flag usage for javac + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + * Fixing the --html5 flag usage for javadoc + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Fixing soft deletes deprecation warning (#2339)__ + + [Vacha Shah](mailto:vachshah@amazon.com) - Fri, 4 Mar 2022 10:06:11 -0500 + + Signed-off-by: Vacha Shah <vachshah@amazon.com> + + +* __Remove Github DCO action since DCO runs via Github App now (#2317) (#2323)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Thu, 3 Mar 2022 12:12:55 -0800 + + Signed-off-by: Vacha Shah <vachshah@amazon.com> + (cherry picked from commit cdb42ad3013f67970def21e15c546c9c4fd08d6f) + Co-authored-by: Vacha Shah <vachshah@amazon.com> + + +* __[Backport 1.x] Avoid logging duplicate deprecation warnings multiple times (#2315)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Thu, 3 Mar 2022 14:23:05 -0500 + + * Avoid logging duplicate deprecation warnings multiple times (#1660) + + * Avoid logging duplicate deprecation warnings multiple times + Signed-off-by: Vacha <vachshah@amazon.com> + + * Fixes test failures + Signed-off-by: Vacha <vachshah@amazon.com> + + * Adding deprecation logger tests + Signed-off-by: Vacha <vachshah@amazon.com> + + * Using ConcurrentHashMap keySet + Signed-off-by: Vacha Shah <vachshah@amazon.com> + (cherry picked from commit e66ea2c4f3ec583f087a82d1ebfb6383b2f159c1) + + * Fixing failing RestResizeHandlerTests in 1.x + Signed-off-by: Vacha Shah <vachshah@amazon.com> + Co-authored-by: Vacha <vachshah@amazon.com> + + +* __Restore Java 8 compatibility for build tools. (#2300)__ + + [Daniel Doubrovkine (dB.)](mailto:dblock@dblock.org) - Thu, 3 Mar 2022 14:14:23 -0500 + + * Restore Java 8 compatibility for build tools. + Signed-off-by: dblock <dblock@dblock.org> + + * Make source code compatible with Java 8. + Signed-off-by: dblock <dblock@dblock.org> + +* __Add support of SOCKS proxies for S3 repository (#2160) (#2316)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Thu, 3 Mar 2022 13:49:40 -0500 + + Signed-off-by: Andrey Pleskach <ples@aiven.io> + (cherry picked from commit f13b951c7006700a9b8a8bb2cdecd67439bc1e86) + Co-authored-by: Andrey Pleskach <ples@aiven.io> + + +* __Fix flaky test case - string profiler via global ordinals (#2226) (#2313)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Wed, 2 Mar 2022 17:48:34 -0600 + + forcemerge to one segment before executing aggregation query. + Signed-off-by: Peng Huo <penghuo@gmail.com> + (cherry picked from commit 9e225dc9b85c4fc2d3d910846bd0da25bc6a40df) + Co-authored-by: Peng Huo <penghuo@gmail.com> + +* __Auto-increment next development iteration. (#1816) (#2164)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Wed, 2 Mar 2022 15:46:28 -0800 + + * Auto-increment next development iteration. + Signed-off-by: dblock <dblock@amazon.com> + + * Make bwc increments on X.Y and main branches. + Signed-off-by: dblock <dblock@amazon.com> + Signed-off-by: dblock + <dblock@dblock.org> + Co-authored-by: Daniel Doubrovkine (dB.) <dblock@dblock.org> + + +* __Downgrade to JDK 11. (#2301)__ + + [Daniel Doubrovkine (dB.)](mailto:dblock@dblock.org) - Wed, 2 Mar 2022 13:37:23 -0500 + + * Downgrade to JDK 11. + Signed-off-by: dblock <dblock@dblock.org> + + * Added support for patch JDK version, like 11.0.14+1 + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + * Use JDK 11.0.14.1+1. + Signed-off-by: dblock <dblock@dblock.org> + + * ./gradlew :build-tools:spotlessApply + Signed-off-by: dblock <dblock@dblock.org> + Co-authored-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Adding shards per node constraint for predictability to testClusterGr… (#2110) (#2265)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Mon, 28 Feb 2022 15:59:57 -0600 + + * Adding shards per node constraint for predictability to + testClusterGreenAfterPartialRelocation + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Fixing precommit violation + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Adding assertion to ensure invariant + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + (cherry picked from commit 8ae0db5285963b8e3552ce106ef1368813dbc8b1) + Co-authored-by: Ankit Jain <jain.ankitk@gmail.com> + + +* __Revert "[Backport 1.x] Override Default Distribution Download Url with Custom Distribution Url When User Passes a Url (#2191)" (#2243)__ + + [Rabi Panda](mailto:adnapibar@gmail.com) - Thu, 24 Feb 2022 15:58:30 -0800 + + Signed-off-by: Rabi Panda <adnapibar@gmail.com> + + +* __added config file to git issue template directory to disable blank issue creation (#2158) (#2249)__ + + [Joshua Palis](mailto:99766446+joshpalis@users.noreply.github.com) - Thu, 24 Feb 2022 15:34:24 -0800 + + Signed-off-by: Joshua Palis <jpalis@amazon.com> + Co-authored-by: Joshua Palis <jpalis@amazon.com> + (cherry picked from commit fb187eacc26487cd644f09091e462001d8839315) + + +* __Case Insensitive Support in Regexp Interval (#2237) (#2246)__ + + [Matt Weber](mailto:matt@mattweber.org) - Thu, 24 Feb 2022 15:58:09 -0600 + + 1x backport of #2237. Add a `case_insensitive` flag to regexp interval source. + + Signed-off-by: Matt Weber <matt@mattweber.org> + + +* __Add Factory to enable Lucene ConcatenateGraphFilter (#1278) (#2152) (#2219)__ + + [Mau Bach Quang](mailto:quangmaubach@gmail.com) - Thu, 24 Feb 2022 10:49:31 -0800 + + Lucene has a ConcatenateGraphFilter that can concatenate tokens from a + TokenStream + to create a single token (or several tokens that have the same + position if + input TokenStream is a graph). + The change is to enable that ConcatenateGraphFilter by adding a Factory. + + (cherry-pick from 0e95bb9dff976a9c7f9cdac63a92040043d029e2) + Signed-off-by: Mau Bach Quang <quangmaubach@gmail.com> + + +* __[Backport 1.x] Override Default Distribution Download Url with Custom Distribution Url When User Passes a Url (#2191)__ + + [Rishikesh Pasham](mailto:62345295+Rishikesh1159@users.noreply.github.com) - Mon, 21 Feb 2022 10:56:00 -0800 + + * Backport Enabling Sort Optimization to make use of Lucene + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + + * Backport Enabling Sort Optimization to make use of Lucene and small change in + a method call signature + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + + * [Backport 1.x] Override Default Distribution Download Url with Custom + Distribution Url When User Passes a Url + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + + * Adding Spotless check to previous PR + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + +* __Support unordered non-overlapping intervals (#2103) (#2172)__ + + [Matt Weber](mailto:matt@mattweber.org) - Fri, 18 Feb 2022 11:52:52 -0500 + + This commit exposes Intervals.unorderedNoOverlaps (LUCENE-8828). + + (#2103 backport) + Signed-off-by: Matt Weber <matt@mattweber.org> + + +* __Add regexp interval source (#1917) (#2069)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Wed, 16 Feb 2022 14:46:35 -0500 + + * Add regexp interval source + Add a regexp interval source provider so people can use regular + expressions + inside of intervals queries. + Signed-off-by: Matt Weber <matt@mattweber.org> + + * Fixes + + - register regexp interval in SearchModule + - use fully-qualified name for lucene RegExp + - get rid of unnecessary variable + Signed-off-by: Matt Weber <matt@mattweber.org> + (cherry picked from commit b9420d8f70dfc168b9d44f736850af4ef7306a99) + Co-authored-by: Matt Weber <matt@mattweber.org> + + +* __Add proxy username and password settings for Azure repository (#2098) (#2108)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Wed, 16 Feb 2022 12:01:51 -0500 + + Added username/password proxy settings for Azure repository. + Security + settings: + - azure.client.*.proxy.username - Proxy user name + - azure.client.*.proxy.password - Proxy user password + Signed-off-by: Andrey Pleskach <ples@aiven.io> + (cherry picked from commit 62361ceafce4abb735567066d1c4865ca6d7136f) + Co-authored-by: Andrey Pleskach <ples@aiven.io> + + +* __Support first and last parameter for missing bucket ordering in composite aggregation (#1942) (#2049)__ + + [Peng Huo](mailto:penghuo@gmail.com) - Tue, 15 Feb 2022 14:07:35 -0800 + + Support for "first" and "last" parameters for missing bucket ordering in + composite aggregation. + By default, if order is asc, missing_bucket at first, + if order is desc, missing_bucket at last. If + missing_order is "first" or + "last", regardless order, missing_bucket is at first or last respectively. + Signed-off-by: Peng Huo <penghuo@gmail.com> + + +* __Mapping update for “date_range” field type is not idempotent (#2094) (#2106)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Tue, 15 Feb 2022 11:44:17 -0600 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + (cherry picked from commit 6b6f03368f49f5f8001d6d0ed85cd9af7bab76f6) + Co-authored-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Fix integration tests failure (#2067) (#2090)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Fri, 11 Feb 2022 11:07:46 -0500 + + Fixed integration tests failure on Linux with Kernel 5.16.x + Signed-off-by: Andrey Pleskach <ples@aiven.io> + (cherry picked from commit 27ed6fc82c7db7a3a741499f0dbd7722fa053f9d) + Co-authored-by: Andrey Pleskach <ples@aiven.io> + + +* __Backport/backport 2048,2074 to 1.x (#2085)__ + + [Ankit Jain](mailto:jain.ankitk@gmail.com) - Fri, 11 Feb 2022 09:36:21 -0500 + + * Stabilizing org.opensearch.cluster.routing.MovePrimaryFirstTests.test… + (#2048) + + * Stabilizing + org.opensearch.cluster.routing.MovePrimaryFirstTests.testClusterGreenAfterPartialRelocation + + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Removing unused import + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Making code more readable + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + (cherry picked from commit 343b82fe24525bbab01ef5a0d9bb8917068c71bf) + + * Added timeout to ensureGreen() for testClusterGreenAfterPartialRelocation + (#2074) + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + (cherry picked from commit f0984eb409d44e8b68deb1c262bf81accc300acb) + + +* __Removing lingering transportclient (#1955) (#2088)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Thu, 10 Feb 2022 17:21:12 -0800 + + Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + (cherry picked from commit 781156471a1827b1b66445f716c7567f714dda86) + Co-authored-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + + +* __Prioritize primary shard movement during shard allocation (#1445) (#2079)__ + + [opensearch-trigger-bot[bot]](mailto:98922864+opensearch-trigger-bot[bot]@users.noreply.github.com) - Thu, 10 Feb 2022 13:48:38 -0500 + + When some node or set of nodes is excluded (based on some cluster setting) + BalancedShardsAllocator iterates over them in breadth first order picking 1 + shard from + each node and repeating the process until all shards are balanced. + Since shards from + each node are picked randomly it's possible the p and r of + shard1 is relocated first + leaving behind both p and r of shard2. If the + excluded nodes were to go down the + cluster becomes red. + This commit introduces a new setting + "cluster.routing.allocation.move.primary_first" + that prioritizes the p of both + shard1 and shard2 first so the cluster does not become + red if the excluded + nodes were to go down before relocating other shards. Note that + with this + setting enabled performance of this change is a direct function of number + of + indices, shards, replicas, and nodes. The larger the indices, replicas, and + distribution scale, the slower the allocation becomes. This should be used with + care. + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + (cherry picked from commit 6eb8f6f307567892bbabbe37aff7cd42be486df0) + Co-authored-by: Ankit Jain <jain.ankitk@gmail.com> + + +* __Adding workflow to auto delete backport merged branches from backport workflow (#2050) (#2065)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Tue, 8 Feb 2022 12:27:45 -0800 + + Signed-off-by: Vacha Shah <vachshah@amazon.com> + (cherry picked from commit 9c9e218ae697b65e410304825cac81ccdf355e66) + Co-authored-by: Vacha <vachshah@amazon.com> + + +* __Another attempt to fix o.o.transport.netty4.OpenSearchLoggingHandlerIT fails w/ stack overflow (#2051) (#2055)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Mon, 7 Feb 2022 16:11:06 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + (cherry picked from commit 1e5d98329eaa76d1aea19306242e6fa74b840b75) + Co-authored-by: Andriy Redko <andriy.redko@aiven.io> + + +* __added backport for 1.2.5 to 1.x branch (#2057)__ + + [Abhinav Gupta](mailto:guptabhi123@gmail.com) - Mon, 7 Feb 2022 13:33:27 -0500 + + Signed-off-by: Abhinav Gupta <abhng@amazon.com> + + +* __[Backport] Introduce FS Health HEALTHY threshold to fail stuck node (#1269)__ + + [Bukhtawar Khan](mailto:bukhtawa@amazon.com) - Mon, 7 Feb 2022 12:48:03 -0500 + + * Introduce FS Health HEALTHY threshold to fail stuck node (#1167) + This will cause the leader stuck on IO during publication to step down and + eventually trigger a leader election. + * Issue Description + * The publication of cluster state is time bound to 30s by a + cluster.publish.timeout settings. If this time is reached before the new + cluster state is committed, then the cluster state change is rejected and the + leader considers itself to have failed. It stands down and starts trying to + elect a new master. + There is a bug in leader that when it tries to publish the new cluster state + it first tries acquire a lock to flush the new state under a mutex to disk. The + same lock is used to cancel the publication on timeout. Below is the state of + the timeout scheduler meant to cancel the publication. So essentially if the + flushing of cluster state is stuck on IO, so will the cancellation of the + publication since both of them share the same mutex. So leader will not step + down and effectively block the cluster from making progress. + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up settings + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up tests + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up tests + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up tests + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + +* __[Backport] Handle shard over allocation during partial zone/rack or independent … (#1268)__ + + [Bukhtawar Khan](mailto:bukhtawa@amazon.com) - Mon, 7 Feb 2022 09:58:10 -0500 + + * Handle shard over allocation during partial zone/rack or independent node + failures (#1149) + The changes ensure that in the event of a partial zone failure, the surviving + nodes in the minority zone don't get overloaded with shards, this is governed + by a skewness limit. + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up imports + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up imports + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up imports + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + * Fix up check style + Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com> + + +* __Add Version.V_1_2_5 constant__ + + [Nicholas Walter Knize](mailto:nknize@apache.org) - Fri, 4 Feb 2022 18:29:46 -0600 + + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + +* __add 1.2.5 to bwcVersions__ + + [Nicholas Walter Knize](mailto:nknize@apache.org) - Fri, 4 Feb 2022 18:29:35 -0600 + + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + +* __Revert "Upgrading Shadow plugin to 7.1.2 (#2033) (#2037)" (#2047)__ + + [Sarat Vemulapalli](mailto:vemulapallisarat@gmail.com) - Wed, 2 Feb 2022 19:40:51 -0800 + + This reverts commit 8725061c15fac70a81d144ed2d79b09f5e1a2f7f. + Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + + +* __Fix AssertionError message (#2044) (#2045)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Wed, 2 Feb 2022 21:05:15 -0500 + + Signed-off-by: Lukáš Vlček <lukas.vlcek@aiven.io> + (cherry picked from commit 270c59f523acbb3af73ab56dbcfe754e619fdca9) + Co-authored-by: Lukáš Vlček <lukas.vlcek@aiven.io> + + +* __Upgrading Shadow plugin to 7.1.2 (#2033) (#2037)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Wed, 2 Feb 2022 14:52:31 -0800 + + Shadow plugin is used for publishing jars + and this upgrades Log4J dependency + for build. + Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + (cherry picked from commit 1f9517c4caee48eda6eee77f603d815af1fd7770) + Co-authored-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + + +* __[FEATURE] Add OPENSEARCH_JAVA_HOME env to override JAVA_HOME (#2040)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Wed, 2 Feb 2022 12:16:50 -0800 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __build: introduce support for reproducible builds (#1995) (#2038)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Wed, 2 Feb 2022 14:21:34 -0500 + + Reproducible builds is an initiative to create an independently-verifiable path + from source to binary code [1]. This can be done by: + - Make all archive tasks in gradle reproducible by ignoring timestamp on files + [2] + - Preserve the order in side the archives [2] + - Ensure GlobalBuildInfoPlugin.java use [SOURCE_DATE_EPOCH] when available + + [SOURCE_DATE_EPOCH]: https://reproducible-builds.org/docs/source-date-epoch/ + [1]: https://reproducible-builds.org/ + [2]: + https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives + + Signed-off-by: Leonidas Spyropoulos <artafinde@gmail.com> + (cherry picked from commit 6da253b8fff9a9d9cbbf65807efa7aeaddc9c9d3) + Co-authored-by: Leonidas Spyropoulos <artafinde@gmail.com> + + +* __[1x] Deprecate index.merge.policy.max_merge_at_once_explicit (#1981) (#1984)__ + + [Nick Knize](mailto:nknize@apache.org) - Wed, 2 Feb 2022 11:48:00 -0600 + + max_merge_at_once_explicit is removed in lucene 9 so the index setting is + + deprecated for removal in the next major release. + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + +* __[Deprecate] Setting explicit version on analysis component (#1978) (#1985)__ + + [Nick Knize](mailto:nknize@apache.org) - Wed, 2 Feb 2022 12:28:44 -0500 + + Lucene 9 removes the ability to define an explicit version on an analysis + + component. The version parameter is deprecated at parse time and a warning is + + issued to the user through the deprecation logger. + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + +* __[BUG] Docker distribution builds are failing. Switching to http://vault.centos.org (#2024) (#2030)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Tue, 1 Feb 2022 14:16:50 -0600 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __[Backport] Enabling Sort Optimization to make use of Lucene (#1989)__ + + [Rishikesh Pasham](mailto:62345295+Rishikesh1159@users.noreply.github.com) - Mon, 31 Jan 2022 10:48:13 -0600 + + * Backport Enabling Sort Optimization to make use of Lucene + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + + * Backport Enabling Sort Optimization to make use of Lucene and small change in + a method call signature + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + + +* __Upgrading Jackson-Databind version (#1982) (#1987)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Sun, 30 Jan 2022 16:32:14 -0800 + + * Upgrading Jackson-Databind version + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + + * Adding jackson-databind version using getProperty method + Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com> + (cherry picked from commit 1568407c362b2534366048379f1bd93f2d164d89) + Co-authored-by: Rishikesh Pasham + <62345295+Rishikesh1159@users.noreply.github.com> + + +* __Update bundled JDK distribution to 17.0.2+8 (#2007) (#2009)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Sat, 29 Jan 2022 09:45:19 -0800 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Linked the formatting setting file (#1860) (#1961)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Thu, 27 Jan 2022 12:24:34 -0800 + + Signed-off-by: Owais Kazi <owaiskazi19@gmail.com> + (cherry picked from commit cfc9ec292dea2169495deffe6d1e25b654e5e35e) + Co-authored-by: Owais Kazi <owaiskazi19@gmail.com> + + +* __Add hook to execute logic before Integ test task starts (#1969) (#1971)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Wed, 26 Jan 2022 17:42:45 -0600 + + Add hook to execute custom logic before the integ test starts. + This is + required for a workaround to enable the jacoco code coverage for Integ Tests. + Signed-off-by: Ankit Kala <ankikala@amazon.com> + + +* __Fixing typo in TESTING.md (#1849) (#1959)__ + + [github-actions[bot]](mailto:41898282+github-actions[bot]@users.noreply.github.com) - Wed, 26 Jan 2022 17:41:33 -0600 + + Fixes some grammar and link typos found in TESTING.md. + Signed-off-by: Vacha Shah <vachshah@amazon.com> + + +* __Add max_expansions option to wildcard interval (#1916) (#1979)__ + + [Matt Weber](mailto:matt@mattweber.org) - Wed, 26 Jan 2022 16:08:34 -0600 + + Add support for setting the max expansions on a wildcard interval. + The default + value is still 128 and the max value is bounded by + `BooleanQuery.getMaxClauseCount()`. + Signed-off-by: Matt Weber <matt@mattweber.org> + + +* __Update protobuf-java to 3.19.3 (#1945) (#1949)__ + + [Tianli Feng](mailto:ftl94@live.com) - Fri, 21 Jan 2022 08:52:05 -0800 + + * Update protobuf-java to 3.19.3 + Signed-off-by: Tianli Feng <ftl94@live.com> + + * Exclude some API usage violations in the package com.google.protobuf for + thirdPartyAudit task to pass + Signed-off-by: Tianli Feng <ftl94@live.com> + + +* __Timeout fix backport to 1.x (#1953)__ + + [Suraj Singh](mailto:79435743+dreamer-89@users.noreply.github.com) - Thu, 20 Jan 2022 20:53:43 -0600 + + * [Bug] Wait for outstanding requests to complete (#1925) + Signed-off-by: Suraj Singh <surajrider@gmail.com> + + * [BUG] Wait for outstanding requests to complete in LastSuccessfulSett… + (#1939) + + * [BUG] Wait for outstanding requests to complete in + LastSuccessfulSettingsUpdate test + Signed-off-by: Suraj Singh <surajrider@gmail.com> + + * [BUG] Wait for outstanding requests to complete in + LastSuccessfulSettingsUpdate test + Signed-off-by: Suraj Singh <surajrider@gmail.com> + + +* __Update Netty to 4.1.73.Final (#1936) (#1937)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Wed, 19 Jan 2022 00:00:42 -0500 + + efs/remotes/origin/1.3 + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Modernize and consolidate JDKs usage across all stages of the build. Use JDK-17 as bundled JDK distribution to run tests (#1922)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Tue, 18 Jan 2022 10:51:53 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Expand SearchPlugin javadocs. (#1909) (#1923)__ + + [Matt Weber](mailto:matt@mattweber.org) - Tue, 18 Jan 2022 09:48:52 -0600 + + Add and clarify some search plugin point documentation. + Signed-off-by: Matt Weber <matt@mattweber.org> + + +* __Make SortBuilders pluggable (#1856) (#1915)__ + + [Matt Weber](mailto:matt@mattweber.org) - Mon, 17 Jan 2022 12:28:22 -0500 + + Add the ability for plugin authors to add custom sort builders. + Signed-off-by: Matt Weber <matt@mattweber.org> + + +* __Refactor LegacyESVersion tests from Version tests (#1662) (#1663)__ + + [Nick Knize](mailto:nknize@apache.org) - Mon, 17 Jan 2022 12:27:56 -0500 + + In preparation for removing all LegacyESVersion support by 3.0; this commit + + largely refactors the LegacyESVersion test logic from the OpenSearch Version + + test logic into an independent test class. This PR also updates + Version.fromString + to ensure a proper legacy version is returned when major is + > 3 (to support + legacy yaml test and build scripts). + Note that bwc w/ legacy versions are still supported so some cross + compatibility + testing is retained in the Version test class. + + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + +* __Fixing org.opensearch.common.network.InetAddressesTests.testForStringIPv6WithScopeIdInput (#1913) (#1914)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Sat, 15 Jan 2022 10:14:17 -0600 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __[BUG] Serialization bugs can cause node drops (#1885) (#1911)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Fri, 14 Jan 2022 14:23:25 -0600 + + This commit restructures InboundHandler to ensure all data + is consumed over + the wire. + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Fix o.o.transport.netty4.OpenSearchLoggingHandlerIT stack overflow test failure (#1900) (#1906)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Fri, 14 Jan 2022 12:38:18 -0600 + + Attempt to fix o.o.transport.netty4.OpenSearchLoggingHandlerIT fails w/ stack + overflow by + hardening test expectation patterns in regex patterns + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Replace JCenter with Maven Central. (#1057) (#1892)__ + + [Marc Handalian](mailto:handalm@amazon.com) - Wed, 12 Jan 2022 17:03:42 -0800 + + On February 3 2021, JFrog + [announced](https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/) + the shutdown of JCenter. Later on April 27 2021, an update was provided that + the repository will only be read only and new package and versions are no + longer accepted on JCenter. This means we should no longer use JCenter for our + central artifacts repository. + This change replaces JCenter with Maven Central as per the Gradle + recommendation - https://blog.gradle.org/jcenter-shutdown + Signed-off-by: Rabi Panda <adnapibar@gmail.com> + Signed-off-by: Marc Handalian + <handalm@amazon.com> + Co-authored-by: Rabi Panda <adnapibar@gmail.com> + + +* __Update FIPS API libraries of Bouncy Castle (#1853) (#1886)__ + + [Tianli Feng](mailto:ftl94@live.com) - Wed, 12 Jan 2022 09:37:05 -0500 + + * Update bc-fips to 1.0.2.1 + Signed-off-by: Tianli Feng <ftl94@live.com> + + * Update bcpg-fips to 1.0.5.1 + Signed-off-by: Tianli Feng <ftl94@live.com> + + * Update bctls-fips to 1.0.12.2 + Signed-off-by: Tianli Feng <ftl94@live.com> + + * Use the unified bouncycastle version for bcpkix-jdk15on in HDFS testing + fixture + Signed-off-by: Tianli Feng <ftl94@live.com> + + +* __[1.x] Remove remaining Flavor Serialization (#1751) (#1757)__ + + [Nick Knize](mailto:nknize@apache.org) - Thu, 6 Jan 2022 11:11:31 -0800 + + * [Remove] Remaining Flavor Serialization (#1751) + This commit removes unnecessary serialization of unused flavor variable in + build + metadata from V_1_3_0+ + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + * change flavor version check to V_1_3_0 + This commit changes the flavor serialization check in Build from V_2_0_0 to + V_1_3_0. + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + +* __Update junit to 4.13.1 (#1837) (#1842)__ + + [Ashish Agrawal](mailto:ashisagr@amazon.com) - Wed, 5 Jan 2022 08:15:56 -0500 + + * Update junit to 4.13.1 + Signed-off-by: Ashish Agrawal <ashisagr@amazon.com> + + * update junit to 4.13.2 + Signed-off-by: Ashish Agrawal <ashisagr@amazon.com> + + * update SHA1 file + Signed-off-by: Ashish Agrawal <ashisagr@amazon.com> + + +* __Upgrading bouncycastle to 1.70 (#1832) (#1834)__ + + [Sarat Vemulapalli](mailto:vemulapallisarat@gmail.com) - Tue, 4 Jan 2022 11:57:01 -0800 + + Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + + +* __Updatting Netty to 4.1.72.Final (#1831) (#1835)__ + + [Sarat Vemulapalli](mailto:vemulapallisarat@gmail.com) - Tue, 4 Jan 2022 11:56:39 -0800 + + Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + + +* __Intermittent java.lang.Exception: Suite timeout exceeded (>= 1200000 msec) (#1827)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Wed, 29 Dec 2021 13:23:49 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Execution failed for task ':test:fixtures:azure/s3/hdfs/gcs-fixture:composeDown' (#1824) (#1825)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Wed, 29 Dec 2021 11:28:51 -0600 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Update to log4j 2.17.1 (#1820) (#1822)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Tue, 28 Dec 2021 17:57:26 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __RestIntegTestTask fails because of missed log4j-core dependency (#1815) (#1818)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Tue, 28 Dec 2021 17:08:37 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Gradle clean failing after a failed gradle check, folders created by Docker under 'root' user (#1726) (#1775)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Thu, 23 Dec 2021 17:42:09 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __[plugin] repository-azure: add configuration settings for connect/write/response/read timeouts (#1789) (#1802)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Thu, 23 Dec 2021 12:26:27 -0600 + + * [plugin] repository-azure: add configuration settings for + connect/write/response/read timeouts + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + * Addressing code review comments: renaming connectionXxx to connectXxx + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + * Addressing code review comments: adding timeout comment + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Add bwc version 1.2.4 (#1797)__ + + [Rabi Panda](mailto:adnapibar@gmail.com) - Thu, 23 Dec 2021 10:19:15 -0500 + + Signed-off-by: Rabi Panda <adnapibar@gmail.com> + + +* __Use try-with-resources with MockLogAppender (#1595) (#1784)__ + + [Andrew Ross](mailto:andrross@amazon.com) - Tue, 21 Dec 2021 20:03:11 -0800 + + I previously added a helper that started a MockLogAppender to ensure it + was never added to a Logger before it was started. I subsequently found + the opposite case in RolloverIT.java where the appender was stopped + before it was closed, therefore creating a race where a concurrently + running test in the same JVM could cause a logging failure. This seems + like a really easy mistake to make when writing a test or introduce when + refactoring a test. I've made a change to use try-with-resources to + ensure that proper setup and teardown is done. This should make it much + harder to introduce this particular test bug in the future. Unfortunately, + it did involve touching a lot of files. The changes here are purely structural + to leverage try-with-resources; no testing logic has been changed. + + Signed-off-by: Andrew Ross <andrross@amazon.com> + + +* __Ignore file order in test assertion (#1755) (#1782)__ + + [Andrew Ross](mailto:andrross@amazon.com) - Mon, 20 Dec 2021 19:35:36 -0600 + + This unit test asserts that a SHA file for a groovy dependency gets + created. + However, a SHA file for javaparser-core also gets created in + the same + directory. For some reason, builds were failing on my machine + because + `Files::list` was returning the javaparser-core file first. I + don't believe + there are any ordering guarantees with that API, so I + relaxed the assertion to + not depend on ordering. + + Signed-off-by: Andrew Ross <andrross@amazon.com> + + +* __Fixing allocation filters to persist existing state on settings update (#1718) (#1780)__ + + [Ankit Jain](mailto:jain.ankitk@gmail.com) - Mon, 20 Dec 2021 18:31:53 -0500 + + * Fixing allocation filters to persist existing state on settings update + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Adding test for filter settings update + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Adding more tests and review comments + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Adding assertion and unit test for operation type mismatch + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + * Updating test names + + Signed-off-by: Ankit Jain <jain.ankitk@gmail.com> + + +* __Update to log4j 2.17.0 (#1771) (#1773)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Sat, 18 Dec 2021 11:33:16 -0800 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Updating .gitattributes for additional file types (#1727) (#1766)__ + + [Sarat Vemulapalli](mailto:vemulapallisarat@gmail.com) - Fri, 17 Dec 2021 15:51:12 -0800 + + * Updating .gitattributes for additional types + + Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + + +* __Better JDK-18 EA (and beyond) support of SecurityManager (#1750) (#1753)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Fri, 17 Dec 2021 16:08:30 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Add version 1.2.3. (#1759)__ + + [Daniel Doubrovkine (dB.)](mailto:dblock@dblock.org) - Fri, 17 Dec 2021 09:14:45 -0800 + + Signed-off-by: dblock <dblock@dblock.org> + + +* __[plugin] repository-azure is not working properly hangs on basic operations (#1740)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Thu, 16 Dec 2021 15:01:50 -0500 + + * [plugin] repository-azure is not working properly hangs on basic operations + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + * Added tests cases and TODO items, addressing code review comments + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Adding 1.2.2 (#1731) (#1736)__ + + [Sarat Vemulapalli](mailto:vemulapallisarat@gmail.com) - Wed, 15 Dec 2021 14:16:16 -0500 + + Signed-off-by: Sarat Vemulapalli <vemulapallisarat@gmail.com> + + +* __Upgrade to log4j 2.16.0 (#1721) (#1723)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Tue, 14 Dec 2021 12:19:35 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Support JDK 18 EA builds (#1714)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Tue, 14 Dec 2021 06:47:00 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Fixing .gitattributes for binary content, removing *.class files (#1717) (#1720)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Mon, 13 Dec 2021 16:11:25 -0800 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Upgrade to logj4 2.15.0 (#1705)__ + + [Andrew Ross](mailto:andrross@amazon.com) - Fri, 10 Dec 2021 16:35:18 -0500 + + Signed-off-by: Andrew Ross <andrross@amazon.com> + + +* __Add version 1.2.1. (#1701) (#1702)__ + + [Daniel Doubrovkine (dB.)](mailto:dblock@dblock.org) - Fri, 10 Dec 2021 15:36:19 -0500 + + Signed-off-by: dblock <dblock@dblock.org> + + +* __Move Gradle wrapper and precommit checks into OpenSearch repo. (#1664) (#1678)__ + + [Daniel Doubrovkine (dB.)](mailto:dblock@dblock.org) - Wed, 8 Dec 2021 11:45:55 -0500 + + * Move Gradle checks into OpenSearch repo. + Signed-off-by: dblock <dblock@amazon.com> + + * Use working-directory for gradle wrapper validation. + Signed-off-by: dblock <dblock@amazon.com> + + * Use https://github.com/gradle/wrapper-validation-action. + Signed-off-by: dblock <dblock@amazon.com> + + +* __Moving DCO to workflows (#1458) (#1666)__ + + [Daniel Doubrovkine (dB.)](mailto:dblock@dblock.org) - Wed, 8 Dec 2021 07:59:34 -0500 + + Signed-off-by: CEHENKLE <henkle@amazon.com> + Co-authored-by: CEHENKLE <henkle@amazon.com> + + +* __Start MockLogAppender before adding to static context (#1587) (#1659)__ + + [Andrew Ross](mailto:andrross@amazon.com) - Mon, 6 Dec 2021 16:45:49 -0500 + + I observed a test failure with the message + 'Attempted to append to non-started appender mock' from an assertion in + `OpenSearchTestCase::after`. I believe this indicates that a + MockLogAppender + (which is named "mock") was added as an appender to the + static logging context + and some other test in the same JVM happened to + cause a logging statement to + hit that appender and cause an error, which + then caused an unrelated test to + fail (because they share static state + with the logger). Almost all usages of + MockLogAppender start it + immediately after creation. I found a few that did + not and fixed those. + I also made a static helper in MockLogAppender to start + it upon + creation. + Signed-off-by: Andrew Ross <andrross@amazon.com> + + +* __Revert "Support Gradle 7 (#1609) (#1622)" (#1657)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Mon, 6 Dec 2021 10:47:35 -0500 + + This reverts commit 93bd32b14270be0da8a6b5eef8eeabfce7eb2b58. + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Added .gitattributes to manage end-of-line checks for Windows/*nix systems (#1638) (#1655)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Mon, 6 Dec 2021 08:08:01 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Support Gradle 7 (#1609) (#1622)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Fri, 3 Dec 2021 15:53:57 -0500 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Renaming Slave terminology to Replica in 1.x branch (backporting) (#1645)__ + + [Rishikesh Pasham](mailto:62345295+Rishikesh1159@users.noreply.github.com) - Fri, 3 Dec 2021 15:52:51 -0500 + + Signed-off-by: Rishikesh Pasham <rishireddy1159@gmail.com> + + +* __Upgrading commons-codec in hdfs-fixture and cleaning up dependencies in repository-hdfs (#1603) (#1621)__ + + [Vacha](mailto:vachshah@amazon.com) - Tue, 30 Nov 2021 17:17:21 -0500 + + Signed-off-by: Vacha <vachshah@amazon.com> + + +* __Rename field_masking_span to span_field_masking (#1606) (#1623)__ + + [Xue Zhou](mailto:85715413+xuezhou25@users.noreply.github.com) - Mon, 29 Nov 2021 23:18:13 -0500 + + * Rename field_masking_span to span_field_masking + Signed-off-by: Xue Zhou <xuezhou@amazon.com> + + * Update SearchModuleTests.java + Signed-off-by: Xue Zhou <xuezhou@amazon.com> + + * Rename field_masking_span to span_field_masking + Signed-off-by: Xue Zhou <xuezhou@amazon.com> + + +* __Upgrade dependency (#1571) (#1594)__ + + [Vacha](mailto:vachshah@amazon.com) - Mon, 29 Nov 2021 14:48:33 -0500 + + * Upgrading guava, commons-io and apache-ant dependencies. + Signed-off-by: Vacha <vachshah@amazon.com> + + * Adding failureaccess since guava needs it. + Signed-off-by: Vacha <vachshah@amazon.com> + + +* __Lower build requirement from Java 14+ to Java 11+ (#940) (#1608)__ + + [Marc Handalian](mailto:handalm@amazon.com) - Tue, 23 Nov 2021 21:41:59 -0500 + + * Lower build requirement from Java 14+ to Java 11+ + Avoid use of -Werror -Xlint:all, which may change significantly across + java + releases (new warnings could be added). Instead, just list the + warnings + individually. + Workaround JDK 11 compiler bug (JDK-8209058) that only impacts test fixture + code in the build itself. + Signed-off-by: Robert Muir <rmuir@apache.org> + + * Disable warning around -source 7 -release 7 for java version checker + The java version checker triggers some default warnings because it + targets + java7: + + ``` + Task :distribution:tools:java-version-checker:compileJava FAILED + warning: [options] source value 7 is obsolete and will be removed in a future release + warning: [options] target value 7 is obsolete and will be removed in a future release + warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. + + error: warnings found and -Werror specified + ``` + + * Suppress this warning explicitly for this module. + Signed-off-by: Robert Muir <rmuir@apache.org> + + * more java14 -> java11 cleanup + Signed-off-by: Robert Muir <rmuir@apache.org> + Co-authored-by: Robert Muir <rmuir@apache.org> + Signed-off-by: Marc Handalian + <handalm@amazon.com> + Co-authored-by: Daniel Doubrovkine (dB.) <dblock@dblock.org> + Co-authored-by: + Robert Muir <rmuir@apache.org> + + +* __Giving informative error messages for double slashes in API call URLs- [ BACKPORT-1.x ] (#1601)__ + + [Megha Sai Kavikondala](mailto:kavmegha@amazon.com) - Tue, 23 Nov 2021 13:34:31 -0500 + + * Integration test that checks for settings upgrade (#1482) + + * Made changes. + Signed-off-by: Megha Sai Kavikondala <kavmegha@amazon.com> + + * Signed-off-by: Megha Sai Kavikondala <kavmegha@amazon.com> + Changes made by deleting the TestSettingsIT file and adding new lines in + FullClusterRestartSettingsUpgradeIT.java + Signed-off-by: Megha Sai Kavikondala <kavmegha@amazon.com> + + * Signed-off-by: Megha Sai Kavikondala <kavmegha@amazon.com> + Informative error messages related to empty index name.[Backport] + + +* __Enable RestHighLevel-Client to set parameter require_alias for bulk index and reindex requests (#1604)__ + + [Jan Baudisch](mailto:jan.baudisch.de@gmail.com) - Tue, 23 Nov 2021 10:20:07 -0500 + + Signed-off-by: Jan Baudisch <jan.baudisch.libri@gmail.com> + Co-authored-by: Jan Baudisch <jan.baudisch.libri@gmail.com> + + +* __Upgrading gson to 2.8.9 (#1541). (#1545)__ + + [Vacha](mailto:vachshah@amazon.com) - Fri, 19 Nov 2021 16:52:38 -0500 + + Signed-off-by: Vacha <vachshah@amazon.com> + + +* __[repository-azure] Update to the latest Azure Storage SDK v12, remove privileged runnable wrapper in favor of access helper (#1521) (#1538)__ + + [Andriy Redko](mailto:andriy.redko@aiven.io) - Thu, 11 Nov 2021 14:05:47 -0800 + + Signed-off-by: Andriy Redko <andriy.redko@aiven.io> + + +* __Integration test that checks for settings upgrade (#1482) (#1524)__ + + [Megha Sai Kavikondala](mailto:kavmegha@amazon.com) - Thu, 11 Nov 2021 12:55:11 -0800 + + * Made changes. + Signed-off-by: Megha Sai Kavikondala <kavmegha@amazon.com> + + * Signed-off-by: Megha Sai Kavikondala <kavmegha@amazon.com> + Changes made by deleting the TestSettingsIT file and adding new lines in + FullClusterRestartSettingsUpgradeIT.java + Signed-off-by: Megha Sai Kavikondala <kavmegha@amazon.com> + + +* __Added logic to allow {dot} files on startup (#1437) (#1516)__ + + [Ryan Bogan](mailto:10944539+ryanbogan@users.noreply.github.com) - Thu, 11 Nov 2021 11:02:03 -0800 + + * Added logic to allow {dot} files on startup + Signed-off-by: Ryan Bogan <rbogan@amazon.com> + + * Ensures that only plugin directories are returned by findPluginDirs() + Signed-off-by: Ryan Bogan <rbogan@amazon.com> + + * Prevents . files from being returned as plugins + Signed-off-by: Ryan Bogan <rbogan@amazon.com> + + +* __Add staged version 1.1.1 (#1509)__ + + [Nick Knize](mailto:nknize@apache.org) - Thu, 4 Nov 2021 14:46:57 -0500 + + Signed-off-by: Nicholas Walter Knize <nknize@apache.org> + + diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cat.master.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cat.cluster_manager.json similarity index 67% rename from rest-api-spec/src/main/resources/rest-api-spec/api/cat.master.json rename to rest-api-spec/src/main/resources/rest-api-spec/api/cat.cluster_manager.json index 63fe159ee56b8..c1084825546bf 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/cat.master.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cat.cluster_manager.json @@ -1,17 +1,27 @@ { - "cat.master":{ + "cat.cluster_manager":{ "documentation":{ - "url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html", - "description":"Returns information about the master node." + "url":"https://opensearch.org/docs/latest/opensearch/rest-api/cat/cat-master/", + "description":"Returns information about the cluster-manager node." }, "stability":"stable", "url":{ "paths":[ { - "path":"/_cat/master", + "path":"/_cat/cluster_manager", "methods":[ "GET" ] + }, + { + "path":"/_cat/master", + "methods":[ + "GET" + ], + "deprecated":{ + "version":"2.0.0", + "description":"To promote inclusive language, please use '/_cat/cluster_manager' instead." + } } ] }, @@ -22,7 +32,7 @@ }, "local":{ "type":"boolean", - "description":"Return local information, do not retrieve the state from master node (default: false)" + "description":"Return local information, do not retrieve the state from cluster-manager node (default: false)" }, "master_timeout":{ "type":"time", diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cat.nodes.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cat.nodes.json index ba3faa92c5ec6..abb13d015b4d5 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/cat.nodes.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cat.nodes.json @@ -51,7 +51,15 @@ }, "master_timeout":{ "type":"time", - "description":"Explicit operation timeout for connection to master node" + "description":"Explicit operation timeout for connection to master node", + "deprecated":{ + "version":"2.0.0", + "description":"To promote inclusive language, use 'cluster_manager_timeout' instead." + } + }, + "cluster_manager_timeout":{ + "type":"time", + "description":"Explicit operation timeout for connection to cluster-manager node" }, "h":{ "type":"list", diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.reroute.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.reroute.json index b0e8054fc9e53..bcf2704110664 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.reroute.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.reroute.json @@ -37,6 +37,7 @@ "nodes", "routing_table", "master_node", + "cluster_manager_node", "version" ], "description":"Limit the information returned to the specified metrics. Defaults to all but metadata" diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.state.json b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.state.json index 017705082d189..c17e5b073e361 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.state.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.state.json @@ -55,6 +55,7 @@ "routing_table", "routing_nodes", "master_node", + "cluster_manager_node", "version" ], "description":"Limit the information returned to the specified metrics" diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.cluster_manager/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.cluster_manager/10_basic.yml new file mode 100644 index 0000000000000..b0f1c81b56a0e --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.cluster_manager/10_basic.yml @@ -0,0 +1,46 @@ +setup: + - skip: + features: allowed_warnings + +--- +"Help": + - skip: + version: " - 1.4.99" + reason: "path _cat/cluster_manager is introduced in 2.0.0" + + - do: + cat.cluster_manager: + help: true + allowed_warnings: + - '[GET /_cat/master] is deprecated! Use [GET /_cat/cluster_manager] instead.' + + - match: + $body: | + /^ id .+ \n + host .+ \n + ip .+ \n + node .+ \n + + $/ + +--- +"Test cat cluster_manager output": + - skip: + version: " - 1.4.99" + reason: "path _cat/cluster_manager is introduced in 2.0.0" + + - do: + cat.cluster_manager: {} + allowed_warnings: + - '[GET /_cat/master] is deprecated! Use [GET /_cat/cluster_manager] instead.' + + - match: + $body: | + /^ + ( \S+ \s+ # node id + [-\w.]+ \s+ # host name + (\d{1,3}\.){3}\d{1,3} \s+ # ip address + [-\w.]+ # node name + \n + ) + $/ diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml index 731fc5d166eca..0d945d01a6ddb 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.health/10_basic.yml @@ -1,11 +1,19 @@ --- -"Help": +"Help - before 2.0.0": - skip: - version: " - 7.10.99" - reason: "discovered_master added in OpenSearch 1.0.0" + version: " - 7.10.99 , 2.0.0 - " + reason: "discovered_master added in OpenSearch 1.0.0, and renamed to discovered_cluster_manager in 2.0.0" + features: node_selector - do: cat.health: help: true + node_selector: + # Only send request to nodes in <2.0 versions, especially during ':qa:mixed-cluster:v1.x.x#mixedClusterTest'. + # Because YAML REST test takes the minimum OpenSearch version in the cluster to apply the filter in 'skip' section, + # see OpenSearchClientYamlSuiteTestCase#initAndResetContext() for detail. + # During 'mixedClusterTest', the cluster can be mixed with nodes in 1.x and 2.x versions, + # so node_selector is required, and only filtering version in 'skip' is not enough. + version: "1.0.0 - 1.4.99" - match: $body: | @@ -27,6 +35,34 @@ $/ +--- +"Help": + - skip: + version: " - 1.4.99" + reason: "discovered_cluster_manager is added in OpenSearch 2.0.0" + - do: + cat.health: + help: true + + - match: + $body: | + /^ epoch .+ \n + timestamp .+ \n + cluster .+ \n + status .+ \n + node.total .+ \n + node.data .+ \n + discovered_cluster_manager .+ \n + shards .+ \n + pri .+ \n + relo .+ \n + init .+ \n + unassign .+ \n + pending_tasks .+ \n + max_task_wait_time .+ \n + active_shards_percent .+ \n + + $/ --- "Empty cluster": diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.nodes/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.nodes/10_basic.yml index 16bf099081c6d..789ea5fc19c3f 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.nodes/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.nodes/10_basic.yml @@ -1,13 +1,39 @@ +--- +"Test cat nodes output - before 2.0.0": + - skip: + version: "2.0.0 - " + reason: "master is replaced by cluster_manager in 2.0.0" + features: node_selector + + - do: + cat.nodes: + v: true + node_selector: + # Only send request to nodes in <2.0 versions, especially during ':qa:mixed-cluster:v1.x.x#mixedClusterTest'. + # Because YAML REST test takes the minimum OpenSearch version in the cluster to apply the filter in 'skip' section, + # see OpenSearchClientYamlSuiteTestCase#initAndResetContext() for detail. + # During 'mixedClusterTest', the cluster can be mixed with nodes in 1.x and 2.x versions, + # so node_selector is required, and only filtering version in 'skip' is not enough. + version: "1.0.0 - 1.4.99" + + - match: + $body: | + /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n + ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + --- "Test cat nodes output": + - skip: + version: " - 1.4.99" + reason: "cluster_manager is introduced in 2.0.0" - do: cat.nodes: {} - match: $body: | - / #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name - ^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + / #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role cluster_manager name + ^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ - do: cat.nodes: @@ -15,8 +41,8 @@ - match: $body: | - /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n - ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ cluster_manager \s+ name \n + ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[cdhilmrstvw]{1,11}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ - do: cat.nodes: diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/10_basic.yml index db74e51cc2f91..0f12a87bd8771 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/10_basic.yml @@ -275,3 +275,16 @@ cluster.health: index: index-2 - match: { status: yellow } + +--- +"Get cluster health has same value for discovered_master and discovered_cluster_manager": + - skip: + version: " - 1.4.99" + reason: "discovered_cluster_manager is added in 2.0.0" + - do: + cluster.health: {} + - set: + discovered_master: discovered_or_not + + - match: { discovered_master: $discovered_or_not } + - match: { discovered_cluster_manager: $discovered_or_not } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/10_basic.yml index 771f647a952c7..1b45e19c24acf 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/10_basic.yml @@ -2,3 +2,18 @@ "Basic sanity check": - do: cluster.reroute: {} + +--- +"Cluster reroute returns cluster_manager_node": + - skip: + version: " - 1.4.99" + reason: "The metric cluster_manager_node is added to cluster state in version 2.0.0" + + - do: + cluster.reroute: {} + + - set: + state.cluster_manager_node: node_id + + - match: {state.master_node: $node_id} + - match: {state.cluster_manager_node: $node_id} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/20_response_filtering.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/20_response_filtering.yml index 437b78e6119a7..c05d1db51142e 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/20_response_filtering.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.reroute/20_response_filtering.yml @@ -3,6 +3,7 @@ - do: cluster.reroute: {} - is_false: state.metadata + --- "return metadata if requested": - do: @@ -12,3 +13,15 @@ - is_true: state.metadata - is_false: state.nodes +--- +"Filter the cluster reroute by cluster_manager_node only should work": + - skip: + version: " - 1.4.99" + reason: "The metric cluster_manager_node is added to cluster state in version 2.0.0" + + - do: + cluster.reroute: + metric: [ cluster_manager_node ] + + - is_true: state.cluster_manager_node + - is_false: state.master_node diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/10_basic.yml index b443e322f80f6..fa973454cfba5 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/10_basic.yml @@ -17,3 +17,18 @@ - is_true: cluster_uuid - is_true: master_node + +--- +"Get cluster state returns cluster_manager_node": + - skip: + version: " - 1.4.99" + reason: "The metric cluster_manager_node is added to cluster state in version 2.0.0" + + - do: + cluster.state: {} + + - set: + cluster_manager_node: node_id + + - match: {master_node: $node_id} + - match: {cluster_manager_node: $node_id} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/20_filtering.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/20_filtering.yml index 88da42ee876be..3d20f1d0f7e52 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/20_filtering.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.state/20_filtering.yml @@ -158,6 +158,7 @@ setup: - skip: version: " - 6.3.99" reason: "cluster state including cluster_uuid at the top level is new in v6.4.0 and higher" + features: allowed_warnings # Get the current cluster_uuid - do: @@ -167,6 +168,8 @@ setup: - do: cluster.state: metric: [ master_node, version ] + allowed_warnings: + - 'Deprecated value [master_node] used for parameter [metric]. To promote inclusive language, please use [cluster_manager_node] instead. It will be unsupported in a future major version.' - match: { cluster_uuid: $cluster_uuid } - is_true: master_node @@ -180,3 +183,16 @@ setup: - match: { cluster_uuid: $cluster_uuid } - is_true: routing_table + +--- +"Filter the cluster state by cluster_manager_node only should work": + - skip: + version: " - 1.4.99" + reason: "The metric cluster_manager_node is added to cluster state in version 2.0.0" + + - do: + cluster.state: + metric: [ cluster_manager_node ] + + - is_true: cluster_manager_node + - is_false: master_node diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.stats/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.stats/10_basic.yml index a0432fa7aa558..6e149b297d843 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.stats/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cluster.stats/10_basic.yml @@ -91,3 +91,22 @@ cluster.stats: {} - is_true: nodes.packaging_types + +--- +"get cluster stats nodes count with both master and cluster_manager": + - skip: + version: " - 1.4.99" + reason: "node role cluster_manager is added in 2.0.0" + + - do: + cluster.stats: {} + + - set: + nodes.count.cluster_manager: cluster_manager_count + + - gte: { nodes.count.total: 1} + - match: { nodes.count.cluster_manager: $cluster_manager_count } + - match: { nodes.count.master: $cluster_manager_count } + - gte: { nodes.count.data: 1} + - gte: { nodes.count.ingest: 0} + - gte: { nodes.count.coordinating_only: 0} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/nodes.info/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/nodes.info/10_basic.yml index 2a4bbfe0a20ba..c779cb80d13b3 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/nodes.info/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/nodes.info/10_basic.yml @@ -12,14 +12,24 @@ setup: - is_true: cluster_name --- -"node_info role test": +"node_info role test - before 2.0.0": - skip: - version: " - 7.7.99" + version: " - 7.7.99 , 2.0.0 - " reason: "node roles were not sorted before 7.8.0" + features: node_selector - do: nodes.info: {} + node_selector: + # Only send request to nodes in <2.0 versions, especially during ':qa:mixed-cluster:v1.x.x#mixedClusterTest'. + # Because YAML REST test takes the minimum OpenSearch version in the cluster to apply the filter in 'skip' section, + # see OpenSearchClientYamlSuiteTestCase#initAndResetContext() for detail. + # During 'mixedClusterTest', the cluster can be mixed with nodes in 1.x and 2.x versions, + # so node_selector is required, and only filtering version in 'skip' is not enough. + version: "1.0.0 - 1.4.99" + - set: + # Note: It will only stash the first node_id in the api response. nodes._arbitrary_key_: node_id - is_true: nodes.$node_id.roles @@ -29,3 +39,21 @@ setup: - match: { nodes.$node_id.roles.2: "master" } - match: { nodes.$node_id.roles.3: "remote_cluster_client" } +--- +"node_info role test": + - skip: + version: " - 1.4.99" + reason: "node role cluster_manager is added in 2.0.0" + + - do: + nodes.info: {} + + - set: + nodes._arbitrary_key_: node_id + + - is_true: nodes.$node_id.roles + # the roles output is sorted + - match: { nodes.$node_id.roles.0: "cluster_manager" } + - match: { nodes.$node_id.roles.1: "data" } + - match: { nodes.$node_id.roles.2: "ingest" } + - match: { nodes.$node_id.roles.3: "remote_cluster_client" } diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/stats/ClusterStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/stats/ClusterStatsIT.java index 72f34133067ee..5b48268dfa89f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/stats/ClusterStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/stats/ClusterStatsIT.java @@ -85,6 +85,7 @@ public void testNodeCounts() { Map expectedCounts = new HashMap<>(); expectedCounts.put(DiscoveryNodeRole.DATA_ROLE.roleName(), 1); expectedCounts.put(DiscoveryNodeRole.MASTER_ROLE.roleName(), 1); + expectedCounts.put(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(), 1); expectedCounts.put(DiscoveryNodeRole.INGEST_ROLE.roleName(), 1); expectedCounts.put(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE.roleName(), 1); expectedCounts.put(ClusterStatsNodes.Counts.COORDINATING_ONLY, 0); @@ -106,7 +107,7 @@ public void testNodeCounts() { roles.add(DiscoveryNodeRole.INGEST_ROLE); } if (isMasterNode) { - roles.add(DiscoveryNodeRole.MASTER_ROLE); + roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } if (isRemoteClusterClientNode) { roles.add(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE); @@ -129,6 +130,7 @@ public void testNodeCounts() { } if (isMasterNode) { incrementCountForRole(DiscoveryNodeRole.MASTER_ROLE.roleName(), expectedCounts); + incrementCountForRole(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(), expectedCounts); } if (isRemoteClusterClientNode) { incrementCountForRole(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE.roleName(), expectedCounts); diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java index ef5c56c50ed83..e8a6c68a41076 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/ShrinkIndexIT.java @@ -71,7 +71,6 @@ import org.opensearch.index.Index; import org.opensearch.index.IndexService; import org.opensearch.index.engine.SegmentsStats; -import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.TermsQueryBuilder; import org.opensearch.index.seqno.SeqNoStats; import org.opensearch.index.shard.IndexShard; @@ -527,7 +526,7 @@ public void testCreateShrinkWithIndexSort() throws Exception { .put("sort.order", "desc") .put("number_of_shards", 8) .put("number_of_replicas", 0) - ).addMapping(MapperService.SINGLE_MAPPING_NAME, "id", "type=keyword,doc_values=true").get(); + ).setMapping("id", "type=keyword,doc_values=true").get(); for (int i = 0; i < 20; i++) { client().prepareIndex("source") .setId(Integer.toString(i)) diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java index 42b1d5f4a757f..89e11984621da 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java @@ -65,7 +65,6 @@ import org.opensearch.index.Index; import org.opensearch.index.IndexService; import org.opensearch.index.engine.SegmentsStats; -import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.TermsQueryBuilder; import org.opensearch.index.seqno.SeqNoStats; import org.opensearch.index.shard.IndexShard; @@ -136,12 +135,12 @@ private void splitToN(int sourceShards, int firstSplitShards, int secondSplitSha int numRoutingShards = MetadataCreateIndexService.calculateNumRoutingShards(secondSplitShards, Version.CURRENT) - 1; settings.put("index.routing_partition_size", randomIntBetween(1, numRoutingShards)); if (useNested) { - createInitialIndex.addMapping(MapperService.SINGLE_MAPPING_NAME, "_routing", "required=true", "nested1", "type=nested"); + createInitialIndex.setMapping("_routing", "required=true", "nested1", "type=nested"); } else { - createInitialIndex.addMapping(MapperService.SINGLE_MAPPING_NAME, "_routing", "required=true"); + createInitialIndex.setMapping("_routing", "required=true"); } } else if (useNested) { - createInitialIndex.addMapping(MapperService.SINGLE_MAPPING_NAME, "nested1", "type=nested"); + createInitialIndex.setMapping("nested1", "type=nested"); } logger.info("use routing {} use mixed routing {} use nested {}", useRouting, useMixedRouting, useNested); createInitialIndex.setSettings(settings).get(); @@ -523,7 +522,7 @@ public void testCreateSplitWithIndexSort() throws Exception { .put("sort.order", "desc") .put("number_of_shards", 2) .put("number_of_replicas", 0) - ).addMapping(MapperService.SINGLE_MAPPING_NAME, "id", "type=keyword,doc_values=true").get(); + ).setMapping("id", "type=keyword,doc_values=true").get(); for (int i = 0; i < 20; i++) { client().prepareIndex("source") .setId(Integer.toString(i)) diff --git a/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java index c7985d972de5e..a356d273f7060 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/search/TransportSearchIT.java @@ -348,7 +348,7 @@ public void testSearchIdle() throws Exception { .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 5)) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numOfReplicas) .put(IndexSettings.INDEX_SEARCH_IDLE_AFTER.getKey(), TimeValue.timeValueMillis(randomIntBetween(50, 500))); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("_doc", "created_date", "type=date,format=yyyy-MM-dd")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("created_date", "type=date,format=yyyy-MM-dd")); ensureGreen("test"); assertBusy(() -> { for (String node : internalCluster().nodesInclude("test")) { diff --git a/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java b/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java index 8ab6450ead2af..b5e60f44983f5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/termvectors/GetTermVectorsIT.java @@ -161,8 +161,7 @@ public void testNotIndexedField() throws Exception { // must be of type string and indexed. assertAcked( prepareCreate("test").addAlias(new Alias("alias")) - .addMapping( - "type1", + .setMapping( "field0", "type=integer,", // no tvs "field1", @@ -548,10 +547,8 @@ 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]).addMapping("type1", "field1", "type=text,term_vector=with_positions_offsets,analyzer=keyword") - ); - assertAcked(prepareCreate(indexNames[1]).addMapping("type1", "field1", "type=text,term_vector=no,analyzer=keyword")); + 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")); ensureGreen(); // index documents with and without term vectors @@ -656,9 +653,7 @@ public void testSimpleWildCards() throws IOException { public void testArtificialVsExisting() throws ExecutionException, InterruptedException, IOException { // setup indices Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "standard"); - assertAcked( - prepareCreate("test").setSettings(settings).addMapping("type1", "field1", "type=text,term_vector=with_positions_offsets") - ); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("field1", "type=text,term_vector=with_positions_offsets")); ensureGreen(); // index documents existing document @@ -704,7 +699,7 @@ public void testArtificialVsExisting() throws ExecutionException, InterruptedExc public void testArtificialNoDoc() throws IOException { // setup indices Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "standard"); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", "field1", "type=text")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("field1", "type=text")); ensureGreen(); // request tvs from artificial document @@ -929,7 +924,7 @@ public void testTermVectorsWithVersion() { public void testFilterLength() throws ExecutionException, InterruptedException, IOException { logger.info("Setting up the index ..."); Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "keyword"); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", "tags", "type=text")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("tags", "type=text")); int numTerms = scaledRandomIntBetween(10, 50); logger.info("Indexing one document with tags of increasing length ..."); @@ -962,7 +957,7 @@ public void testFilterLength() throws ExecutionException, InterruptedException, public void testFilterTermFreq() throws ExecutionException, InterruptedException, IOException { logger.info("Setting up the index ..."); Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "keyword"); - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", "tags", "type=text")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("tags", "type=text")); logger.info("Indexing one document with tags of increasing frequencies ..."); int numTerms = scaledRandomIntBetween(10, 50); @@ -1000,7 +995,7 @@ public void testFilterDocFreq() throws ExecutionException, InterruptedException, .put(indexSettings()) .put("index.analysis.analyzer", "keyword") .put("index.number_of_shards", 1); // no dfs - assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", "tags", "type=text")); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("tags", "type=text")); int numDocs = scaledRandomIntBetween(10, 50); // as many terms as there are docs logger.info("Indexing {} documents with tags of increasing dfs ...", numDocs); @@ -1030,9 +1025,7 @@ public void testFilterDocFreq() throws ExecutionException, InterruptedException, public void testArtificialDocWithPreference() throws InterruptedException, IOException { // setup indices Settings.Builder settings = Settings.builder().put(indexSettings()).put("index.analysis.analyzer", "standard"); - assertAcked( - prepareCreate("test").setSettings(settings).addMapping("type1", "field1", "type=text,term_vector=with_positions_offsets") - ); + assertAcked(prepareCreate("test").setSettings(settings).setMapping("field1", "type=text,term_vector=with_positions_offsets")); ensureGreen(); // index document @@ -1076,8 +1069,7 @@ public void testWithKeywordAndNormalizer() throws IOException, ExecutionExceptio .putList("index.analysis.normalizer.my_normalizer.filter", "lowercase"); assertAcked( prepareCreate(indexNames[0]).setSettings(builder.build()) - .addMapping( - "type1", + .setMapping( "field1", "type=text,term_vector=with_positions_offsets,analyzer=my_analyzer", "field2", @@ -1086,7 +1078,7 @@ public void testWithKeywordAndNormalizer() throws IOException, ExecutionExceptio ); assertAcked( prepareCreate(indexNames[1]).setSettings(builder.build()) - .addMapping("type1", "field1", "type=keyword,normalizer=my_normalizer", "field2", "type=keyword") + .setMapping("field1", "type=keyword,normalizer=my_normalizer", "field2", "type=keyword") ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java b/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java index 2d01e4c031538..ff64a2cd90cb8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/aliases/IndexAliasesIT.java @@ -226,7 +226,7 @@ public void testFailedFilter() throws Exception { public void testFilteringAliases() throws Exception { logger.info("--> creating index [test]"); - assertAcked(prepareCreate("test").addMapping("type", "user", "type=text")); + assertAcked(prepareCreate("test").setMapping("user", "type=text")); ensureGreen(); @@ -260,7 +260,7 @@ public void testEmptyFilter() throws Exception { public void testSearchingFilteringAliasesSingleIndex() throws Exception { logger.info("--> creating index [test]"); - assertAcked(prepareCreate("test").addMapping("type1", "id", "type=text", "name", "type=text,fielddata=true")); + assertAcked(prepareCreate("test").setMapping("id", "type=text", "name", "type=text,fielddata=true")); ensureGreen(); @@ -363,9 +363,9 @@ public void testSearchingFilteringAliasesSingleIndex() throws Exception { public void testSearchingFilteringAliasesTwoIndices() throws Exception { logger.info("--> creating index [test1]"); - assertAcked(prepareCreate("test1").addMapping("type1", "name", "type=text")); + assertAcked(prepareCreate("test1").setMapping("name", "type=text")); logger.info("--> creating index [test2]"); - assertAcked(prepareCreate("test2").addMapping("type1", "name", "type=text")); + assertAcked(prepareCreate("test2").setMapping("name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -593,8 +593,8 @@ public void testSearchingFilteringAliasesMultipleIndices() throws Exception { public void testDeletingByQueryFilteringAliases() throws Exception { logger.info("--> creating index [test1] and [test2"); - assertAcked(prepareCreate("test1").addMapping("type1", "name", "type=text")); - assertAcked(prepareCreate("test2").addMapping("type1", "name", "type=text")); + assertAcked(prepareCreate("test1").setMapping("name", "type=text")); + assertAcked(prepareCreate("test2").setMapping("name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -648,8 +648,8 @@ public void testDeletingByQueryFilteringAliases() throws Exception { public void testDeleteAliases() throws Exception { logger.info("--> creating index [test1] and [test2]"); - assertAcked(prepareCreate("test1").addMapping("type", "name", "type=text")); - assertAcked(prepareCreate("test2").addMapping("type", "name", "type=text")); + assertAcked(prepareCreate("test1").setMapping("name", "type=text")); + assertAcked(prepareCreate("test2").setMapping("name", "type=text")); ensureGreen(); logger.info("--> adding filtering aliases to index [test1]"); @@ -780,7 +780,7 @@ public void run() { public void testSameAlias() throws Exception { logger.info("--> creating index [test]"); - assertAcked(prepareCreate("test").addMapping("type", "name", "type=text")); + assertAcked(prepareCreate("test").setMapping("name", "type=text")); ensureGreen(); logger.info("--> creating alias1 "); @@ -1073,7 +1073,7 @@ public void testGetAllAliasesWorks() { public void testCreateIndexWithAliases() throws Exception { assertAcked( - prepareCreate("test").addMapping("type", "field", "type=text") + prepareCreate("test").setMapping("field", "type=text") .addAlias(new Alias("alias1")) .addAlias(new Alias("alias2").filter(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery("field")))) .addAlias(new Alias("alias3").indexRouting("index").searchRouting("search")) @@ -1103,7 +1103,7 @@ public void testCreateIndexWithAliasesInSource() throws Exception { public void testCreateIndexWithAliasesSource() throws Exception { assertAcked( - prepareCreate("test").addMapping("type", "field", "type=text") + prepareCreate("test").setMapping("field", "type=text") .setAliases( "{\n" + " \"alias1\" : {},\n" @@ -1180,7 +1180,7 @@ public void testAddAliasWithFilterNoMapping() throws Exception { } public void testAliasFilterWithNowInRangeFilterAndQuery() throws Exception { - assertAcked(prepareCreate("my-index").addMapping("my-type", "timestamp", "type=date")); + assertAcked(prepareCreate("my-index").setMapping("timestamp", "type=date")); assertAliasesVersionIncreases( "my-index", () -> assertAcked( diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java index cef22343a1fea..5226eed2b6610 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/NoMasterNodeIT.java @@ -90,7 +90,7 @@ protected Collection> nodePlugins() { public void testNoMasterActions() throws Exception { Settings settings = Settings.builder() .put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), true) - .put(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey(), "all") + .put(NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "all") .build(); final TimeValue timeout = TimeValue.timeValueMillis(10); @@ -242,7 +242,7 @@ void checkWriteAction(ActionRequestBuilder builder) { public void testNoMasterActionsWriteMasterBlock() throws Exception { Settings settings = Settings.builder() .put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), false) - .put(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey(), "write") + .put(NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "write") .build(); final List nodes = internalCluster().startNodes(3, settings); @@ -323,7 +323,7 @@ public void testNoMasterActionsWriteMasterBlock() throws Exception { public void testNoMasterActionsMetadataWriteMasterBlock() throws Exception { Settings settings = Settings.builder() - .put(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey(), "metadata_write") + .put(NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "metadata_write") .put(MappingUpdatedAction.INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING.getKey(), "100ms") .build(); diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java index 3060b5c23fe75..6f4c6fca77196 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java @@ -176,9 +176,7 @@ public void testDeleteCreateInOneBulk() throws Exception { internalCluster().startMasterOnlyNode(); String dataNode = internalCluster().startDataOnlyNode(); assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes("2").get().isTimedOut()); - prepareCreate("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping(MapperService.SINGLE_MAPPING_NAME) - .get(); + prepareCreate("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)).get(); ensureGreen("test"); // block none master node. diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java index ddba0e175beec..0bbd1ab9799f1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterDisruptionIT.java @@ -422,7 +422,7 @@ public boolean clearData(String nodeName) { @Override public Settings onNodeStopped(String nodeName) { return Settings.builder() - .put(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey(), nodeName) + .put(ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), nodeName) /* * the data node might join while the master is still not fully established as master just yet and bypasses the join * validation that is done before adding the node to the cluster. Only the join validation when handling the publish diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/MasterDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/MasterDisruptionIT.java index 243458c682e09..041d665521e16 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/MasterDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/MasterDisruptionIT.java @@ -196,7 +196,7 @@ public void testIsolateMasterAndVerifyClusterStateConsensus() throws Exception { * Verify that the proper block is applied when nodes lose their master */ public void testVerifyApiBlocksDuringPartition() throws Exception { - internalCluster().startNodes(3, Settings.builder().putNull(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey()).build()); + internalCluster().startNodes(3, Settings.builder().putNull(NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey()).build()); // Makes sure that the get request can be executed on each node locally: assertAcked( @@ -254,11 +254,11 @@ public void testVerifyApiBlocksDuringPartition() throws Exception { // Wait until the master node sees al 3 nodes again. ensureStableCluster(3, new TimeValue(DISRUPTION_HEALING_OVERHEAD.millis() + networkDisruption.expectedTimeToHeal().millis())); - logger.info("Verify no master block with {} set to {}", NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey(), "all"); + logger.info("Verify no master block with {} set to {}", NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "all"); client().admin() .cluster() .prepareUpdateSettings() - .setTransientSettings(Settings.builder().put(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey(), "all")) + .setTransientSettings(Settings.builder().put(NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "all")) .get(); networkDisruption.startDisrupting(); diff --git a/server/src/internalClusterTest/java/org/opensearch/document/AliasedIndexDocumentActionsIT.java b/server/src/internalClusterTest/java/org/opensearch/document/AliasedIndexDocumentActionsIT.java index de9db5f145116..1d9f7c1e39de2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/document/AliasedIndexDocumentActionsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/document/AliasedIndexDocumentActionsIT.java @@ -49,7 +49,7 @@ protected void createIndex() { logger.info("--> creating index test"); client().admin() .indices() - .create(createIndexRequest("test1").mapping("type1", "name", "type=keyword,store=true").alias(new Alias("test"))) + .create(createIndexRequest("test1").simpleMapping("name", "type=keyword,store=true").alias(new Alias("test"))) .actionGet(); } diff --git a/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java b/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java index f3693be3b7227..1e40cc14bbb36 100644 --- a/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/document/DocumentActionsIT.java @@ -69,7 +69,7 @@ */ public class DocumentActionsIT extends OpenSearchIntegTestCase { protected void createIndex() { - OpenSearchAssertions.assertAcked(prepareCreate(getConcreteIndexName()).addMapping("type1", "name", "type=keyword,store=true")); + OpenSearchAssertions.assertAcked(prepareCreate(getConcreteIndexName()).setMapping("name", "type=keyword,store=true")); } protected String getConcreteIndexName() { diff --git a/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java b/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java index be1335bd56ba9..5f217548794db 100644 --- a/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/document/ShardInfoIT.java @@ -125,7 +125,7 @@ private void prepareIndex(int numberOfPrimaryShards, boolean routingRequired) th Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfPrimaryShards) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numCopies - 1) - ).addMapping("type", "_routing", "required=" + routingRequired).get() + ).setMapping("_routing", "required=" + routingRequired).get() ); for (int i = 0; i < numberOfPrimaryShards; i++) { ensureActiveShardCopies(i, numNodes); diff --git a/server/src/internalClusterTest/java/org/opensearch/env/NodeEnvironmentIT.java b/server/src/internalClusterTest/java/org/opensearch/env/NodeEnvironmentIT.java index 0bebcce27f975..83c103bd82738 100644 --- a/server/src/internalClusterTest/java/org/opensearch/env/NodeEnvironmentIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/env/NodeEnvironmentIT.java @@ -95,7 +95,7 @@ public Settings onNodeStopped(String nodeName) { }) ); if (writeDanglingIndices) { - assertThat(ex.getMessage(), startsWith("node does not have the data and master roles but has index metadata")); + assertThat(ex.getMessage(), startsWith("node does not have the data and cluster_manager roles but has index metadata")); } else { assertThat(ex.getMessage(), startsWith("node does not have the data role but has shard data")); } diff --git a/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java b/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java index 78069970c1a60..53da0309aa602 100644 --- a/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/explain/ExplainActionIT.java @@ -115,7 +115,7 @@ public void testSimple() throws Exception { public void testExplainWithFields() throws Exception { assertAcked( - prepareCreate("test").addMapping("test", "obj1.field1", "type=keyword,store=true", "obj1.field2", "type=keyword,store=true") + prepareCreate("test").setMapping("obj1.field1", "type=keyword,store=true", "obj1.field2", "type=keyword,store=true") .addAlias(new Alias("alias")) ); ensureGreen("test"); @@ -212,7 +212,7 @@ public void testExplainWithSource() throws Exception { public void testExplainWithFilteredAlias() { assertAcked( - prepareCreate("test").addMapping("test", "field2", "type=text") + prepareCreate("test").setMapping("field2", "type=text") .addAlias(new Alias("alias1").filter(QueryBuilders.termQuery("field2", "value2"))) ); ensureGreen("test"); @@ -231,7 +231,7 @@ public void testExplainWithFilteredAliasFetchSource() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("test", "field2", "type=text") + .setMapping("field2", "type=text") .addAlias(new Alias("alias1").filter(QueryBuilders.termQuery("field2", "value2"))) ); ensureGreen("test"); diff --git a/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java b/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java index 3c5f2828ff94f..d76e21ea712f3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/gateway/RecoveryFromGatewayIT.java @@ -83,7 +83,7 @@ import java.util.Set; import java.util.stream.IntStream; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS; import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS; import static org.opensearch.common.xcontent.XContentFactory.jsonBuilder; @@ -383,7 +383,7 @@ public void testTwoNodeFirstNodeCleared() throws Exception { public Settings onNodeStopped(String nodeName) { return Settings.builder() .put(RECOVER_AFTER_NODES_SETTING.getKey(), 2) - .putList(INITIAL_MASTER_NODES_SETTING.getKey()) // disable bootstrapping + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey()) // disable bootstrapping .build(); } diff --git a/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java b/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java index a09778582b604..2f811d4a901bf 100644 --- a/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/get/GetActionIT.java @@ -84,7 +84,7 @@ protected Collection> nodePlugins() { public void testSimpleGet() { assertAcked( - prepareCreate("test").addMapping("type1", "field1", "type=keyword,store=true", "field2", "type=keyword,store=true") + prepareCreate("test").setMapping("field1", "type=keyword,store=true", "field2", "type=keyword,store=true") .setSettings(Settings.builder().put("index.refresh_interval", -1)) .addAlias(new Alias("alias").writeIndex(randomFrom(true, false, null))) ); @@ -234,7 +234,7 @@ static String indexOrAlias() { public void testSimpleMultiGet() throws Exception { assertAcked( prepareCreate("test").addAlias(new Alias("alias").writeIndex(randomFrom(true, false, null))) - .addMapping("type1", "field", "type=keyword,store=true") + .setMapping("field", "type=keyword,store=true") .setSettings(Settings.builder().put("index.refresh_interval", -1)) ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/index/HiddenIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/index/HiddenIndexIT.java index 54fbc8cecb967..7d1c92cba3205 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/HiddenIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/HiddenIndexIT.java @@ -122,7 +122,7 @@ public void testGlobalTemplatesDoNotApply() { .indices() .preparePutTemplate("a_global_template") .setPatterns(Collections.singletonList("*")) - .addMapping("_doc", "foo", "type=text") + .setMapping("foo", "type=text") .get() ); assertAcked( @@ -130,7 +130,7 @@ public void testGlobalTemplatesDoNotApply() { .indices() .preparePutTemplate("not_global_template") .setPatterns(Collections.singletonList("a*")) - .addMapping("_doc", "bar", "type=text") + .setMapping("bar", "type=text") .get() ); assertAcked( @@ -138,7 +138,7 @@ public void testGlobalTemplatesDoNotApply() { .indices() .preparePutTemplate("specific_template") .setPatterns(Collections.singletonList("a_hidden_index")) - .addMapping("_doc", "baz", "type=text") + .setMapping("baz", "type=text") .get() ); assertAcked( @@ -146,7 +146,7 @@ public void testGlobalTemplatesDoNotApply() { .indices() .preparePutTemplate("unused_template") .setPatterns(Collections.singletonList("not_used")) - .addMapping("_doc", "foobar", "type=text") + .setMapping("foobar", "type=text") .get() ); @@ -192,7 +192,7 @@ public void testNonGlobalTemplateCanMakeIndexHidden() { .indices() .preparePutTemplate("a_global_template") .setPatterns(Collections.singletonList("my_hidden_pattern*")) - .addMapping("_doc", "foo", "type=text") + .setMapping("foo", "type=text") .setSettings(Settings.builder().put("index.hidden", true).build()) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/index/suggest/stats/SuggestStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/index/suggest/stats/SuggestStatsIT.java index 1137a3038fd18..9940b1eb13a52 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/suggest/stats/SuggestStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/suggest/stats/SuggestStatsIT.java @@ -79,12 +79,12 @@ public void testSimpleStats() throws Exception { assertAcked( prepareCreate("test1").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, shardsIdx1).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("type", "f", "type=text") + ).setMapping("f", "type=text") ); assertAcked( prepareCreate("test2").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, shardsIdx2).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("type", "f", "type=text") + ).setMapping("f", "type=text") ); assertThat(shardsIdx1 + shardsIdx2, equalTo(numAssignedShards("test1", "test2"))); assertThat(numAssignedShards("test1", "test2"), greaterThanOrEqualTo(2)); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java index 18940cba80799..12fee85288bc2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/IndicesRequestCacheIT.java @@ -73,7 +73,7 @@ public void testCacheAggs() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "f", "type=date") + .setMapping("f", "type=date") .setSettings(Settings.builder().put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true)) .get() ); @@ -137,7 +137,7 @@ public void testQueryRewrite() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "s", "type=date") + .setMapping("s", "type=date") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) @@ -208,7 +208,7 @@ public void testQueryRewriteMissingValues() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "s", "type=date") + .setMapping("s", "type=date") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) @@ -274,7 +274,7 @@ public void testQueryRewriteDates() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "d", "type=date") + .setMapping("d", "type=date") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) @@ -345,9 +345,9 @@ public void testQueryRewriteDatesWithNow() throws Exception { .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .build(); - assertAcked(client.admin().indices().prepareCreate("index-1").addMapping("type", "d", "type=date").setSettings(settings).get()); - assertAcked(client.admin().indices().prepareCreate("index-2").addMapping("type", "d", "type=date").setSettings(settings).get()); - assertAcked(client.admin().indices().prepareCreate("index-3").addMapping("type", "d", "type=date").setSettings(settings).get()); + assertAcked(client.admin().indices().prepareCreate("index-1").setMapping("d", "type=date").setSettings(settings).get()); + assertAcked(client.admin().indices().prepareCreate("index-2").setMapping("d", "type=date").setSettings(settings).get()); + assertAcked(client.admin().indices().prepareCreate("index-3").setMapping("d", "type=date").setSettings(settings).get()); ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC); DateFormatter formatter = DateFormatter.forPattern("strict_date_optional_time"); indexRandom( @@ -426,7 +426,7 @@ public void testCanCache() throws Exception { .put("index.number_of_routing_shards", 2) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .build(); - assertAcked(client.admin().indices().prepareCreate("index").addMapping("type", "s", "type=date").setSettings(settings).get()); + assertAcked(client.admin().indices().prepareCreate("index").setMapping("s", "type=date").setSettings(settings).get()); indexRandom( true, client.prepareIndex("index").setId("1").setRouting("1").setSource("s", "2016-03-19"), @@ -529,7 +529,7 @@ public void testCacheWithFilteredAlias() { client.admin() .indices() .prepareCreate("index") - .addMapping("type", "created_at", "type=date") + .setMapping("created_at", "type=date") .setSettings(settings) .addAlias(new Alias("last_week").filter(QueryBuilders.rangeQuery("created_at").gte("now-7d/d"))) .get() @@ -578,7 +578,7 @@ public void testProfileDisableCache() throws Exception { client.admin() .indices() .prepareCreate("index") - .addMapping("_doc", "k", "type=keyword") + .setMapping("k", "type=keyword") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/analyze/AnalyzeActionIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/analyze/AnalyzeActionIT.java index 7218495898677..1d25051eefe44 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/analyze/AnalyzeActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/analyze/AnalyzeActionIT.java @@ -99,7 +99,7 @@ public void testSimpleAnalyzerTests() throws Exception { } public void testAnalyzeNumericField() throws IOException { - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("test", "long", "type=long", "double", "type=double")); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setMapping("long", "type=long", "double", "type=double")); ensureGreen("test"); expectThrows( @@ -413,7 +413,7 @@ public void testCustomTokenFilterInRequest() throws Exception { } public void testAnalyzeKeywordField() throws IOException { - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("test", "keyword", "type=keyword")); + assertAcked(prepareCreate("test").addAlias(new Alias("alias")).setMapping("keyword", "type=keyword")); ensureGreen("test"); AnalyzeAction.Response analyzeResponse = client().admin().indices().prepareAnalyze(indexOrAlias(), "ABC").setField("keyword").get(); @@ -435,7 +435,7 @@ public void testAnalyzeNormalizedKeywordField() throws IOException { .put("index.analysis.normalizer.my_normalizer.type", "custom") .putList("index.analysis.normalizer.my_normalizer.filter", "lowercase") ) - .addMapping("test", "keyword", "type=keyword,normalizer=my_normalizer") + .setMapping("keyword", "type=keyword,normalizer=my_normalizer") ); ensureGreen("test"); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/memory/breaker/CircuitBreakerServiceIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/memory/breaker/CircuitBreakerServiceIT.java index e9bb9f5a90477..2dc6b2085b866 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/memory/breaker/CircuitBreakerServiceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/memory/breaker/CircuitBreakerServiceIT.java @@ -142,8 +142,7 @@ public void testMemoryBreaker() throws Exception { return; } assertAcked( - prepareCreate("cb-test", 1, Settings.builder().put(SETTING_NUMBER_OF_REPLICAS, between(0, 1))).addMapping( - "type", + prepareCreate("cb-test", 1, Settings.builder().put(SETTING_NUMBER_OF_REPLICAS, between(0, 1))).setMapping( "test", "type=text,fielddata=true" ) diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java index 7fd2466647272..08cf33a342c65 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexPrimaryRelocationIT.java @@ -62,7 +62,7 @@ public void testPrimaryRelocationWhileIndexing() throws Exception { .indices() .prepareCreate("test") .setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)) - .addMapping("type", "field", "type=text") + .setMapping("field", "type=text") .get(); ensureGreen("test"); AtomicInteger numAutoGenDocs = new AtomicInteger(); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java index a24f55be3f010..be8a1ad4f0c61 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/stats/IndexStatsIT.java @@ -148,7 +148,7 @@ public void testFieldDataStats() { .indices() .prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_shards", 2)) - .addMapping("type", "field", "type=text,fielddata=true", "field2", "type=text,fielddata=true") + .setMapping("field", "type=text,fielddata=true", "field2", "type=text,fielddata=true") .get() ); ensureGreen(); @@ -270,7 +270,7 @@ public void testClearAllCaches() throws Exception { .indices() .prepareCreate("test") .setSettings(settingsBuilder().put("index.number_of_replicas", 0).put("index.number_of_shards", 2)) - .addMapping("type", "field", "type=text,fielddata=true") + .setMapping("field", "type=text,fielddata=true") .get() ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java index 378657a6554b4..090cf81de60a3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/template/SimpleIndexTemplateIT.java @@ -554,7 +554,7 @@ public void testIndexTemplateWithAliases() throws Exception { .indices() .preparePutTemplate("template_with_aliases") .setPatterns(Collections.singletonList("te*")) - .addMapping("_doc", "type", "type=keyword", "field", "type=text") + .setMapping("type", "type=keyword", "field", "type=text") .addAlias(new Alias("simple_alias")) .addAlias(new Alias("templated_alias-{index}")) .addAlias(new Alias("filtered_alias").filter("{\"term\":{\"type\":\"type2\"}}")) @@ -624,7 +624,7 @@ public void testIndexTemplateWithAliasesInSource() { ) .get(); - assertAcked(prepareCreate("test_index").addMapping("_doc")); + assertAcked(prepareCreate("test_index")); ensureGreen(); GetAliasesResponse getAliasesResponse = client().admin().indices().prepareGetAliases().setIndices("test_index").get(); @@ -663,7 +663,7 @@ public void testIndexTemplateWithAliasesSource() { ) .get(); - assertAcked(prepareCreate("test_index").addMapping("_doc")); + assertAcked(prepareCreate("test_index")); ensureGreen(); GetAliasesResponse getAliasesResponse = client().admin().indices().prepareGetAliases().setIndices("test_index").get(); @@ -820,7 +820,7 @@ public void testStrictAliasParsingInIndicesCreatedViaTemplates() throws Exceptio .preparePutTemplate("template1") .setPatterns(Collections.singletonList("a*")) .setOrder(0) - .addMapping("test", "field", "type=text") + .setMapping("field", "type=text") .addAlias(new Alias("alias1").filter(termQuery("field", "value"))) .get(); // Indexing into b index should fail, since there is field with name 'field' in the mapping @@ -930,7 +930,7 @@ public void testOrderAndVersion() { .setPatterns(Collections.singletonList("te*")) .setVersion(version) .setOrder(order) - .addMapping("test", "field", "type=text") + .setMapping("field", "type=text") .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java b/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java index 71da9168c6205..1708454faf7b3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/recovery/TruncatedRecoveryIT.java @@ -108,7 +108,7 @@ public void testCancelRecoveryAndResume() throws Exception { // create the index and prevent allocation on any other nodes than the lucky one // we have no replicas so far and make sure that we allocate the primary on the lucky node assertAcked( - prepareCreate("test").addMapping("type1", "field1", "type=text", "the_id", "type=text") + prepareCreate("test").setMapping("field1", "type=text", "the_id", "type=text") .setSettings( Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/AggregationsIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/AggregationsIntegrationIT.java index 303b84151cf3e..6778765599fe9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/AggregationsIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/AggregationsIntegrationIT.java @@ -52,7 +52,7 @@ public class AggregationsIntegrationIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "f", "type=keyword").get()); + assertAcked(prepareCreate("index").setMapping("f", "type=keyword").get()); numDocs = randomIntBetween(1, 20); List docs = new ArrayList<>(); for (int i = 0; i < numDocs; ++i) { diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MetadataIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MetadataIT.java index c00152a54bd37..f210af7c10fb3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MetadataIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MetadataIT.java @@ -53,7 +53,7 @@ public class MetadataIT extends OpenSearchIntegTestCase { public void testMetadataSetOnAggregationResult() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "name", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("name", "type=keyword").get()); IndexRequestBuilder[] builders = new IndexRequestBuilder[randomInt(30)]; for (int i = 0; i < builders.length; i++) { String name = "name_" + randomIntBetween(1, 10); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MissingValueIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MissingValueIT.java index 9135ca0f0a364..7d3f06760882d 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MissingValueIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/MissingValueIT.java @@ -67,9 +67,7 @@ protected int maximumNumberOfShards() { @Override protected void setupSuiteScopeCluster() throws Exception { - assertAcked( - prepareCreate("idx").addMapping("type", "date", "type=date", "location", "type=geo_point", "str", "type=keyword").get() - ); + assertAcked(prepareCreate("idx").setMapping("date", "type=date", "location", "type=geo_point", "str", "type=keyword").get()); indexRandom( true, client().prepareIndex("idx").setId("1").setSource(), diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/AdjacencyMatrixIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/AdjacencyMatrixIT.java index 5d54359152816..af3cc85ed40c0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/AdjacencyMatrixIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/AdjacencyMatrixIT.java @@ -117,7 +117,7 @@ public void setupSuiteScopeCluster() throws Exception { builders.add(client().prepareIndex("idx").setId("" + i).setSource(source)); } } - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramIT.java index 2c095857089e1..782bcde39ce8d 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramIT.java @@ -144,7 +144,7 @@ private IndexRequestBuilder indexDoc(int month, int day, int value) throws Excep public void setupSuiteScopeCluster() throws Exception { createIndex("idx", "idx_unmapped"); // TODO: would be nice to have more random data here - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping("value", "type=integer")); List builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( @@ -188,7 +188,7 @@ private void getMultiSortDocs(List builders) throws IOExcep addExpectedBucket(date(1, 6), 1, 5, 1); addExpectedBucket(date(1, 7), 1, 5, 1); - assertAcked(client().admin().indices().prepareCreate("sort_idx").addMapping("type", "date", "type=date").get()); + assertAcked(client().admin().indices().prepareCreate("sort_idx").setMapping("date", "type=date").get()); for (int i = 1; i <= 3; i++) { builders.add( client().prepareIndex("sort_idx") @@ -1038,7 +1038,7 @@ public void testEmptyAggregation() throws Exception { } public void testSingleValueWithTimeZone() throws Exception { - prepareCreate("idx2").addMapping("type", "date", "type=date").get(); + prepareCreate("idx2").setMapping("date", "type=date").get(); IndexRequestBuilder[] reqs = new IndexRequestBuilder[5]; ZonedDateTime date = date("2014-03-11T00:00:00+00:00"); for (int i = 0; i < reqs.length; i++) { @@ -1394,7 +1394,7 @@ public void testIssue6965() { } public void testDSTBoundaryIssue9491() throws InterruptedException, ExecutionException { - assertAcked(client().admin().indices().prepareCreate("test9491").addMapping("type", "d", "type=date").get()); + assertAcked(client().admin().indices().prepareCreate("test9491").setMapping("d", "type=date").get()); indexRandom( true, client().prepareIndex("test9491").setSource("d", "2014-10-08T13:00:00Z"), @@ -1417,7 +1417,7 @@ public void testDSTBoundaryIssue9491() throws InterruptedException, ExecutionExc } public void testIssue8209() throws InterruptedException, ExecutionException { - assertAcked(client().admin().indices().prepareCreate("test8209").addMapping("type", "d", "type=date").get()); + assertAcked(client().admin().indices().prepareCreate("test8209").setMapping("d", "type=date").get()); indexRandom( true, client().prepareIndex("test8209").setSource("d", "2014-01-01T00:00:00Z"), @@ -1498,7 +1498,7 @@ public void testFormatIndexUnmapped() throws InterruptedException, ExecutionExce */ public void testRewriteTimeZone_EpochMillisFormat() throws InterruptedException, ExecutionException { String index = "test31392"; - assertAcked(client().admin().indices().prepareCreate(index).addMapping("type", "d", "type=date,format=epoch_millis").get()); + assertAcked(client().admin().indices().prepareCreate(index).setMapping("d", "type=date,format=epoch_millis").get()); indexRandom(true, client().prepareIndex(index).setSource("d", "1477954800000")); ensureSearchable(index); SearchResponse response = client().prepareSearch(index) @@ -1608,7 +1608,7 @@ public void testDSTEndTransition() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=date") + prepareCreate("cache_test_idx").setMapping("d", "type=date") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); @@ -1828,7 +1828,7 @@ private ZonedDateTime key(Histogram.Bucket bucket) { * timeZones. */ public void testDateNanosHistogram() throws Exception { - assertAcked(prepareCreate("nanos").addMapping("_doc", "date", "type=date_nanos").get()); + assertAcked(prepareCreate("nanos").setMapping("date", "type=date_nanos").get()); indexRandom(true, client().prepareIndex("nanos").setId("1").setSource("date", "2000-01-01")); indexRandom(true, client().prepareIndex("nanos").setId("2").setSource("date", "2000-01-02")); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramOffsetIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramOffsetIT.java index 2505cb48245c3..19e5bdb8916b8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramOffsetIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateHistogramOffsetIT.java @@ -72,7 +72,7 @@ private ZonedDateTime date(String date) { @Before public void beforeEachTest() throws IOException { - prepareCreate("idx2").addMapping("type", "date", "type=date").get(); + prepareCreate("idx2").setMapping("date", "type=date").get(); } @After diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateRangeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateRangeIT.java index 7a28df00980cc..470ee6a4d2cea 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateRangeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DateRangeIT.java @@ -125,7 +125,7 @@ public void setupSuiteScopeCluster() throws Exception { for (int i = docs.size(); i < numDocs; ++i) { docs.add(indexDoc(randomIntBetween(6, 10), randomIntBetween(1, 20), randomInt(100))); } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping("value", "type=integer")); for (int i = 0; i < 2; i++) { docs.add( client().prepareIndex("empty_bucket_idx") @@ -913,7 +913,7 @@ public void testNoRangesInQuery() { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "date", "type=date") + prepareCreate("cache_test_idx").setMapping("date", "type=date") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); @@ -1070,7 +1070,7 @@ public void testScriptCaching() throws Exception { */ public void testRangeWithFormatStringValue() throws Exception { String indexName = "dateformat_test_idx"; - assertAcked(prepareCreate(indexName).addMapping("type", "date", "type=date,format=strict_hour_minute_second")); + assertAcked(prepareCreate(indexName).setMapping("date", "type=date,format=strict_hour_minute_second")); indexRandom( true, client().prepareIndex(indexName).setId("1").setSource(jsonBuilder().startObject().field("date", "00:16:40").endObject()), @@ -1132,7 +1132,7 @@ public void testRangeWithFormatStringValue() throws Exception { */ public void testRangeWithFormatNumericValue() throws Exception { String indexName = "dateformat_numeric_test_idx"; - assertAcked(prepareCreate(indexName).addMapping("type", "date", "type=date,format=epoch_second")); + assertAcked(prepareCreate(indexName).setMapping("date", "type=date,format=epoch_second")); indexRandom( true, client().prepareIndex(indexName).setId("1").setSource(jsonBuilder().startObject().field("date", 1002).endObject()), diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DiversifiedSamplerIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DiversifiedSamplerIT.java index aa4bb671d14e8..5b01e7573908c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DiversifiedSamplerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DiversifiedSamplerIT.java @@ -78,14 +78,14 @@ public void setupSuiteScopeCluster() throws Exception { assertAcked( prepareCreate("test").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("book", "author", "type=keyword", "name", "type=keyword", "genre", "type=keyword", "price", "type=float") + ).setMapping("author", "type=keyword", "name", "type=keyword", "genre", "type=keyword", "price", "type=float") ); createIndex("idx_unmapped"); // idx_unmapped_author is same as main index but missing author field assertAcked( prepareCreate("idx_unmapped_author").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("book", "name", "type=keyword", "genre", "type=keyword", "price", "type=float") + ).setMapping("name", "type=keyword", "genre", "type=keyword", "price", "type=float") ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DoubleTermsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DoubleTermsIT.java index 6c6e6ccc679e8..3093c7490a2a5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DoubleTermsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/DoubleTermsIT.java @@ -178,7 +178,7 @@ public void setupSuiteScopeCluster() throws Exception { } createIndex("idx_unmapped"); - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") @@ -238,7 +238,7 @@ private void getMultiSortDocs(List builders) throws IOExcep bucketProps.put("sum_d", 1d); expectedMultiSortBuckets.put((Double) bucketProps.get("_term"), bucketProps); - assertAcked(prepareCreate("sort_idx").addMapping("multi_sort_type", SINGLE_VALUED_FIELD_NAME, "type=double")); + assertAcked(prepareCreate("sort_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=double")); for (int i = 1; i <= 3; i++) { builders.add( client().prepareIndex("sort_idx") @@ -980,7 +980,7 @@ public void testOtherDocCount() { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=float") + prepareCreate("cache_test_idx").setMapping("d", "type=float") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FilterIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FilterIT.java index b938db8891d7b..0845db4f332d7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FilterIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FilterIT.java @@ -90,7 +90,7 @@ public void setupSuiteScopeCluster() throws Exception { builders.add(client().prepareIndex("idx").setId("" + i).setSource(source)); } } - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FiltersIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FiltersIT.java index 0b895f32a1259..a64fe61b29b8a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FiltersIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/FiltersIT.java @@ -109,7 +109,7 @@ public void setupSuiteScopeCluster() throws Exception { builders.add(client().prepareIndex("idx").setId("" + i).setSource(source)); } } - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java index a2d6533ae0afb..603a141abcaec 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java @@ -93,9 +93,9 @@ private IndexRequestBuilder indexCity(String idx, String name, String... latLons @Override public void setupSuiteScopeCluster() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - prepareCreate("idx").setSettings(settings).addMapping("type", "location", "type=geo_point", "city", "type=keyword").get(); + prepareCreate("idx").setSettings(settings).setMapping("location", "type=geo_point", "city", "type=keyword").get(); - prepareCreate("idx-multi").addMapping("type", "location", "type=geo_point", "city", "type=keyword").get(); + prepareCreate("idx-multi").setMapping("location", "type=geo_point", "city", "type=keyword").get(); createIndex("idx_unmapped"); @@ -138,7 +138,7 @@ public void setupSuiteScopeCluster() throws Exception { cities.add(indexCity("idx-multi", cityName)); } indexRandom(true, cities); - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer", "location", "type=geo_point").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer", "location", "type=geo_point").get(); List builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java index c7c21c203af61..56d918feef9d8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java @@ -101,7 +101,7 @@ public void setupSuiteScopeCluster() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - assertAcked(prepareCreate("idx").setSettings(settings).addMapping("type", "location", "type=geo_point", "city", "type=keyword")); + assertAcked(prepareCreate("idx").setSettings(settings).setMapping("location", "type=geo_point", "city", "type=keyword")); List cities = new ArrayList<>(); Random random = random(); @@ -126,7 +126,7 @@ public void setupSuiteScopeCluster() throws Exception { indexRandom(true, cities); assertAcked( - prepareCreate("multi_valued_idx").setSettings(settings).addMapping("type", "location", "type=geo_point", "city", "type=keyword") + prepareCreate("multi_valued_idx").setSettings(settings).setMapping("location", "type=geo_point", "city", "type=keyword") ); cities = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/HistogramIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/HistogramIT.java index fbdcc6b878943..dae788abe0d10 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/HistogramIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/HistogramIT.java @@ -180,7 +180,7 @@ public void setupSuiteScopeCluster() throws Exception { getMultiSortDocs(builders); - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") @@ -211,7 +211,7 @@ private void getMultiSortDocs(List builders) throws IOExcep addExpectedBucket(6, 1, 5, 1); addExpectedBucket(7, 1, 5, 1); - assertAcked(client().admin().indices().prepareCreate("sort_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=double").get()); + assertAcked(client().admin().indices().prepareCreate("sort_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=double").get()); for (int i = 1; i <= 3; i++) { builders.add( client().prepareIndex("sort_idx") @@ -1124,7 +1124,7 @@ public void testExeptionOnNegativerInterval() { } public void testDecimalIntervalAndOffset() throws Exception { - assertAcked(prepareCreate("decimal_values").addMapping("type", "d", "type=float").get()); + assertAcked(prepareCreate("decimal_values").setMapping("d", "type=float").get()); indexRandom( true, client().prepareIndex("decimal_values").setId("1").setSource("d", -0.6), @@ -1151,7 +1151,7 @@ public void testDecimalIntervalAndOffset() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=float") + prepareCreate("cache_test_idx").setMapping("d", "type=float") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); @@ -1349,7 +1349,7 @@ public void testInvalidBounds() { } public void testHardBounds() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "d", "type=double").get()); + assertAcked(prepareCreate("test").setMapping("d", "type=double").get()); indexRandom( true, client().prepareIndex("test").setId("1").setSource("d", -0.6), diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpRangeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpRangeIT.java index b768631225b90..f8f666aaa3c1b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpRangeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpRangeIT.java @@ -70,7 +70,7 @@ protected Collection> nodePlugins() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", "ip", "type=ip", "ips", "type=ip")); + assertAcked(prepareCreate("idx").setMapping("ip", "type=ip", "ips", "type=ip")); waitForRelocation(ClusterHealthStatus.GREEN); indexRandom( diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpTermsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpTermsIT.java index 53ff70dd240d1..cff51e74fdbd0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpTermsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/IpTermsIT.java @@ -76,7 +76,7 @@ protected Map, Object>> pluginScripts() { } public void testScriptValue() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "ip", "type=ip")); + assertAcked(prepareCreate("index").setMapping("ip", "type=ip")); indexRandom( true, client().prepareIndex("index").setId("1").setSource("ip", "192.168.1.7"), @@ -104,7 +104,7 @@ public void testScriptValue() throws Exception { } public void testScriptValues() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "ip", "type=ip")); + assertAcked(prepareCreate("index").setMapping("ip", "type=ip")); indexRandom( true, client().prepareIndex("index").setId("1").setSource("ip", "192.168.1.7"), @@ -132,7 +132,7 @@ public void testScriptValues() throws Exception { } public void testMissingValue() throws Exception { - assertAcked(prepareCreate("index").addMapping("type", "ip", "type=ip")); + assertAcked(prepareCreate("index").setMapping("ip", "type=ip")); indexRandom( true, client().prepareIndex("index").setId("1").setSource("ip", "192.168.1.7"), diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/LongTermsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/LongTermsIT.java index 115b30643ff21..87968bd2117c6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/LongTermsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/LongTermsIT.java @@ -164,7 +164,7 @@ public void setupSuiteScopeCluster() throws Exception { indexRandom(true, highCardBuilders); createIndex("idx_unmapped"); - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); List builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( @@ -928,7 +928,7 @@ public void testOtherDocCount() { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MinDocCountIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MinDocCountIT.java index 47cddbf856090..08e696245209e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MinDocCountIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/MinDocCountIT.java @@ -117,7 +117,7 @@ protected Map, Object>> pluginScripts() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "s", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("s", "type=keyword").get()); cardinality = randomIntBetween(8, 30); final List indexRequests = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NaNSortingIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NaNSortingIT.java index f03a3bdeb1716..3a3e02c577096 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NaNSortingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NaNSortingIT.java @@ -132,7 +132,7 @@ public String sortKey() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "string_value", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("string_value", "type=keyword").get()); final int numDocs = randomIntBetween(2, 10); for (int i = 0; i < numDocs; ++i) { final long value = randomInt(5); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java index 969a48b514f1a..fcde2f628ecd7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/NestedIT.java @@ -96,7 +96,7 @@ public class NestedIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", "nested", "type=nested", "incorrect", "type=object")); + assertAcked(prepareCreate("idx").setMapping("nested", "type=nested", "incorrect", "type=object")); ensureGreen("idx"); List builders = new ArrayList<>(); @@ -126,7 +126,7 @@ public void setupSuiteScopeCluster() throws Exception { builders.add(client().prepareIndex("idx").setId("" + i + 1).setSource(source)); } - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer", "nested", "type=nested").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer", "nested", "type=nested").get(); ensureGreen("empty_bucket_idx"); for (int i = 0; i < 2; i++) { builders.add( @@ -539,7 +539,7 @@ public void testParentFilterResolvedCorrectly() throws Exception { public void testNestedSameDocIdProcessedMultipleTime() throws Exception { assertAcked( prepareCreate("idx4").setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping("product", "categories", "type=keyword", "name", "type=text", "property", "type=nested") + .setMapping("categories", "type=keyword", "name", "type=text", "property", "type=nested") ); ensureGreen("idx4"); @@ -808,7 +808,7 @@ public void testExtractInnerHitBuildersWithDuplicateHitName() throws Exception { assertAcked( prepareCreate("idxduplicatehitnames").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("product", "categories", "type=keyword", "name", "type=text", "property", "type=nested") + ).setMapping("categories", "type=keyword", "name", "type=text", "property", "type=nested") ); ensureGreen("idxduplicatehitnames"); @@ -832,7 +832,7 @@ public void testExtractInnerHitBuildersWithDuplicatePath() throws Exception { assertAcked( prepareCreate("idxnullhitnames").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("product", "categories", "type=keyword", "name", "type=text", "property", "type=nested") + ).setMapping("categories", "type=keyword", "name", "type=text", "property", "type=nested") ); ensureGreen("idxnullhitnames"); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/RangeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/RangeIT.java index bfbfc53ed7e76..c46d6dcd847e1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/RangeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/RangeIT.java @@ -136,7 +136,7 @@ public void setupSuiteScopeCluster() throws Exception { ); } createIndex("idx_unmapped"); - prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") @@ -152,8 +152,8 @@ public void setupSuiteScopeCluster() throws Exception { // Create two indices and add the field 'route_length_miles' as an alias in // one, and a concrete field in the other. - prepareCreate("old_index").addMapping("_doc", "distance", "type=double", "route_length_miles", "type=alias,path=distance").get(); - prepareCreate("new_index").addMapping("_doc", "route_length_miles", "type=double").get(); + prepareCreate("old_index").setMapping("distance", "type=double", "route_length_miles", "type=alias,path=distance").get(); + prepareCreate("new_index").setMapping("route_length_miles", "type=double").get(); builders.add(client().prepareIndex("old_index").setSource("distance", 42.0)); builders.add(client().prepareIndex("old_index").setSource("distance", 50.5)); @@ -931,7 +931,7 @@ public void testEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "i", "type=integer") + prepareCreate("cache_test_idx").setMapping("i", "type=integer") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SamplerIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SamplerIT.java index 94204b6519374..0bfeff9297ce8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SamplerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SamplerIT.java @@ -77,14 +77,14 @@ public void setupSuiteScopeCluster() throws Exception { assertAcked( prepareCreate("test").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("book", "author", "type=keyword", "name", "type=text", "genre", "type=keyword", "price", "type=float") + ).setMapping("author", "type=keyword", "name", "type=text", "genre", "type=keyword", "price", "type=float") ); createIndex("idx_unmapped"); // idx_unmapped_author is same as main index but missing author field assertAcked( prepareCreate("idx_unmapped_author").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS).put(SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("book", "name", "type=text", "genre", "type=keyword", "price", "type=float") + ).setMapping("name", "type=text", "genre", "type=keyword", "price", "type=float") ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ShardReduceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ShardReduceIT.java index 2300e42b84bbc..7352dc7170a21 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ShardReduceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/ShardReduceIT.java @@ -94,8 +94,7 @@ private IndexRequestBuilder indexDoc(String date, int value) throws Exception { @Override public void setupSuiteScopeCluster() throws Exception { assertAcked( - prepareCreate("idx").addMapping( - "type", + prepareCreate("idx").setMapping( "nested", "type=nested", "ip", diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java index cbcc9c396fc06..9c334df1d806b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/SignificantTermsSignificanceScoreIT.java @@ -40,7 +40,6 @@ import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; -import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.QueryBuilder; import org.opensearch.index.query.QueryBuilders; import org.opensearch.plugins.Plugin; @@ -215,7 +214,7 @@ public void testPopularTermManyDeletedDocs() throws Exception { String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}"; assertAcked( prepareCreate(INDEX_NAME).setSettings(settings, XContentType.JSON) - .addMapping("_doc", "text", "type=keyword", CLASS_FIELD, "type=keyword") + .setMapping("text", "type=keyword", CLASS_FIELD, "type=keyword") ); String[] cat1v1 = { "constant", "one" }; String[] cat1v2 = { "constant", "uno" }; @@ -453,7 +452,7 @@ public void testSubAggregations() throws Exception { private void indexEqualTestData() throws ExecutionException, InterruptedException { assertAcked( prepareCreate("test").setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping("_doc", "text", "type=text,fielddata=true", "class", "type=keyword") + .setMapping("text", "type=text,fielddata=true", "class", "type=keyword") ); createIndex("idx_unmapped"); @@ -545,9 +544,7 @@ private void indexRandomFrequencies01(String type) throws ExecutionException, In if (type.equals("text")) { textMappings += ",fielddata=true"; } - assertAcked( - prepareCreate(INDEX_NAME).addMapping(MapperService.SINGLE_MAPPING_NAME, TEXT_FIELD, textMappings, CLASS_FIELD, "type=keyword") - ); + assertAcked(prepareCreate(INDEX_NAME).setMapping(TEXT_FIELD, textMappings, CLASS_FIELD, "type=keyword")); String[] gb = { "0", "1" }; List indexRequestBuilderList = new ArrayList<>(); for (int i = 0; i < randomInt(20); i++) { @@ -575,7 +572,7 @@ public void testReduceFromSeveralShards() throws IOException, ExecutionException */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsDocCountErrorIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsDocCountErrorIT.java index 9b941860177bb..3d76b994ebac3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsDocCountErrorIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsDocCountErrorIT.java @@ -74,7 +74,7 @@ public static String randomExecutionHint() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", STRING_FIELD_NAME, "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping(STRING_FIELD_NAME, "type=keyword").get()); List builders = new ArrayList<>(); int numDocs = between(10, 200); int numUniqueTerms = between(2, numDocs / 2); @@ -92,7 +92,7 @@ public void setupSuiteScopeCluster() throws Exception { ); } assertAcked( - prepareCreate("idx_single_shard").addMapping("type", STRING_FIELD_NAME, "type=keyword") + prepareCreate("idx_single_shard").setMapping(STRING_FIELD_NAME, "type=keyword") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) ); for (int i = 0; i < numDocs; i++) { @@ -125,7 +125,7 @@ public void setupSuiteScopeCluster() throws Exception { ); } assertAcked( - prepareCreate("idx_fixed_docs_0").addMapping("type", STRING_FIELD_NAME, "type=keyword") + prepareCreate("idx_fixed_docs_0").setMapping(STRING_FIELD_NAME, "type=keyword") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) ); Map shard0DocsPerTerm = new HashMap<>(); @@ -151,7 +151,7 @@ public void setupSuiteScopeCluster() throws Exception { } assertAcked( - prepareCreate("idx_fixed_docs_1").addMapping("type", STRING_FIELD_NAME, "type=keyword") + prepareCreate("idx_fixed_docs_1").setMapping(STRING_FIELD_NAME, "type=keyword") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) ); Map shard1DocsPerTerm = new HashMap<>(); @@ -177,7 +177,7 @@ public void setupSuiteScopeCluster() throws Exception { } assertAcked( - prepareCreate("idx_fixed_docs_2").addMapping("type", STRING_FIELD_NAME, "type=keyword") + prepareCreate("idx_fixed_docs_2").setMapping(STRING_FIELD_NAME, "type=keyword") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) ); Map shard2DocsPerTerm = new HashMap<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java index af006210326d8..852c3760751b3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/TermsShardMinDocCountIT.java @@ -35,7 +35,6 @@ import org.opensearch.action.search.SearchResponse; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentType; -import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.QueryBuilders; import org.opensearch.search.aggregations.BucketOrder; import org.opensearch.search.aggregations.bucket.filter.InternalFilter; @@ -73,7 +72,7 @@ public void testShardMinDocCountSignificantTermsTest() throws Exception { } assertAcked( prepareCreate(index).setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping(MapperService.SINGLE_MAPPING_NAME, "text", textMappings) + .setMapping("text", textMappings) ); List indexBuilders = new ArrayList<>(); @@ -142,7 +141,7 @@ public void testShardMinDocCountTermsTest() throws Exception { } assertAcked( prepareCreate(index).setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0)) - .addMapping(MapperService.SINGLE_MAPPING_NAME, "text", termMappings) + .setMapping("text", termMappings) ); List indexBuilders = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/terms/StringTermsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/terms/StringTermsIT.java index 252ffeb4ca0e7..3190bcb72fcbb 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/terms/StringTermsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/terms/StringTermsIT.java @@ -157,15 +157,7 @@ public void setupSuiteScopeCluster() throws Exception { client().admin() .indices() .prepareCreate("idx") - .addMapping( - "type", - SINGLE_VALUED_FIELD_NAME, - "type=keyword", - MULTI_VALUED_FIELD_NAME, - "type=keyword", - "tag", - "type=keyword" - ) + .setMapping(SINGLE_VALUED_FIELD_NAME, "type=keyword", MULTI_VALUED_FIELD_NAME, "type=keyword", "tag", "type=keyword") .get() ); List builders = new ArrayList<>(); @@ -193,15 +185,7 @@ public void setupSuiteScopeCluster() throws Exception { client().admin() .indices() .prepareCreate("high_card_idx") - .addMapping( - "type", - SINGLE_VALUED_FIELD_NAME, - "type=keyword", - MULTI_VALUED_FIELD_NAME, - "type=keyword", - "tag", - "type=keyword" - ) + .setMapping(SINGLE_VALUED_FIELD_NAME, "type=keyword", MULTI_VALUED_FIELD_NAME, "type=keyword", "tag", "type=keyword") .get() ); for (int i = 0; i < 100; i++) { @@ -218,7 +202,7 @@ public void setupSuiteScopeCluster() throws Exception { ) ); } - prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer").get(); for (int i = 0; i < 2; i++) { builders.add( @@ -281,15 +265,7 @@ private void getMultiSortDocs(List builders) throws IOExcep client().admin() .indices() .prepareCreate("sort_idx") - .addMapping( - "type", - SINGLE_VALUED_FIELD_NAME, - "type=keyword", - MULTI_VALUED_FIELD_NAME, - "type=keyword", - "tag", - "type=keyword" - ) + .setMapping(SINGLE_VALUED_FIELD_NAME, "type=keyword", MULTI_VALUED_FIELD_NAME, "type=keyword", "tag", "type=keyword") .get() ); for (int i = 1; i <= 3; i++) { @@ -1262,7 +1238,7 @@ public void testOtherDocCount() { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=keyword") + prepareCreate("cache_test_idx").setMapping("d", "type=keyword") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java index 7996e2bee44c1..147f451c14de8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/CardinalityIT.java @@ -491,7 +491,7 @@ public void testAsSubAgg() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ExtendedStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ExtendedStatsIT.java index 9549aad5399b5..cd0a649659c6e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ExtendedStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ExtendedStatsIT.java @@ -869,7 +869,7 @@ private void checkUpperLowerBounds(ExtendedStats stats, double sigma) { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksIT.java index 7aa602fff2ee8..20fc6aaee20c9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentileRanksIT.java @@ -585,7 +585,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentilesIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentilesIT.java index 68f8cf6da575a..2660dbe0a88ed 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentilesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/HDRPercentilesIT.java @@ -554,7 +554,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationIT.java index 79f1809fc2f3a..226b4dbca18d9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/MedianAbsoluteDeviationIT.java @@ -137,7 +137,7 @@ public void setupSuiteScopeCluster() throws Exception { indexRandom(true, builders); - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { @@ -516,7 +516,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java index beacf7aa1ccec..27dbc56cf3b79 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ScriptedMetricIT.java @@ -310,7 +310,7 @@ public void setupSuiteScopeCluster() throws Exception { // "1". then each test will have // to check that this bucket exists with the appropriate sub // aggregations. - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( @@ -1183,7 +1183,7 @@ public void testScriptCaching() throws Exception { Script ndRandom = new Script(ScriptType.INLINE, CustomScriptPlugin.NAME, "return Math.random()", Collections.emptyMap()); assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/StatsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/StatsIT.java index 27fc26a114cc4..debdde8e13fe7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/StatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/StatsIT.java @@ -258,7 +258,7 @@ private void assertShardExecutionState(SearchResponse response, int expectedFail */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/SumIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/SumIT.java index e9b8c91090695..fe236f04c19e8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/SumIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/SumIT.java @@ -79,8 +79,7 @@ public void setupSuiteScopeCluster() throws Exception { // Create two indices and add the field 'route_length_miles' as an alias in // one, and a concrete field in the other. - prepareCreate("old_index").addMapping( - "_doc", + prepareCreate("old_index").setMapping( "transit_mode", "type=keyword", "distance", @@ -88,7 +87,7 @@ public void setupSuiteScopeCluster() throws Exception { "route_length_miles", "type=alias,path=distance" ).get(); - prepareCreate("new_index").addMapping("_doc", "transit_mode", "type=keyword", "route_length_miles", "type=double").get(); + prepareCreate("new_index").setMapping("transit_mode", "type=keyword", "route_length_miles", "type=double").get(); List builders = new ArrayList<>(); builders.add(client().prepareIndex("old_index").setSource("transit_mode", "train", "distance", 42.0)); @@ -236,7 +235,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksIT.java index 8b28261f7f00b..adf027222d7d9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentileRanksIT.java @@ -497,7 +497,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesIT.java index 2da6ac3f9e586..fda15f9b90ea2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TDigestPercentilesIT.java @@ -469,7 +469,7 @@ public void testOrderByEmptyAggregation() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java index 53a3cd4da5446..c3240c5eef7c5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/TopHitsIT.java @@ -135,8 +135,8 @@ public static String randomExecutionHint() { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", TERMS_AGGS_FIELD, "type=keyword")); - assertAcked(prepareCreate("field-collapsing").addMapping("type", "group", "type=keyword")); + assertAcked(prepareCreate("idx").setMapping(TERMS_AGGS_FIELD, "type=keyword")); + assertAcked(prepareCreate("field-collapsing").setMapping("group", "type=keyword")); createIndex("empty"); assertAcked( prepareCreate("articles").setMapping( @@ -1143,7 +1143,7 @@ public void testNoStoredFields() throws Exception { public void testScriptCaching() throws Exception { try { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings( Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1) ) diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ValueCountIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ValueCountIT.java index 6d3fe1ed3f190..82e667bccc576 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ValueCountIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/metrics/ValueCountIT.java @@ -238,7 +238,7 @@ public void testMultiValuedScriptWithParams() throws Exception { */ public void testScriptCaching() throws Exception { assertAcked( - prepareCreate("cache_test_idx").addMapping("type", "d", "type=long") + prepareCreate("cache_test_idx").setMapping("d", "type=long") .setSettings(Settings.builder().put("requests.cache.enable", true).put("number_of_shards", 1).put("number_of_replicas", 1)) .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/AvgBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/AvgBucketIT.java index 590587185b80e..6cd16a47e98d2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/AvgBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/AvgBucketIT.java @@ -71,7 +71,7 @@ public class AvgBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -100,7 +100,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DateDerivativeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DateDerivativeIT.java index d7f16b25a46e8..2c7890fb7b1cb 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DateDerivativeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DateDerivativeIT.java @@ -103,7 +103,7 @@ public void setupSuiteScopeCluster() throws Exception { createIndex("idx"); createIndex("idx_unmapped"); // TODO: would be nice to have more random data here - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").get(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").get(); List builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DerivativeIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DerivativeIT.java index cff655e040124..c03ed8277a3b4 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DerivativeIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/DerivativeIT.java @@ -140,7 +140,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts_empty = new Long[] { 1L, 1L, 2L, 0L, 2L, 2L, 0L, 0L, 0L, 3L, 2L, 1L }; firstDerivValueCounts_empty = new Double[] { null, 0d, 1d, -2d, 2d, 0d, -2d, 0d, 0d, 3d, -1d, -1d }; - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < valueCounts_empty.length; i++) { for (int docs = 0; docs < valueCounts_empty[i]; docs++) { builders.add(client().prepareIndex("empty_bucket_idx").setSource(newDocBuilder(i))); @@ -154,7 +154,7 @@ public void setupSuiteScopeCluster() throws Exception { firstDerivValueCounts_empty_rnd = new Double[numBuckets_empty_rnd]; firstDerivValueCounts_empty_rnd[0] = null; - assertAcked(prepareCreate("empty_bucket_idx_rnd").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx_rnd").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < numBuckets_empty_rnd; i++) { valueCounts_empty_rnd[i] = (long) randomIntBetween(1, 10); // make approximately half of the buckets empty diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java index 4400181eb2226..85fe794b05fc6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/ExtendedStatsBucketIT.java @@ -74,7 +74,7 @@ public class ExtendedStatsBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped", "idx_gappy"); numDocs = randomIntBetween(6, 20); @@ -113,7 +113,7 @@ public void setupSuiteScopeCluster() throws Exception { ); } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java index 0d63e6d719610..22890620d6b15 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MaxBucketIT.java @@ -85,7 +85,7 @@ public class MaxBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -114,7 +114,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MinBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MinBucketIT.java index 33cc350f10ff1..b3929943f0d02 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MinBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/MinBucketIT.java @@ -71,7 +71,7 @@ public class MinBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -100,7 +100,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/PercentilesBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/PercentilesBucketIT.java index 6728c9f888aeb..1da079781dc63 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/PercentilesBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/PercentilesBucketIT.java @@ -75,7 +75,7 @@ public class PercentilesBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -104,7 +104,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/StatsBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/StatsBucketIT.java index 90b0aba10e40a..e9f34f6aa65d9 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/StatsBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/StatsBucketIT.java @@ -71,7 +71,7 @@ public class StatsBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -100,7 +100,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/SumBucketIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/SumBucketIT.java index 873c43d8b0f4c..5bd962017c247 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/SumBucketIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/pipeline/SumBucketIT.java @@ -71,7 +71,7 @@ public class SumBucketIT extends OpenSearchIntegTestCase { @Override public void setupSuiteScopeCluster() throws Exception { - assertAcked(client().admin().indices().prepareCreate("idx").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("idx").setMapping("tag", "type=keyword").get()); createIndex("idx_unmapped"); numDocs = randomIntBetween(6, 20); @@ -100,7 +100,7 @@ public void setupSuiteScopeCluster() throws Exception { valueCounts[bucket]++; } - assertAcked(prepareCreate("empty_bucket_idx").addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=integer")); + assertAcked(prepareCreate("empty_bucket_idx").setMapping(SINGLE_VALUED_FIELD_NAME, "type=integer")); for (int i = 0; i < 2; i++) { builders.add( client().prepareIndex("empty_bucket_idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWhileRelocatingIT.java b/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWhileRelocatingIT.java index fedb6b18d93fb..c184d876dcb33 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWhileRelocatingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/basic/SearchWhileRelocatingIT.java @@ -65,7 +65,7 @@ private void testSearchAndRelocateConcurrently(final int numberOfReplicas) throw .indices() .prepareCreate("test") .setSettings(Settings.builder().put("index.number_of_shards", numShards).put("index.number_of_replicas", numberOfReplicas)) - .addMapping("type", "loc", "type=geo_point", "test", "type=text") + .setMapping("loc", "type=geo_point", "test", "type=text") .get(); ensureGreen(); List indexBuilders = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportSearchFailuresIT.java b/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportSearchFailuresIT.java index 7982d9f5781fc..34b202cc09cf7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportSearchFailuresIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportSearchFailuresIT.java @@ -65,7 +65,7 @@ protected int maximumNumberOfReplicas() { public void testFailedSearchWithWrongQuery() throws Exception { logger.info("Start Testing failed search with wrong query"); - assertAcked(prepareCreate("test", 1).addMapping("type", "foo", "type=geo_point")); + assertAcked(prepareCreate("test", 1).setMapping("foo", "type=geo_point")); NumShards test = getNumShards("test"); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportTwoNodesSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportTwoNodesSearchIT.java index 420121006a943..5cd6e76e1e487 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportTwoNodesSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/basic/TransportTwoNodesSearchIT.java @@ -96,7 +96,7 @@ private Set prepareData(int numShards) throws Exception { client().admin() .indices() - .create(createIndexRequest("test").settings(settingsBuilder).mapping("type", "foo", "type=geo_point")) + .create(createIndexRequest("test").settings(settingsBuilder).simpleMapping("foo", "type=geo_point")) .actionGet(); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java index e28ef3c00a485..837e1e7e23ddf 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/InnerHitsIT.java @@ -242,7 +242,7 @@ public void testSimpleNested() throws Exception { } public void testRandomNested() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", "field1", "type=nested", "field2", "type=nested")); + assertAcked(prepareCreate("idx").setMapping("field1", "type=nested", "field2", "type=nested")); int numDocs = scaledRandomIntBetween(25, 100); List requestBuilders = new ArrayList<>(); @@ -538,7 +538,7 @@ public void testNestedMultipleLayers() throws Exception { // Issue #9723 public void testNestedDefinedAsObject() throws Exception { - assertAcked(prepareCreate("articles").addMapping("article", "comments", "type=nested", "title", "type=text")); + assertAcked(prepareCreate("articles").setMapping("comments", "type=nested", "title", "type=text")); List requests = new ArrayList<>(); requests.add( @@ -852,7 +852,7 @@ public void testMatchesQueriesNestedInnerHits() throws Exception { } public void testNestedSource() throws Exception { - assertAcked(prepareCreate("index1").addMapping("message", "comments", "type=nested")); + assertAcked(prepareCreate("index1").setMapping("comments", "type=nested")); client().prepareIndex("index1") .setId("1") .setSource( @@ -947,7 +947,7 @@ public void testNestedSource() throws Exception { } public void testInnerHitsWithIgnoreUnmapped() throws Exception { - assertAcked(prepareCreate("index1").addMapping("_doc", "nested_type", "type=nested")); + assertAcked(prepareCreate("index1").setMapping("nested_type", "type=nested")); createIndex("index2"); client().prepareIndex("index1").setId("1").setSource("nested_type", Collections.singletonMap("key", "value")).get(); client().prepareIndex("index2").setId("3").setSource("key", "value").get(); @@ -967,7 +967,7 @@ public void testInnerHitsWithIgnoreUnmapped() throws Exception { } public void testUseMaxDocInsteadOfSize() throws Exception { - assertAcked(prepareCreate("index2").addMapping("type", "nested", "type=nested")); + assertAcked(prepareCreate("index2").setMapping("nested", "type=nested")); client().admin() .indices() .prepareUpdateSettings("index2") @@ -990,7 +990,7 @@ public void testUseMaxDocInsteadOfSize() throws Exception { } public void testTooHighResultWindow() throws Exception { - assertAcked(prepareCreate("index2").addMapping("type", "nested", "type=nested")); + assertAcked(prepareCreate("index2").setMapping("nested", "type=nested")); client().prepareIndex("index2") .setId("1") .setSource( diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java index 74c2922ebf328..193a48cf0daa6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fetch/subphase/highlight/HighlighterSearchIT.java @@ -332,9 +332,7 @@ public void testHighlightingWhenFieldsAreNotStoredThereIsNoSource() throws IOExc // see #3486 public void testHighTermFrequencyDoc() throws IOException { - assertAcked( - prepareCreate("test").addMapping("test", "name", "type=text,term_vector=with_positions_offsets,store=" + randomBoolean()) - ); + assertAcked(prepareCreate("test").setMapping("name", "type=text,term_vector=with_positions_offsets,store=" + randomBoolean())); StringBuilder builder = new StringBuilder(); for (int i = 0; i < 6000; i++) { builder.append("abc").append(" "); @@ -350,8 +348,7 @@ public void testHighTermFrequencyDoc() throws IOException { public void testEnsureNoNegativeOffsets() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "no_long_term", "type=text,term_vector=with_positions_offsets", "long_term", @@ -620,8 +617,7 @@ public void testSourceLookupHighlightingUsingPostingsHighlighter() throws Except public void testHighlightIssue1994() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "title", "type=text,store=false", "titleTV", @@ -697,8 +693,7 @@ public void testGlobalHighlightingSettingsOverriddenAtFieldLevel() { // Issue #5175 public void testHighlightingOnWildcardFields() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "field-postings", "type=text,index_options=offsets", "field-fvh", @@ -1277,7 +1272,7 @@ public XContentBuilder type1TermVectorMapping() throws IOException { } public void testSameContent() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets")); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=with_positions_offsets")); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < 5; i++) { @@ -1305,7 +1300,7 @@ public void testSameContent() throws Exception { } public void testFastVectorHighlighterOffsetParameter() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets").get()); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=with_positions_offsets").get()); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < 5; i++) { @@ -1327,7 +1322,7 @@ public void testFastVectorHighlighterOffsetParameter() throws Exception { } public void testEscapeHtml() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true")); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true")); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < indexRequestBuilders.length; i++) { @@ -1348,7 +1343,7 @@ public void testEscapeHtml() throws Exception { } public void testEscapeHtmlVector() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets")); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=with_positions_offsets")); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < 5; i++) { @@ -1547,7 +1542,7 @@ public void testMultiMapperNoVectorFromSource() throws Exception { } public void testFastVectorHighlighterShouldFailIfNoTermVectors() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=no")); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=no")); ensureGreen(); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; @@ -1584,9 +1579,7 @@ public void testFastVectorHighlighterShouldFailIfNoTermVectors() throws Exceptio } public void testDisableFastVectorHighlighter() throws Exception { - assertAcked( - prepareCreate("test").addMapping("type1", "title", "type=text,store=true,term_vector=with_positions_offsets,analyzer=classic") - ); + assertAcked(prepareCreate("test").setMapping("title", "type=text,store=true,term_vector=with_positions_offsets,analyzer=classic")); ensureGreen(); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; @@ -1645,7 +1638,7 @@ public void testDisableFastVectorHighlighter() throws Exception { } public void testFSHHighlightAllMvFragments() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "tags", "type=text,term_vector=with_positions_offsets")); + assertAcked(prepareCreate("test").setMapping("tags", "type=text,term_vector=with_positions_offsets")); ensureGreen(); client().prepareIndex("test") .setId("1") @@ -1737,7 +1730,7 @@ public void testCommonTermsTermVector() throws IOException { } public void testPlainHighlightDifferentFragmenter() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "tags", "type=text")); + assertAcked(prepareCreate("test").setMapping("tags", "type=text")); ensureGreen(); client().prepareIndex("test") .setId("1") @@ -1824,8 +1817,7 @@ public void testPlainHighlighterMultipleFields() { public void testFastVectorHighlighterMultipleFields() { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "field1", "type=text,term_vector=with_positions_offsets", "field2", @@ -1849,7 +1841,7 @@ public void testFastVectorHighlighterMultipleFields() { } public void testMissingStoredField() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "highlight_field", "type=text,store=true")); + assertAcked(prepareCreate("test").setMapping("highlight_field", "type=text,store=true")); ensureGreen(); client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject().field("field", "highlight").endObject()).get(); refresh(); @@ -1869,8 +1861,7 @@ public void testMissingStoredField() throws Exception { // Issue #3211 public void testNumericHighlighting() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "test", + prepareCreate("test").setMapping( "text", "type=text", "byte", @@ -1911,7 +1902,7 @@ public void testResetTwice() throws Exception { assertAcked( prepareCreate("test").setSettings( Settings.builder().put(indexSettings()).put("analysis.analyzer.my_analyzer.type", "mock_whitespace").build() - ).addMapping("type", "text", "type=text,analyzer=my_analyzer") + ).setMapping("text", "type=text,analyzer=my_analyzer") ); ensureGreen(); client().prepareIndex("test").setId("1").setSource("text", "opensearch test").get(); @@ -1927,8 +1918,7 @@ public void testResetTwice() throws Exception { public void testHighlightUsesHighlightQuery() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets" ) @@ -1974,8 +1964,7 @@ private static String randomStoreField() { public void testHighlightNoMatchSize() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets" ) @@ -2085,8 +2074,7 @@ public void testHighlightNoMatchSize() throws IOException { public void testHighlightNoMatchSizeWithMultivaluedFields() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets" ) @@ -2181,8 +2169,7 @@ public void testHighlightNoMatchSizeWithMultivaluedFields() throws IOException { public void testHighlightNoMatchSizeNumberOfFragments() throws IOException { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "text", "type=text," + randomStoreField() + "term_vector=with_positions_offsets,index_options=offsets" ) @@ -2506,7 +2493,7 @@ public void testPostingsHighlighterOrderByScore() throws Exception { } public void testPostingsHighlighterEscapeHtml() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "title", "type=text," + randomStoreField() + "index_options=offsets")); + assertAcked(prepareCreate("test").setMapping("title", "type=text," + randomStoreField() + "index_options=offsets")); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[5]; for (int i = 0; i < 5; i++) { @@ -3342,7 +3329,7 @@ public void testHighlightQueryRewriteDatesWithNow() throws Exception { client().admin() .indices() .prepareCreate("index-1") - .addMapping("type", "d", "type=date", "field", "type=text,store=true,term_vector=with_positions_offsets") + .setMapping("d", "type=date", "field", "type=text,store=true,term_vector=with_positions_offsets") .setSettings(Settings.builder().put("index.number_of_replicas", 0).put("index.number_of_shards", 2)) .get() ); @@ -3461,9 +3448,7 @@ public void testWithNestedQuery() throws Exception { public void testWithNormalizer() throws Exception { Builder builder = Settings.builder().put(indexSettings()).putList("index.analysis.normalizer.my_normalizer.filter", "lowercase"); - assertAcked( - prepareCreate("test").setSettings(builder.build()).addMapping("doc", "keyword", "type=keyword,normalizer=my_normalizer") - ); + assertAcked(prepareCreate("test").setSettings(builder.build()).setMapping("keyword", "type=keyword,normalizer=my_normalizer")); ensureGreen(); client().prepareIndex("test") @@ -3485,7 +3470,7 @@ public void testWithNormalizer() throws Exception { } public void testDisableHighlightIdField() throws Exception { - assertAcked(prepareCreate("test").addMapping("doc", "keyword", "type=keyword")); + assertAcked(prepareCreate("test").setMapping("keyword", "type=keyword")); ensureGreen(); client().prepareIndex("test") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java index aed2975ed3234..dacf388e2faa0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fieldcaps/FieldCapabilitiesIT.java @@ -222,8 +222,8 @@ public void testWithIndexAlias() { } public void testWithIndexFilter() throws InterruptedException { - assertAcked(prepareCreate("index-1").addMapping("_doc", "timestamp", "type=date", "field1", "type=keyword")); - assertAcked(prepareCreate("index-2").addMapping("_doc", "timestamp", "type=date", "field1", "type=long")); + assertAcked(prepareCreate("index-1").setMapping("timestamp", "type=date", "field1", "type=keyword")); + assertAcked(prepareCreate("index-2").setMapping("timestamp", "type=date", "field1", "type=long")); List reqs = new ArrayList<>(); reqs.add(client().prepareIndex("index-1").setSource("timestamp", "2015-07-08")); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java b/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java index 46d47d838f68b..25782f8dc18db 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/fields/SearchFieldsIT.java @@ -444,7 +444,7 @@ public void testScriptFieldWithNanos() throws Exception { } public void testIdBasedScriptFields() throws Exception { - prepareCreate("test").addMapping("type1", "num1", "type=long").get(); + prepareCreate("test").setMapping("num1", "type=long").get(); int numDocs = randomIntBetween(1, 30); IndexRequestBuilder[] indexRequestBuilders = new IndexRequestBuilder[numDocs]; @@ -839,7 +839,7 @@ public void testGetFieldsComplexField() throws Exception { // see #8203 public void testSingleValueFieldDatatField() throws ExecutionException, InterruptedException { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type", "test_field", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("test_field", "type=keyword").get()); indexRandom(true, client().prepareIndex("test").setId("1").setSource("test_field", "foobar")); refresh(); SearchResponse searchResponse = client().prepareSearch("test") @@ -1114,8 +1114,7 @@ public void testDocValueFields() throws Exception { public void testScriptFields() throws Exception { assertAcked( - prepareCreate("index").addMapping( - "type", + prepareCreate("index").setMapping( "s", "type=keyword", "l", diff --git a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/RandomScoreFunctionIT.java b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/RandomScoreFunctionIT.java index 670f5e65eb575..0701e96b71f38 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/RandomScoreFunctionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/RandomScoreFunctionIT.java @@ -168,8 +168,7 @@ public void testConsistentHitsWithSameSeed() throws Exception { public void testScoreAccessWithinScript() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type", + prepareCreate("test").setMapping( "body", "type=text", "index", diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java index c2d75b6aa55af..d0b017732b270 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java @@ -66,8 +66,7 @@ protected void setupSuiteScopeCluster() throws Exception { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); assertAcked( - prepareCreate("test").setSettings(settings) - .addMapping("type1", "location", "type=geo_point", "alias", "type=alias,path=location") + prepareCreate("test").setSettings(settings).setMapping("location", "type=geo_point", "alias", "type=alias,path=location") ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java index 7315155e39520..89eb6038d8110 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoShapeIntegrationIT.java @@ -136,9 +136,7 @@ public void testOrientationPersistence() throws Exception { */ public void testIgnoreMalformed() throws Exception { // create index - assertAcked( - client().admin().indices().prepareCreate("test").addMapping("geometry", "shape", "type=geo_shape,ignore_malformed=true").get() - ); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape,ignore_malformed=true").get()); ensureGreen(); // test self crossing ccw poly not crossing dateline @@ -188,7 +186,7 @@ public void testIgnoreMalformed() throws Exception { public void testMappingUpdate() throws Exception { // create index - assertAcked(client().admin().indices().prepareCreate("test").addMapping("geometry", "shape", "type=geo_shape").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape").get()); ensureGreen(); String update = "{\n" diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java index 28b00acd21479..61af97d46e7f3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/LegacyGeoShapeIntegrationIT.java @@ -131,11 +131,7 @@ public void testOrientationPersistence() throws Exception { public void testIgnoreMalformed() throws Exception { // create index assertAcked( - client().admin() - .indices() - .prepareCreate("test") - .addMapping("geometry", "shape", "type=geo_shape,tree=quadtree,ignore_malformed=true") - .get() + client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape,tree=quadtree,ignore_malformed=true").get() ); ensureGreen(); @@ -226,11 +222,7 @@ public void testIndexShapeRouting() throws Exception { public void testLegacyCircle() throws Exception { // create index assertAcked( - client().admin() - .indices() - .prepareCreate("test") - .addMapping("geometry", "shape", "type=geo_shape,strategy=recursive,tree=geohash") - .get() + client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape,strategy=recursive,tree=geohash").get() ); ensureGreen(); @@ -255,11 +247,7 @@ public void testDisallowExpensiveQueries() throws InterruptedException, IOExcept try { // create index assertAcked( - client().admin() - .indices() - .prepareCreate("test") - .addMapping("_doc", "shape", "type=geo_shape,strategy=recursive,tree=geohash") - .get() + client().admin().indices().prepareCreate("test").setMapping("shape", "type=geo_shape,strategy=recursive,tree=geohash").get() ); ensureGreen(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java b/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java index 69b2e655dd0ad..b3253b036bda6 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/morelikethis/MoreLikeThisIT.java @@ -42,7 +42,6 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentBuilder; import org.opensearch.common.xcontent.XContentFactory; -import org.opensearch.index.mapper.MapperService; import org.opensearch.index.query.MoreLikeThisQueryBuilder; import org.opensearch.index.query.MoreLikeThisQueryBuilder.Item; import org.opensearch.index.query.QueryBuilder; @@ -183,7 +182,7 @@ public void testMoreLikeThisForZeroTokensInOneOfTheAnalyzedFields() throws Excep public void testSimpleMoreLikeOnLongField() throws Exception { logger.info("Creating index test"); - assertAcked(prepareCreate("test").addMapping("type1", "some_long", "type=long")); + assertAcked(prepareCreate("test").setMapping("some_long", "type=long")); logger.info("Running Cluster Health"); assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN)); @@ -598,7 +597,7 @@ public void testSimpleMoreLikeThisIds() throws Exception { public void testMoreLikeThisMultiValueFields() throws Exception { logger.info("Creating the index ..."); assertAcked( - prepareCreate("test").addMapping("type1", "text", "type=text,analyzer=keyword") + prepareCreate("test").setMapping("text", "type=text,analyzer=keyword") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1)) ); ensureGreen(); @@ -632,7 +631,7 @@ public void testMoreLikeThisMultiValueFields() throws Exception { public void testMinimumShouldMatch() throws ExecutionException, InterruptedException { logger.info("Creating the index ..."); assertAcked( - prepareCreate("test").addMapping("type1", "text", "type=text,analyzer=whitespace") + prepareCreate("test").setMapping("text", "type=text,analyzer=whitespace") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1)) ); ensureGreen(); @@ -693,15 +692,7 @@ public void testMoreLikeThisArtificialDocs() throws Exception { public void testMoreLikeThisMalformedArtificialDocs() throws Exception { logger.info("Creating the index ..."); - assertAcked( - prepareCreate("test").addMapping( - MapperService.SINGLE_MAPPING_NAME, - "text", - "type=text,analyzer=whitespace", - "date", - "type=date" - ) - ); + assertAcked(prepareCreate("test").setMapping("text", "type=text,analyzer=whitespace", "date", "type=date")); ensureGreen("test"); logger.info("Creating an index with a single document ..."); @@ -790,9 +781,7 @@ public void testMoreLikeThisUnlike() throws ExecutionException, InterruptedExcep } public void testSelectFields() throws IOException, ExecutionException, InterruptedException { - assertAcked( - prepareCreate("test").addMapping("type1", "text", "type=text,analyzer=whitespace", "text1", "type=text,analyzer=whitespace") - ); + assertAcked(prepareCreate("test").setMapping("text", "type=text,analyzer=whitespace", "text1", "type=text,analyzer=whitespace")); ensureGreen("test"); indexRandom( diff --git a/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java b/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java index e3c1abff5d206..d2d23cd47fc01 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/nested/SimpleNestedIT.java @@ -73,7 +73,7 @@ public class SimpleNestedIT extends OpenSearchIntegTestCase { public void testSimpleNested() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "nested1", "type=nested")); + assertAcked(prepareCreate("test").setMapping("nested1", "type=nested")); ensureGreen(); // check on no data, see it works @@ -1597,7 +1597,7 @@ public void testCheckFixedBitSetCache() throws Exception { if (loadFixedBitSeLazily) { settingsBuilder.put("index.load_fixed_bitset_filters_eagerly", false); } - assertAcked(prepareCreate("test").setSettings(settingsBuilder).addMapping("type")); + assertAcked(prepareCreate("test").setSettings(settingsBuilder)); client().prepareIndex("test").setId("0").setSource("field", "value").get(); client().prepareIndex("test").setId("1").setSource("field", "value").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java b/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java index 7d63db78e205a..f3d1a479f1b46 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/profile/aggregation/AggregationProfilerIT.java @@ -108,7 +108,7 @@ protected void setupSuiteScopeCluster() throws Exception { .indices() .prepareCreate("idx") .setSettings(org.opensearch.common.collect.Map.of("number_of_shards", 1, "number_of_replicas", 0)) - .addMapping("type", STRING_FIELD, "type=keyword", NUMBER_FIELD, "type=integer", TAG_FIELD, "type=keyword") + .setMapping(STRING_FIELD, "type=keyword", NUMBER_FIELD, "type=integer", TAG_FIELD, "type=keyword") .get() ); List builders = new ArrayList<>(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java index 66b42fe266887..d87bbfb1fb69c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/MultiMatchQueryIT.java @@ -1015,7 +1015,7 @@ public void testFuzzyFieldLevelBoosting() throws InterruptedException, Execution CreateIndexRequestBuilder builder = prepareCreate(idx).setSettings( Settings.builder().put(indexSettings()).put(SETTING_NUMBER_OF_SHARDS, 3).put(SETTING_NUMBER_OF_REPLICAS, 0) ); - assertAcked(builder.addMapping("type", "title", "type=text", "body", "type=text")); + assertAcked(builder.setMapping("title", "type=text", "body", "type=text")); ensureGreen(); List builders = new ArrayList<>(); builders.add(client().prepareIndex(idx).setId("1").setSource("title", "foo", "body", "bar")); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/ScriptScoreQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/ScriptScoreQueryIT.java index 59f9e020df0d9..d736365a6e236 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/ScriptScoreQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/ScriptScoreQueryIT.java @@ -88,7 +88,7 @@ protected Map, Object>> pluginScripts() { // 2) score is calculated based on a script with params // 3) min score applied public void testScriptScore() { - assertAcked(prepareCreate("test-index").addMapping("_doc", "field1", "type=text", "field2", "type=double")); + assertAcked(prepareCreate("test-index").setMapping("field1", "type=text", "field2", "type=double")); int docCount = 10; for (int i = 1; i <= docCount; i++) { client().prepareIndex("test-index").setId("" + i).setSource("field1", "text" + (i % 2), "field2", i).get(); @@ -114,7 +114,7 @@ public void testScriptScore() { } public void testScriptScoreBoolQuery() { - assertAcked(prepareCreate("test-index").addMapping("_doc", "field1", "type=text", "field2", "type=double")); + assertAcked(prepareCreate("test-index").setMapping("field1", "type=text", "field2", "type=double")); int docCount = 10; for (int i = 1; i <= docCount; i++) { client().prepareIndex("test-index").setId("" + i).setSource("field1", "text" + i, "field2", i).get(); @@ -136,7 +136,7 @@ public void testScriptScoreBoolQuery() { public void testRewrittenQuery() { assertAcked( prepareCreate("test-index2").setSettings(Settings.builder().put("index.number_of_shards", 1)) - .addMapping("_doc", "field1", "type=date", "field2", "type=double") + .setMapping("field1", "type=date", "field2", "type=double") ); client().prepareIndex("test-index2").setId("1").setSource("field1", "2019-09-01", "field2", 1).get(); client().prepareIndex("test-index2").setId("2").setSource("field1", "2019-10-01", "field2", 2).get(); @@ -154,7 +154,7 @@ public void testRewrittenQuery() { public void testDisallowExpensiveQueries() { try { - assertAcked(prepareCreate("test-index").addMapping("_doc", "field1", "type=text", "field2", "type=double")); + assertAcked(prepareCreate("test-index").setMapping("field1", "type=text", "field2", "type=double")); int docCount = 10; for (int i = 1; i <= docCount; i++) { client().prepareIndex("test-index").setId("" + i).setSource("field1", "text" + (i % 2), "field2", i).get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java index fa2d79ecb2017..fed5561c1df64 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/query/SearchQueryIT.java @@ -211,7 +211,7 @@ public void testIssue3177() { } public void testIndexOptions() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "field1", "type=text,index_options=docs")); + assertAcked(prepareCreate("test").setMapping("field1", "type=text,index_options=docs")); indexRandom( true, client().prepareIndex("test").setId("1").setSource("field1", "quick brown fox", "field2", "quick brown fox"), @@ -337,7 +337,7 @@ public void testCommonTermsQuery() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping("type1", "field1", "type=text,analyzer=whitespace") + .setMapping("field1", "type=text,analyzer=whitespace") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1)) .get(); indexRandom( @@ -479,7 +479,7 @@ public void testLowercaseExpandedTerms() { public void testDateRangeInQueryString() { // the mapping needs to be provided upfront otherwise we are not sure how many failures we get back // as with dynamic mappings some shards might be lacking behind and parse a different query - assertAcked(prepareCreate("test").addMapping("type", "past", "type=date", "future", "type=date")); + assertAcked(prepareCreate("test").setMapping("past", "type=date", "future", "type=date")); ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC); String aMonthAgo = DateTimeFormatter.ISO_LOCAL_DATE.format(now.minusMonths(1)); @@ -505,7 +505,7 @@ public void testDateRangeInQueryString() { public void testDateRangeInQueryStringWithTimeZone_7880() { // the mapping needs to be provided upfront otherwise we are not sure how many failures we get back // as with dynamic mappings some shards might be lacking behind and parse a different query - assertAcked(prepareCreate("test").addMapping("type", "past", "type=date")); + assertAcked(prepareCreate("test").setMapping("past", "type=date")); ZoneId timeZone = randomZone(); String now = DateFormatter.forPattern("strict_date_optional_time").format(Instant.now().atZone(timeZone)); @@ -523,7 +523,7 @@ public void testDateRangeInQueryStringWithTimeZone_7880() { public void testDateRangeInQueryStringWithTimeZone_10477() { // the mapping needs to be provided upfront otherwise we are not sure how many failures we get back // as with dynamic mappings some shards might be lacking behind and parse a different query - assertAcked(prepareCreate("test").addMapping("type", "past", "type=date")); + assertAcked(prepareCreate("test").setMapping("past", "type=date")); client().prepareIndex("test").setId("1").setSource("past", "2015-04-05T23:00:00+0000").get(); client().prepareIndex("test").setId("2").setSource("past", "2015-04-06T00:00:00+0000").get(); @@ -732,7 +732,7 @@ public void testFiltersWithCustomCacheKey() throws Exception { } public void testMatchQueryNumeric() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "long", "type=long", "double", "type=double")); + assertAcked(prepareCreate("test").setMapping("long", "type=long", "double", "type=double")); indexRandom( true, @@ -752,7 +752,7 @@ public void testMatchQueryNumeric() throws Exception { } public void testMatchQueryFuzzy() throws Exception { - assertAcked(prepareCreate("test").addMapping("_doc", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); indexRandom( true, @@ -846,9 +846,7 @@ public void testMultiMatchQuery() throws Exception { } public void testMatchQueryZeroTermsQuery() { - assertAcked( - prepareCreate("test").addMapping("type1", "field1", "type=text,analyzer=classic", "field2", "type=text,analyzer=classic") - ); + assertAcked(prepareCreate("test").setMapping("field1", "type=text,analyzer=classic", "field2", "type=text,analyzer=classic")); client().prepareIndex("test").setId("1").setSource("field1", "value1").get(); client().prepareIndex("test").setId("2").setSource("field1", "value2").get(); refresh(); @@ -869,9 +867,7 @@ public void testMatchQueryZeroTermsQuery() { } public void testMultiMatchQueryZeroTermsQuery() { - assertAcked( - prepareCreate("test").addMapping("type1", "field1", "type=text,analyzer=classic", "field2", "type=text,analyzer=classic") - ); + assertAcked(prepareCreate("test").setMapping("field1", "type=text,analyzer=classic", "field2", "type=text,analyzer=classic")); client().prepareIndex("test").setId("1").setSource("field1", "value1", "field2", "value2").get(); client().prepareIndex("test").setId("2").setSource("field1", "value3", "field2", "value4").get(); refresh(); @@ -1039,7 +1035,7 @@ public void testSpecialRangeSyntaxInQueryString() { } public void testEmptytermsQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "term", "type=text")); + assertAcked(prepareCreate("test").setMapping("term", "type=text")); indexRandom( true, @@ -1059,7 +1055,7 @@ public void testEmptytermsQuery() throws Exception { } public void testTermsQuery() throws Exception { - assertAcked(prepareCreate("test").addMapping("type", "str", "type=text", "lng", "type=long", "dbl", "type=double")); + assertAcked(prepareCreate("test").setMapping("str", "type=text", "lng", "type=long", "dbl", "type=double")); indexRandom( true, @@ -1117,7 +1113,7 @@ public void testTermsQuery() throws Exception { } public void testTermsLookupFilter() throws Exception { - assertAcked(prepareCreate("lookup").addMapping("type", "terms", "type=text", "other", "type=text")); + assertAcked(prepareCreate("lookup").setMapping("terms", "type=text", "other", "type=text")); assertAcked( prepareCreate("lookup2").setMapping( jsonBuilder().startObject() @@ -1133,8 +1129,8 @@ public void testTermsLookupFilter() throws Exception { .endObject() ) ); - assertAcked(prepareCreate("lookup3").addMapping("type", "_source", "enabled=false", "terms", "type=text")); - assertAcked(prepareCreate("test").addMapping("type", "term", "type=text")); + assertAcked(prepareCreate("lookup3").setMapping("_source", "enabled=false", "terms", "type=text")); + assertAcked(prepareCreate("test").setMapping("term", "type=text")); indexRandom( true, @@ -1283,8 +1279,7 @@ public void testBasicQueryById() throws Exception { public void testNumericTermsAndRanges() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "num_byte", "type=byte", "num_short", @@ -1400,8 +1395,7 @@ public void testNumericTermsAndRanges() throws Exception { public void testNumericRangeFilter_2826() throws Exception { assertAcked( - prepareCreate("test").addMapping( - "type1", + prepareCreate("test").setMapping( "num_byte", "type=byte", "num_short", @@ -1780,7 +1774,7 @@ public void testDateProvidedAsNumber() throws InterruptedException { } public void testRangeQueryWithTimeZone() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "date", "type=date", "num", "type=integer")); + assertAcked(prepareCreate("test").setMapping("date", "type=date", "num", "type=integer")); indexRandom( true, @@ -1955,7 +1949,7 @@ public void testQueryStringParserCache() throws Exception { } public void testRangeQueryRangeFields_24744() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "int_range", "type=integer_range")); + assertAcked(prepareCreate("test").setMapping("int_range", "type=integer_range")); client().prepareIndex("test") .setId("1") @@ -2064,7 +2058,7 @@ public void testWildcardQueryNormalizationOnKeywordField() { .put("index.analysis.normalizer.lowercase_normalizer.type", "custom") .putList("index.analysis.normalizer.lowercase_normalizer.filter", "lowercase") .build() - ).addMapping("_doc", "field1", "type=keyword,normalizer=lowercase_normalizer") + ).setMapping("field1", "type=keyword,normalizer=lowercase_normalizer") ); client().prepareIndex("test").setId("1").setSource("field1", "Bbb Aaa").get(); refresh(); @@ -2091,7 +2085,7 @@ public void testWildcardQueryNormalizationOnTextField() { .put("index.analysis.analyzer.lowercase_analyzer.tokenizer", "standard") .putList("index.analysis.analyzer.lowercase_analyzer.filter", "lowercase") .build() - ).addMapping("_doc", "field1", "type=text,analyzer=lowercase_analyzer") + ).setMapping("field1", "type=text,analyzer=lowercase_analyzer") ); client().prepareIndex("test").setId("1").setSource("field1", "Bbb Aaa").get(); refresh(); @@ -2119,7 +2113,7 @@ public void testWildcardQueryNormalizationKeywordSpecialCharacters() { .put("index.analysis.normalizer.no_wildcard.type", "custom") .put("index.analysis.normalizer.no_wildcard.char_filter", "no_wildcard") .build() - ).addMapping("_doc", "field", "type=keyword,normalizer=no_wildcard") + ).setMapping("field", "type=keyword,normalizer=no_wildcard") ); client().prepareIndex("test").setId("1").setSource("field", "label-1").get(); refresh(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java index 3bc9eb5b25261..5e45fd8d0ad2a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/scriptfilter/ScriptQuerySearchIT.java @@ -240,7 +240,7 @@ public void testCustomScriptBoost() throws Exception { public void testDisallowExpensiveQueries() { try { - assertAcked(prepareCreate("test-index").addMapping("_doc", "num1", "type=double")); + assertAcked(prepareCreate("test-index").setMapping("num1", "type=double")); int docCount = 10; for (int i = 1; i <= docCount; i++) { client().prepareIndex("test-index").setId("" + i).setSource("num1", i).get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/scroll/SearchScrollIT.java b/server/src/internalClusterTest/java/org/opensearch/search/scroll/SearchScrollIT.java index 5c56671384868..3818566e2eb11 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/scroll/SearchScrollIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/scroll/SearchScrollIT.java @@ -541,7 +541,7 @@ public void testStringSortMissingAscTerminates() throws Exception { assertAcked( prepareCreate("test").setSettings( Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - ).addMapping("test", "no_field", "type=keyword", "some_field", "type=keyword") + ).setMapping("no_field", "type=keyword", "some_field", "type=keyword") ); client().prepareIndex("test").setId("1").setSource("some_field", "test").get(); refresh(); @@ -718,7 +718,7 @@ public void testScrollRewrittenToMatchNoDocs() { .indices() .prepareCreate("test") .setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numShards)) - .addMapping("_doc", "created_date", "type=date,format=yyyy-MM-dd") + .setMapping("created_date", "type=date,format=yyyy-MM-dd") ); client().prepareIndex("test").setId("1").setSource("created_date", "2020-01-01").get(); client().prepareIndex("test").setId("2").setSource("created_date", "2020-01-02").get(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java b/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java index b88e56b4f675d..926e21294ffc8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/searchafter/SearchAfterIT.java @@ -59,13 +59,10 @@ public class SearchAfterIT extends OpenSearchIntegTestCase { private static final String INDEX_NAME = "test"; - private static final String TYPE_NAME = "type1"; private static final int NUM_DOCS = 100; public void testsShouldFail() throws Exception { - assertAcked( - client().admin().indices().prepareCreate("test").addMapping("type1", "field1", "type=long", "field2", "type=keyword").get() - ); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field1", "type=long", "field2", "type=keyword").get()); ensureGreen(); indexRandom(true, client().prepareIndex("test").setId("0").setSource("field1", 0, "field2", "toto")); { @@ -159,7 +156,7 @@ public void testsShouldFail() throws Exception { } public void testWithNullStrings() throws InterruptedException { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type1", "field2", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field2", "type=keyword").get()); ensureGreen(); indexRandom( true, @@ -219,7 +216,7 @@ public void testWithSimpleTypes() throws Exception { if (reqSize == 0) { reqSize = 1; } - assertSearchFromWithSortValues(INDEX_NAME, TYPE_NAME, documents, reqSize); + assertSearchFromWithSortValues(INDEX_NAME, documents, reqSize); } private static class ListComparator implements Comparator { @@ -250,10 +247,10 @@ public int compare(List o1, List o2) { private ListComparator LST_COMPARATOR = new ListComparator(); - private void assertSearchFromWithSortValues(String indexName, String typeName, List documents, int reqSize) throws Exception { + private void assertSearchFromWithSortValues(String indexName, List documents, int reqSize) throws Exception { int numFields = documents.get(0).size(); { - createIndexMappingsFromObjectType(indexName, typeName, documents.get(0)); + createIndexMappingsFromObjectType(indexName, documents.get(0)); List requests = new ArrayList<>(); for (int i = 0; i < documents.size(); i++) { XContentBuilder builder = jsonBuilder(); @@ -289,7 +286,7 @@ private void assertSearchFromWithSortValues(String indexName, String typeName, L } } - private void createIndexMappingsFromObjectType(String indexName, String typeName, List types) { + private void createIndexMappingsFromObjectType(String indexName, List types) { CreateIndexRequestBuilder indexRequestBuilder = client().admin().indices().prepareCreate(indexName); List mappings = new ArrayList<>(); int numFields = types.size(); @@ -323,7 +320,7 @@ private void createIndexMappingsFromObjectType(String indexName, String typeName fail("Can't match type [" + type + "]"); } } - indexRequestBuilder.addMapping(typeName, mappings.toArray()).get(); + indexRequestBuilder.setMapping(mappings.toArray(new String[0])).get(); ensureGreen(); } diff --git a/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java index 0652b38228ec5..7382d4e157bc4 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java @@ -295,7 +295,7 @@ public void testSimpleTerminateAfterCount() throws Exception { public void testSimpleIndexSortEarlyTerminate() throws Exception { prepareCreate("test").setSettings( Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 0).put("index.sort.field", "rank") - ).addMapping(MapperService.SINGLE_MAPPING_NAME, "rank", "type=integer").get(); + ).setMapping("rank", "type=integer").get(); ensureGreen(); int max = randomIntBetween(3, 29); List docbuilders = new ArrayList<>(max); @@ -498,7 +498,7 @@ public void testTooLargeRescoreOkByDynamicResultWindowSetting() throws Exception } public void testQueryNumericFieldWithRegex() throws Exception { - assertAcked(prepareCreate("idx").addMapping("type", "num", "type=integer")); + assertAcked(prepareCreate("idx").setMapping("num", "type=integer")); ensureGreen("idx"); try { @@ -510,7 +510,7 @@ public void testQueryNumericFieldWithRegex() throws Exception { } public void testTermQueryBigInt() throws Exception { - prepareCreate("idx").addMapping("type", "field", "type=keyword").get(); + prepareCreate("idx").setMapping("field", "type=keyword").get(); ensureGreen("idx"); client().prepareIndex("idx") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java index 3d1d407b386e1..4bf4cd138cbd1 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/FieldSortIT.java @@ -137,7 +137,7 @@ public void testIssue8226() { final boolean useMapping = randomBoolean(); for (int i = 0; i < numIndices; i++) { if (useMapping) { - assertAcked(prepareCreate("test_" + i).addAlias(new Alias("test")).addMapping("foo", "entry", "type=long")); + assertAcked(prepareCreate("test_" + i).addAlias(new Alias("test")).setMapping("entry", "type=long")); } else { assertAcked(prepareCreate("test_" + i).addAlias(new Alias("test"))); } @@ -243,7 +243,7 @@ public void testIssue6614() throws ExecutionException, InterruptedException { } public void testTrackScores() throws Exception { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type1", "svalue", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("svalue", "type=keyword").get()); ensureGreen(); index( "test", @@ -354,7 +354,7 @@ public void testRandomSorting() throws IOException, InterruptedException, Execut } public void test3078() { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type", "field", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field", "type=keyword").get()); ensureGreen(); for (int i = 1; i < 101; i++) { @@ -492,7 +492,7 @@ public void testScoreSortDirectionWithFunctionScore() throws Exception { } public void testIssue2986() { - assertAcked(client().admin().indices().prepareCreate("test").addMapping("post", "field1", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("field1", "type=keyword").get()); client().prepareIndex("test").setId("1").setSource("{\"field1\":\"value1\"}", XContentType.JSON).get(); client().prepareIndex("test").setId("2").setSource("{\"field1\":\"value2\"}", XContentType.JSON).get(); @@ -516,7 +516,7 @@ public void testIssue2991() { } catch (Exception e) { // ignore } - assertAcked(client().admin().indices().prepareCreate("test").addMapping("type", "tag", "type=keyword").get()); + assertAcked(client().admin().indices().prepareCreate("test").setMapping("tag", "type=keyword").get()); ensureGreen(); client().prepareIndex("test").setId("1").setSource("tag", "alpha").get(); refresh(); @@ -1610,11 +1610,11 @@ public void testSortDuelBetweenSingleShardAndMultiShardIndex() throws Exception assertAcked( prepareCreate("test1").setSettings( Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(2, maximumNumberOfShards())) - ).addMapping("type", sortField, "type=long").get() + ).setMapping(sortField, "type=long").get() ); assertAcked( prepareCreate("test2").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)) - .addMapping("type", sortField, "type=long") + .setMapping(sortField, "type=long") .get() ); @@ -1650,7 +1650,7 @@ public void testCustomFormat() throws Exception { // Use an ip field, which uses different internal/external // representations of values, to make sure values are both correctly // rendered and parsed (search_after) - assertAcked(prepareCreate("test").addMapping("type", "ip", "type=ip")); + assertAcked(prepareCreate("test").setMapping("ip", "type=ip")); indexRandom( true, client().prepareIndex("test").setId("1").setSource("ip", "192.168.1.7"), @@ -1671,7 +1671,7 @@ public void testCustomFormat() throws Exception { } public void testScriptFieldSort() throws Exception { - assertAcked(prepareCreate("test").addMapping("t", "keyword", "type=keyword", "number", "type=integer")); + assertAcked(prepareCreate("test").setMapping("keyword", "type=keyword", "number", "type=integer")); ensureGreen(); final int numDocs = randomIntBetween(10, 20); IndexRequestBuilder[] indexReqs = new IndexRequestBuilder[numDocs]; @@ -1721,10 +1721,8 @@ public void testScriptFieldSort() throws Exception { public void testFieldAlias() throws Exception { // Create two indices and add the field 'route_length_miles' as an alias in // one, and a concrete field in the other. - assertAcked( - prepareCreate("old_index").addMapping("_doc", "distance", "type=double", "route_length_miles", "type=alias,path=distance") - ); - assertAcked(prepareCreate("new_index").addMapping("_doc", "route_length_miles", "type=double")); + assertAcked(prepareCreate("old_index").setMapping("distance", "type=double", "route_length_miles", "type=alias,path=distance")); + assertAcked(prepareCreate("new_index").setMapping("route_length_miles", "type=double")); ensureGreen("old_index", "new_index"); List builders = new ArrayList<>(); @@ -1749,10 +1747,8 @@ public void testFieldAlias() throws Exception { public void testFieldAliasesWithMissingValues() throws Exception { // Create two indices and add the field 'route_length_miles' as an alias in // one, and a concrete field in the other. - assertAcked( - prepareCreate("old_index").addMapping("_doc", "distance", "type=double", "route_length_miles", "type=alias,path=distance") - ); - assertAcked(prepareCreate("new_index").addMapping("_doc", "route_length_miles", "type=double")); + assertAcked(prepareCreate("old_index").setMapping("distance", "type=double", "route_length_miles", "type=alias,path=distance")); + assertAcked(prepareCreate("new_index").setMapping("route_length_miles", "type=double")); ensureGreen("old_index", "new_index"); List builders = new ArrayList<>(); @@ -1775,9 +1771,9 @@ public void testFieldAliasesWithMissingValues() throws Exception { } public void testCastNumericType() throws Exception { - assertAcked(prepareCreate("index_double").addMapping("_doc", "field", "type=double")); - assertAcked(prepareCreate("index_long").addMapping("_doc", "field", "type=long")); - assertAcked(prepareCreate("index_float").addMapping("_doc", "field", "type=float")); + assertAcked(prepareCreate("index_double").setMapping("field", "type=double")); + assertAcked(prepareCreate("index_long").setMapping("field", "type=long")); + assertAcked(prepareCreate("index_float").setMapping("field", "type=float")); ensureGreen("index_double", "index_long", "index_float"); List builders = new ArrayList<>(); @@ -1821,8 +1817,8 @@ public void testCastNumericType() throws Exception { } public void testCastDate() throws Exception { - assertAcked(prepareCreate("index_date").addMapping("_doc", "field", "type=date")); - assertAcked(prepareCreate("index_date_nanos").addMapping("_doc", "field", "type=date_nanos")); + assertAcked(prepareCreate("index_date").setMapping("field", "type=date")); + assertAcked(prepareCreate("index_date_nanos").setMapping("field", "type=date_nanos")); ensureGreen("index_date", "index_date_nanos"); List builders = new ArrayList<>(); @@ -1937,7 +1933,7 @@ public void testCastDate() throws Exception { } public void testCastNumericTypeExceptions() throws Exception { - assertAcked(prepareCreate("index").addMapping("_doc", "keyword", "type=keyword", "ip", "type=ip")); + assertAcked(prepareCreate("index").setMapping("keyword", "type=keyword", "ip", "type=ip")); ensureGreen("index"); for (String invalidField : new String[] { "keyword", "ip" }) { for (String numericType : new String[] { "long", "double", "date", "date_nanos" }) { @@ -1957,7 +1953,7 @@ public void testCastNumericTypeExceptions() throws Exception { public void testLongSortOptimizationCorrectResults() { assertAcked( prepareCreate("test1").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 2)) - .addMapping("_doc", "long_field", "type=long") + .setMapping("long_field", "type=long") .get() ); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java index c283444666f0b..aebd83592e793 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java @@ -83,7 +83,7 @@ public void testManyToManyGeoPoints() throws ExecutionException, InterruptedExce */ Version version = randomBoolean() ? Version.CURRENT : VersionUtils.randomIndexCompatibleVersion(random()); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point")); + assertAcked(prepareCreate("index").setSettings(settings).setMapping(LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); GeoPoint[] d1Points = { new GeoPoint(3, 2), new GeoPoint(4, 1) }; createShuffeldJSONArray(d1Builder, d1Points); @@ -174,7 +174,7 @@ public void testSingeToManyAvgMedian() throws ExecutionException, InterruptedExc */ Version version = randomBoolean() ? Version.CURRENT : VersionUtils.randomIndexCompatibleVersion(random()); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point")); + assertAcked(prepareCreate("index").setSettings(settings).setMapping(LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); GeoPoint[] d1Points = { new GeoPoint(0, 1), new GeoPoint(0, 4), new GeoPoint(0, 10) }; createShuffeldJSONArray(d1Builder, d1Points); @@ -248,7 +248,7 @@ public void testManyToManyGeoPointsWithDifferentFormats() throws ExecutionExcept */ Version version = randomBoolean() ? Version.CURRENT : VersionUtils.randomIndexCompatibleVersion(random()); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); - assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point")); + assertAcked(prepareCreate("index").setSettings(settings).setMapping(LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); GeoPoint[] d1Points = { new GeoPoint(2.5, 1), new GeoPoint(2.75, 2), new GeoPoint(3, 3), new GeoPoint(3.25, 4) }; createShuffeldJSONArray(d1Builder, d1Points); @@ -306,7 +306,7 @@ public void testManyToManyGeoPointsWithDifferentFormats() throws ExecutionExcept } public void testSinglePointGeoDistanceSort() throws ExecutionException, InterruptedException, IOException { - assertAcked(prepareCreate("index").addMapping("type", LOCATION_FIELD, "type=geo_point")); + assertAcked(prepareCreate("index").setMapping(LOCATION_FIELD, "type=geo_point")); indexRandom( true, client().prepareIndex("index") @@ -382,8 +382,7 @@ private static void checkCorrectSortOrderForGeoSort(SearchResponse searchRespons public void testCrossIndexIgnoreUnmapped() throws Exception { assertAcked( - prepareCreate("test1").addMapping("type", "str_field", "type=keyword", "long_field", "type=long", "double_field", "type=double") - .get() + prepareCreate("test1").setMapping("str_field", "type=keyword", "long_field", "type=long", "double_field", "type=double").get() ); assertAcked(prepareCreate("test2").get()); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/source/MetadataFetchingIT.java b/server/src/internalClusterTest/java/org/opensearch/search/source/MetadataFetchingIT.java index 758d749f0be8e..4f6dd89285bee 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/source/MetadataFetchingIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/source/MetadataFetchingIT.java @@ -69,7 +69,7 @@ public void testSimple() { } public void testInnerHits() { - assertAcked(prepareCreate("test").addMapping("_doc", "nested", "type=nested")); + assertAcked(prepareCreate("test").setMapping("nested", "type=nested")); ensureGreen(); client().prepareIndex("test").setId("1").setSource("field", "value", "nested", Collections.singletonMap("title", "foo")).get(); refresh(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java b/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java index cd3921d91a3ed..07e58db836740 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/suggest/SuggestSearchIT.java @@ -97,7 +97,7 @@ public class SuggestSearchIT extends OpenSearchIntegTestCase { // see #3196 public void testSuggestAcrossMultipleIndices() throws IOException { - assertAcked(prepareCreate("test").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); ensureGreen(); index("test", "type1", "1", "text", "abcd"); @@ -111,7 +111,7 @@ public void testSuggestAcrossMultipleIndices() throws IOException { .text("abcd"); logger.info("--> run suggestions with one index"); searchSuggest("test", termSuggest); - assertAcked(prepareCreate("test_1").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test_1").setMapping("text", "type=text")); ensureGreen(); index("test_1", "type1", "1", "text", "ab cd"); @@ -342,7 +342,7 @@ public void testUnmappedField() throws IOException, InterruptedException, Execut } public void testSimple() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); ensureGreen(); index("test", "type1", "1", "text", "abcd"); @@ -367,7 +367,7 @@ public void testSimple() throws Exception { } public void testEmpty() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); ensureGreen(); index("test", "type1", "1", "text", "bar"); @@ -386,7 +386,7 @@ public void testEmpty() throws Exception { } public void testEmptyIndex() throws Exception { - assertAcked(prepareCreate("test").addMapping("type1", "text", "type=text")); + assertAcked(prepareCreate("test").setMapping("text", "type=text")); ensureGreen(); // use SuggestMode.ALWAYS, otherwise the results can vary between requests. @@ -412,7 +412,7 @@ public void testEmptyIndex() throws Exception { } public void testWithMultipleCommands() throws Exception { - assertAcked(prepareCreate("test").addMapping("typ1", "field1", "type=text", "field2", "type=text")); + assertAcked(prepareCreate("test").setMapping("field1", "type=text", "field2", "type=text")); ensureGreen(); index("test", "typ1", "1", "field1", "prefix_abcd", "field2", "prefix_efgh"); @@ -516,7 +516,7 @@ public void testSizeAndSort() throws Exception { // see #2817 public void testStopwordsOnlyPhraseSuggest() throws IOException { assertAcked( - prepareCreate("test").addMapping("typ1", "body", "type=text,analyzer=stopwd") + prepareCreate("test").setMapping("body", "type=text,analyzer=stopwd") .setSettings( Settings.builder() .put("index.analysis.analyzer.stopwd.tokenizer", "standard") diff --git a/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java b/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java index c6ec91a6ab078..16b0e8829b1a7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/update/UpdateIT.java @@ -542,7 +542,7 @@ public void testUpdateRequestWithScriptAndShouldUpsertDoc() throws Exception { } public void testContextVariables() throws Exception { - assertAcked(prepareCreate("test").addAlias(new Alias("alias")).addMapping("type1")); + assertAcked(prepareCreate("test").addAlias(new Alias("alias"))); ensureGreen(); // Index some documents diff --git a/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java index a97c4a0d13f12..86a51e7367ade 100644 --- a/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/validate/SimpleValidateQueryIT.java @@ -297,7 +297,7 @@ public void testExplainNoQuery() { public void testExplainFilteredAlias() { assertAcked( - prepareCreate("test").addMapping("test", "field", "type=text") + prepareCreate("test").setMapping("field", "type=text") .addAlias(new Alias("alias").filter(QueryBuilders.termQuery("field", "value1"))) ); ensureGreen(); @@ -318,7 +318,7 @@ public void testExplainWithRewriteValidateQuery() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping(MapperService.SINGLE_MAPPING_NAME, "field", "type=text,analyzer=whitespace") + .setMapping("field", "type=text,analyzer=whitespace") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 1)) .get(); client().prepareIndex("test").setId("1").setSource("field", "quick lazy huge brown pidgin").get(); @@ -380,7 +380,7 @@ public void testExplainWithRewriteValidateQueryAllShards() throws Exception { client().admin() .indices() .prepareCreate("test") - .addMapping(MapperService.SINGLE_MAPPING_NAME, "field", "type=text,analyzer=whitespace") + .setMapping("field", "type=text,analyzer=whitespace") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 2).put("index.number_of_routing_shards", 2)) .get(); // We are relying on specific routing behaviors for the result to be right, so @@ -484,7 +484,7 @@ public void testExplainTermsQueryWithLookup() throws Exception { client().admin() .indices() .prepareCreate("twitter") - .addMapping("_doc", "user", "type=integer", "followers", "type=integer") + .setMapping("user", "type=integer", "followers", "type=integer") .setSettings(Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 2).put("index.number_of_routing_shards", 2)) .get(); client().prepareIndex("twitter").setId("1").setSource("followers", new int[] { 1, 2, 3 }).get(); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java index ab328eda73753..538a641ecd42d 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java @@ -66,7 +66,8 @@ public class ClusterHealthResponse extends ActionResponse implements StatusToXCo private static final String TIMED_OUT = "timed_out"; private static final String NUMBER_OF_NODES = "number_of_nodes"; private static final String NUMBER_OF_DATA_NODES = "number_of_data_nodes"; - private static final String DISCOVERED_CLUSTER_MANAGER = "discovered_master"; + private static final String DISCOVERED_MASTER = "discovered_master"; + private static final String DISCOVERED_CLUSTER_MANAGER = "discovered_cluster_manager"; private static final String NUMBER_OF_PENDING_TASKS = "number_of_pending_tasks"; private static final String NUMBER_OF_IN_FLIGHT_FETCH = "number_of_in_flight_fetch"; private static final String DELAYED_UNASSIGNED_SHARDS = "delayed_unassigned_shards"; @@ -376,6 +377,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field(TIMED_OUT, isTimedOut()); builder.field(NUMBER_OF_NODES, getNumberOfNodes()); builder.field(NUMBER_OF_DATA_NODES, getNumberOfDataNodes()); + builder.field(DISCOVERED_MASTER, hasDiscoveredMaster()); // the field will be removed in a future major version builder.field(DISCOVERED_CLUSTER_MANAGER, hasDiscoveredMaster()); builder.field(ACTIVE_PRIMARY_SHARDS, getActivePrimaryShards()); builder.field(ACTIVE_SHARDS, getActiveShards()); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsNodes.java b/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsNodes.java index 0ae7ebd17aaa5..fbca94780f827 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsNodes.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsNodes.java @@ -223,7 +223,14 @@ private Counts(final List nodeInfos) { roles.merge(COORDINATING_ONLY, 1, Integer::sum); } else { for (DiscoveryNodeRole role : nodeInfo.getNode().getRoles()) { - roles.merge(role.roleName(), 1, Integer::sum); + // TODO: Remove the 'if' condition and only keep the statement in 'else' after removing MASTER_ROLE. + // As of 2.0, CLUSTER_MANAGER_ROLE is added, and it should be taken as MASTER_ROLE + if (role.isClusterManager()) { + roles.merge(DiscoveryNodeRole.MASTER_ROLE.roleName(), 1, Integer::sum); + roles.merge(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(), 1, Integer::sum); + } else { + roles.merge(role.roleName(), 1, Integer::sum); + } } } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java index b234561563e56..7f1f516d13a04 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java @@ -305,11 +305,9 @@ private CreateIndexRequest mapping(String type, Map source) { /** * A specialized simplified mapping source method, takes the form of simple properties definition: * ("field1", "type=string,store=true"). - * @deprecated types are being removed */ - @Deprecated - public CreateIndexRequest mapping(String type, Object... source) { - mapping(PutMappingRequest.buildFromSimplifiedDef(source)); + public CreateIndexRequest simpleMapping(String... source) { + mapping(PutMappingRequest.simpleMapping(source)); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java index 41f364517fd06..cc99f63c6a844 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequestBuilder.java @@ -141,11 +141,9 @@ public CreateIndexRequestBuilder setMapping(Map source) { /** * A specialized simplified mapping source method, takes the form of simple properties definition: * ("field1", "type=string,store=true"). - * @deprecated types are being removed */ - @Deprecated - public CreateIndexRequestBuilder addMapping(String type, Object... source) { - request.mapping(type, source); + public CreateIndexRequestBuilder setMapping(String... source) { + request.simpleMapping(source); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java index 52be45054ba55..be3e676a4a1a2 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java @@ -217,8 +217,8 @@ public String source() { * Also supports metadata mapping fields such as `_all` and `_parent` as property definition, these metadata * mapping fields will automatically be put on the top level mapping object. */ - public PutMappingRequest source(Object... source) { - return source(buildFromSimplifiedDef(source)); + public PutMappingRequest source(String... source) { + return source(simpleMapping(source)); } public String origin() { @@ -239,7 +239,7 @@ public PutMappingRequest origin(String origin) { * if the number of the source arguments is not divisible by two * @return the mappings definition */ - public static XContentBuilder buildFromSimplifiedDef(Object... source) { + public static XContentBuilder simpleMapping(String... source) { if (source.length % 2 != 0) { throw new IllegalArgumentException("mapping source must be pairs of fieldnames and properties definition."); } @@ -248,10 +248,10 @@ public static XContentBuilder buildFromSimplifiedDef(Object... source) { builder.startObject(); for (int i = 0; i < source.length; i++) { - String fieldName = source[i++].toString(); + String fieldName = source[i++]; if (RESERVED_FIELDS.contains(fieldName)) { builder.startObject(fieldName); - String[] s1 = Strings.splitStringByCommaToArray(source[i].toString()); + String[] s1 = Strings.splitStringByCommaToArray(source[i]); for (String s : s1) { String[] s2 = Strings.split(s, "="); if (s2.length != 2) { @@ -265,13 +265,13 @@ public static XContentBuilder buildFromSimplifiedDef(Object... source) { builder.startObject("properties"); for (int i = 0; i < source.length; i++) { - String fieldName = source[i++].toString(); + String fieldName = source[i++]; if (RESERVED_FIELDS.contains(fieldName)) { continue; } builder.startObject(fieldName); - String[] s1 = Strings.splitStringByCommaToArray(source[i].toString()); + String[] s1 = Strings.splitStringByCommaToArray(source[i]); for (String s : s1) { String[] s2 = Strings.split(s, "="); if (s2.length != 2) { diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java index a1b3b40d4e961..3ef96254b3f9b 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestBuilder.java @@ -102,7 +102,7 @@ public PutMappingRequestBuilder setSource(String mappingSource, XContentType xCo * A specialized simplified mapping source method, takes the form of simple properties definition: * ("field1", "type=string,store=true"). */ - public PutMappingRequestBuilder setSource(Object... source) { + public PutMappingRequestBuilder setSource(String... source) { request.source(source); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequestBuilder.java index a7af2f963d15b..c74f71a70e09d 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequestBuilder.java @@ -84,8 +84,8 @@ public RolloverRequestBuilder alias(Alias alias) { return this; } - public RolloverRequestBuilder mapping(String type, Object... source) { - this.request.getCreateIndexRequest().mapping(type, source); + public RolloverRequestBuilder simpleMapping(String... source) { + this.request.getCreateIndexRequest().simpleMapping(source); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java index 2ea2e492ffe4d..d443d14f3f463 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java @@ -58,6 +58,7 @@ import org.opensearch.common.xcontent.XContentType; import org.opensearch.common.xcontent.json.JsonXContent; import org.opensearch.common.xcontent.support.XContentMapValues; +import org.opensearch.index.mapper.MapperService; import java.io.IOException; import java.util.Collections; @@ -303,8 +304,8 @@ public PutIndexTemplateRequest mapping(String type, Map source) * A specialized simplified mapping source method, takes the form of simple properties definition: * ("field1", "type=string,store=true"). */ - public PutIndexTemplateRequest mapping(String type, Object... source) { - mapping(type, PutMappingRequest.buildFromSimplifiedDef(source)); + public PutIndexTemplateRequest mapping(String... source) { + mapping(MapperService.SINGLE_MAPPING_NAME, PutMappingRequest.simpleMapping(source)); return this; } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java index caff201abeda7..df3b5f6417576 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequestBuilder.java @@ -137,8 +137,8 @@ public PutIndexTemplateRequestBuilder addMapping(String type, String source, XCo * A specialized simplified mapping source method, takes the form of simple properties definition: * ("field1", "type=string,store=true"). */ - public PutIndexTemplateRequestBuilder addMapping(String type, Object... source) { - request.mapping(type, source); + public PutIndexTemplateRequestBuilder setMapping(String... source) { + request.mapping(source); return this; } diff --git a/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineRequest.java b/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineRequest.java index 6223f25488d88..bc0317e076319 100644 --- a/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineRequest.java +++ b/server/src/main/java/org/opensearch/action/ingest/SimulatePipelineRequest.java @@ -194,12 +194,6 @@ private static List parseDocs(Map config) { Map dataMap = (Map) object; Map document = ConfigurationUtils.readMap(null, null, dataMap, Fields.SOURCE); String index = ConfigurationUtils.readStringOrIntProperty(null, null, dataMap, Metadata.INDEX.getFieldName(), "_index"); - if (dataMap.containsKey(Metadata.TYPE.getFieldName())) { - deprecationLogger.deprecate( - "simulate_pipeline_with_types", - "[types removal] specifying _type in pipeline simulation requests is deprecated" - ); - } String id = ConfigurationUtils.readStringOrIntProperty(null, null, dataMap, Metadata.ID.getFieldName(), "_id"); String routing = ConfigurationUtils.readOptionalStringOrIntProperty(null, null, dataMap, Metadata.ROUTING.getFieldName()); Long version = null; diff --git a/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java b/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java index e2072cae84733..79019a73c69e3 100644 --- a/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java +++ b/server/src/main/java/org/opensearch/bootstrap/BootstrapChecks.java @@ -64,6 +64,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; import static org.opensearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; @@ -773,10 +774,12 @@ public BootstrapCheckResult check(BootstrapContext context) { return BootstrapCheckResult.failure( String.format( Locale.ROOT, - "the default discovery settings are unsuitable for production use; at least one of [%s] must be configured", - Stream.of(DISCOVERY_SEED_HOSTS_SETTING, DISCOVERY_SEED_PROVIDERS_SETTING, INITIAL_MASTER_NODES_SETTING) + // TODO: Remove ' / %s' from the error message after removing MASTER_ROLE, and update unit test. + "the default discovery settings are unsuitable for production use; at least one of [%s / %s] must be configured", + Stream.of(DISCOVERY_SEED_HOSTS_SETTING, DISCOVERY_SEED_PROVIDERS_SETTING, INITIAL_CLUSTER_MANAGER_NODES_SETTING) .map(Setting::getKey) - .collect(Collectors.joining(", ")) + .collect(Collectors.joining(", ")), + INITIAL_MASTER_NODES_SETTING.getKey() ) ); } diff --git a/server/src/main/java/org/opensearch/cluster/ClusterState.java b/server/src/main/java/org/opensearch/cluster/ClusterState.java index 6e17be690dd9d..459c0b9502acf 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterState.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterState.java @@ -402,7 +402,13 @@ public boolean supersedes(ClusterState other) { public enum Metric { VERSION("version"), + + /** + * @deprecated As of 2.0, because promoting inclusive language, replaced by {@link #CLUSTER_MANAGER_NODE} + */ + @Deprecated MASTER_NODE("master_node"), + CLUSTER_MANAGER_NODE("cluster_manager_node"), BLOCKS("blocks"), NODES("nodes"), METADATA("metadata"), @@ -467,6 +473,11 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field("master_node", nodes().getMasterNodeId()); } + // Value of the field is identical with the above, and aims to replace the above field. + if (metrics.contains(Metric.CLUSTER_MANAGER_NODE)) { + builder.field("cluster_manager_node", nodes().getMasterNodeId()); + } + if (metrics.contains(Metric.BLOCKS)) { builder.startObject("blocks"); diff --git a/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java b/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java index de7fc6cf264fd..a7d0719d9306a 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java @@ -75,6 +75,15 @@ public class ClusterBootstrapService { "cluster.initial_master_nodes", emptyList(), Function.identity(), + Property.NodeScope, + Property.Deprecated + ); + // The setting below is going to replace the above. + // To keep backwards compatibility, the old usage is remained, and it's also used as the fallback for the new usage. + public static final Setting> INITIAL_CLUSTER_MANAGER_NODES_SETTING = Setting.listSetting( + "cluster.initial_cluster_manager_nodes", + INITIAL_MASTER_NODES_SETTING, + Function.identity(), Property.NodeScope ); @@ -105,10 +114,14 @@ public ClusterBootstrapService( Consumer votingConfigurationConsumer ) { if (DiscoveryModule.isSingleNodeDiscovery(settings)) { - if (INITIAL_MASTER_NODES_SETTING.exists(settings)) { + if (INITIAL_CLUSTER_MANAGER_NODES_SETTING.existsOrFallbackExists(settings)) { + // TODO: Remove variable 'initialClusterManagerSettingName' after removing MASTER_ROLE. + String initialClusterManagerSettingName = INITIAL_CLUSTER_MANAGER_NODES_SETTING.exists(settings) + ? INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + : INITIAL_MASTER_NODES_SETTING.getKey(); throw new IllegalArgumentException( "setting [" - + INITIAL_MASTER_NODES_SETTING.getKey() + + initialClusterManagerSettingName + "] is not allowed when [" + DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey() + "] is set to [" @@ -128,11 +141,11 @@ public ClusterBootstrapService( bootstrapRequirements = Collections.singleton(Node.NODE_NAME_SETTING.get(settings)); unconfiguredBootstrapTimeout = null; } else { - final List initialClusterManagerNodes = INITIAL_MASTER_NODES_SETTING.get(settings); + final List initialClusterManagerNodes = INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings); bootstrapRequirements = unmodifiableSet(new LinkedHashSet<>(initialClusterManagerNodes)); if (bootstrapRequirements.size() != initialClusterManagerNodes.size()) { throw new IllegalArgumentException( - "setting [" + INITIAL_MASTER_NODES_SETTING.getKey() + "] contains duplicates: " + initialClusterManagerNodes + "setting [" + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + "] contains duplicates: " + initialClusterManagerNodes ); } unconfiguredBootstrapTimeout = discoveryIsConfigured(settings) ? null : UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING.get(settings); @@ -150,7 +163,7 @@ public static boolean discoveryIsConfigured(Settings settings) { LEGACY_DISCOVERY_HOSTS_PROVIDER_SETTING, DISCOVERY_SEED_HOSTS_SETTING, LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING, - INITIAL_MASTER_NODES_SETTING + INITIAL_CLUSTER_MANAGER_NODES_SETTING ).anyMatch(s -> s.exists(settings)); } diff --git a/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java b/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java index 394a33eb3cac3..c36a2983a011a 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java @@ -56,7 +56,7 @@ import java.util.stream.Collectors; import java.util.stream.StreamSupport; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.monitor.StatusInfo.Status.UNHEALTHY; public class ClusterFormationFailureHelper { @@ -198,13 +198,13 @@ String getDescription() { if (clusterState.getLastAcceptedConfiguration().isEmpty()) { final String bootstrappingDescription; - if (INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY).equals(INITIAL_MASTER_NODES_SETTING.get(settings))) { - bootstrappingDescription = "[" + INITIAL_MASTER_NODES_SETTING.getKey() + "] is empty on this node"; + if (INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(Settings.EMPTY).equals(INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings))) { + bootstrappingDescription = "[" + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + "] is empty on this node"; } else { bootstrappingDescription = String.format( Locale.ROOT, "this node must discover master-eligible nodes %s to bootstrap a cluster", - INITIAL_MASTER_NODES_SETTING.get(settings) + INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings) ); } diff --git a/server/src/main/java/org/opensearch/cluster/coordination/NoMasterBlockService.java b/server/src/main/java/org/opensearch/cluster/coordination/NoMasterBlockService.java index c0bb4019c27e1..64e3512e38d55 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/NoMasterBlockService.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/NoMasterBlockService.java @@ -76,14 +76,24 @@ public class NoMasterBlockService { "write", NoMasterBlockService::parseNoClusterManagerBlock, Property.Dynamic, + Property.NodeScope, + Property.Deprecated + ); + // The setting below is going to replace the above. + // To keep backwards compatibility, the old usage is remained, and it's also used as the fallback for the new usage. + public static final Setting NO_CLUSTER_MANAGER_BLOCK_SETTING = new Setting<>( + "cluster.no_cluster_manager_block", + NO_MASTER_BLOCK_SETTING, + NoMasterBlockService::parseNoClusterManagerBlock, + Property.Dynamic, Property.NodeScope ); private volatile ClusterBlock noClusterManagerBlock; public NoMasterBlockService(Settings settings, ClusterSettings clusterSettings) { - this.noClusterManagerBlock = NO_MASTER_BLOCK_SETTING.get(settings); - clusterSettings.addSettingsUpdateConsumer(NO_MASTER_BLOCK_SETTING, this::setNoMasterBlock); + this.noClusterManagerBlock = NO_CLUSTER_MANAGER_BLOCK_SETTING.get(settings); + clusterSettings.addSettingsUpdateConsumer(NO_CLUSTER_MANAGER_BLOCK_SETTING, this::setNoMasterBlock); } private static ClusterBlock parseNoClusterManagerBlock(String value) { diff --git a/server/src/main/java/org/opensearch/cluster/health/ClusterStateHealth.java b/server/src/main/java/org/opensearch/cluster/health/ClusterStateHealth.java index c6b214d31707e..bc3f747b3f866 100644 --- a/server/src/main/java/org/opensearch/cluster/health/ClusterStateHealth.java +++ b/server/src/main/java/org/opensearch/cluster/health/ClusterStateHealth.java @@ -53,7 +53,7 @@ public final class ClusterStateHealth implements Iterable, W private final int numberOfNodes; private final int numberOfDataNodes; - private final boolean hasDiscoveredMaster; + private final boolean hasDiscoveredClusterManager; private final int activeShards; private final int relocatingShards; private final int activePrimaryShards; @@ -81,7 +81,7 @@ public ClusterStateHealth(final ClusterState clusterState) { public ClusterStateHealth(final ClusterState clusterState, final String[] concreteIndices) { numberOfNodes = clusterState.nodes().getSize(); numberOfDataNodes = clusterState.nodes().getDataNodes().size(); - hasDiscoveredMaster = clusterState.nodes().getMasterNodeId() != null; + hasDiscoveredClusterManager = clusterState.nodes().getMasterNodeId() != null; indices = new HashMap<>(); for (String index : concreteIndices) { IndexRoutingTable indexRoutingTable = clusterState.routingTable().index(index); @@ -150,9 +150,9 @@ public ClusterStateHealth(final StreamInput in) throws IOException { numberOfNodes = in.readVInt(); numberOfDataNodes = in.readVInt(); if (in.getVersion().onOrAfter(Version.V_1_0_0)) { - hasDiscoveredMaster = in.readBoolean(); + hasDiscoveredClusterManager = in.readBoolean(); } else { - hasDiscoveredMaster = true; + hasDiscoveredClusterManager = true; } status = ClusterHealthStatus.fromValue(in.readByte()); int size = in.readVInt(); @@ -187,7 +187,7 @@ public ClusterStateHealth( this.unassignedShards = unassignedShards; this.numberOfNodes = numberOfNodes; this.numberOfDataNodes = numberOfDataNodes; - this.hasDiscoveredMaster = hasDiscoveredMaster; + this.hasDiscoveredClusterManager = hasDiscoveredMaster; this.activeShardsPercent = activeShardsPercent; this.status = status; this.indices = indices; @@ -234,7 +234,7 @@ public double getActiveShardsPercent() { } public boolean hasDiscoveredMaster() { - return hasDiscoveredMaster; + return hasDiscoveredClusterManager; } @Override @@ -252,7 +252,7 @@ public void writeTo(final StreamOutput out) throws IOException { out.writeVInt(numberOfNodes); out.writeVInt(numberOfDataNodes); if (out.getVersion().onOrAfter(Version.V_1_0_0)) { - out.writeBoolean(hasDiscoveredMaster); + out.writeBoolean(hasDiscoveredClusterManager); } out.writeByte(status.value()); out.writeVInt(indices.size()); @@ -270,7 +270,7 @@ public String toString() { + ", numberOfDataNodes=" + numberOfDataNodes + ", hasDiscoveredMaster=" - + hasDiscoveredMaster + + hasDiscoveredClusterManager + ", activeShards=" + activeShards + ", relocatingShards=" @@ -297,7 +297,7 @@ public boolean equals(Object o) { ClusterStateHealth that = (ClusterStateHealth) o; return numberOfNodes == that.numberOfNodes && numberOfDataNodes == that.numberOfDataNodes - && hasDiscoveredMaster == that.hasDiscoveredMaster + && hasDiscoveredClusterManager == that.hasDiscoveredClusterManager && activeShards == that.activeShards && relocatingShards == that.relocatingShards && activePrimaryShards == that.activePrimaryShards @@ -313,7 +313,7 @@ public int hashCode() { return Objects.hash( numberOfNodes, numberOfDataNodes, - hasDiscoveredMaster, + hasDiscoveredClusterManager, activeShards, relocatingShards, activePrimaryShards, diff --git a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java index 9fa49ec93d307..6bd943c5e1d0d 100644 --- a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java +++ b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java @@ -94,7 +94,7 @@ public static boolean hasRole(final Settings settings, final DiscoveryNodeRole r } public static boolean isMasterNode(Settings settings) { - return hasRole(settings, DiscoveryNodeRole.MASTER_ROLE); + return hasRole(settings, DiscoveryNodeRole.MASTER_ROLE) || hasRole(settings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } /** @@ -343,7 +343,7 @@ public DiscoveryNode(StreamInput in) throws IOException { final LegacyRole legacyRole = in.readEnum(LegacyRole.class); switch (legacyRole) { case MASTER: - roles.add(DiscoveryNodeRole.MASTER_ROLE); + roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); break; case DATA: roles.add(DiscoveryNodeRole.DATA_ROLE); @@ -390,11 +390,11 @@ public void writeTo(StreamOutput out) throws IOException { .collect(Collectors.toList()); out.writeVInt(rolesToWrite.size()); for (final DiscoveryNodeRole role : rolesToWrite) { - if (role == DiscoveryNodeRole.MASTER_ROLE) { + if (role.isClusterManager()) { out.writeEnum(LegacyRole.MASTER); - } else if (role == DiscoveryNodeRole.DATA_ROLE) { + } else if (role.equals(DiscoveryNodeRole.DATA_ROLE)) { out.writeEnum(LegacyRole.DATA); - } else if (role == DiscoveryNodeRole.INGEST_ROLE) { + } else if (role.equals(DiscoveryNodeRole.INGEST_ROLE)) { out.writeEnum(LegacyRole.INGEST); } } @@ -456,7 +456,7 @@ public boolean isDataNode() { * Can this node become master or not. */ public boolean isMasterNode() { - return roles.contains(DiscoveryNodeRole.MASTER_ROLE); + return roles.contains(DiscoveryNodeRole.MASTER_ROLE) || roles.contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } /** @@ -591,7 +591,11 @@ public static void setAdditionalRoles(final Set additionalRol + "], roles by name abbreviation [" + roleNameAbbreviationToPossibleRoles + "]"; - roleMap = roleNameToPossibleRoles; + // TODO: Remove the Map 'roleNameToPossibleRolesWithMaster' and let 'roleMap = roleNameToPossibleRoles', after removing MASTER_ROLE. + // It's used to allow CLUSTER_MANAGER_ROLE that introduced in 2.0, having the same abbreviation name with MASTER_ROLE. + final Map roleNameToPossibleRolesWithMaster = new HashMap<>(roleNameToPossibleRoles); + roleNameToPossibleRolesWithMaster.put(DiscoveryNodeRole.MASTER_ROLE.roleName(), DiscoveryNodeRole.MASTER_ROLE); + roleMap = Collections.unmodifiableMap(roleNameToPossibleRolesWithMaster); } public static Set getPossibleRoleNames() { @@ -599,7 +603,7 @@ public static Set getPossibleRoleNames() { } /** - * Enum that holds all the possible roles that that a node can fulfill in a cluster. + * Enum that holds all the possible roles that a node can fulfill in a cluster. * Each role has its name and a corresponding abbreviation used by cat apis. */ private enum LegacyRole { diff --git a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java index fb1cfb24166c4..cff1a77f4cdb7 100644 --- a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java +++ b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodeRole.java @@ -34,6 +34,7 @@ import org.opensearch.LegacyESVersion; import org.opensearch.Version; +import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Setting; import org.opensearch.common.settings.Setting.Property; import org.opensearch.common.settings.Settings; @@ -41,6 +42,8 @@ import java.util.Arrays; import java.util.Collections; +import java.util.List; +import java.util.Locale; import java.util.Objects; import java.util.SortedSet; import java.util.TreeSet; @@ -50,6 +53,10 @@ */ public abstract class DiscoveryNodeRole implements Comparable { + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DiscoveryNodeRole.class); + public static final String MASTER_ROLE_DEPRECATION_MESSAGE = + "Assigning [master] role in setting [node.roles] is deprecated. To promote inclusive language, please use [cluster_manager] role instead."; + private final String roleName; /** @@ -129,6 +136,13 @@ public DiscoveryNodeRole getCompatibilityRole(Version nodeVersion) { return this; } + /** + * Validate the role is compatible with the other roles in the list, when assigning the list of roles to a node. + * An {@link IllegalArgumentException} is expected to be thrown, if the role can't coexist with the other roles. + * @param roles a {@link List} of {@link DiscoveryNodeRole} that a node is going to have + */ + public void validateRole(List roles) {}; + @Override public final boolean equals(Object o) { if (this == o) return true; @@ -193,15 +207,60 @@ public Setting legacySetting() { /** * Represents the role for a master-eligible node. + * @deprecated As of 2.0, because promoting inclusive language, replaced by {@link #CLUSTER_MANAGER_ROLE} */ + @Deprecated public static final DiscoveryNodeRole MASTER_ROLE = new DiscoveryNodeRole("master", "m") { + @Override + public Setting legacySetting() { + // copy the setting here so we can mark it private in org.opensearch.node.Node + // As of 2.0, set the default value to 'false', so that MASTER_ROLE isn't added as a default value of NODE_ROLES_SETTING + return Setting.boolSetting("node.master", false, Property.Deprecated, Property.NodeScope); + } + + @Override + public void validateRole(List roles) { + deprecationLogger.deprecate("node_role_master", MASTER_ROLE_DEPRECATION_MESSAGE); + } + + }; + + /** + * Represents the role for a cluster-manager-eligible node. + */ + public static final DiscoveryNodeRole CLUSTER_MANAGER_ROLE = new DiscoveryNodeRole("cluster_manager", "m") { + @Override public Setting legacySetting() { // copy the setting here so we can mark it private in org.opensearch.node.Node return Setting.boolSetting("node.master", true, Property.Deprecated, Property.NodeScope); } + @Override + public DiscoveryNodeRole getCompatibilityRole(Version nodeVersion) { + if (nodeVersion.onOrAfter(Version.V_2_0_0)) { + return this; + } else { + return DiscoveryNodeRole.MASTER_ROLE; + } + } + + @Override + public void validateRole(List roles) { + if (roles.contains(DiscoveryNodeRole.MASTER_ROLE)) { + throw new IllegalArgumentException( + String.format( + Locale.ROOT, + "The two roles [%s, %s] can not be assigned together to a node. %s", + DiscoveryNodeRole.MASTER_ROLE.roleName(), + DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(), + MASTER_ROLE_DEPRECATION_MESSAGE + ) + ); + } + } + }; public static final DiscoveryNodeRole REMOTE_CLUSTER_CLIENT_ROLE = new DiscoveryNodeRole("remote_cluster_client", "r") { @@ -223,7 +282,7 @@ public Setting legacySetting() { * The built-in node roles. */ public static SortedSet BUILT_IN_ROLES = Collections.unmodifiableSortedSet( - new TreeSet<>(Arrays.asList(DATA_ROLE, INGEST_ROLE, MASTER_ROLE, REMOTE_CLUSTER_CLIENT_ROLE)) + new TreeSet<>(Arrays.asList(DATA_ROLE, INGEST_ROLE, CLUSTER_MANAGER_ROLE, REMOTE_CLUSTER_CLIENT_ROLE)) ); /** @@ -262,4 +321,13 @@ public Setting legacySetting() { } + /** + * Check if the role is {@link #CLUSTER_MANAGER_ROLE} or {@link #MASTER_ROLE}. + * @deprecated As of 2.0, because promoting inclusive language. MASTER_ROLE is deprecated. + * @return true if the node role is{@link #CLUSTER_MANAGER_ROLE} or {@link #MASTER_ROLE} + */ + @Deprecated + public boolean isClusterManager() { + return this.equals(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE) || this.equals(DiscoveryNodeRole.MASTER_ROLE); + } } diff --git a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodes.java b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodes.java index 56225962a0173..01296f05aebfd 100644 --- a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodes.java +++ b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodes.java @@ -370,7 +370,7 @@ public DiscoveryNode resolveNode(String node) { * Works by tracking the current set of nodes and applying each node specification in sequence. The set starts out empty and each node * specification may either add or remove nodes. For instance: * - * - _local, _master and _all respectively add to the subset the local node, the currently-elected master, and all the nodes + * - _local, _cluster_manager (_master) and _all respectively add to the subset the local node, the currently-elected cluster_manager, and all the nodes * - node IDs, names, hostnames and IP addresses all add to the subset any nodes which match * - a wildcard-based pattern of the form "attr*:value*" adds to the subset all nodes with a matching attribute with a matching value * - role:true adds to the subset all nodes with a matching role @@ -393,7 +393,7 @@ public String[] resolveNodes(String... nodes) { if (localNodeId != null) { resolvedNodesIds.add(localNodeId); } - } else if (nodeId.equals("_master")) { + } else if (nodeId.equals("_master") || nodeId.equals("_cluster_manager")) { String masterNodeId = getMasterNodeId(); if (masterNodeId != null) { resolvedNodesIds.add(masterNodeId); @@ -419,7 +419,7 @@ public String[] resolveNodes(String... nodes) { } else { resolvedNodesIds.removeAll(dataNodes.keys()); } - } else if (DiscoveryNodeRole.MASTER_ROLE.roleName().equals(matchAttrName)) { + } else if (roleNameIsClusterManager(matchAttrName)) { if (Booleans.parseBoolean(matchAttrValue, true)) { resolvedNodesIds.addAll(masterNodes.keys()); } else { @@ -797,4 +797,17 @@ public boolean isLocalNodeElectedMaster() { return masterNodeId != null && masterNodeId.equals(localNodeId); } } + + /** + * Check if the given name of the node role is 'cluster_manger' or 'master'. + * The method is added for {@link #resolveNodes} to keep the code clear, when support the both above roles. + * @deprecated As of 2.0, because promoting inclusive language. MASTER_ROLE is deprecated. + * @param matchAttrName a given String for a name of the node role. + * @return true if the given roleName is 'cluster_manger' or 'master' + */ + @Deprecated + private boolean roleNameIsClusterManager(String matchAttrName) { + return DiscoveryNodeRole.MASTER_ROLE.roleName().equals(matchAttrName) + || DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName().equals(matchAttrName); + } } diff --git a/server/src/main/java/org/opensearch/cluster/service/MasterService.java b/server/src/main/java/org/opensearch/cluster/service/MasterService.java index dc52ecaca8954..c0f0d0e6a853f 100644 --- a/server/src/main/java/org/opensearch/cluster/service/MasterService.java +++ b/server/src/main/java/org/opensearch/cluster/service/MasterService.java @@ -90,6 +90,15 @@ public class MasterService extends AbstractLifecycleComponent { "cluster.service.slow_master_task_logging_threshold", TimeValue.timeValueSeconds(10), Setting.Property.Dynamic, + Setting.Property.NodeScope, + Setting.Property.Deprecated + ); + // The setting below is going to replace the above. + // To keep backwards compatibility, the old usage is remained, and it's also used as the fallback for the new usage. + public static final Setting CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING = Setting.positiveTimeSetting( + "cluster.service.slow_cluster_manager_task_logging_threshold", + MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, + Setting.Property.Dynamic, Setting.Property.NodeScope ); @@ -111,8 +120,11 @@ public class MasterService extends AbstractLifecycleComponent { public MasterService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool) { this.nodeName = Objects.requireNonNull(Node.NODE_NAME_SETTING.get(settings)); - this.slowTaskLoggingThreshold = MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings); - clusterSettings.addSettingsUpdateConsumer(MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, this::setSlowTaskLoggingThreshold); + this.slowTaskLoggingThreshold = CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings); + clusterSettings.addSettingsUpdateConsumer( + CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, + this::setSlowTaskLoggingThreshold + ); this.threadPool = threadPool; } diff --git a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java index 308ab13a8a785..c758b7d2918e7 100644 --- a/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/opensearch/common/settings/ClusterSettings.java @@ -272,7 +272,8 @@ public void apply(Settings value, Settings current, Settings previous) { InternalClusterInfoService.INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING, InternalSnapshotsInfoService.INTERNAL_SNAPSHOT_INFO_MAX_CONCURRENT_FETCHES_SETTING, DestructiveOperations.REQUIRES_NAME_SETTING, - NoMasterBlockService.NO_MASTER_BLOCK_SETTING, + NoMasterBlockService.NO_MASTER_BLOCK_SETTING, // deprecated + NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING, GatewayService.EXPECTED_DATA_NODES_SETTING, GatewayService.EXPECTED_MASTER_NODES_SETTING, GatewayService.EXPECTED_NODES_SETTING, @@ -332,7 +333,8 @@ public void apply(Settings value, Settings current, Settings previous) { IndexModule.NODE_STORE_ALLOW_MMAP, ClusterApplierService.CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, ClusterService.USER_DEFINED_METADATA, - MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, + MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, // deprecated + MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, SearchService.DEFAULT_SEARCH_TIMEOUT_SETTING, SearchService.DEFAULT_ALLOW_PARTIAL_SEARCH_RESULTS, TransportSearchAction.SHARD_COUNT_LIMIT_SETTING, @@ -539,7 +541,8 @@ public void apply(Settings value, Settings current, Settings previous) { LeaderChecker.LEADER_CHECK_RETRY_COUNT_SETTING, Reconfigurator.CLUSTER_AUTO_SHRINK_VOTING_CONFIGURATION, TransportAddVotingConfigExclusionsAction.MAXIMUM_VOTING_CONFIG_EXCLUSIONS_SETTING, - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING, + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING, // deprecated + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING, ClusterBootstrapService.UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING, LagDetector.CLUSTER_FOLLOWER_LAG_TIMEOUT_SETTING, HandshakingTransportAddressConnector.PROBE_CONNECT_TIMEOUT_SETTING, diff --git a/server/src/main/java/org/opensearch/env/NodeEnvironment.java b/server/src/main/java/org/opensearch/env/NodeEnvironment.java index 06109e7fcdc5b..555ca990b736d 100644 --- a/server/src/main/java/org/opensearch/env/NodeEnvironment.java +++ b/server/src/main/java/org/opensearch/env/NodeEnvironment.java @@ -1138,7 +1138,7 @@ private void ensureNoIndexMetadata(final NodePath[] nodePaths) throws IOExceptio Locale.ROOT, "node does not have the %s and %s roles but has index metadata: %s. Use 'opensearch-node repurpose' tool to clean up", DiscoveryNodeRole.DATA_ROLE.roleName(), - DiscoveryNodeRole.MASTER_ROLE.roleName(), + DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName(), indexMetadataPaths ); throw new IllegalStateException(message); diff --git a/server/src/main/java/org/opensearch/ingest/IngestDocument.java b/server/src/main/java/org/opensearch/ingest/IngestDocument.java index b496799c34dd0..b18946486f8c6 100644 --- a/server/src/main/java/org/opensearch/ingest/IngestDocument.java +++ b/server/src/main/java/org/opensearch/ingest/IngestDocument.java @@ -38,7 +38,6 @@ import org.opensearch.index.mapper.IndexFieldMapper; import org.opensearch.index.mapper.RoutingFieldMapper; import org.opensearch.index.mapper.SourceFieldMapper; -import org.opensearch.index.mapper.TypeFieldMapper; import org.opensearch.index.mapper.VersionFieldMapper; import org.opensearch.script.TemplateScript; @@ -846,7 +845,6 @@ public String toString() { public enum Metadata { INDEX(IndexFieldMapper.NAME), - TYPE(TypeFieldMapper.NAME), ID(IdFieldMapper.NAME), ROUTING(RoutingFieldMapper.NAME), VERSION(VersionFieldMapper.NAME), diff --git a/server/src/main/java/org/opensearch/node/NodeRoleSettings.java b/server/src/main/java/org/opensearch/node/NodeRoleSettings.java index 1e29f22b140f9..d690cfa4caa69 100644 --- a/server/src/main/java/org/opensearch/node/NodeRoleSettings.java +++ b/server/src/main/java/org/opensearch/node/NodeRoleSettings.java @@ -51,7 +51,11 @@ public class NodeRoleSettings { .filter(role -> role.isEnabledByDefault(settings)) .map(DiscoveryNodeRole::roleName) .collect(Collectors.toList()), - roles -> {}, + roles -> { + for (DiscoveryNodeRole role : roles) { + role.validateRole(roles); + } + }, Property.NodeScope ); diff --git a/server/src/main/java/org/opensearch/repositories/RepositoriesService.java b/server/src/main/java/org/opensearch/repositories/RepositoriesService.java index ec5cb02c32379..e7c5804f458a0 100644 --- a/server/src/main/java/org/opensearch/repositories/RepositoriesService.java +++ b/server/src/main/java/org/opensearch/repositories/RepositoriesService.java @@ -346,8 +346,9 @@ protected void doRun() { }); } + // Note: "voting_only" role has not been implemented yet, so the method always returns false. static boolean isDedicatedVotingOnlyNode(Set roles) { - return roles.contains(DiscoveryNodeRole.MASTER_ROLE) + return roles.contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE) && roles.contains(DiscoveryNodeRole.DATA_ROLE) == false && roles.stream().anyMatch(role -> role.roleName().equals("voting_only")); } diff --git a/server/src/main/java/org/opensearch/rest/RestRequest.java b/server/src/main/java/org/opensearch/rest/RestRequest.java index 7d11da7e122cd..e04d8faa8af39 100644 --- a/server/src/main/java/org/opensearch/rest/RestRequest.java +++ b/server/src/main/java/org/opensearch/rest/RestRequest.java @@ -54,6 +54,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -578,6 +579,32 @@ public static XContentType parseContentType(List header) { throw new IllegalArgumentException("empty Content-Type header"); } + /** + * The method is only used to validate whether the values of the 2 request parameters "master_timeout" and "cluster_manager_timeout" is the same value or not. + * If the 2 values are not the same, throw an {@link OpenSearchParseException}. + * @param keys Names of the request parameters. + * @deprecated The method will be removed along with the request parameter "master_timeout". + */ + @Deprecated + public void validateParamValuesAreEqual(String... keys) { + // Track the last seen value and ensure that every subsequent value matches it. + // The value to be tracked is the non-empty values of the parameters with the key. + String lastSeenValue = null; + for (String key : keys) { + String value = param(key); + if (!Strings.isNullOrEmpty(value)) { + if (lastSeenValue == null || value.equals(lastSeenValue)) { + lastSeenValue = value; + } else { + throw new OpenSearchParseException( + "The values of the request parameters: {} are required to be equal, otherwise please only assign value to one of the request parameters.", + Arrays.toString(keys) + ); + } + } + } + } + public static class ContentTypeHeaderException extends RuntimeException { ContentTypeHeaderException(final IllegalArgumentException cause) { diff --git a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java index 1d1feff36f239..f519da109ba09 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterRerouteAction.java @@ -39,6 +39,7 @@ import org.opensearch.cluster.routing.allocation.command.AllocationCommands; import org.opensearch.common.ParseField; import org.opensearch.common.Strings; +import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.common.settings.SettingsFilter; import org.opensearch.common.xcontent.ObjectParser; @@ -78,6 +79,12 @@ public RestClusterRerouteAction(SettingsFilter settingsFilter) { this.settingsFilter = settingsFilter; } + // TODO: Remove the DeprecationLogger after removing MASTER_ROLE. + // It's used to log deprecation when request parameter 'metric' contains 'master_node'. + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestClusterRerouteAction.class); + private static final String DEPRECATED_MESSAGE_MASTER_NODE = + "Deprecated value [master_node] used for parameter [metric]. To promote inclusive language, please use [cluster_manager_node] instead. It will be unsupported in a future major version."; + @Override public List routes() { return singletonList(new Route(POST, "/_cluster/reroute")); @@ -104,6 +111,14 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC final String metric = request.param("metric"); if (metric == null) { request.params().put("metric", DEFAULT_METRICS); + } else { + // TODO: Remove the statements in 'else' after removing MASTER_ROLE. + EnumSet metrics = ClusterState.Metric.parseString(request.param("metric"), true); + // Because "_all" value will add all Metric into metrics set, for prevent deprecation message shown in that case, + // add the check of validating metrics set doesn't contain all enum elements. + if (!metrics.equals(EnumSet.allOf(ClusterState.Metric.class)) && metrics.contains(ClusterState.Metric.MASTER_NODE)) { + deprecationLogger.deprecate("cluster_reroute_metric_parameter_master_node_value", DEPRECATED_MESSAGE_MASTER_NODE); + } } return channel -> client.admin().cluster().reroute(clusterRerouteRequest, new RestToXContentListener<>(channel)); } diff --git a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterStateAction.java b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterStateAction.java index 5056e29d47dce..32aa055c18300 100644 --- a/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterStateAction.java +++ b/server/src/main/java/org/opensearch/rest/action/admin/cluster/RestClusterStateAction.java @@ -40,6 +40,7 @@ import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.metadata.Metadata; import org.opensearch.common.Strings; +import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.common.settings.SettingsFilter; import org.opensearch.common.xcontent.ToXContent; @@ -71,6 +72,12 @@ public RestClusterStateAction(SettingsFilter settingsFilter) { this.settingsFilter = settingsFilter; } + // TODO: Remove the DeprecationLogger after removing MASTER_ROLE. + // It's used to log deprecation when request parameter 'metric' contains 'master_node'. + private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestClusterStateAction.class); + private static final String DEPRECATED_MESSAGE_MASTER_NODE = + "Deprecated value [master_node] used for parameter [metric]. To promote inclusive language, please use [cluster_manager_node] instead. It will be unsupported in a future major version."; + @Override public String getName() { return "cluster_state_action"; @@ -112,7 +119,17 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC if (request.hasParam("metric")) { EnumSet metrics = ClusterState.Metric.parseString(request.param("metric"), true); // do not ask for what we do not need. - clusterStateRequest.nodes(metrics.contains(ClusterState.Metric.NODES) || metrics.contains(ClusterState.Metric.MASTER_NODE)); + clusterStateRequest.nodes( + metrics.contains(ClusterState.Metric.NODES) + || metrics.contains(ClusterState.Metric.MASTER_NODE) + || metrics.contains(ClusterState.Metric.CLUSTER_MANAGER_NODE) + ); + // TODO: Remove the DeprecationLogger after removing MASTER_ROLE. + // Because "_all" value will add all Metric into metrics set, for prevent deprecation message shown in that case, + // add the check of validating metrics set doesn't contain all enum elements. + if (!metrics.equals(EnumSet.allOf(ClusterState.Metric.class)) && metrics.contains(ClusterState.Metric.MASTER_NODE)) { + deprecationLogger.deprecate("cluster_state_metric_parameter_master_node_value", DEPRECATED_MESSAGE_MASTER_NODE); + } /* * there is no distinction in Java api between routing_table and routing_nodes, it's the same info set over the wire, one single * flag to ask for it diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java index b6e945620f918..c05b0b9c77129 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java @@ -88,7 +88,12 @@ protected Table getTableWithHeader(final RestRequest request) { t.addCell("status", "alias:st;desc:health status"); t.addCell("node.total", "alias:nt,nodeTotal;text-align:right;desc:total number of nodes"); t.addCell("node.data", "alias:nd,nodeData;text-align:right;desc:number of nodes that can store data"); - t.addCell("discovered_master", "alias:dm;text-align:right;desc:discovered master"); + // TODO: Remove the header alias 'discovered_master', after removing MASTER_ROLE. + // The alias 'discovered_master' is added for compatibility when using request parameter 'h=discovered_master'. + t.addCell( + "discovered_cluster_manager", + "alias:dcm,dm,discovered_master;text-align:right;desc:cluster manager is discovered or not" + ); t.addCell("shards", "alias:t,sh,shards.total,shardsTotal;text-align:right;desc:total number of shards"); t.addCell("pri", "alias:p,shards.primary,shardsPrimary;text-align:right;desc:number of primary shards"); t.addCell("relo", "alias:r,shards.relocating,shardsRelocating;text-align:right;desc:number of relocating nodes"); diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestMasterAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestMasterAction.java index c1170ea5b19ce..7dd3225dd9d21 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestMasterAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestMasterAction.java @@ -50,18 +50,19 @@ public class RestMasterAction extends AbstractCatAction { @Override - public List routes() { - return singletonList(new Route(GET, "/_cat/master")); + public List replacedRoutes() { + // The deprecated path will be removed in a future major version. + return singletonList(new ReplacedRoute(GET, "/_cat/cluster_manager", "/_cat/master")); } @Override public String getName() { - return "cat_master_action"; + return "cat_cluster_manager_action"; } @Override protected void documentation(StringBuilder sb) { - sb.append("/_cat/master\n"); + sb.append("/_cat/cluster_manager\n"); } @Override diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java index bce9b2d6b7e9d..abc4b48b01cff 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java @@ -86,6 +86,8 @@ public class RestNodesAction extends AbstractCatAction { private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestNodesAction.class); static final String LOCAL_DEPRECATED_MESSAGE = "Deprecated parameter [local] used. This parameter does not cause this API to act " + "locally, and should not be used. It will be unsupported in version 8.0."; + static final String MASTER_TIMEOUT_DEPRECATED_MESSAGE = + "Deprecated parameter [master_timeout] used. To promote inclusive language, please use [cluster_manager_timeout] instead. It will be unsupported in a future major version."; @Override public List routes() { @@ -110,7 +112,8 @@ public RestChannelConsumer doCatRequest(final RestRequest request, final NodeCli deprecationLogger.deprecate("cat_nodes_local_parameter", LOCAL_DEPRECATED_MESSAGE); } clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); - clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout())); + clusterStateRequest.masterNodeTimeout(request.paramAsTime("cluster_manager_timeout", clusterStateRequest.masterNodeTimeout())); + parseDeprecatedMasterTimeoutParameter(clusterStateRequest, request); final boolean fullId = request.paramAsBoolean("full_id", false); return channel -> client.admin().cluster().state(clusterStateRequest, new RestActionListener(channel) { @Override @@ -193,7 +196,8 @@ protected Table getTableWithHeader(final RestRequest request) { "node.role", "alias:r,role,nodeRole;desc:m:master eligible node, d:data node, i:ingest node, -:coordinating node only" ); - table.addCell("master", "alias:m;desc:*:current master"); + // TODO: Remove the header alias 'master', after removing MASTER_ROLE. It's added for compatibility when using parameter 'h=master'. + table.addCell("cluster_manager", "alias:cm,m,master;desc:*:current cluster manager"); table.addCell("name", "alias:n;desc:node name"); table.addCell("completion.size", "alias:cs,completionSize;default:false;text-align:right;desc:size of completion"); @@ -525,4 +529,20 @@ Table buildTable( private short calculatePercentage(long used, long max) { return max <= 0 ? 0 : (short) ((100d * used) / max); } + + /** + * Parse the deprecated request parameter 'master_timeout', and add deprecated log if the parameter is used. + * It also validates whether the value of 'master_timeout' is the same with 'cluster_manager_timeout'. + * Remove the method along with MASTER_ROLE. + * @deprecated As of 2.0, because promoting inclusive language. + */ + @Deprecated + private void parseDeprecatedMasterTimeoutParameter(ClusterStateRequest clusterStateRequest, RestRequest request) { + final String deprecatedTimeoutParam = "master_timeout"; + if (request.hasParam(deprecatedTimeoutParam)) { + deprecationLogger.deprecate("cat_nodes_master_timeout_parameter", MASTER_TIMEOUT_DEPRECATED_MESSAGE); + request.validateParamValuesAreEqual(deprecatedTimeoutParam, "cluster_manager_timeout"); + clusterStateRequest.masterNodeTimeout(request.paramAsTime(deprecatedTimeoutParam, clusterStateRequest.masterNodeTimeout())); + } + } } diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequestTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequestTests.java index a1aa38017a808..8da65ba13b9cb 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequestTests.java @@ -113,7 +113,7 @@ public void testResolve() { "local", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion localNodeExclusion = new VotingConfigExclusion(localNode); @@ -122,7 +122,7 @@ public void testResolve() { "other1", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion otherNode1Exclusion = new VotingConfigExclusion(otherNode1); @@ -131,7 +131,7 @@ public void testResolve() { "other2", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion otherNode2Exclusion = new VotingConfigExclusion(otherNode2); @@ -238,7 +238,7 @@ public void testResolveByNodeIds() { "nodeId1", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion node1Exclusion = new VotingConfigExclusion(node1); @@ -248,7 +248,7 @@ public void testResolveByNodeIds() { "nodeId2", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion node2Exclusion = new VotingConfigExclusion(node2); @@ -258,7 +258,7 @@ public void testResolveByNodeIds() { "nodeId3", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); @@ -298,7 +298,7 @@ public void testResolveByNodeNames() { "nodeId1", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion node1Exclusion = new VotingConfigExclusion(node1); @@ -308,7 +308,7 @@ public void testResolveByNodeNames() { "nodeId2", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion node2Exclusion = new VotingConfigExclusion(node2); @@ -318,7 +318,7 @@ public void testResolveByNodeNames() { "nodeId3", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); @@ -348,7 +348,7 @@ public void testResolveRemoveExistingVotingConfigExclusions() { "nodeId1", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); @@ -357,7 +357,7 @@ public void testResolveRemoveExistingVotingConfigExclusions() { "nodeId2", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion node2Exclusion = new VotingConfigExclusion(node2); @@ -367,7 +367,7 @@ public void testResolveRemoveExistingVotingConfigExclusions() { "nodeId3", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); @@ -399,7 +399,7 @@ public void testResolveAndCheckMaximum() { "local", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion localNodeExclusion = new VotingConfigExclusion(localNode); @@ -408,7 +408,7 @@ public void testResolveAndCheckMaximum() { "other1", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion otherNode1Exclusion = new VotingConfigExclusion(otherNode1); @@ -417,7 +417,7 @@ public void testResolveAndCheckMaximum() { "other2", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final VotingConfigExclusion otherNode2Exclusion = new VotingConfigExclusion(otherNode2); diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java index b4540a66c9264..a570db040a805 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java @@ -119,7 +119,7 @@ private static DiscoveryNode makeDiscoveryNode(String name) { name, buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); } diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java index f0384f249879d..7a7bc18876932 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java @@ -94,6 +94,7 @@ public void testToXContent() throws IOException { + clusterState.stateUUID() + "\",\n" + " \"master_node\" : \"node0\",\n" + + " \"cluster_manager_node\" : \"node0\",\n" + " \"blocks\" : { },\n" + " \"nodes\" : {\n" + " \"node0\" : {\n" @@ -173,7 +174,7 @@ public void testToXContent() throws IOException { XContentBuilder builder = JsonXContent.contentBuilder().prettyPrint(); Map params = new HashMap<>(); params.put("explain", "true"); - params.put("metric", "version,master_node"); + params.put("metric", "version,cluster_manager_node"); clusterRerouteResponse.toXContent(builder, new ToXContent.MapParams(params)); assertEquals( "{\n" @@ -184,7 +185,7 @@ public void testToXContent() throws IOException { + " \"state_uuid\" : \"" + clusterState.stateUUID() + "\",\n" - + " \"master_node\" : \"node0\"\n" + + " \"cluster_manager_node\" : \"node0\"\n" + " },\n" + " \"explanations\" : [\n" + " {\n" diff --git a/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java b/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java index ab401b7d45792..d8178769ba7b1 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequestTests.java @@ -92,15 +92,12 @@ public void testValidation() { } /** - * Test that {@link PutMappingRequest#buildFromSimplifiedDef(Object...)} + * Test that {@link PutMappingRequest#simpleMapping(String...)} * rejects inputs where the {@code Object...} varargs of field name and properties are not * paired correctly */ public void testBuildFromSimplifiedDef() { - IllegalArgumentException e = expectThrows( - IllegalArgumentException.class, - () -> PutMappingRequest.buildFromSimplifiedDef("only_field") - ); + IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> PutMappingRequest.simpleMapping("only_field")); assertEquals("mapping source must be pairs of fieldnames and properties definition.", e.getMessage()); } diff --git a/server/src/test/java/org/opensearch/action/admin/indices/shrink/TransportResizeActionTests.java b/server/src/test/java/org/opensearch/action/admin/indices/shrink/TransportResizeActionTests.java index 37cdda6c365b8..e4b79ac54f8fd 100644 --- a/server/src/test/java/org/opensearch/action/admin/indices/shrink/TransportResizeActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/indices/shrink/TransportResizeActionTests.java @@ -278,7 +278,7 @@ public void testShrinkIndexSettings() { private DiscoveryNode newNode(String nodeId) { final Set roles = Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE)) + new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE)) ); return new DiscoveryNode(nodeId, buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT); } diff --git a/server/src/test/java/org/opensearch/action/ingest/SimulatePipelineRequestParsingTests.java b/server/src/test/java/org/opensearch/action/ingest/SimulatePipelineRequestParsingTests.java index c85c0a01de63e..36b1f8089fdea 100644 --- a/server/src/test/java/org/opensearch/action/ingest/SimulatePipelineRequestParsingTests.java +++ b/server/src/test/java/org/opensearch/action/ingest/SimulatePipelineRequestParsingTests.java @@ -57,7 +57,6 @@ import static org.opensearch.ingest.IngestDocument.Metadata.ID; import static org.opensearch.ingest.IngestDocument.Metadata.INDEX; import static org.opensearch.ingest.IngestDocument.Metadata.ROUTING; -import static org.opensearch.ingest.IngestDocument.Metadata.TYPE; import static org.opensearch.ingest.IngestDocument.Metadata.VERSION; import static org.opensearch.ingest.IngestDocument.Metadata.VERSION_TYPE; import static org.opensearch.ingest.IngestDocument.Metadata.IF_SEQ_NO; @@ -132,15 +131,7 @@ public void testParseUsingPipelineStore(boolean useExplicitType) throws Exceptio assertThat(actualRequest.getPipeline().getProcessors().size(), equalTo(1)); } - public void testParseWithProvidedPipelineNoType() throws Exception { - innerTestParseWithProvidedPipeline(false); - } - - public void testParseWithProvidedPipelineWithType() throws Exception { - innerTestParseWithProvidedPipeline(true); - } - - private void innerTestParseWithProvidedPipeline(boolean useExplicitType) throws Exception { + public void innerTestParseWithProvidedPipeline() throws Exception { int numDocs = randomIntBetween(1, 10); Map requestContent = new HashMap<>(); @@ -150,16 +141,7 @@ private void innerTestParseWithProvidedPipeline(boolean useExplicitType) throws for (int i = 0; i < numDocs; i++) { Map doc = new HashMap<>(); Map expectedDoc = new HashMap<>(); - List fields = Arrays.asList( - INDEX, - TYPE, - ID, - ROUTING, - VERSION, - VERSION_TYPE, - IF_SEQ_NO, - IF_PRIMARY_TERM - ); + List fields = Arrays.asList(INDEX, ID, ROUTING, VERSION, VERSION_TYPE, IF_SEQ_NO, IF_PRIMARY_TERM); for (IngestDocument.Metadata field : fields) { if (field == VERSION) { Long value = randomLong(); @@ -173,14 +155,6 @@ private void innerTestParseWithProvidedPipeline(boolean useExplicitType) throws Long value = randomNonNegativeLong(); doc.put(field.getFieldName(), value); expectedDoc.put(field.getFieldName(), value); - } else if (field == TYPE) { - if (useExplicitType) { - String value = randomAlphaOfLengthBetween(1, 10); - doc.put(field.getFieldName(), value); - expectedDoc.put(field.getFieldName(), value); - } else { - expectedDoc.put(field.getFieldName(), "_doc"); - } } else { if (randomBoolean()) { String value = randomAlphaOfLengthBetween(1, 10); @@ -249,9 +223,6 @@ private void innerTestParseWithProvidedPipeline(boolean useExplicitType) throws assertThat(actualRequest.getPipeline().getId(), equalTo(SIMULATED_PIPELINE_ID)); assertThat(actualRequest.getPipeline().getDescription(), nullValue()); assertThat(actualRequest.getPipeline().getProcessors().size(), equalTo(numProcessors)); - if (useExplicitType) { - assertWarnings("[types removal] specifying _type in pipeline simulation requests is deprecated"); - } } public void testNullPipelineId() { diff --git a/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java b/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java index 05f9ef8baed29..09ab2438bd106 100644 --- a/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java +++ b/server/src/test/java/org/opensearch/action/search/TransportMultiSearchActionTests.java @@ -263,7 +263,7 @@ public void testDefaultMaxConcurrentSearches() { "master", buildNewFakeTransportAddress(), Collections.emptyMap(), - Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ) ); diff --git a/server/src/test/java/org/opensearch/action/support/master/TransportMasterNodeActionTests.java b/server/src/test/java/org/opensearch/action/support/master/TransportMasterNodeActionTests.java index c568216683b97..ba372891e098b 100644 --- a/server/src/test/java/org/opensearch/action/support/master/TransportMasterNodeActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/master/TransportMasterNodeActionTests.java @@ -121,14 +121,14 @@ public void setUp() throws Exception { "local_node", buildNewFakeTransportAddress(), Collections.emptyMap(), - Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); remoteNode = new DiscoveryNode( "remote_node", buildNewFakeTransportAddress(), Collections.emptyMap(), - Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); allNodes = new DiscoveryNode[] { localNode, remoteNode }; diff --git a/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java b/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java index a8755df6b5daa..53ebceb25510a 100644 --- a/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java @@ -172,7 +172,9 @@ private List mockList(Supplier supplier, int size) { private enum NodeSelector { LOCAL("_local"), ELECTED_MASTER("_master"), + // TODO: Remove this element after removing DiscoveryNodeRole.MASTER_ROLE MASTER_ELIGIBLE("master:true"), + CLUSTER_MANAGER_ELIGIBLE("cluster_manager:true"), DATA("data:true"), CUSTOM_ATTRIBUTE("attr:value"); diff --git a/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java b/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java index 04cc138061539..d941c624509da 100644 --- a/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java +++ b/server/src/test/java/org/opensearch/bootstrap/BootstrapChecksTests.java @@ -802,7 +802,7 @@ public void testDiscoveryConfiguredCheck() throws NodeValidationException { hasToString( containsString( "the default discovery settings are unsuitable for production use; at least one " - + "of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured" + + "of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_cluster_manager_nodes / cluster.initial_master_nodes] must be configured" ) ) ); @@ -815,7 +815,7 @@ public void testDiscoveryConfiguredCheck() throws NodeValidationException { BootstrapChecks.check(context, true, checks); }; - ensureChecksPass.accept(Settings.builder().putList(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey())); + ensureChecksPass.accept(Settings.builder().putList(ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey())); ensureChecksPass.accept(Settings.builder().putList(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey())); ensureChecksPass.accept(Settings.builder().putList(SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING.getKey())); } diff --git a/server/src/test/java/org/opensearch/cluster/ClusterChangedEventTests.java b/server/src/test/java/org/opensearch/cluster/ClusterChangedEventTests.java index 4f68358b15b3d..49d4a8baf0a1c 100644 --- a/server/src/test/java/org/opensearch/cluster/ClusterChangedEventTests.java +++ b/server/src/test/java/org/opensearch/cluster/ClusterChangedEventTests.java @@ -447,17 +447,17 @@ private static DiscoveryNodes createDiscoveryNodes(final int numNodes, final boo if (i == 0) { // the master node builder.masterNodeId(nodeId); - roles.add(DiscoveryNodeRole.MASTER_ROLE); + roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } else if (i == 1) { // the alternate master node - roles.add(DiscoveryNodeRole.MASTER_ROLE); + roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } else if (i == 2) { // we need at least one data node roles.add(DiscoveryNodeRole.DATA_ROLE); } else { // remaining nodes can be anything (except for master) if (randomBoolean()) { - roles.add(DiscoveryNodeRole.MASTER_ROLE); + roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } if (randomBoolean()) { roles.add(DiscoveryNodeRole.DATA_ROLE); diff --git a/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java b/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java index 4cc3108d6bf85..7cbab104cd07a 100644 --- a/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java +++ b/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java @@ -147,6 +147,7 @@ public void testToXContent() throws IOException { + " \"version\" : 0,\n" + " \"state_uuid\" : \"stateUUID\",\n" + " \"master_node\" : \"masterNodeId\",\n" + + " \"cluster_manager_node\" : \"masterNodeId\",\n" + " \"blocks\" : {\n" + " \"global\" : {\n" + " \"1\" : {\n" @@ -352,6 +353,7 @@ public void testToXContent_FlatSettingTrue_ReduceMappingFalse() throws IOExcepti + " \"version\" : 0,\n" + " \"state_uuid\" : \"stateUUID\",\n" + " \"master_node\" : \"masterNodeId\",\n" + + " \"cluster_manager_node\" : \"masterNodeId\",\n" + " \"blocks\" : {\n" + " \"global\" : {\n" + " \"1\" : {\n" @@ -550,6 +552,7 @@ public void testToXContent_FlatSettingFalse_ReduceMappingTrue() throws IOExcepti + " \"version\" : 0,\n" + " \"state_uuid\" : \"stateUUID\",\n" + " \"master_node\" : \"masterNodeId\",\n" + + " \"cluster_manager_node\" : \"masterNodeId\",\n" + " \"blocks\" : {\n" + " \"global\" : {\n" + " \"1\" : {\n" @@ -772,6 +775,7 @@ public void testToXContentSameTypeName() throws IOException { + " \"version\" : 0,\n" + " \"state_uuid\" : \"stateUUID\",\n" + " \"master_node\" : null,\n" + + " \"cluster_manager_node\" : null,\n" + " \"blocks\" : { },\n" + " \"nodes\" : { },\n" + " \"metadata\" : {\n" diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java new file mode 100644 index 0000000000000..09fb6a5ea256d --- /dev/null +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceRenamedSettingTests.java @@ -0,0 +1,84 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.cluster.coordination; + +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Setting; +import org.opensearch.common.settings.Settings; +import org.opensearch.test.OpenSearchTestCase; + +import java.util.Arrays; +import java.util.Set; + +/** + * A unit test to validate the former name of the setting 'cluster.initial_cluster_manager_nodes' still take effect, + * after it is deprecated, so that the backwards compatibility is maintained. + * The test can be removed along with removing support of the deprecated setting. + */ +public class ClusterBootstrapServiceRenamedSettingTests extends OpenSearchTestCase { + /** + * Validate the both settings are known and supported. + */ + public void testReindexSettingsExist() { + Set> settings = ClusterSettings.BUILT_IN_CLUSTER_SETTINGS; + assertTrue( + "Both 'cluster.initial_cluster_manager_nodes' and its predecessor should be supported built-in settings.", + settings.containsAll( + Arrays.asList( + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING, + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING + ) + ) + ); + } + + /** + * Validate the default value of the both settings is the same. + */ + public void testSettingFallback() { + assertEquals( + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY), + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(Settings.EMPTY) + ); + } + + /** + * Validate the new setting can be configured correctly, and it doesn't impact the old setting. + */ + public void testSettingGetValue() { + Settings settings = Settings.builder().put("cluster.initial_cluster_manager_nodes", "node-a").build(); + assertEquals(Arrays.asList("node-a"), ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings)); + assertEquals( + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getDefault(Settings.EMPTY), + ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(settings) + ); + } + + /** + * Validate the value of the old setting will be applied to the new setting, if the new setting is not configured. + */ + public void testSettingGetValueWithFallback() { + Settings settings = Settings.builder().put("cluster.initial_master_nodes", "node-a").build(); + assertEquals(Arrays.asList("node-a"), ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings)); + assertSettingDeprecationsAndWarnings(new Setting[] { ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING }); + } + + /** + * Validate the value of the old setting will be ignored, if the new setting is configured. + */ + public void testSettingGetValueWhenBothAreConfigured() { + Settings settings = Settings.builder() + .put("cluster.initial_cluster_manager_nodes", "node-a") + .put("cluster.initial_master_nodes", "node-a, node-b") + .build(); + assertEquals(Arrays.asList("node-a"), ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(settings)); + assertEquals(Arrays.asList("node-a", "node-b"), ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(settings)); + assertSettingDeprecationsAndWarnings(new Setting[] { ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING }); + } +} diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java index a2fe39ef4531e..079b31f31f599 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterBootstrapServiceTests.java @@ -57,6 +57,7 @@ import static java.util.Collections.emptySet; import static java.util.Collections.singletonList; import static org.opensearch.cluster.coordination.ClusterBootstrapService.BOOTSTRAP_PLACEHOLDER_PREFIX; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; import static org.opensearch.cluster.coordination.ClusterBootstrapService.UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING; import static org.opensearch.common.settings.Settings.builder; @@ -111,7 +112,7 @@ private DiscoveryNode newDiscoveryNode(String nodeName) { randomAlphaOfLength(10), buildNewFakeTransportAddress(), emptyMap(), - Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); } @@ -166,7 +167,7 @@ public void testDoesNothingByDefaultIfSeedHostsConfigured() { } public void testDoesNothingByDefaultIfMasterNodesConfigured() { - testDoesNothingWithSettings(builder().putList(INITIAL_MASTER_NODES_SETTING.getKey())); + testDoesNothingWithSettings(builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey())); } public void testDoesNothingByDefaultOnMasterIneligibleNodes() { @@ -197,7 +198,7 @@ private void testDoesNothingWithSettings(Settings.Builder builder) { public void testThrowsExceptionOnDuplicates() { final IllegalArgumentException illegalArgumentException = expectThrows(IllegalArgumentException.class, () -> { new ClusterBootstrapService( - builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), "duplicate-requirement", "duplicate-requirement").build(), + builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), "duplicate-requirement", "duplicate-requirement").build(), transportService, Collections::emptyList, () -> false, @@ -205,7 +206,7 @@ public void testThrowsExceptionOnDuplicates() { ); }); - assertThat(illegalArgumentException.getMessage(), containsString(INITIAL_MASTER_NODES_SETTING.getKey())); + assertThat(illegalArgumentException.getMessage(), containsString(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey())); assertThat(illegalArgumentException.getMessage(), containsString("duplicate-requirement")); } @@ -214,7 +215,7 @@ public void testBootstrapsOnDiscoveryOfAllRequiredNodes() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(otherNode1, otherNode2).collect(Collectors.toList()), @@ -242,7 +243,7 @@ public void testBootstrapsOnDiscoveryOfTwoOfThreeRequiredNodes() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> singletonList(otherNode1), @@ -276,7 +277,7 @@ public void testBootstrapsOnDiscoveryOfThreeOfFiveRequiredNodes() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() .putList( - INITIAL_MASTER_NODES_SETTING.getKey(), + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName(), @@ -325,7 +326,7 @@ public void testBootstrapsOnDiscoveryOfThreeOfFiveRequiredNodes() { public void testDoesNotBootstrapIfNoNodesDiscovered() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, Collections::emptyList, @@ -342,7 +343,7 @@ public void testDoesNotBootstrapIfTwoOfFiveNodesDiscovered() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() .putList( - INITIAL_MASTER_NODES_SETTING.getKey(), + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName(), @@ -365,7 +366,7 @@ public void testDoesNotBootstrapIfThreeOfSixNodesDiscovered() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() .putList( - INITIAL_MASTER_NODES_SETTING.getKey(), + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName(), @@ -388,7 +389,7 @@ public void testDoesNotBootstrapIfThreeOfSixNodesDiscovered() { public void testDoesNotBootstrapIfAlreadyBootstrapped() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(otherNode1, otherNode2).collect(Collectors.toList()), @@ -412,7 +413,7 @@ public void testDoesNotBootstrapsOnNonMasterNode() { ); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(localNode, otherNode1, otherNode2).collect(Collectors.toList()), @@ -424,9 +425,9 @@ public void testDoesNotBootstrapsOnNonMasterNode() { deterministicTaskQueue.runAllTasks(); } - public void testDoesNotBootstrapsIfLocalNodeNotInInitialMasterNodes() { + public void testDoesNotBootstrapsIfLocalNodeNotInInitialClusterManagerNodes() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), otherNode1.getName(), otherNode2.getName()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), otherNode1.getName(), otherNode2.getName()).build(), transportService, () -> Stream.of(localNode, otherNode1, otherNode2).collect(Collectors.toList()), () -> false, @@ -439,7 +440,7 @@ public void testDoesNotBootstrapsIfLocalNodeNotInInitialMasterNodes() { public void testDoesNotBootstrapsIfNotConfigured() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey()).build(), transportService, () -> Stream.of(localNode, otherNode1, otherNode2).collect(Collectors.toList()), () -> false, @@ -455,7 +456,7 @@ public void testRetriesBootstrappingOnException() { final AtomicLong bootstrappingAttempts = new AtomicLong(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(otherNode1, otherNode2).collect(Collectors.toList()), @@ -480,7 +481,7 @@ public void testCancelsBootstrapIfRequirementMatchesMultipleNodes() { Stream.of(otherNode1, otherNode2).collect(Collectors.toList()) ); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getAddress().getAddress()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getAddress().getAddress()).build(), transportService, discoveredNodes::get, () -> false, @@ -502,7 +503,7 @@ public void testCancelsBootstrapIfNodeMatchesMultipleRequirements() { ); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), otherNode1.getAddress().toString(), otherNode1.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), otherNode1.getAddress().toString(), otherNode1.getName()) .build(), transportService, discoveredNodes::get, @@ -521,7 +522,7 @@ public void testCancelsBootstrapIfNodeMatchesMultipleRequirements() { randomAlphaOfLength(10), buildNewFakeTransportAddress(), emptyMap(), - Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ), new DiscoveryNode( @@ -529,7 +530,7 @@ public void testCancelsBootstrapIfNodeMatchesMultipleRequirements() { randomAlphaOfLength(10), otherNode1.getAddress(), emptyMap(), - Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ) ).collect(Collectors.toList()) @@ -542,7 +543,7 @@ public void testCancelsBootstrapIfNodeMatchesMultipleRequirements() { public void testMatchesOnNodeName() { final AtomicBoolean bootstrapped = new AtomicBoolean(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName()).build(), transportService, Collections::emptyList, () -> false, @@ -558,7 +559,7 @@ public void testMatchesOnNodeName() { public void testMatchesOnNodeAddress() { final AtomicBoolean bootstrapped = new AtomicBoolean(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getAddress().toString()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getAddress().toString()).build(), transportService, Collections::emptyList, () -> false, @@ -574,7 +575,7 @@ public void testMatchesOnNodeAddress() { public void testMatchesOnNodeHostAddress() { final AtomicBoolean bootstrapped = new AtomicBoolean(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getAddress().getAddress()).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getAddress().getAddress()).build(), transportService, Collections::emptyList, () -> false, @@ -589,7 +590,7 @@ public void testMatchesOnNodeHostAddress() { public void testDoesNotJustMatchEverything() { ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), randomAlphaOfLength(10)).build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), randomAlphaOfLength(10)).build(), transportService, Collections::emptyList, () -> false, @@ -606,7 +607,7 @@ public void testDoesNotIncludeExtraNodes() { final AtomicBoolean bootstrapped = new AtomicBoolean(); ClusterBootstrapService clusterBootstrapService = new ClusterBootstrapService( Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), localNode.getName(), otherNode1.getName(), otherNode2.getName()) .build(), transportService, () -> Stream.of(otherNode1, otherNode2, extraNode).collect(Collectors.toList()), @@ -670,6 +671,29 @@ public void testFailBootstrapWithBothSingleNodeDiscoveryAndInitialMasterNodes() ); } + /** + * Validate the correct setting name of cluster.initial_cluster_manager_nodes is shown in the exception, + * when discovery type is single-node. + */ + public void testFailBootstrapWithBothSingleNodeDiscoveryAndInitialClusterManagerNodes() { + final Settings.Builder settings = Settings.builder() + .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE) + .put(NODE_NAME_SETTING.getKey(), localNode.getName()) + .put(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), "test"); + + assertThat( + expectThrows( + IllegalArgumentException.class, + () -> new ClusterBootstrapService(settings.build(), transportService, () -> emptyList(), () -> false, vc -> fail()) + ).getMessage(), + containsString( + "setting [" + + INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey() + + "] is not allowed when [discovery.type] is set to [single-node]" + ) + ); + } + public void testFailBootstrapNonMasterEligibleNodeWithSingleNodeDiscovery() { final Settings.Builder settings = Settings.builder() .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE) diff --git a/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java b/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java index 2058f2d180711..92de7ab8b3f4a 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelperTests.java @@ -56,7 +56,7 @@ import static java.util.Collections.emptySet; import static java.util.Collections.singletonList; import static org.opensearch.cluster.coordination.ClusterBootstrapService.BOOTSTRAP_PLACEHOLDER_PREFIX; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.monitor.StatusInfo.Status.HEALTHY; import static org.opensearch.monitor.StatusInfo.Status.UNHEALTHY; import static org.opensearch.node.Node.NODE_NAME_SETTING; @@ -287,7 +287,7 @@ public void testDescriptionOnUnhealthyNodes() { "local", buildNewFakeTransportAddress(), emptyMap(), - org.opensearch.common.collect.Set.of(DiscoveryNodeRole.MASTER_ROLE), + org.opensearch.common.collect.Set.of(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); clusterState = ClusterState.builder(ClusterName.DEFAULT) @@ -329,7 +329,7 @@ public void testDescriptionBeforeBootstrapping() { ).getDescription(), is( "master not discovered yet, this node has not previously joined a bootstrapped cluster, and " - + "[cluster.initial_master_nodes] is empty on this node: have discovered []; " + + "[cluster.initial_cluster_manager_nodes] is empty on this node: have discovered []; " + "discovery will continue using [] from hosts providers and [" + localNode + "] from last-known cluster state; node term 1, last-accepted version 7 in term 4" @@ -349,7 +349,7 @@ public void testDescriptionBeforeBootstrapping() { ).getDescription(), is( "master not discovered yet, this node has not previously joined a bootstrapped cluster, and " - + "[cluster.initial_master_nodes] is empty on this node: have discovered []; " + + "[cluster.initial_cluster_manager_nodes] is empty on this node: have discovered []; " + "discovery will continue using [" + otherAddress + "] from hosts providers and [" @@ -371,7 +371,7 @@ public void testDescriptionBeforeBootstrapping() { ).getDescription(), is( "master not discovered yet, this node has not previously joined a bootstrapped cluster, and " - + "[cluster.initial_master_nodes] is empty on this node: have discovered [" + + "[cluster.initial_cluster_manager_nodes] is empty on this node: have discovered [" + otherNode + "]; " + "discovery will continue using [] from hosts providers and [" @@ -382,7 +382,7 @@ public void testDescriptionBeforeBootstrapping() { assertThat( new ClusterFormationState( - Settings.builder().putList(INITIAL_MASTER_NODES_SETTING.getKey(), "other").build(), + Settings.builder().putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), "other").build(), clusterState, emptyList(), emptyList(), @@ -825,7 +825,7 @@ public void testDescriptionAfterBootstrapping() { emptyMap(), new HashSet<>( randomSubsetOf(DiscoveryNodeRole.BUILT_IN_ROLES).stream() - .filter(r -> r != DiscoveryNodeRole.MASTER_ROLE) + .filter(r -> r != DiscoveryNodeRole.CLUSTER_MANAGER_ROLE) .collect(Collectors.toList()) ), Version.CURRENT diff --git a/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java b/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java index 8164047178b1f..1cdea588564c4 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java @@ -84,7 +84,7 @@ import static org.opensearch.cluster.coordination.LeaderChecker.LEADER_CHECK_TIMEOUT_SETTING; import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_ALL; import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_METADATA_WRITES; -import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_SETTING; +import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING; import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_WRITES; import static org.opensearch.cluster.coordination.Reconfigurator.CLUSTER_AUTO_SHRINK_VOTING_CONFIGURATION; import static org.opensearch.discovery.PeerFinder.DISCOVERY_FIND_PEERS_INTERVAL_SETTING; @@ -1143,9 +1143,9 @@ private void testAppliesNoMasterBlock(String noMasterBlockSetting, ClusterBlock cluster.stabilise(); final ClusterNode leader = cluster.getAnyLeader(); - leader.submitUpdateTask("update NO_MASTER_BLOCK_SETTING", cs -> { + leader.submitUpdateTask("update NO_CLUSTER_MANAGER_BLOCK_SETTING", cs -> { final Builder settingsBuilder = Settings.builder().put(cs.metadata().persistentSettings()); - settingsBuilder.put(NO_MASTER_BLOCK_SETTING.getKey(), noMasterBlockSetting); + settingsBuilder.put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), noMasterBlockSetting); return ClusterState.builder(cs) .metadata(Metadata.builder(cs.metadata()).persistentSettings(settingsBuilder.build())) .build(); @@ -1789,7 +1789,7 @@ private ClusterState buildNewClusterStateWithVotingConfigExclusion( "resolvableNodeId", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ) ) diff --git a/server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceRenamedSettingTests.java b/server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceRenamedSettingTests.java new file mode 100644 index 0000000000000..2c988cad5f79c --- /dev/null +++ b/server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceRenamedSettingTests.java @@ -0,0 +1,87 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.cluster.coordination; + +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Setting; +import org.opensearch.common.settings.Settings; +import org.opensearch.test.OpenSearchTestCase; + +import java.util.Arrays; +import java.util.Set; + +/** + * A unit test to validate the former name of the setting 'cluster.no_cluster_manager_block' still take effect, + * after it is deprecated, so that the backwards compatibility is maintained. + * The test can be removed along with removing support of the deprecated setting. + */ +public class NoMasterBlockServiceRenamedSettingTests extends OpenSearchTestCase { + + /** + * Validate the both settings are known and supported. + */ + public void testReindexSettingsExist() { + Set> settings = ClusterSettings.BUILT_IN_CLUSTER_SETTINGS; + assertTrue( + "Both 'cluster.no_cluster_manager_block' and its predecessor should be supported built-in settings.", + settings.containsAll( + Arrays.asList(NoMasterBlockService.NO_MASTER_BLOCK_SETTING, NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING) + ) + ); + } + + /** + * Validate the default value of the both settings is the same. + */ + public void testSettingFallback() { + assertEquals( + NoMasterBlockService.NO_MASTER_BLOCK_SETTING.get(Settings.EMPTY), + NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.get(Settings.EMPTY) + + ); + } + + /** + * Validate the new setting can be configured correctly, and it doesn't impact the old setting. + */ + public void testSettingGetValue() { + Settings settings = Settings.builder().put("cluster.no_cluster_manager_block", "all").build(); + assertEquals(NoMasterBlockService.NO_MASTER_BLOCK_ALL, NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.get(settings)); + assertEquals( + NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getDefault(Settings.EMPTY), + NoMasterBlockService.NO_MASTER_BLOCK_SETTING.get(settings) + ); + } + + /** + * Validate the value of the old setting will be applied to the new setting, if the new setting is not configured. + */ + public void testSettingGetValueWithFallback() { + Settings settings = Settings.builder().put("cluster.no_master_block", "metadata_write").build(); + assertEquals( + NoMasterBlockService.NO_MASTER_BLOCK_METADATA_WRITES, + NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.get(settings) + ); + assertSettingDeprecationsAndWarnings(new Setting[] { NoMasterBlockService.NO_MASTER_BLOCK_SETTING }); + } + + /** + * Validate the value of the old setting will be ignored, if the new setting is configured. + */ + public void testSettingGetValueWhenBothAreConfigured() { + Settings settings = Settings.builder() + .put("cluster.no_cluster_manager_block", "all") + .put("cluster.no_master_block", "metadata_write") + .build(); + assertEquals(NoMasterBlockService.NO_MASTER_BLOCK_ALL, NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.get(settings)); + assertEquals(NoMasterBlockService.NO_MASTER_BLOCK_METADATA_WRITES, NoMasterBlockService.NO_MASTER_BLOCK_SETTING.get(settings)); + assertSettingDeprecationsAndWarnings(new Setting[] { NoMasterBlockService.NO_MASTER_BLOCK_SETTING }); + } + +} diff --git a/server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceTests.java b/server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceTests.java index 1fd2d4ef5c0dc..a44026bbbf477 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/NoMasterBlockServiceTests.java @@ -37,7 +37,7 @@ import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_ALL; import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_METADATA_WRITES; -import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_SETTING; +import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING; import static org.opensearch.cluster.coordination.NoMasterBlockService.NO_MASTER_BLOCK_WRITES; import static org.opensearch.common.settings.ClusterSettings.BUILT_IN_CLUSTER_SETTINGS; import static org.hamcrest.Matchers.sameInstance; @@ -65,35 +65,35 @@ public void testBlocksWritesByDefault() { } public void testBlocksWritesIfConfiguredBySetting() { - createService(Settings.builder().put(NO_MASTER_BLOCK_SETTING.getKey(), "write").build()); + createService(Settings.builder().put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "write").build()); assertThat(noClusterManagerBlockService.getNoMasterBlock(), sameInstance(NO_MASTER_BLOCK_WRITES)); } public void testBlocksAllIfConfiguredBySetting() { - createService(Settings.builder().put(NO_MASTER_BLOCK_SETTING.getKey(), "all").build()); + createService(Settings.builder().put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "all").build()); assertThat(noClusterManagerBlockService.getNoMasterBlock(), sameInstance(NO_MASTER_BLOCK_ALL)); } public void testBlocksMetadataWritesIfConfiguredBySetting() { - createService(Settings.builder().put(NO_MASTER_BLOCK_SETTING.getKey(), "metadata_write").build()); + createService(Settings.builder().put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "metadata_write").build()); assertThat(noClusterManagerBlockService.getNoMasterBlock(), sameInstance(NO_MASTER_BLOCK_METADATA_WRITES)); } public void testRejectsInvalidSetting() { expectThrows( IllegalArgumentException.class, - () -> createService(Settings.builder().put(NO_MASTER_BLOCK_SETTING.getKey(), "unknown").build()) + () -> createService(Settings.builder().put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "unknown").build()) ); } public void testSettingCanBeUpdated() { - createService(Settings.builder().put(NO_MASTER_BLOCK_SETTING.getKey(), "all").build()); + createService(Settings.builder().put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "all").build()); assertThat(noClusterManagerBlockService.getNoMasterBlock(), sameInstance(NO_MASTER_BLOCK_ALL)); - clusterSettings.applySettings(Settings.builder().put(NO_MASTER_BLOCK_SETTING.getKey(), "write").build()); + clusterSettings.applySettings(Settings.builder().put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "write").build()); assertThat(noClusterManagerBlockService.getNoMasterBlock(), sameInstance(NO_MASTER_BLOCK_WRITES)); - clusterSettings.applySettings(Settings.builder().put(NO_MASTER_BLOCK_SETTING.getKey(), "metadata_write").build()); + clusterSettings.applySettings(Settings.builder().put(NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), "metadata_write").build()); assertThat(noClusterManagerBlockService.getNoMasterBlock(), sameInstance(NO_MASTER_BLOCK_METADATA_WRITES)); } } diff --git a/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java b/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java index 369b6a2ef8212..f00361160f2d7 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java @@ -248,7 +248,7 @@ protected DiscoveryNode newNode(int i) { protected DiscoveryNode newNode(int i, boolean master) { final Set roles; if (master) { - roles = singleton(DiscoveryNodeRole.MASTER_ROLE); + roles = singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } else { roles = Collections.emptySet(); } @@ -492,7 +492,7 @@ public void testJoinUpdateVotingConfigExclusion() throws Exception { "newNodeId", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); long newTerm = initialTerm + randomLongBetween(1, 10); diff --git a/server/src/test/java/org/opensearch/cluster/health/ClusterHealthAllocationTests.java b/server/src/test/java/org/opensearch/cluster/health/ClusterHealthAllocationTests.java index 2e4bba0ff1c7b..2f05297146f8e 100644 --- a/server/src/test/java/org/opensearch/cluster/health/ClusterHealthAllocationTests.java +++ b/server/src/test/java/org/opensearch/cluster/health/ClusterHealthAllocationTests.java @@ -87,7 +87,9 @@ public void testClusterHealth() { private ClusterState addNode(ClusterState clusterState, String nodeName, boolean isMaster) { DiscoveryNodes.Builder nodeBuilder = DiscoveryNodes.builder(clusterState.getNodes()); - nodeBuilder.add(newNode(nodeName, Collections.singleton(isMaster ? DiscoveryNodeRole.MASTER_ROLE : DiscoveryNodeRole.DATA_ROLE))); + nodeBuilder.add( + newNode(nodeName, Collections.singleton(isMaster ? DiscoveryNodeRole.CLUSTER_MANAGER_ROLE : DiscoveryNodeRole.DATA_ROLE)) + ); return ClusterState.builder(clusterState).nodes(nodeBuilder).build(); } diff --git a/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java b/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java index 13bc108591f7f..d6c62e4bb0903 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java @@ -146,7 +146,7 @@ public void testAutoExpandWhenNodeLeavesAndPossiblyRejoins() throws InterruptedE try { List allNodes = new ArrayList<>(); - DiscoveryNode localNode = createNode(DiscoveryNodeRole.MASTER_ROLE); // local node is the master + DiscoveryNode localNode = createNode(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); // local node is the master allNodes.add(localNode); int numDataNodes = randomIntBetween(3, 5); List dataNodes = new ArrayList<>(numDataNodes); @@ -245,7 +245,7 @@ public void testOnlyAutoExpandAllocationFilteringAfterAllNodesUpgraded() { List allNodes = new ArrayList<>(); DiscoveryNode oldNode = createNode( VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, LegacyESVersion.V_7_5_1), - DiscoveryNodeRole.MASTER_ROLE, + DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE ); // local node is the master allNodes.add(oldNode); @@ -266,11 +266,11 @@ public void testOnlyAutoExpandAllocationFilteringAfterAllNodesUpgraded() { state = cluster.reroute(state, new ClusterRerouteRequest()); } - DiscoveryNode newNode = createNode(LegacyESVersion.V_7_6_0, DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE); // local - // node - // is - // the - // master + DiscoveryNode newNode = createNode( + LegacyESVersion.V_7_6_0, + DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, + DiscoveryNodeRole.DATA_ROLE + ); // local node is the cluster_manager state = cluster.addNodes(state, Collections.singletonList(newNode)); diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java index 19f6a516ca83a..5bea69c5bbd66 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataCreateIndexServiceTests.java @@ -582,7 +582,7 @@ private void runPrepareResizeIndexSettingsTest( private DiscoveryNode newNode(String nodeId) { final Set roles = Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE)) + new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE)) ); return new DiscoveryNode(nodeId, buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT); } diff --git a/server/src/test/java/org/opensearch/cluster/metadata/MetadataMappingServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/MetadataMappingServiceTests.java index 94bf162303127..5388c0a866c5f 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/MetadataMappingServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/MetadataMappingServiceTests.java @@ -39,7 +39,6 @@ import org.opensearch.common.compress.CompressedXContent; import org.opensearch.index.Index; import org.opensearch.index.IndexService; -import org.opensearch.index.mapper.MapperService; import org.opensearch.plugins.Plugin; import org.opensearch.test.OpenSearchSingleNodeTestCase; import org.opensearch.test.InternalSettingsPlugin; @@ -58,10 +57,7 @@ protected Collection> getPlugins() { } public void testMappingClusterStateUpdateDoesntChangeExistingIndices() throws Exception { - final IndexService indexService = createIndex( - "test", - client().admin().indices().prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME) - ); + final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test").setMapping()); final CompressedXContent currentMapping = indexService.mapperService().documentMapper().mappingSource(); final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); @@ -86,7 +82,7 @@ public void testMappingClusterStateUpdateDoesntChangeExistingIndices() throws Ex } public void testClusterStateIsNotChangedWithIdenticalMappings() throws Exception { - createIndex("test", client().admin().indices().prepareCreate("test").addMapping("type")); + createIndex("test", client().admin().indices().prepareCreate("test")); final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); @@ -106,7 +102,7 @@ public void testClusterStateIsNotChangedWithIdenticalMappings() throws Exception } public void testMappingVersion() throws Exception { - final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test").addMapping("type")); + final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test")); final long previousVersion = indexService.getMetadata().getMappingVersion(); final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); @@ -122,7 +118,7 @@ public void testMappingVersion() throws Exception { } public void testMappingVersionUnchanged() throws Exception { - final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test").addMapping("type")); + final IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test").setMapping()); final long previousVersion = indexService.getMetadata().getMappingVersion(); final MetadataMappingService mappingService = getInstanceFromNode(MetadataMappingService.class); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); diff --git a/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java index e4692fe7d21f7..1e52fa380793e 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java @@ -261,7 +261,7 @@ public void testUpdateTemplates() { } private static final Set MASTER_DATA_ROLES = Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE)) + new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE)) ); @SuppressWarnings("unchecked") diff --git a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleSettingTests.java b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleSettingTests.java index 006968a2f2ac2..55c518c62973e 100644 --- a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleSettingTests.java +++ b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleSettingTests.java @@ -56,9 +56,15 @@ public void testIsIngestNode() { } public void testIsMasterNode() { + // It's used to add MASTER_ROLE into 'roleMap', because MASTER_ROLE is removed from DiscoveryNodeRole.BUILT_IN_ROLES in 2.0. + DiscoveryNode.setAdditionalRoles(Collections.emptySet()); runRoleTest(DiscoveryNode::isMasterNode, DiscoveryNodeRole.MASTER_ROLE); } + public void testIsClusterManagerNode() { + runRoleTest(DiscoveryNode::isMasterNode, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); + } + public void testIsRemoteClusterClient() { runRoleTest(DiscoveryNode::isRemoteClusterClient, DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE); } diff --git a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleTests.java b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleTests.java index 76f9843e386b8..d1acec2832b7c 100644 --- a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleTests.java +++ b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleTests.java @@ -128,4 +128,14 @@ public void testUnknownRoleIsDistinctFromKnownRoles() { assertNotEquals(buildInRole.toString(), unknownDataRole.toString()); } } + + /** + * Validate the method can identify the role as cluster-manager. + * Remove along with MASTER_ROLE. + */ + public void testIsClusterManager() { + assertTrue(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.isClusterManager()); + assertTrue(DiscoveryNodeRole.MASTER_ROLE.isClusterManager()); + assertFalse(randomFrom(DiscoveryNodeRole.DATA_ROLE.isClusterManager(), DiscoveryNodeRole.INGEST_ROLE.isClusterManager())); + } } diff --git a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeTests.java b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeTests.java index 39a3381bede26..933d9d5f825e9 100644 --- a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeTests.java +++ b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeTests.java @@ -174,6 +174,12 @@ public void testDiscoveryNodeIsRemoteClusterClientUnset() { runTestDiscoveryNodeIsRemoteClusterClient(nonRemoteClusterClientNode(), false); } + // TODO: Remove the test along with MASTER_ROLE. It is added in 2.0, along with the introduction of CLUSTER_MANAGER_ROLE. + public void testSetAdditionalRolesCanAddDeprecatedMasterRole() { + DiscoveryNode.setAdditionalRoles(Collections.emptySet()); + assertTrue(DiscoveryNode.getPossibleRoleNames().contains(DiscoveryNodeRole.MASTER_ROLE.roleName())); + } + private void runTestDiscoveryNodeIsRemoteClusterClient(final Settings settings, final boolean expected) { final DiscoveryNode node = DiscoveryNode.createLocal(settings, new TransportAddress(TransportAddress.META_ADDRESS, 9200), "node"); assertThat(node.isRemoteClusterClient(), equalTo(expected)); diff --git a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java index b9904eec98cc6..e8ea6137c41dd 100644 --- a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java +++ b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java @@ -361,6 +361,7 @@ Set matchingNodeIds(DiscoveryNodes nodes) { return Collections.singleton(nodes.getMasterNodeId()); } }, + // TODO: Remove this element after removing DiscoveryNodeRole.MASTER_ROLE MASTER_ELIGIBLE(DiscoveryNodeRole.MASTER_ROLE.roleName() + ":true") { @Override Set matchingNodeIds(DiscoveryNodes nodes) { @@ -369,6 +370,14 @@ Set matchingNodeIds(DiscoveryNodes nodes) { return ids; } }, + CLUSTER_MANAGER_ELIGIBLE(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleName() + ":true") { + @Override + Set matchingNodeIds(DiscoveryNodes nodes) { + Set ids = new HashSet<>(); + nodes.getMasterNodes().keysIt().forEachRemaining(ids::add); + return ids; + } + }, DATA(DiscoveryNodeRole.DATA_ROLE.roleName() + ":true") { @Override Set matchingNodeIds(DiscoveryNodes nodes) { diff --git a/server/src/test/java/org/opensearch/cluster/routing/DelayedAllocationServiceTests.java b/server/src/test/java/org/opensearch/cluster/routing/DelayedAllocationServiceTests.java index 1f79d52d84d74..1f45c5c1dfce4 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/DelayedAllocationServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/DelayedAllocationServiceTests.java @@ -262,7 +262,7 @@ public void testDelayedUnassignedScheduleRerouteAfterDelayedReroute() throws Exc .routingTable(RoutingTable.builder().addAsNew(metadata.index("short_delay")).addAsNew(metadata.index("long_delay")).build()) .nodes( DiscoveryNodes.builder() - .add(newNode("node0", singleton(DiscoveryNodeRole.MASTER_ROLE))) + .add(newNode("node0", singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))) .localNodeId("node0") .masterNodeId("node0") .add(newNode("node1")) diff --git a/server/src/test/java/org/opensearch/cluster/routing/OperationRoutingTests.java b/server/src/test/java/org/opensearch/cluster/routing/OperationRoutingTests.java index eb2c8ace45537..5ff502e02f3c9 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/OperationRoutingTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/OperationRoutingTests.java @@ -778,7 +778,7 @@ private DiscoveryNode[] setupNodes() { "master", buildNewFakeTransportAddress(), Collections.emptyMap(), - Collections.singleton(DiscoveryNodeRole.MASTER_ROLE), + Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); allNodes[i] = clusterManager; diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/AllocationCommandsTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/AllocationCommandsTests.java index 28599ea0b9baa..cda0f1afaf62c 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/AllocationCommandsTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/AllocationCommandsTests.java @@ -188,7 +188,7 @@ public void testAllocateCommand() { .add(newNode("node1")) .add(newNode("node2")) .add(newNode("node3")) - .add(newNode("node4", singleton(DiscoveryNodeRole.MASTER_ROLE))) + .add(newNode("node4", singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))) ) .build(); clusterState = allocation.reroute(clusterState, "reroute"); @@ -748,7 +748,9 @@ public void testMoveShardToNonDataNode() { "test2", buildNewFakeTransportAddress(), emptyMap(), - new HashSet<>(randomSubsetOf(new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.INGEST_ROLE)))), + new HashSet<>( + randomSubsetOf(new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.INGEST_ROLE))) + ), Version.CURRENT ); @@ -817,7 +819,9 @@ public void testMoveShardFromNonDataNode() { "test2", buildNewFakeTransportAddress(), emptyMap(), - new HashSet<>(randomSubsetOf(new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.INGEST_ROLE)))), + new HashSet<>( + randomSubsetOf(new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.INGEST_ROLE))) + ), Version.CURRENT ); diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/FailedNodeRoutingTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/FailedNodeRoutingTests.java index f871d74d3d1a5..f60497b4108b7 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/FailedNodeRoutingTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/FailedNodeRoutingTests.java @@ -230,7 +230,7 @@ private static Version getNodeVersion(ShardRouting shardRouting, ClusterState st public ClusterState randomInitialClusterState() { List allNodes = new ArrayList<>(); - DiscoveryNode localNode = createNode(DiscoveryNodeRole.MASTER_ROLE); // local node is the master + DiscoveryNode localNode = createNode(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); // local node is the master allNodes.add(localNode); // at least two nodes that have the data role so that we can allocate shards allNodes.add(createNode(DiscoveryNodeRole.DATA_ROLE)); diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java index 2ddfa852a5d3e..fa73c981f4d1c 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/DiskThresholdDeciderTests.java @@ -1078,7 +1078,7 @@ public void testForSingleDataNode() { "node1", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); DiscoveryNode discoveryNode2 = new DiscoveryNode( @@ -1227,7 +1227,7 @@ public void testWatermarksEnabledForSingleDataNode() { "master", buildNewFakeTransportAddress(), emptyMap(), - singleton(DiscoveryNodeRole.MASTER_ROLE), + singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); DiscoveryNode dataNode = new DiscoveryNode( diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java index 8917b9793e621..5b05cb3afd83e 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java @@ -199,7 +199,7 @@ private ClusterState createInitialClusterState() { RoutingTable routingTable = RoutingTable.builder().addAsNew(metadata.index("test")).build(); DiscoveryNodes discoveryNodes = DiscoveryNodes.builder() - .add(newNode("master", Collections.singleton(DiscoveryNodeRole.MASTER_ROLE))) + .add(newNode("master", Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))) .localNodeId("master") .masterNodeId("master") .build(); diff --git a/server/src/test/java/org/opensearch/cluster/service/MasterServiceRenamedSettingTests.java b/server/src/test/java/org/opensearch/cluster/service/MasterServiceRenamedSettingTests.java new file mode 100644 index 0000000000000..acf089dc43b56 --- /dev/null +++ b/server/src/test/java/org/opensearch/cluster/service/MasterServiceRenamedSettingTests.java @@ -0,0 +1,99 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.cluster.service; + +import org.opensearch.common.settings.ClusterSettings; +import org.opensearch.common.settings.Setting; +import org.opensearch.common.settings.Settings; +import org.opensearch.common.unit.TimeValue; +import org.opensearch.test.OpenSearchTestCase; + +import java.util.Arrays; +import java.util.Set; + +/** + * A unit test to validate the former name of the setting 'cluster.service.slow_cluster_manager_task_logging_threshold' still take effect, + * after it is deprecated, so that the backwards compatibility is maintained. + * The test can be removed along with removing support of the deprecated setting. + */ +public class MasterServiceRenamedSettingTests extends OpenSearchTestCase { + + /** + * Validate the both settings are known and supported. + */ + public void testClusterManagerServiceSettingsExist() { + Set> settings = ClusterSettings.BUILT_IN_CLUSTER_SETTINGS; + assertTrue( + "Both 'cluster.service.slow_cluster_manager_task_logging_threshold' and its predecessor should be supported built-in settings", + settings.containsAll( + Arrays.asList( + MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING, + MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING + ) + ) + ); + } + + /** + * Validate the default value of the both settings is the same. + */ + public void testSettingFallback() { + assertEquals( + MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY), + MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY) + ); + } + + /** + * Validate the new setting can be configured correctly, and it doesn't impact the old setting. + */ + public void testSettingGetValue() { + Settings settings = Settings.builder().put("cluster.service.slow_cluster_manager_task_logging_threshold", "9s").build(); + assertEquals( + TimeValue.timeValueSeconds(9), + MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings) + ); + assertEquals( + MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.getDefault(Settings.EMPTY), + MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings) + + ); + } + + /** + * Validate the value of the old setting will be applied to the new setting, if the new setting is not configured. + */ + public void testSettingGetValueWithFallback() { + Settings settings = Settings.builder().put("cluster.service.slow_master_task_logging_threshold", "8s").build(); + assertEquals( + TimeValue.timeValueSeconds(8), + MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings) + + ); + assertSettingDeprecationsAndWarnings(new Setting[] { MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING }); + } + + /** + * Validate the value of the old setting will be ignored, if the new setting is configured. + */ + public void testSettingGetValueWhenBothAreConfigured() { + Settings settings = Settings.builder() + .put("cluster.service.slow_cluster_manager_task_logging_threshold", "9s") + .put("cluster.service.slow_master_task_logging_threshold", "8s") + .build(); + assertEquals( + TimeValue.timeValueSeconds(9), + MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings) + + ); + assertEquals(TimeValue.timeValueSeconds(8), MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings)); + assertSettingDeprecationsAndWarnings(new Setting[] { MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING }); + } + +} diff --git a/server/src/test/java/org/opensearch/cluster/service/MasterServiceTests.java b/server/src/test/java/org/opensearch/cluster/service/MasterServiceTests.java index 134356b6e04c2..845a5ee91052d 100644 --- a/server/src/test/java/org/opensearch/cluster/service/MasterServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/service/MasterServiceTests.java @@ -809,12 +809,14 @@ public void testLongClusterStateUpdateLogging() throws Exception { final AtomicReference clusterStateRef = new AtomicReference<>(initialClusterState); masterService.setClusterStatePublisher((event, publishListener, ackListener) -> { if (event.source().contains("test5")) { - relativeTimeInMillis += MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY) - .millis() + randomLongBetween(1, 1000000); + relativeTimeInMillis += MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get( + Settings.EMPTY + ).millis() + randomLongBetween(1, 1000000); } if (event.source().contains("test6")) { - relativeTimeInMillis += MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY) - .millis() + randomLongBetween(1, 1000000); + relativeTimeInMillis += MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get( + Settings.EMPTY + ).millis() + randomLongBetween(1, 1000000); throw new OpenSearchException("simulated error during slow publication which should trigger logging"); } clusterStateRef.set(event.state()); @@ -830,7 +832,7 @@ public void testLongClusterStateUpdateLogging() throws Exception { public ClusterState execute(ClusterState currentState) { relativeTimeInMillis += randomLongBetween( 0L, - MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY).millis() + MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY).millis() ); return currentState; } @@ -851,8 +853,9 @@ public void onFailure(String source, Exception e) { masterService.submitStateUpdateTask("test2", new ClusterStateUpdateTask() { @Override public ClusterState execute(ClusterState currentState) { - relativeTimeInMillis += MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY) - .millis() + randomLongBetween(1, 1000000); + relativeTimeInMillis += MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get( + Settings.EMPTY + ).millis() + randomLongBetween(1, 1000000); throw new IllegalArgumentException("Testing handling of exceptions in the cluster state task"); } @@ -869,8 +872,9 @@ public void onFailure(String source, Exception e) { masterService.submitStateUpdateTask("test3", new ClusterStateUpdateTask() { @Override public ClusterState execute(ClusterState currentState) { - relativeTimeInMillis += MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY) - .millis() + randomLongBetween(1, 1000000); + relativeTimeInMillis += MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get( + Settings.EMPTY + ).millis() + randomLongBetween(1, 1000000); return ClusterState.builder(currentState).incrementVersion().build(); } @@ -887,8 +891,9 @@ public void onFailure(String source, Exception e) { masterService.submitStateUpdateTask("test4", new ClusterStateUpdateTask() { @Override public ClusterState execute(ClusterState currentState) { - relativeTimeInMillis += MasterService.MASTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(Settings.EMPTY) - .millis() + randomLongBetween(1, 1000000); + relativeTimeInMillis += MasterService.CLUSTER_MANAGER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get( + Settings.EMPTY + ).millis() + randomLongBetween(1, 1000000); return currentState; } diff --git a/server/src/test/java/org/opensearch/env/NodeEnvironmentTests.java b/server/src/test/java/org/opensearch/env/NodeEnvironmentTests.java index 39f3d3f1b933e..152116815e4a2 100644 --- a/server/src/test/java/org/opensearch/env/NodeEnvironmentTests.java +++ b/server/src/test/java/org/opensearch/env/NodeEnvironmentTests.java @@ -602,7 +602,7 @@ private void verifyFailsOnMetadata(Settings settings, Path indexPath) { ); assertThat(ex.getMessage(), containsString(indexPath.resolve(MetadataStateFormat.STATE_DIR_NAME).toAbsolutePath().toString())); - assertThat(ex.getMessage(), startsWith("node does not have the data and master roles but has index metadata")); + assertThat(ex.getMessage(), startsWith("node does not have the data and cluster_manager roles but has index metadata")); } /** Converts an array of Strings to an array of Paths, adding an additional child if specified */ diff --git a/server/src/test/java/org/opensearch/env/NodeRepurposeCommandTests.java b/server/src/test/java/org/opensearch/env/NodeRepurposeCommandTests.java index e4f36d359de1c..19709c0e848a9 100644 --- a/server/src/test/java/org/opensearch/env/NodeRepurposeCommandTests.java +++ b/server/src/test/java/org/opensearch/env/NodeRepurposeCommandTests.java @@ -105,7 +105,7 @@ public void createNodePaths() throws IOException { dataNoClusterManagerSettings = nonMasterNode(dataClusterManagerSettings); noDataNoClusterManagerSettings = removeRoles( dataClusterManagerSettings, - Collections.unmodifiableSet(new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE))) + Collections.unmodifiableSet(new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))) ); noDataClusterManagerSettings = masterNode(nonDataNode(dataClusterManagerSettings)); diff --git a/server/src/test/java/org/opensearch/gateway/ClusterStateUpdatersTests.java b/server/src/test/java/org/opensearch/gateway/ClusterStateUpdatersTests.java index f6a8f1515002d..1f63dff04b3df 100644 --- a/server/src/test/java/org/opensearch/gateway/ClusterStateUpdatersTests.java +++ b/server/src/test/java/org/opensearch/gateway/ClusterStateUpdatersTests.java @@ -304,7 +304,7 @@ public void testSetLocalNode() { "node1", buildNewFakeTransportAddress(), Collections.emptyMap(), - Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE), + Sets.newHashSet(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); @@ -354,7 +354,7 @@ public void testHideStateIfNotRecovered() { "node1", buildNewFakeTransportAddress(), Collections.emptyMap(), - Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE), + Sets.newHashSet(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); final ClusterState updatedState = Function.identity() diff --git a/server/src/test/java/org/opensearch/gateway/GatewayMetaStatePersistedStateTests.java b/server/src/test/java/org/opensearch/gateway/GatewayMetaStatePersistedStateTests.java index 4ab5d7c44f356..339b04f45c830 100644 --- a/server/src/test/java/org/opensearch/gateway/GatewayMetaStatePersistedStateTests.java +++ b/server/src/test/java/org/opensearch/gateway/GatewayMetaStatePersistedStateTests.java @@ -97,7 +97,7 @@ public void setUp() throws Exception { "node1", buildNewFakeTransportAddress(), Collections.emptyMap(), - Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE), + Sets.newHashSet(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE), Version.CURRENT ); clusterName = new ClusterName(randomAlphaOfLength(10)); diff --git a/server/src/test/java/org/opensearch/index/fieldstats/FieldStatsProviderRefreshTests.java b/server/src/test/java/org/opensearch/index/fieldstats/FieldStatsProviderRefreshTests.java index d7cf873e133df..35c16c9954622 100644 --- a/server/src/test/java/org/opensearch/index/fieldstats/FieldStatsProviderRefreshTests.java +++ b/server/src/test/java/org/opensearch/index/fieldstats/FieldStatsProviderRefreshTests.java @@ -55,7 +55,7 @@ public void testQueryRewriteOnRefresh() throws Exception { client().admin() .indices() .prepareCreate("index") - .addMapping("type", "s", "type=text") + .setMapping("s", "type=text") .setSettings( Settings.builder() .put(IndicesRequestCache.INDEX_CACHE_REQUEST_ENABLED_SETTING.getKey(), true) diff --git a/server/src/test/java/org/opensearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java index 0a01d86e76dea..a8245627c6930 100644 --- a/server/src/test/java/org/opensearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/RangeFieldQueryStringQueryBuilderTests.java @@ -73,7 +73,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws "_doc", new CompressedXContent( Strings.toString( - PutMappingRequest.buildFromSimplifiedDef( + PutMappingRequest.simpleMapping( INTEGER_RANGE_FIELD_NAME, "type=integer_range", LONG_RANGE_FIELD_NAME, diff --git a/server/src/test/java/org/opensearch/index/mapper/UpdateMappingTests.java b/server/src/test/java/org/opensearch/index/mapper/UpdateMappingTests.java index 80fd4edc6ac78..0349307ad20ea 100644 --- a/server/src/test/java/org/opensearch/index/mapper/UpdateMappingTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/UpdateMappingTests.java @@ -259,7 +259,7 @@ public void testRejectFieldDefinedTwice() throws IOException { } public void testMappingVersion() { - createIndex("test", client().admin().indices().prepareCreate("test").addMapping(MapperService.SINGLE_MAPPING_NAME)); + createIndex("test", client().admin().indices().prepareCreate("test")); final ClusterService clusterService = getInstanceFromNode(ClusterService.class); { final long previousVersion = clusterService.state().metadata().index("test").getMappingVersion(); diff --git a/server/src/test/java/org/opensearch/index/query/CommonTermsQueryParserTests.java b/server/src/test/java/org/opensearch/index/query/CommonTermsQueryParserTests.java index 1dcda74308f45..61ef0c746995a 100644 --- a/server/src/test/java/org/opensearch/index/query/CommonTermsQueryParserTests.java +++ b/server/src/test/java/org/opensearch/index/query/CommonTermsQueryParserTests.java @@ -38,8 +38,7 @@ public class CommonTermsQueryParserTests extends OpenSearchSingleNodeTestCase { public void testWhenParsedQueryIsNullNoNullPointerExceptionIsThrown() { final String index = "test-index"; - final String type = "test-type"; - client().admin().indices().prepareCreate(index).addMapping(type, "name", "type=text,analyzer=stop").execute().actionGet(); + client().admin().indices().prepareCreate(index).setMapping("name", "type=text,analyzer=stop").execute().actionGet(); ensureGreen(); CommonTermsQueryBuilder commonTermsQueryBuilder = new CommonTermsQueryBuilder("name", "the").queryName("query-name"); diff --git a/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java index dac32849e3cef..d6cd157d6f84e 100644 --- a/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/MatchQueryBuilderTests.java @@ -390,7 +390,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws "_doc", new CompressedXContent( Strings.toString( - PutMappingRequest.buildFromSimplifiedDef("string_boost", "type=text", "string_no_pos", "type=text,index_options=docs") + PutMappingRequest.simpleMapping("string_boost", "type=text", "string_no_pos", "type=text,index_options=docs") ) ), MapperService.MergeReason.MAPPING_UPDATE diff --git a/server/src/test/java/org/opensearch/index/query/NestedQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/NestedQueryBuilderTests.java index b95d9f8d36ad8..abc3e0bb8c4c3 100644 --- a/server/src/test/java/org/opensearch/index/query/NestedQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/NestedQueryBuilderTests.java @@ -77,7 +77,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws "_doc", new CompressedXContent( Strings.toString( - PutMappingRequest.buildFromSimplifiedDef( + PutMappingRequest.simpleMapping( TEXT_FIELD_NAME, "type=text", INT_FIELD_NAME, diff --git a/server/src/test/java/org/opensearch/index/query/QueryStringQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/QueryStringQueryBuilderTests.java index b091fc2103344..393d4cb3f2121 100644 --- a/server/src/test/java/org/opensearch/index/query/QueryStringQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/QueryStringQueryBuilderTests.java @@ -1096,7 +1096,7 @@ public void testDisabledFieldNamesField() throws Exception { .merge( "_doc", new CompressedXContent( - Strings.toString(PutMappingRequest.buildFromSimplifiedDef("foo", "type=text", "_field_names", "enabled=false")) + Strings.toString(PutMappingRequest.simpleMapping("foo", "type=text", "_field_names", "enabled=false")) ), MapperService.MergeReason.MAPPING_UPDATE ); @@ -1112,7 +1112,7 @@ public void testDisabledFieldNamesField() throws Exception { .merge( "_doc", new CompressedXContent( - Strings.toString(PutMappingRequest.buildFromSimplifiedDef("foo", "type=text", "_field_names", "enabled=true")) + Strings.toString(PutMappingRequest.simpleMapping("foo", "type=text", "_field_names", "enabled=true")) ), MapperService.MergeReason.MAPPING_UPDATE ); diff --git a/server/src/test/java/org/opensearch/index/query/TermsSetQueryBuilderTests.java b/server/src/test/java/org/opensearch/index/query/TermsSetQueryBuilderTests.java index 3c39773108830..43ca3139e30cb 100644 --- a/server/src/test/java/org/opensearch/index/query/TermsSetQueryBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/TermsSetQueryBuilderTests.java @@ -93,7 +93,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws String docType = "_doc"; mapperService.merge( docType, - new CompressedXContent(Strings.toString(PutMappingRequest.buildFromSimplifiedDef("m_s_m", "type=long"))), + new CompressedXContent(Strings.toString(PutMappingRequest.simpleMapping("m_s_m", "type=long"))), MapperService.MergeReason.MAPPING_UPDATE ); } diff --git a/server/src/test/java/org/opensearch/indices/IndicesServiceCloseTests.java b/server/src/test/java/org/opensearch/indices/IndicesServiceCloseTests.java index ff97b87708202..e3b2afaccf054 100644 --- a/server/src/test/java/org/opensearch/indices/IndicesServiceCloseTests.java +++ b/server/src/test/java/org/opensearch/indices/IndicesServiceCloseTests.java @@ -64,7 +64,7 @@ import java.util.Collections; import java.util.concurrent.TimeUnit; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS; import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS; import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; @@ -94,7 +94,7 @@ private Node startNode() throws NodeValidationException { // turn it off for these tests. .put(HierarchyCircuitBreakerService.USE_REAL_MEMORY_USAGE_SETTING.getKey(), false) .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey()) // empty list disables a port scan for other nodes - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), nodeName) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), nodeName) .put(IndicesQueryCache.INDICES_QUERIES_CACHE_ALL_SEGMENTS_SETTING.getKey(), true) .build(); diff --git a/server/src/test/java/org/opensearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java b/server/src/test/java/org/opensearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java index 5574e3c911213..7789054cfdc16 100644 --- a/server/src/test/java/org/opensearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java +++ b/server/src/test/java/org/opensearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java @@ -327,7 +327,7 @@ public ClusterState randomInitialClusterState( Supplier indicesServiceSupplier ) { List allNodes = new ArrayList<>(); - DiscoveryNode localNode = createNode(DiscoveryNodeRole.MASTER_ROLE); // local node is the master + DiscoveryNode localNode = createNode(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); // local node is the master allNodes.add(localNode); // at least two nodes that have the data role so that we can allocate shards allNodes.add(createNode(DiscoveryNodeRole.DATA_ROLE)); diff --git a/server/src/test/java/org/opensearch/node/NodeRoleSettingsTests.java b/server/src/test/java/org/opensearch/node/NodeRoleSettingsTests.java new file mode 100644 index 0000000000000..c875fec1979d1 --- /dev/null +++ b/server/src/test/java/org/opensearch/node/NodeRoleSettingsTests.java @@ -0,0 +1,57 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.node; + +import org.opensearch.cluster.node.DiscoveryNode; +import org.opensearch.cluster.node.DiscoveryNodeRole; +import org.opensearch.common.settings.Settings; +import org.opensearch.test.OpenSearchTestCase; + +import java.util.Arrays; +import java.util.Collections; + +import static org.hamcrest.Matchers.containsString; + +public class NodeRoleSettingsTests extends OpenSearchTestCase { + + /** + * Validate cluster_manager role and master role can not coexist in a node. + * Remove the test after removing MASTER_ROLE. + */ + public void testClusterManagerAndMasterRoleCanNotCoexist() { + // It's used to add MASTER_ROLE into 'roleMap', because MASTER_ROLE is removed from DiscoveryNodeRole.BUILT_IN_ROLES in 2.0. + DiscoveryNode.setAdditionalRoles(Collections.emptySet()); + Settings roleSettings = Settings.builder().put(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), "cluster_manager, master").build(); + Exception exception = expectThrows(IllegalArgumentException.class, () -> NodeRoleSettings.NODE_ROLES_SETTING.get(roleSettings)); + assertThat(exception.getMessage(), containsString("[master, cluster_manager] can not be assigned together to a node")); + } + + /** + * Validate cluster_manager role and data role can coexist in a node. The test is added along with validateRole(). + */ + public void testClusterManagerAndDataNodeRoles() { + Settings roleSettings = Settings.builder().put(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), "cluster_manager, data").build(); + assertEquals( + Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE), + NodeRoleSettings.NODE_ROLES_SETTING.get(roleSettings) + ); + } + + /** + * Validate setting master role will result a deprecation message. + * Remove the test after removing MASTER_ROLE. + */ + public void testMasterRoleDeprecationMessage() { + // It's used to add MASTER_ROLE into 'roleMap', because MASTER_ROLE is removed from DiscoveryNodeRole.BUILT_IN_ROLES in 2.0. + DiscoveryNode.setAdditionalRoles(Collections.emptySet()); + Settings roleSettings = Settings.builder().put(NodeRoleSettings.NODE_ROLES_SETTING.getKey(), "master").build(); + assertEquals(Collections.singletonList(DiscoveryNodeRole.MASTER_ROLE), NodeRoleSettings.NODE_ROLES_SETTING.get(roleSettings)); + assertWarnings(DiscoveryNodeRole.MASTER_ROLE_DEPRECATION_MESSAGE); + } +} diff --git a/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java b/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java index de9dbdc2d5793..bb8f0405ecf7e 100644 --- a/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java +++ b/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java @@ -886,7 +886,7 @@ private String addTask(PersistentTasksCustomMetadata.Builder tasks, String param private DiscoveryNode newNode(String nodeId) { final Set roles = Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE)) + new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE)) ); return new DiscoveryNode(nodeId, buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT); } diff --git a/server/src/test/java/org/opensearch/rest/RestRequestTests.java b/server/src/test/java/org/opensearch/rest/RestRequestTests.java index 7abc53e4ca610..d5a915b42cf87 100644 --- a/server/src/test/java/org/opensearch/rest/RestRequestTests.java +++ b/server/src/test/java/org/opensearch/rest/RestRequestTests.java @@ -34,6 +34,7 @@ import org.opensearch.OpenSearchParseException; import org.opensearch.common.CheckedConsumer; +import org.opensearch.common.Strings; import org.opensearch.common.bytes.BytesArray; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.collect.MapBuilder; @@ -50,11 +51,13 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; import static java.util.Collections.emptyMap; import static java.util.Collections.singletonMap; +import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.instanceOf; import static org.mockito.Mockito.mock; @@ -280,6 +283,40 @@ public void testRequiredContent() { assertEquals("unknown content type", e.getMessage()); } + /* + * The test is added in 2.0 when the request parameter "cluster_manager_timeout" is introduced. + * Remove the test along with the removal of the non-inclusive terminology "master_timeout". + */ + public void testValidateParamValuesAreEqualWhenTheyAreEqual() { + FakeRestRequest request = new FakeRestRequest(); + String valueForKey1 = randomFrom("value1", "", null); + String valueForKey2 = "value1"; + request.params().put("key1", valueForKey1); + request.params().put("key2", valueForKey2); + request.validateParamValuesAreEqual("key1", "key2"); + assertTrue( + String.format( + Locale.ROOT, + "The 2 values should be equal, or having 1 null/empty value. Value of key1: %s. Value of key2: %s", + valueForKey1, + valueForKey2 + ), + Strings.isNullOrEmpty(valueForKey1) || valueForKey1.equals(valueForKey2) + ); + } + + /* + * The test is added in 2.0 when the request parameter "cluster_manager_timeout" is introduced. + * Remove the test along with the removal of the non-inclusive terminology "master_timeout". + */ + public void testValidateParamValuesAreEqualWhenTheyAreNotEqual() { + FakeRestRequest request = new FakeRestRequest(); + request.params().put("key1", "value1"); + request.params().put("key2", "value2"); + Exception e = assertThrows(OpenSearchParseException.class, () -> request.validateParamValuesAreEqual("key1", "key2")); + assertThat(e.getMessage(), containsString("The values of the request parameters: [key1, key2] are required to be equal")); + } + private static RestRequest contentRestRequest(String content, Map params) { Map> headers = new HashMap<>(); headers.put("Content-Type", Collections.singletonList("application/json")); diff --git a/server/src/test/java/org/opensearch/rest/action/cat/RestNodesActionTests.java b/server/src/test/java/org/opensearch/rest/action/cat/RestNodesActionTests.java index 593ad2907797e..9293d40605f42 100644 --- a/server/src/test/java/org/opensearch/rest/action/cat/RestNodesActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/cat/RestNodesActionTests.java @@ -32,6 +32,7 @@ package org.opensearch.rest.action.cat; +import org.opensearch.OpenSearchParseException; import org.opensearch.Version; import org.opensearch.action.admin.cluster.node.info.NodesInfoResponse; import org.opensearch.action.admin.cluster.node.stats.NodesStatsResponse; @@ -51,6 +52,7 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; +import static org.hamcrest.CoreMatchers.containsString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -89,4 +91,20 @@ public void testCatNodesWithLocalDeprecationWarning() { terminate(threadPool); } + + /** + * Validate both cluster_manager_timeout and its predecessor can be parsed correctly. + * Remove the test along with MASTER_ROLE. It's added in version 2.0.0. + */ + public void testCatNodesWithClusterManagerTimeout() { + TestThreadPool threadPool = new TestThreadPool(RestNodesActionTests.class.getName()); + NodeClient client = new NodeClient(Settings.EMPTY, threadPool); + FakeRestRequest request = new FakeRestRequest(); + request.params().put("cluster_manager_timeout", randomFrom("1h", "2m")); + request.params().put("master_timeout", "3s"); + Exception e = assertThrows(OpenSearchParseException.class, () -> action.doCatRequest(request, client)); + assertThat(e.getMessage(), containsString("[master_timeout, cluster_manager_timeout] are required to be equal")); + assertWarnings(RestNodesAction.MASTER_TIMEOUT_DEPRECATED_MESSAGE); + terminate(threadPool); + } } diff --git a/server/src/test/java/org/opensearch/search/aggregations/bucket/ShardSizeTestCase.java b/server/src/test/java/org/opensearch/search/aggregations/bucket/ShardSizeTestCase.java index bf16f70d400fc..d6981d1c34652 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/bucket/ShardSizeTestCase.java +++ b/server/src/test/java/org/opensearch/search/aggregations/bucket/ShardSizeTestCase.java @@ -55,7 +55,7 @@ protected int numberOfShards() { } protected void createIdx(String keyFieldMapping) { - assertAcked(prepareCreate("idx").addMapping("type", "key", keyFieldMapping)); + assertAcked(prepareCreate("idx").setMapping("key", keyFieldMapping)); } protected static String routing1; // routing key to shard 1 diff --git a/server/src/test/java/org/opensearch/search/aggregations/metrics/AbstractGeoTestCase.java b/server/src/test/java/org/opensearch/search/aggregations/metrics/AbstractGeoTestCase.java index 9243a1ccd517e..5dd8421bf5fc1 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/metrics/AbstractGeoTestCase.java +++ b/server/src/test/java/org/opensearch/search/aggregations/metrics/AbstractGeoTestCase.java @@ -87,8 +87,7 @@ public abstract class AbstractGeoTestCase extends OpenSearchIntegTestCase { public void setupSuiteScopeCluster() throws Exception { createIndex(UNMAPPED_IDX_NAME); assertAcked( - prepareCreate(IDX_NAME).addMapping( - "type", + prepareCreate(IDX_NAME).setMapping( SINGLE_VALUED_FIELD_NAME, "type=geo_point", MULTI_VALUED_FIELD_NAME, @@ -168,11 +167,10 @@ public void setupSuiteScopeCluster() throws Exception { ); } - assertAcked(prepareCreate(EMPTY_IDX_NAME).addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=geo_point")); + assertAcked(prepareCreate(EMPTY_IDX_NAME).setMapping(SINGLE_VALUED_FIELD_NAME, "type=geo_point")); assertAcked( - prepareCreate(DATELINE_IDX_NAME).addMapping( - "type", + prepareCreate(DATELINE_IDX_NAME).setMapping( SINGLE_VALUED_FIELD_NAME, "type=geo_point", MULTI_VALUED_FIELD_NAME, @@ -205,8 +203,7 @@ public void setupSuiteScopeCluster() throws Exception { } assertAcked( prepareCreate(HIGH_CARD_IDX_NAME).setSettings(Settings.builder().put("number_of_shards", 2)) - .addMapping( - "type", + .setMapping( SINGLE_VALUED_FIELD_NAME, "type=geo_point", MULTI_VALUED_FIELD_NAME, @@ -247,7 +244,7 @@ public void setupSuiteScopeCluster() throws Exception { client().prepareIndex(IDX_ZERO_NAME) .setSource(jsonBuilder().startObject().array(SINGLE_VALUED_FIELD_NAME, 0.0, 1.0).endObject()) ); - assertAcked(prepareCreate(IDX_ZERO_NAME).addMapping("type", SINGLE_VALUED_FIELD_NAME, "type=geo_point")); + assertAcked(prepareCreate(IDX_ZERO_NAME).setMapping(SINGLE_VALUED_FIELD_NAME, "type=geo_point")); indexRandom(true, builders); ensureSearchable(); diff --git a/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java b/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java index 4247a2ccabff2..d6c5e4f9a6083 100644 --- a/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java +++ b/server/src/test/java/org/opensearch/search/geo/GeoShapeQueryTests.java @@ -148,7 +148,7 @@ protected XContentBuilder createRandomMapping() throws Exception { public void testShapeFetchingPath() throws Exception { createIndex("shapes"); - client().admin().indices().prepareCreate("test").addMapping("type", "geo", "type=geo_shape").get(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape").get(); String location = "\"geo\" : {\"type\":\"polygon\", \"coordinates\":[[[-10,-10],[10,-10],[10,10],[-10,10],[-10,-10]]]}"; @@ -538,14 +538,9 @@ public void testPointQuery() throws Exception { PointBuilder pb = new PointBuilder(pt[0], pt[1]); gcb.shape(pb); if (randomBoolean()) { - client().admin().indices().prepareCreate("test").addMapping("type", "geo", "type=geo_shape").execute().actionGet(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape").execute().actionGet(); } else { - client().admin() - .indices() - .prepareCreate("test") - .addMapping("type", "geo", "type=geo_shape,tree=quadtree") - .execute() - .actionGet(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape,tree=quadtree").execute().actionGet(); } XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("geo"), null).endObject(); client().prepareIndex("test").setId("1").setSource(docSource).setRefreshPolicy(IMMEDIATE).get(); @@ -578,14 +573,9 @@ public void testContainsShapeQuery() throws Exception { } if (usePrefixTrees) { - client().admin() - .indices() - .prepareCreate("test") - .addMapping("type", "geo", "type=geo_shape,tree=quadtree") - .execute() - .actionGet(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape,tree=quadtree").execute().actionGet(); } else { - client().admin().indices().prepareCreate("test").addMapping("type", "geo", "type=geo_shape").execute().actionGet(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape").execute().actionGet(); } XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("geo"), null).endObject(); @@ -805,7 +795,7 @@ public void testQueryRandomGeoCollection() throws Exception { public void testShapeFilterWithDefinedGeoCollection() throws Exception { createIndex("shapes"); - client().admin().indices().prepareCreate("test").addMapping("type", "geo", "type=geo_shape,tree=quadtree").get(); + client().admin().indices().prepareCreate("test").setMapping("geo", "type=geo_shape,tree=quadtree").get(); XContentBuilder docSource = jsonBuilder().startObject() .startObject("geo") diff --git a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java index 74da44af28e1d..7855f7f2b0e59 100644 --- a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java +++ b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java @@ -1445,8 +1445,8 @@ private Environment createEnvironment(String nodeName) { .put(PATH_HOME_SETTING.getKey(), tempDir.resolve(nodeName).toAbsolutePath()) .put(Environment.PATH_REPO_SETTING.getKey(), tempDir.resolve("repo").toAbsolutePath()) .putList( - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey(), - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY) + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(Settings.EMPTY) ) .put(MappingUpdatedAction.INDICES_MAX_IN_FLIGHT_UPDATES_SETTING.getKey(), 1000) // o.w. some tests might block .build() @@ -1500,7 +1500,7 @@ public TestClusterNode nodeById(final String nodeId) { } private TestClusterNode newMasterNode(String nodeName) throws IOException { - return newNode(nodeName, DiscoveryNodeRole.MASTER_ROLE); + return newNode(nodeName, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } private TestClusterNode newDataNode(String nodeName) throws IOException { diff --git a/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java b/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java index c2c2728a348f5..1092bc4f8f47c 100644 --- a/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java +++ b/server/src/test/java/org/opensearch/test/search/aggregations/bucket/SharedSignificantTermsTestMethods.java @@ -100,7 +100,7 @@ public static void index01Docs(String type, String settings, OpenSearchIntegTest assertAcked( testCase.prepareCreate(INDEX_NAME) .setSettings(settings, XContentType.JSON) - .addMapping("_doc", "text", textMappings, CLASS_FIELD, "type=keyword") + .setMapping("text", textMappings, CLASS_FIELD, "type=keyword") ); String[] gb = { "0", "1" }; List indexRequestBuilderList = new ArrayList<>(); diff --git a/server/src/test/java/org/opensearch/transport/SniffConnectionStrategyTests.java b/server/src/test/java/org/opensearch/transport/SniffConnectionStrategyTests.java index 9cf4f06205e8c..60b8b68ec0feb 100644 --- a/server/src/test/java/org/opensearch/transport/SniffConnectionStrategyTests.java +++ b/server/src/test/java/org/opensearch/transport/SniffConnectionStrategyTests.java @@ -747,7 +747,7 @@ public void testGetNodePredicateNodeRoles() { "id", address, Collections.emptyMap(), - new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.MASTER_ROLE)), + new HashSet<>(Arrays.asList(DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)), Version.CURRENT ); assertTrue(nodePredicate.test(dataMaster)); @@ -757,7 +757,7 @@ public void testGetNodePredicateNodeRoles() { "id", address, Collections.emptyMap(), - new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE)), + new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)), Version.CURRENT ); assertFalse(nodePredicate.test(dedicatedMaster)); @@ -777,7 +777,7 @@ public void testGetNodePredicateNodeRoles() { "id", address, Collections.emptyMap(), - new HashSet<>(Arrays.asList(DiscoveryNodeRole.INGEST_ROLE, DiscoveryNodeRole.MASTER_ROLE)), + new HashSet<>(Arrays.asList(DiscoveryNodeRole.INGEST_ROLE, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)), Version.CURRENT ); assertTrue(nodePredicate.test(clusterManagerIngest)); @@ -855,7 +855,7 @@ public void testGetNodePredicatesCombination() { TransportAddress address = new TransportAddress(TransportAddress.META_ADDRESS, 0); Settings settings = Settings.builder().put("cluster.remote.node.attr", "gateway").build(); Predicate nodePredicate = SniffConnectionStrategy.getNodePredicate(settings); - Set dedicatedMasterRoles = new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE)); + Set dedicatedMasterRoles = new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)); Set allRoles = DiscoveryNodeRole.BUILT_IN_ROLES; { DiscoveryNode node = new DiscoveryNode( diff --git a/test/framework/src/main/java/org/opensearch/cluster/OpenSearchAllocationTestCase.java b/test/framework/src/main/java/org/opensearch/cluster/OpenSearchAllocationTestCase.java index e806548cee088..e42dd42b18da5 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/OpenSearchAllocationTestCase.java +++ b/test/framework/src/main/java/org/opensearch/cluster/OpenSearchAllocationTestCase.java @@ -149,7 +149,7 @@ public static AllocationDeciders randomAllocationDeciders(Settings settings, Clu } protected static Set MASTER_DATA_ROLES = Collections.unmodifiableSet( - new HashSet<>(Arrays.asList(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE)) + new HashSet<>(Arrays.asList(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE)) ); protected static DiscoveryNode newNode(String nodeId) { diff --git a/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java b/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java index 828496ebfa3a4..9841daa5f81b7 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java +++ b/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java @@ -1089,8 +1089,8 @@ protected Optional getDisruptableMockTransport(Transpo : Settings.builder() .put(nodeSettings) .putList( - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey(), - ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY) + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), + ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING.get(Settings.EMPTY) ) .build(); // suppress auto-bootstrap transportService = mockTransport.createTransportService( diff --git a/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java b/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java index 0e308e64617fe..291eee501c4df 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java +++ b/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java @@ -164,10 +164,10 @@ void reboot() { final Set roles = new HashSet<>(localNode.getRoles()); if (randomBoolean()) { - if (roles.contains(DiscoveryNodeRole.MASTER_ROLE)) { - roles.remove(DiscoveryNodeRole.MASTER_ROLE); + if (roles.contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)) { + roles.remove(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } else { - roles.add(DiscoveryNodeRole.MASTER_ROLE); + roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } } diff --git a/test/framework/src/main/java/org/opensearch/search/aggregations/metrics/AbstractNumericTestCase.java b/test/framework/src/main/java/org/opensearch/search/aggregations/metrics/AbstractNumericTestCase.java index 495eb73e3f39a..a4f6b97115bb0 100644 --- a/test/framework/src/main/java/org/opensearch/search/aggregations/metrics/AbstractNumericTestCase.java +++ b/test/framework/src/main/java/org/opensearch/search/aggregations/metrics/AbstractNumericTestCase.java @@ -76,7 +76,7 @@ public void setupSuiteScopeCluster() throws Exception { // two docs {value: 0} and {value : 2}, then building a histogram agg with interval 1 and with empty // buckets computed.. the empty bucket is the one associated with key "1". then each test will have // to check that this bucket exists with the appropriate sub aggregations. - prepareCreate("empty_bucket_idx").addMapping("type", "value", "type=integer").execute().actionGet(); + prepareCreate("empty_bucket_idx").setMapping("value", "type=integer").execute().actionGet(); builders = new ArrayList<>(); for (int i = 0; i < 2; i++) { builders.add( diff --git a/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java b/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java index e5d14333de828..ae32db5fe6032 100644 --- a/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/AbstractBuilderTestCase.java @@ -438,7 +438,7 @@ public void onRemoval(ShardId shardId, Accountable accountable) { "_doc", new CompressedXContent( Strings.toString( - PutMappingRequest.buildFromSimplifiedDef( + PutMappingRequest.simpleMapping( TEXT_FIELD_NAME, "type=text", KEYWORD_FIELD_NAME, diff --git a/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java index 081ca7c593cc0..6ae6f852b6e45 100644 --- a/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java @@ -157,7 +157,7 @@ import static org.apache.lucene.tests.util.LuceneTestCase.TEST_NIGHTLY; import static org.apache.lucene.tests.util.LuceneTestCase.rarely; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.common.unit.TimeValue.timeValueMillis; import static org.opensearch.common.unit.TimeValue.timeValueSeconds; import static org.opensearch.discovery.DiscoveryModule.DISCOVERY_TYPE_SETTING; @@ -434,8 +434,8 @@ public InternalTestCluster( RandomNumbers.randomIntBetween(random, 1, 4) ); // TODO: currently we only randomize "cluster.no_master_block" between "write" and "metadata_write", as "all" is fragile - // and fails shards when a cluster manager abdicates, which breaks many tests. - builder.put(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey(), randomFrom(random, "write", "metadata_write")); + // and fails shards when a cluster-manager abdicates, which breaks many tests. + builder.put(NoMasterBlockService.NO_CLUSTER_MANAGER_BLOCK_SETTING.getKey(), randomFrom(random, "write", "metadata_write")); defaultSettings = builder.build(); executor = OpenSearchExecutors.newScaling( "internal_test_cluster_executor", @@ -617,7 +617,7 @@ private NodeAndClient getOrBuildRandomNode() { final int nodeId = nextNodeId.getAndIncrement(); final Settings settings = getNodeSettings(nodeId, random.nextLong(), Settings.EMPTY, 1); final Settings nodeSettings = Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), Node.NODE_NAME_SETTING.get(settings)) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), Node.NODE_NAME_SETTING.get(settings)) .put(settings) .build(); final NodeAndClient buildNode = buildNode(nodeId, nodeSettings, false, onTransportServiceStarted); @@ -788,13 +788,13 @@ private static String getRoleSuffix(Settings settings) { String suffix = ""; // only add the suffixes if roles are explicitly defined if (settings.hasValue("nodes.roles")) { - if (DiscoveryNode.hasRole(settings, DiscoveryNodeRole.MASTER_ROLE)) { - suffix = suffix + DiscoveryNodeRole.MASTER_ROLE.roleNameAbbreviation(); + if (DiscoveryNode.isMasterNode(settings)) { + suffix = suffix + DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleNameAbbreviation(); } if (DiscoveryNode.isDataNode(settings)) { suffix = suffix + DiscoveryNodeRole.DATA_ROLE.roleNameAbbreviation(); } - if (DiscoveryNode.hasRole(settings, DiscoveryNodeRole.MASTER_ROLE) == false && DiscoveryNode.isDataNode(settings) == false) { + if (!DiscoveryNode.isMasterNode(settings) && !DiscoveryNode.isDataNode(settings)) { suffix = suffix + "c"; } } @@ -991,8 +991,8 @@ Settings closeForRestart(RestartCallback callback, int minMasterNodes) throws Ex Settings.Builder newSettings = Settings.builder(); newSettings.put(callbackSettings); if (minMasterNodes >= 0) { - if (INITIAL_MASTER_NODES_SETTING.exists(callbackSettings) == false) { - newSettings.putList(INITIAL_MASTER_NODES_SETTING.getKey()); + if (INITIAL_CLUSTER_MANAGER_NODES_SETTING.exists(callbackSettings) == false) { + newSettings.putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey()); } } // delete data folders now, before we start other nodes that may claim it @@ -1178,7 +1178,7 @@ private synchronized void reset(boolean wipeData) throws IOException { Settings nodeSettings = updatedSettings.get(i); if (i == autoBootstrapMasterNodeIndex) { nodeSettings = Settings.builder() - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), clusterManagerNodeNames) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), clusterManagerNodeNames) .put(nodeSettings) .build(); } @@ -2040,7 +2040,7 @@ private List bootstrapClusterManagerNodeWithSpecifiedIndex(List startNodes(Settings... extraSettings) { final Builder builder = Settings.builder(); if (DiscoveryNode.isMasterNode(nodeSettings)) { if (autoBootstrapClusterManagerNodeIndex == 0) { - builder.putList(INITIAL_MASTER_NODES_SETTING.getKey(), initialClusterManagerNodes); + builder.putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), initialClusterManagerNodes); } autoBootstrapClusterManagerNodeIndex -= 1; } @@ -2153,7 +2153,7 @@ public List startMasterOnlyNodes(int numNodes) { } public List startMasterOnlyNodes(int numNodes, Settings settings) { - return startNodes(numNodes, Settings.builder().put(onlyRole(settings, DiscoveryNodeRole.MASTER_ROLE)).build()); + return startNodes(numNodes, Settings.builder().put(onlyRole(settings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)).build()); } public List startDataOnlyNodes(int numNodes) { diff --git a/test/framework/src/main/java/org/opensearch/test/NodeRoles.java b/test/framework/src/main/java/org/opensearch/test/NodeRoles.java index ed5f505e02304..64fd6b22e9805 100644 --- a/test/framework/src/main/java/org/opensearch/test/NodeRoles.java +++ b/test/framework/src/main/java/org/opensearch/test/NodeRoles.java @@ -80,6 +80,13 @@ public static Settings removeRoles(final Settings settings, final Set roles.contains(r) == false) + // TODO: Remove the below filter after removing MASTER_ROLE. + // It's used to remove both CLUSTER_MANAGER_ROLE and MASTER_ROLE, when requested to remove either. + .filter( + roles.contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE) || roles.contains(DiscoveryNodeRole.MASTER_ROLE) + ? r -> !r.isClusterManager() + : r -> true + ) .map(DiscoveryNodeRole::roleName) .collect(Collectors.toList()) ) @@ -166,7 +173,7 @@ public static Settings masterNode() { } public static Settings masterNode(final Settings settings) { - return addRoles(settings, Collections.singleton(DiscoveryNodeRole.MASTER_ROLE)); + return addRoles(settings, Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)); } public static Settings masterOnlyNode() { @@ -174,7 +181,7 @@ public static Settings masterOnlyNode() { } public static Settings masterOnlyNode(final Settings settings) { - return onlyRole(settings, DiscoveryNodeRole.MASTER_ROLE); + return onlyRole(settings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } public static Settings nonMasterNode() { @@ -182,7 +189,7 @@ public static Settings nonMasterNode() { } public static Settings nonMasterNode(final Settings settings) { - return removeRoles(settings, Collections.singleton(DiscoveryNodeRole.MASTER_ROLE)); + return removeRoles(settings, Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE)); } public static Settings remoteClusterClientNode() { diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java index fb4831f881092..e3f6e6019546b 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchSingleNodeTestCase.java @@ -78,7 +78,7 @@ import java.util.Collections; import java.util.concurrent.TimeUnit; -import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; +import static org.opensearch.cluster.coordination.ClusterBootstrapService.INITIAL_CLUSTER_MANAGER_NODES_SETTING; import static org.opensearch.discovery.SettingsBasedSeedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; import static org.opensearch.test.NodeRoles.dataNode; import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; @@ -241,7 +241,7 @@ private Node newNode() { // turn it off for these tests. .put(HierarchyCircuitBreakerService.USE_REAL_MEMORY_USAGE_SETTING.getKey(), false) .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey()) // empty list disables a port scan for other nodes - .putList(INITIAL_MASTER_NODES_SETTING.getKey(), nodeName) + .putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), nodeName) .put(nodeSettings()) // allow test cases to provide their own settings or override these .build(); @@ -320,10 +320,10 @@ protected IndexService createIndex(String index, Settings settings, String type, * @deprecated types are being removed */ @Deprecated - protected IndexService createIndex(String index, Settings settings, String type, Object... mappings) { + protected IndexService createIndex(String index, Settings settings, String type, String... mappings) { CreateIndexRequestBuilder createIndexRequestBuilder = client().admin().indices().prepareCreate(index).setSettings(settings); - if (type != null) { - createIndexRequestBuilder.addMapping(type, mappings); + if (mappings != null) { + createIndexRequestBuilder.setMapping(mappings); } return createIndex(index, createIndexRequestBuilder); } diff --git a/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java b/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java index cbd8dff645445..748b35f3bf701 100644 --- a/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java +++ b/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java @@ -398,17 +398,19 @@ public Path nodeConfigPath(int nodeOrdinal) { Function.identity() ); cluster.beforeTest(random()); + // TODO: Remove this line, and replace 'clusterManagerRole' with CLUSTER_MANAGER_ROLE, after MASTER_ROLE is removed. + // It is added in 2.0, along with the introduction of CLUSTER_MANAGER_ROLE, aims to test the 2 roles have the same effect. + DiscoveryNodeRole clusterManagerRole = randomFrom(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.MASTER_ROLE); List roles = new ArrayList<>(); for (int i = 0; i < numNodes; i++) { - final DiscoveryNodeRole role = i == numNodes - 1 && roles.contains(DiscoveryNodeRole.MASTER_ROLE) == false - ? DiscoveryNodeRole.MASTER_ROLE - : // last node and still no master - randomFrom(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.INGEST_ROLE); + final DiscoveryNodeRole role = i == numNodes - 1 && roles.contains(clusterManagerRole) == false + ? clusterManagerRole // last node and still no master + : randomFrom(clusterManagerRole, DiscoveryNodeRole.DATA_ROLE, DiscoveryNodeRole.INGEST_ROLE); roles.add(role); } cluster.setBootstrapMasterNodeIndex( - randomIntBetween(0, (int) roles.stream().filter(role -> role.equals(DiscoveryNodeRole.MASTER_ROLE)).count() - 1) + randomIntBetween(0, (int) roles.stream().filter(role -> role.equals(clusterManagerRole)).count() - 1) ); try { @@ -416,7 +418,7 @@ public Path nodeConfigPath(int nodeOrdinal) { for (int i = 0; i < numNodes; i++) { final DiscoveryNodeRole role = roles.get(i); final String node; - if (role == DiscoveryNodeRole.MASTER_ROLE) { + if (role == clusterManagerRole) { node = cluster.startMasterOnlyNode(); } else if (role == DiscoveryNodeRole.DATA_ROLE) { node = cluster.startDataOnlyNode(); @@ -438,7 +440,7 @@ public Path nodeConfigPath(int nodeOrdinal) { DiscoveryNode node = cluster.getInstance(ClusterService.class, name).localNode(); List paths = Arrays.stream(getNodePaths(cluster, name)).map(Path::toString).collect(Collectors.toList()); if (node.isMasterNode()) { - result.computeIfAbsent(DiscoveryNodeRole.MASTER_ROLE, k -> new HashSet<>()).addAll(paths); + result.computeIfAbsent(clusterManagerRole, k -> new HashSet<>()).addAll(paths); } else if (node.isDataNode()) { result.computeIfAbsent(DiscoveryNodeRole.DATA_ROLE, k -> new HashSet<>()).addAll(paths); } else {