Skip to content

Commit

Permalink
Restore rolling upgrade test for the _all field
Browse files Browse the repository at this point in the history
This commit adapts the rolling upgrade test introduced in elastic#37808
to ignore runs that upgrade from a version on or after 7.0.

Closes elastic#41453
  • Loading branch information
jimczi committed Apr 23, 2019
1 parent a74ba7d commit 249338e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
4 changes: 4 additions & 0 deletions qa/rolling-upgrade/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ for (Version version : bwcVersions.wireCompatible) {
Task oldClusterTestRunner = tasks.getByName("${baseName}#oldClusterTestRunner")
oldClusterTestRunner.configure {
systemProperty 'tests.rest.suite', 'old_cluster'
systemProperty 'tests.upgrade_from_version', version.toString().replace('-SNAPSHOT', '')
}

Closure configureUpgradeCluster = {String name, Task lastRunner, int stopNode, Closure getOtherUnicastHostAddresses ->
Expand All @@ -95,6 +96,7 @@ for (Version version : bwcVersions.wireCompatible) {
Task oneThirdUpgradedTestRunner = tasks.getByName("${baseName}#oneThirdUpgradedTestRunner")
oneThirdUpgradedTestRunner.configure {
systemProperty 'tests.rest.suite', 'mixed_cluster'
systemProperty 'tests.upgrade_from_version', version.toString()
systemProperty 'tests.first_round', 'true'
finalizedBy "${baseName}#oldClusterTestCluster#node1.stop"
}
Expand All @@ -108,6 +110,7 @@ for (Version version : bwcVersions.wireCompatible) {
Task twoThirdsUpgradedTestRunner = tasks.getByName("${baseName}#twoThirdsUpgradedTestRunner")
twoThirdsUpgradedTestRunner.configure {
systemProperty 'tests.rest.suite', 'mixed_cluster'
systemProperty 'tests.upgrade_from_version', version.toString()
systemProperty 'tests.first_round', 'false'
finalizedBy "${baseName}#oldClusterTestCluster#node2.stop"
}
Expand All @@ -121,6 +124,7 @@ for (Version version : bwcVersions.wireCompatible) {
Task upgradedClusterTestRunner = tasks.getByName("${baseName}#upgradedClusterTestRunner")
upgradedClusterTestRunner.configure {
systemProperty 'tests.rest.suite', 'upgraded_cluster'
systemProperty 'tests.upgrade_from_version', version.toString()
/*
* Force stopping all the upgraded nodes after the test runner
* so they are alive during the test.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.elasticsearch.upgrades;

import org.elasticsearch.Version;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.rest.ESRestTestCase;

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

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

@Override
protected final boolean preserveIndicesUponCompletion() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.upgrades;

import org.elasticsearch.Version;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.xcontent.support.XContentMapValues;

public class MappingIT extends AbstractRollingTestCase {
/**
* Create a mapping that explicitly disables the _all field (possible in 6x, see #37429)
* and check that it can be upgraded to 7x.
*/
public void testAllFieldDisable6x() throws Exception {
assumeTrue("_all", UPGRADE_FROM_VERSION.before(Version.V_7_0_0));
switch (CLUSTER_TYPE) {
case OLD:
Request createTestIndex = new Request("PUT", "all-index");
createTestIndex.addParameter("include_type_name", "false");
createTestIndex.setJsonEntity(
"{ \"settings\": { \"index.number_of_shards\": 1 }, " +
"\"mappings\": {\"_all\": { \"enabled\": false }, \"properties\": { \"field\": { \"type\": \"text\" }}}}"
);
createTestIndex.setOptions(expectWarnings("[_all] is deprecated in 6.0+ and will be removed in 7.0. As a replacement," +
" " + "you can use [copy_to] on mapping fields to create your own catch all field."));
Response resp = client().performRequest(createTestIndex);
assertEquals(200, resp.getStatusLine().getStatusCode());
break;

default:
final Request request = new Request("GET", "all-index");
Response response = client().performRequest(request);
assertEquals(200, response.getStatusLine().getStatusCode());
Object enabled = XContentMapValues.extractValue("all-index.mappings._all.enabled", entityAsMap(response));
assertNotNull(enabled);
assertEquals(false, enabled);
break;
}
}
}

0 comments on commit 249338e

Please sign in to comment.