diff --git a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MappingIT.java b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MappingIT.java index d3f5e6ddbcc07..35b0952b2d713 100644 --- a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MappingIT.java +++ b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MappingIT.java @@ -10,8 +10,12 @@ import org.elasticsearch.Version; import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; +import org.elasticsearch.common.Strings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.support.XContentMapValues; +import java.io.IOException; + public class MappingIT extends AbstractRollingTestCase { /** * Create a mapping that explicitly disables the _all field (possible in 6x, see #37429) @@ -48,4 +52,28 @@ public void testAllFieldDisable6x() throws Exception { break; } } + + public void testMapperDynamicIndexSetting() throws IOException { + assumeTrue("Setting not removed before 7.0", UPGRADE_FROM_VERSION.onOrAfter(Version.V_7_0_0)); + switch (CLUSTER_TYPE) { + case OLD: + createIndex("my-index", Settings.EMPTY); + + Request request = new Request("PUT", "/my-index/_settings"); + request.setJsonEntity(Strings.toString(Settings.builder().put("index.mapper.dynamic", true).build())); + request.setOptions( + expectWarnings( + "[index.mapper.dynamic] setting was deprecated in Elasticsearch and will be removed in a future release! " + + "See the breaking changes documentation for the next major version." + ) + ); + assertOK(client().performRequest(request)); + break; + case MIXED: + case UPGRADED: + ensureGreen("my-index"); + break; + } + } + } diff --git a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java index 624a297d351ed..ed402b6c40df5 100644 --- a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java +++ b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java @@ -823,4 +823,20 @@ public void testSoftDeletesDisabledWarning() throws Exception { ensureGreen(indexName); indexDocs(indexName, randomInt(100), randomInt(100)); } + + protected static void updateIndexSettings(String index, Settings.Builder settings) throws IOException { + Request request = new Request("PUT", "/" + index + "/_settings"); + request.setJsonEntity(Strings.toString(settings.build())); + if (UPGRADE_FROM_VERSION.before(Version.V_7_17_9)) { + // There is a bug (fixed in 7.17.9 and 8.7.0 where deprecation warnings could leak into ClusterApplierService#applyChanges) + // Below warnings are set (and leaking) from an index in this test case + request.setOptions(expectVersionSpecificWarnings(v -> { + v.compatible( + "[index.mapper.dynamic] setting was deprecated in Elasticsearch and will be removed in a future release! " + + "See the breaking changes documentation for the next major version." + ); + })); + } + assertOK(client().performRequest(request)); + } }