Skip to content

Commit a8c3c5c

Browse files
authored
Restore rolling upgrade test for the _all field (#41462)
This commit adapts the rolling upgrade test introduced in #37808 to ignore runs that upgrade from a version on or after 7.0. Closes #41453
1 parent 615a021 commit a8c3c5c

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

qa/rolling-upgrade/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ for (Version version : bwcVersions.wireCompatible) {
7070
Task oldClusterTestRunner = tasks.getByName("${baseName}#oldClusterTestRunner")
7171
oldClusterTestRunner.configure {
7272
systemProperty 'tests.rest.suite', 'old_cluster'
73+
systemProperty 'tests.upgrade_from_version', version.toString().replace('-SNAPSHOT', '')
7374
}
7475

7576
Closure configureUpgradeCluster = {String name, Task lastRunner, int stopNode, Closure getOtherUnicastHostAddresses ->
@@ -95,6 +96,7 @@ for (Version version : bwcVersions.wireCompatible) {
9596
Task oneThirdUpgradedTestRunner = tasks.getByName("${baseName}#oneThirdUpgradedTestRunner")
9697
oneThirdUpgradedTestRunner.configure {
9798
systemProperty 'tests.rest.suite', 'mixed_cluster'
99+
systemProperty 'tests.upgrade_from_version', version.toString()
98100
systemProperty 'tests.first_round', 'true'
99101
finalizedBy "${baseName}#oldClusterTestCluster#node1.stop"
100102
}
@@ -108,6 +110,7 @@ for (Version version : bwcVersions.wireCompatible) {
108110
Task twoThirdsUpgradedTestRunner = tasks.getByName("${baseName}#twoThirdsUpgradedTestRunner")
109111
twoThirdsUpgradedTestRunner.configure {
110112
systemProperty 'tests.rest.suite', 'mixed_cluster'
113+
systemProperty 'tests.upgrade_from_version', version.toString()
111114
systemProperty 'tests.first_round', 'false'
112115
finalizedBy "${baseName}#oldClusterTestCluster#node2.stop"
113116
}
@@ -121,6 +124,7 @@ for (Version version : bwcVersions.wireCompatible) {
121124
Task upgradedClusterTestRunner = tasks.getByName("${baseName}#upgradedClusterTestRunner")
122125
upgradedClusterTestRunner.configure {
123126
systemProperty 'tests.rest.suite', 'upgraded_cluster'
127+
systemProperty 'tests.upgrade_from_version', version.toString()
124128
/*
125129
* Force stopping all the upgraded nodes after the test runner
126130
* so they are alive during the test.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.elasticsearch.upgrades;
2020

21+
import org.elasticsearch.Version;
2122
import org.elasticsearch.common.settings.Settings;
2223
import org.elasticsearch.test.rest.ESRestTestCase;
2324

@@ -42,6 +43,7 @@ public static ClusterType parse(String value) {
4243
}
4344

4445
protected static final ClusterType CLUSTER_TYPE = ClusterType.parse(System.getProperty("tests.rest.suite"));
46+
protected static final Version UPGRADE_FROM_VERSION = Version.fromString(System.getProperty("tests.upgrade_from_version"));
4547

4648
@Override
4749
protected final boolean preserveIndicesUponCompletion() {
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.elasticsearch.upgrades;
20+
21+
import org.elasticsearch.Version;
22+
import org.elasticsearch.client.Request;
23+
import org.elasticsearch.client.Response;
24+
import org.elasticsearch.common.xcontent.support.XContentMapValues;
25+
26+
public class MappingIT extends AbstractRollingTestCase {
27+
/**
28+
* Create a mapping that explicitly disables the _all field (possible in 6x, see #37429)
29+
* and check that it can be upgraded to 7x.
30+
*/
31+
public void testAllFieldDisable6x() throws Exception {
32+
assumeTrue("_all", UPGRADE_FROM_VERSION.before(Version.V_7_0_0));
33+
switch (CLUSTER_TYPE) {
34+
case OLD:
35+
Request createTestIndex = new Request("PUT", "all-index");
36+
createTestIndex.addParameter("include_type_name", "false");
37+
createTestIndex.setJsonEntity(
38+
"{ \"settings\": { \"index.number_of_shards\": 1 }, " +
39+
"\"mappings\": {\"_all\": { \"enabled\": false }, \"properties\": { \"field\": { \"type\": \"text\" }}}}"
40+
);
41+
createTestIndex.setOptions(expectWarnings("[_all] is deprecated in 6.0+ and will be removed in 7.0. As a replacement," +
42+
" " + "you can use [copy_to] on mapping fields to create your own catch all field."));
43+
Response resp = client().performRequest(createTestIndex);
44+
assertEquals(200, resp.getStatusLine().getStatusCode());
45+
break;
46+
47+
default:
48+
final Request request = new Request("GET", "all-index");
49+
Response response = client().performRequest(request);
50+
assertEquals(200, response.getStatusLine().getStatusCode());
51+
Object enabled = XContentMapValues.extractValue("all-index.mappings._all.enabled", entityAsMap(response));
52+
assertNotNull(enabled);
53+
assertEquals(false, enabled);
54+
break;
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)