|
@@ -12,6 +12,7 @@ package org.elasticsearch.datastreams.logsdb;
|
|
|
import org.elasticsearch.client.Request;
|
|
|
import org.elasticsearch.client.ResponseException;
|
|
|
import org.elasticsearch.client.RestClient;
|
|
|
+import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.test.cluster.ElasticsearchCluster;
|
|
|
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
|
|
|
import org.junit.Before;
|
|
@@ -284,6 +285,55 @@ public class LogsIndexModeCustomSettingsIT extends LogsIndexModeRestTestIT {
|
|
|
assertThat(ignoreDynamicBeyondLimitIndexSetting, equalTo("false"));
|
|
|
}
|
|
|
|
|
|
+ public void testIgnoreMalformedSetting() throws IOException {
|
|
|
+ // with default template
|
|
|
+ {
|
|
|
+ assertOK(createDataStream(client, "logs-test-1"));
|
|
|
+ String logsIndex1 = getDataStreamBackingIndex(client, "logs-test-1", 0);
|
|
|
+ assertThat(getSetting(client, logsIndex1, "index.mapping.ignore_malformed"), equalTo("true"));
|
|
|
+ for (String newValue : List.of("false", "true")) {
|
|
|
+ closeIndex(logsIndex1);
|
|
|
+ updateIndexSettings(logsIndex1, Settings.builder().put("index.mapping.ignore_malformed", newValue));
|
|
|
+ assertThat(getSetting(client, logsIndex1, "index.mapping.ignore_malformed"), equalTo(newValue));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // with override template
|
|
|
+ {
|
|
|
+ var template = """
|
|
|
+ {
|
|
|
+ "template": {
|
|
|
+ "settings": {
|
|
|
+ "index": {
|
|
|
+ "mapping": {
|
|
|
+ "ignore_malformed": "false"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }""";
|
|
|
+ assertOK(putComponentTemplate(client, "logs@custom", template));
|
|
|
+ assertOK(createDataStream(client, "logs-custom-dev"));
|
|
|
+ String index = getDataStreamBackingIndex(client, "logs-custom-dev", 0);
|
|
|
+ assertThat(getSetting(client, index, "index.mapping.ignore_malformed"), equalTo("false"));
|
|
|
+ for (String newValue : List.of("true", "false")) {
|
|
|
+ closeIndex(index);
|
|
|
+ updateIndexSettings(index, Settings.builder().put("index.mapping.ignore_malformed", newValue));
|
|
|
+ assertThat(getSetting(client, index, "index.mapping.ignore_malformed"), equalTo(newValue));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // standard index
|
|
|
+ {
|
|
|
+ String index = "test-index";
|
|
|
+ createIndex(index);
|
|
|
+ assertThat(getSetting(client, index, "index.mapping.ignore_malformed"), equalTo("false"));
|
|
|
+ for (String newValue : List.of("false", "true")) {
|
|
|
+ closeIndex(index);
|
|
|
+ updateIndexSettings(index, Settings.builder().put("index.mapping.ignore_malformed", newValue));
|
|
|
+ assertThat(getSetting(client, index, "index.mapping.ignore_malformed"), equalTo(newValue));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private static Map<String, Object> getMapping(final RestClient client, final String indexName) throws IOException {
|
|
|
final Request request = new Request("GET", "/" + indexName + "/_mapping");
|
|
|
|