Skip to content

Commit

Permalink
Add rolling upgrade test for the index.mapper.dynamic index setting b…
Browse files Browse the repository at this point in the history
…ug. (#109301)

This is for 7.17 branch only. The test in main branch would be a little bit different.


Relates to #109160 and #96075
  • Loading branch information
martijnvg authored Jun 4, 2024
1 parent 4e08df5 commit da4cec7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
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));
}
}

0 comments on commit da4cec7

Please sign in to comment.