Skip to content

Commit 907476f

Browse files
committed
iter
1 parent 4438d9f commit 907476f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

x-pack/qa/rolling-upgrade/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ buildParams.bwcVersions.withWireCompatible { bwcVersion, baseName ->
6666
setting 'xpack.security.transport.ssl.key', 'testnode.pem'
6767
setting 'xpack.security.transport.ssl.certificate', 'testnode.crt'
6868
keystore 'xpack.security.transport.ssl.secure_key_passphrase', 'testnode'
69+
if (bwcVersion.before('9.1.0')) {
70+
jvmArgs '-da:org.elasticsearch.index.mapper.MapperService'
71+
jvmArgs '-da:org.elasticsearch.index.mapper.DocumentMapper'
72+
}
6973

7074
if (bwcVersion.onOrAfter('7.0.0')) {
7175
setting 'xpack.security.authc.realms.file.file1.order', '0'

x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/DataStreamsUpgradeIT.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ private void compareIndexMetadata(
217217
Map<String, Object> oldIndexMetadata = oldIndicesMetadata.get(oldIndexName);
218218
Map<String, Object> upgradedIndexMetadata = upgradedIndexEntry.getValue();
219219
compareSettings(oldIndexMetadata, upgradedIndexMetadata);
220-
assertThat("Mappings did not match", upgradedIndexMetadata.get("mappings"), equalTo(oldIndexMetadata.get("mappings")));
220+
compareMappings((Map<?, ?>) oldIndexMetadata.get("mappings"), (Map<?, ?>) upgradedIndexMetadata.get("mappings"));
221221
assertThat("ILM states did not match", upgradedIndexMetadata.get("ilm"), equalTo(oldIndexMetadata.get("ilm")));
222222
if (oldIndexName.equals(oldWriteIndex) == false) { // the old write index will have been rolled over by upgrade
223223
assertThat(
@@ -268,6 +268,21 @@ private void compareSettings(Map<String, Object> oldIndexMetadata, Map<String, O
268268
}
269269
}
270270

271+
private void compareMappings(Map<?, ?> oldMappings, Map<?, ?> upgradedMappings) {
272+
boolean ignoreSource = Version.fromString(UPGRADE_FROM_VERSION).before(Version.V_9_0_0);
273+
if (ignoreSource) {
274+
Map<?, ?> doc = (Map<?, ?>) oldMappings.get("_doc");
275+
if (doc != null) {
276+
Map<?, ?> sourceEntry = (Map<?, ?>) doc.get("_source");
277+
if (sourceEntry != null && sourceEntry.isEmpty()) {
278+
doc.remove("_source");
279+
}
280+
assert doc.containsKey("_source") == false;
281+
}
282+
}
283+
assertThat("Mappings did not match", upgradedMappings, equalTo(oldMappings));
284+
}
285+
271286
@SuppressWarnings("unchecked")
272287
private Map<String, Object> getIndexSettingsFromIndexMetadata(Map<String, Object> indexMetadata) {
273288
return (Map<String, Object>) ((Map<String, Object>) indexMetadata.get("settings")).get("index");

0 commit comments

Comments
 (0)