Skip to content

Commit 55cc6e8

Browse files
authored
Scope index templates put during cluster upgrade tests (#58065)
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
1 parent 5e546c4 commit 55cc6e8

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,22 @@ public void testIndexing() throws IOException {
7777
{
7878
Version minimumIndexCompatibilityVersion = Version.CURRENT.minimumIndexCompatibilityVersion();
7979
assertThat("this branch is not needed if we aren't compatible with 6.0",
80-
minimumIndexCompatibilityVersion.onOrBefore(Version.V_6_0_0), equalTo(true));
80+
minimumIndexCompatibilityVersion.onOrBefore(Version.V_6_0_0), equalTo(true));
8181
if (minimumIndexCompatibilityVersion.before(Version.V_7_0_0)) {
8282
XContentBuilder template = jsonBuilder();
8383
template.startObject();
8484
{
85-
template.field("index_patterns", "*");
85+
template.array("index_patterns", "test_index", "index_with_replicas", "empty_index");
8686
template.startObject("settings");
8787
template.field("number_of_shards", 5);
8888
template.endObject();
8989
}
9090
template.endObject();
91-
Request createTemplate = new Request("PUT", "/_template/template");
91+
Request createTemplate = new Request("PUT", "/_template/prevent-bwc-deprecation-template");
9292
createTemplate.setJsonEntity(Strings.toString(template));
9393
client().performRequest(createTemplate);
9494
}
9595
}
96-
9796
Request createTestIndex = new Request("PUT", "/test_index");
9897
createTestIndex.setJsonEntity("{\"settings\": {\"index.number_of_replicas\": 0}}");
9998
client().performRequest(createTestIndex);

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
package org.elasticsearch.upgrades;
77

88
import org.apache.http.util.EntityUtils;
9+
import org.elasticsearch.Version;
10+
import org.elasticsearch.client.Request;
11+
import org.elasticsearch.client.Response;
912
import org.elasticsearch.common.Booleans;
1013
import org.elasticsearch.common.Strings;
1114
import org.elasticsearch.common.xcontent.XContentBuilder;
1215
import org.elasticsearch.rest.action.document.RestBulkAction;
13-
import org.elasticsearch.Version;
14-
import org.elasticsearch.client.Request;
15-
import org.elasticsearch.client.Response;
1616

1717
import java.io.IOException;
1818
import java.nio.charset.StandardCharsets;
@@ -56,23 +56,22 @@ public void testIndexing() throws IOException {
5656
{
5757
Version minimumIndexCompatibilityVersion = Version.CURRENT.minimumIndexCompatibilityVersion();
5858
assertThat("this branch is not needed if we aren't compatible with 6.0",
59-
minimumIndexCompatibilityVersion.onOrBefore(Version.V_6_0_0), equalTo(true));
59+
minimumIndexCompatibilityVersion.onOrBefore(Version.V_6_0_0), equalTo(true));
6060
if (minimumIndexCompatibilityVersion.before(Version.V_7_0_0)) {
6161
XContentBuilder template = jsonBuilder();
6262
template.startObject();
6363
{
64-
template.field("index_patterns", "*");
64+
template.array("index_patterns", "test_index", "index_with_replicas", "empty_index");
6565
template.startObject("settings");
6666
template.field("number_of_shards", 5);
6767
template.endObject();
6868
}
6969
template.endObject();
70-
Request createTemplate = new Request("PUT", "/_template/template");
70+
Request createTemplate = new Request("PUT", "/_template/xpack-prevent-bwc-deprecation-template");
7171
createTemplate.setJsonEntity(Strings.toString(template));
7272
client().performRequest(createTemplate);
7373
}
7474
}
75-
7675
Request createTestIndex = new Request("PUT", "/test_index");
7776
createTestIndex.setJsonEntity("{\"settings\": {\"index.number_of_replicas\": 0}}");
7877
client().performRequest(createTestIndex);

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,18 @@ public void testGeneratingTokensInOldCluster() throws Exception {
6363
{
6464
Version minimumIndexCompatibilityVersion = Version.CURRENT.minimumIndexCompatibilityVersion();
6565
assertThat("this branch is not needed if we aren't compatible with 6.0",
66-
minimumIndexCompatibilityVersion.onOrBefore(Version.V_6_0_0), equalTo(true));
66+
minimumIndexCompatibilityVersion.onOrBefore(Version.V_6_0_0), equalTo(true));
6767
if (minimumIndexCompatibilityVersion.before(Version.V_7_0_0)) {
6868
XContentBuilder template = jsonBuilder();
6969
template.startObject();
7070
{
71-
template.field("index_patterns", "*");
71+
template.field("index_patterns", "token_backwards_compatibility_it");
7272
template.startObject("settings");
7373
template.field("number_of_shards", 5);
7474
template.endObject();
7575
}
7676
template.endObject();
77-
Request createTemplate = new Request("PUT", "/_template/template");
77+
Request createTemplate = new Request("PUT", "/_template/gen-tokens-old-cluster-template");
7878
createTemplate.setJsonEntity(Strings.toString(template));
7979
client().performRequest(createTemplate);
8080
}
@@ -105,18 +105,18 @@ public void testRefreshingTokensInOldCluster() throws Exception {
105105
{
106106
Version minimumIndexCompatibilityVersion = Version.CURRENT.minimumIndexCompatibilityVersion();
107107
assertThat("this branch is not needed if we aren't compatible with 6.0",
108-
minimumIndexCompatibilityVersion.onOrBefore(Version.V_6_0_0), equalTo(true));
108+
minimumIndexCompatibilityVersion.onOrBefore(Version.V_6_0_0), equalTo(true));
109109
if (minimumIndexCompatibilityVersion.before(Version.V_7_0_0)) {
110110
XContentBuilder template = jsonBuilder();
111111
template.startObject();
112112
{
113-
template.field("index_patterns", "*");
113+
template.field("index_patterns", "token_backwards_compatibility_it");
114114
template.startObject("settings");
115115
template.field("number_of_shards", 5);
116116
template.endObject();
117117
}
118118
template.endObject();
119-
Request createTemplate = new Request("PUT", "/_template/template");
119+
Request createTemplate = new Request("PUT", "/_template/refresh-tokens-old-cluster-template");
120120
createTemplate.setJsonEntity(Strings.toString(template));
121121
client().performRequest(createTemplate);
122122
}
@@ -150,18 +150,18 @@ public void testInvalidatingTokensInOldCluster() throws Exception {
150150
{
151151
Version minimumIndexCompatibilityVersion = Version.CURRENT.minimumIndexCompatibilityVersion();
152152
assertThat("this branch is not needed if we aren't compatible with 6.0",
153-
minimumIndexCompatibilityVersion.onOrBefore(Version.V_6_0_0), equalTo(true));
153+
minimumIndexCompatibilityVersion.onOrBefore(Version.V_6_0_0), equalTo(true));
154154
if (minimumIndexCompatibilityVersion.before(Version.V_7_0_0)) {
155155
XContentBuilder template = jsonBuilder();
156156
template.startObject();
157157
{
158-
template.field("index_patterns", "*");
158+
template.field("index_patterns", "token_backwards_compatibility_it");
159159
template.startObject("settings");
160160
template.field("number_of_shards", 5);
161161
template.endObject();
162162
}
163163
template.endObject();
164-
Request createTemplate = new Request("PUT", "/_template/template");
164+
Request createTemplate = new Request("PUT", "/_template/invalid-tokens-old-cluster-template");
165165
createTemplate.setJsonEntity(Strings.toString(template));
166166
client().performRequest(createTemplate);
167167
}
@@ -228,7 +228,7 @@ public void testGeneratingTokensInMixedCluster() throws Exception {
228228
}
229229

230230
public void testRefreshingTokensInMixedCluster() throws Exception {
231-
// verify new nodes can refresh tokens created by old nodes and vice versa
231+
// verify new nodes can refresh tokens created by old nodes and vice versa
232232
assumeTrue("this test should only run against the mixed cluster", CLUSTER_TYPE == ClusterType.MIXED);
233233
for (RestClient client1 : twoClients) {
234234
Map<String, Object> responseMap = createTokens(client1, "test_user", "x-pack-test-password");

0 commit comments

Comments
 (0)