Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}