Skip to content

Commit

Permalink
Add rolling upgrade test for the index.mapper.dynamic index setting bug.
Browse files Browse the repository at this point in the history
Forward port from elastic#109301 to main branch only, and also checks whether the setting gets archived.

Relates to elastic#109160 and elastic#96075
  • Loading branch information
martijnvg committed Jun 4, 2024
1 parent 191caca commit a1999c1
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@

import com.carrotsearch.randomizedtesting.annotations.Name;

import org.elasticsearch.Version;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.Maps;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.core.Strings;
import org.elasticsearch.test.rest.RestTestLegacyFeatures;
Expand Down Expand Up @@ -102,6 +104,30 @@ public void testOldIndexSettings() throws Exception {
}
}

public void testMapperDynamicIndexSetting() throws IOException {
assumeTrue("Setting not removed before 7.0", getOldClusterTestVersion().before("8.0.0"));
if (isOldCluster()) {
createIndex("my-index", Settings.EMPTY);

Request request = new Request("PUT", "/my-index/_settings");
request.setJsonEntity(org.elasticsearch.common.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));
} else {
ensureGreen("my-index");
if (isUpgradedCluster()) {
var indexSettings = getIndexSettings("my-index");
logger.error("indexSettings={}", indexSettings);
assertThat(XContentMapValues.extractValue("index.mapper.archived.dynamic", indexSettings), is(true));
}
}
}

private void assertCount(String index, int countAtLeast) throws IOException {
Request searchTestIndexRequest = new Request("POST", "/" + index + "/_search");
searchTestIndexRequest.addParameter(TOTAL_HITS_AS_INT_PARAM, "true");
Expand Down

0 comments on commit a1999c1

Please sign in to comment.