Skip to content

Commit da4cec7

Browse files
authored
Add rolling upgrade test for the index.mapper.dynamic index setting bug. (#109301)
This is for 7.17 branch only. The test in main branch would be a little bit different. Relates to #109160 and #96075
1 parent 4e08df5 commit da4cec7

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/MappingIT.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010
import org.elasticsearch.Version;
1111
import org.elasticsearch.client.Request;
1212
import org.elasticsearch.client.Response;
13+
import org.elasticsearch.common.Strings;
14+
import org.elasticsearch.common.settings.Settings;
1315
import org.elasticsearch.common.xcontent.support.XContentMapValues;
1416

17+
import java.io.IOException;
18+
1519
public class MappingIT extends AbstractRollingTestCase {
1620
/**
1721
* Create a mapping that explicitly disables the _all field (possible in 6x, see #37429)
@@ -48,4 +52,28 @@ public void testAllFieldDisable6x() throws Exception {
4852
break;
4953
}
5054
}
55+
56+
public void testMapperDynamicIndexSetting() throws IOException {
57+
assumeTrue("Setting not removed before 7.0", UPGRADE_FROM_VERSION.onOrAfter(Version.V_7_0_0));
58+
switch (CLUSTER_TYPE) {
59+
case OLD:
60+
createIndex("my-index", Settings.EMPTY);
61+
62+
Request request = new Request("PUT", "/my-index/_settings");
63+
request.setJsonEntity(Strings.toString(Settings.builder().put("index.mapper.dynamic", true).build()));
64+
request.setOptions(
65+
expectWarnings(
66+
"[index.mapper.dynamic] setting was deprecated in Elasticsearch and will be removed in a future release! "
67+
+ "See the breaking changes documentation for the next major version."
68+
)
69+
);
70+
assertOK(client().performRequest(request));
71+
break;
72+
case MIXED:
73+
case UPGRADED:
74+
ensureGreen("my-index");
75+
break;
76+
}
77+
}
78+
5179
}

qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,4 +823,20 @@ public void testSoftDeletesDisabledWarning() throws Exception {
823823
ensureGreen(indexName);
824824
indexDocs(indexName, randomInt(100), randomInt(100));
825825
}
826+
827+
protected static void updateIndexSettings(String index, Settings.Builder settings) throws IOException {
828+
Request request = new Request("PUT", "/" + index + "/_settings");
829+
request.setJsonEntity(Strings.toString(settings.build()));
830+
if (UPGRADE_FROM_VERSION.before(Version.V_7_17_9)) {
831+
// There is a bug (fixed in 7.17.9 and 8.7.0 where deprecation warnings could leak into ClusterApplierService#applyChanges)
832+
// Below warnings are set (and leaking) from an index in this test case
833+
request.setOptions(expectVersionSpecificWarnings(v -> {
834+
v.compatible(
835+
"[index.mapper.dynamic] setting was deprecated in Elasticsearch and will be removed in a future release! "
836+
+ "See the breaking changes documentation for the next major version."
837+
);
838+
}));
839+
}
840+
assertOK(client().performRequest(request));
841+
}
826842
}

0 commit comments

Comments
 (0)