[7.x] Scope index templates put during cluster upgrade tests (#58065) (#58122)

This template was added for 7.0 for what I am guessing is a BWC issue related to deprecation
warnings. It unfortunately seems to cause failures because templates for these tests are not cleared
after the test (because these are upgrade tests).

Resolves #56363
This commit is contained in:
Lee Hinman 2020-06-15 10:47:36 -06:00 committed by GitHub
parent 3635bd741c
commit d56d2dfb09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 21 deletions

View File

@ -82,18 +82,17 @@ public class IndexingIT extends AbstractRollingTestCase {
XContentBuilder template = jsonBuilder(); XContentBuilder template = jsonBuilder();
template.startObject(); template.startObject();
{ {
template.field("index_patterns", "*"); template.array("index_patterns", "test_index", "index_with_replicas", "empty_index");
template.startObject("settings"); template.startObject("settings");
template.field("number_of_shards", 5); template.field("number_of_shards", 5);
template.endObject(); template.endObject();
} }
template.endObject(); template.endObject();
Request createTemplate = new Request("PUT", "/_template/template"); Request createTemplate = new Request("PUT", "/_template/prevent-bwc-deprecation-template");
createTemplate.setJsonEntity(Strings.toString(template)); createTemplate.setJsonEntity(Strings.toString(template));
client().performRequest(createTemplate); client().performRequest(createTemplate);
} }
} }
Request createTestIndex = new Request("PUT", "/test_index"); Request createTestIndex = new Request("PUT", "/test_index");
createTestIndex.setJsonEntity("{\"settings\": {\"index.number_of_replicas\": 0}}"); createTestIndex.setJsonEntity("{\"settings\": {\"index.number_of_replicas\": 0}}");
client().performRequest(createTestIndex); client().performRequest(createTestIndex);

View File

@ -6,13 +6,13 @@
package org.elasticsearch.upgrades; package org.elasticsearch.upgrades;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.elasticsearch.Version;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.Booleans; import org.elasticsearch.common.Booleans;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.rest.action.document.RestBulkAction; import org.elasticsearch.rest.action.document.RestBulkAction;
import org.elasticsearch.Version;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -61,18 +61,17 @@ public class IndexingIT extends AbstractUpgradeTestCase {
XContentBuilder template = jsonBuilder(); XContentBuilder template = jsonBuilder();
template.startObject(); template.startObject();
{ {
template.field("index_patterns", "*"); template.array("index_patterns", "test_index", "index_with_replicas", "empty_index");
template.startObject("settings"); template.startObject("settings");
template.field("number_of_shards", 5); template.field("number_of_shards", 5);
template.endObject(); template.endObject();
} }
template.endObject(); template.endObject();
Request createTemplate = new Request("PUT", "/_template/template"); Request createTemplate = new Request("PUT", "/_template/xpack-prevent-bwc-deprecation-template");
createTemplate.setJsonEntity(Strings.toString(template)); createTemplate.setJsonEntity(Strings.toString(template));
client().performRequest(createTemplate); client().performRequest(createTemplate);
} }
} }
Request createTestIndex = new Request("PUT", "/test_index"); Request createTestIndex = new Request("PUT", "/test_index");
createTestIndex.setJsonEntity("{\"settings\": {\"index.number_of_replicas\": 0}}"); createTestIndex.setJsonEntity("{\"settings\": {\"index.number_of_replicas\": 0}}");
client().performRequest(createTestIndex); client().performRequest(createTestIndex);

View File

@ -68,13 +68,13 @@ public class TokenBackwardsCompatibilityIT extends AbstractUpgradeTestCase {
XContentBuilder template = jsonBuilder(); XContentBuilder template = jsonBuilder();
template.startObject(); template.startObject();
{ {
template.field("index_patterns", "*"); template.field("index_patterns", "token_backwards_compatibility_it");
template.startObject("settings"); template.startObject("settings");
template.field("number_of_shards", 5); template.field("number_of_shards", 5);
template.endObject(); template.endObject();
} }
template.endObject(); template.endObject();
Request createTemplate = new Request("PUT", "/_template/template"); Request createTemplate = new Request("PUT", "/_template/gen-tokens-old-cluster-template");
createTemplate.setJsonEntity(Strings.toString(template)); createTemplate.setJsonEntity(Strings.toString(template));
client().performRequest(createTemplate); client().performRequest(createTemplate);
} }
@ -110,13 +110,13 @@ public class TokenBackwardsCompatibilityIT extends AbstractUpgradeTestCase {
XContentBuilder template = jsonBuilder(); XContentBuilder template = jsonBuilder();
template.startObject(); template.startObject();
{ {
template.field("index_patterns", "*"); template.field("index_patterns", "token_backwards_compatibility_it");
template.startObject("settings"); template.startObject("settings");
template.field("number_of_shards", 5); template.field("number_of_shards", 5);
template.endObject(); template.endObject();
} }
template.endObject(); template.endObject();
Request createTemplate = new Request("PUT", "/_template/template"); Request createTemplate = new Request("PUT", "/_template/refresh-tokens-old-cluster-template");
createTemplate.setJsonEntity(Strings.toString(template)); createTemplate.setJsonEntity(Strings.toString(template));
client().performRequest(createTemplate); client().performRequest(createTemplate);
} }
@ -155,13 +155,13 @@ public class TokenBackwardsCompatibilityIT extends AbstractUpgradeTestCase {
XContentBuilder template = jsonBuilder(); XContentBuilder template = jsonBuilder();
template.startObject(); template.startObject();
{ {
template.field("index_patterns", "*"); template.field("index_patterns", "token_backwards_compatibility_it");
template.startObject("settings"); template.startObject("settings");
template.field("number_of_shards", 5); template.field("number_of_shards", 5);
template.endObject(); template.endObject();
} }
template.endObject(); template.endObject();
Request createTemplate = new Request("PUT", "/_template/template"); Request createTemplate = new Request("PUT", "/_template/invalid-tokens-old-cluster-template");
createTemplate.setJsonEntity(Strings.toString(template)); createTemplate.setJsonEntity(Strings.toString(template));
client().performRequest(createTemplate); client().performRequest(createTemplate);
} }