Skip to content

Commit 20595e6

Browse files
authored
Adapt bwc after the backport of replicated closed indices (#39566)
This commit adapts the bwc layer et reenables the bwc tests after #39506 has been backported to 7.x. Related to #33888
1 parent fc3dd24 commit 20595e6

File tree

19 files changed

+45
-51
lines changed

19 files changed

+45
-51
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ task verifyVersions {
160160
* after the backport of the backcompat code is complete.
161161
*/
162162

163-
boolean bwc_tests_enabled = false
164-
final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/39506" /* place a PR link here when committing bwc changes */
163+
boolean bwc_tests_enabled = true
164+
final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
165165
if (bwc_tests_enabled == false) {
166166
if (bwc_tests_disabled_issue.isEmpty()) {
167167
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")

qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ public void testClosedIndices() throws Exception {
986986
closeIndex(index);
987987
}
988988

989-
if (getOldClusterVersion().onOrAfter(Version.V_8_0_0)) {
989+
if (getOldClusterVersion().onOrAfter(Version.V_7_1_0)) {
990990
ensureGreenLongWait(index);
991991
assertClosedIndex(index, true);
992992
} else {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public void testRecoveryClosedIndex() throws Exception {
341341
}
342342

343343
final Version indexVersionCreated = indexVersionCreated(indexName);
344-
if (indexVersionCreated.onOrAfter(Version.V_8_0_0)) {
344+
if (indexVersionCreated.onOrAfter(Version.V_7_1_0)) {
345345
// index was created on a version that supports the replication of closed indices,
346346
// so we expect the index to be closed and replicated
347347
ensureGreen(indexName);
@@ -370,7 +370,7 @@ public void testCloseIndexDuringRollingUpgrade() throws Exception {
370370
closeIndex(indexName);
371371
}
372372

373-
if (minimumNodeVersion.onOrAfter(Version.V_8_0_0)) {
373+
if (minimumNodeVersion.onOrAfter(Version.V_7_1_0)) {
374374
// index is created on a version that supports the replication of closed indices,
375375
// so we expect the index to be closed and replicated
376376
ensureGreen(indexName);

rest-api-spec/src/main/resources/rest-api-spec/test/cat.indices/10_basic.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
)
5151
$/
5252
---
53-
"Test cat indices output for closed index (pre 8.0.0)":
53+
"Test cat indices output for closed index (pre 7.1.0)":
5454
- skip:
55-
version: "8.0.0 - "
56-
reason: "closed indices are replicated starting version 8.0"
55+
version: "7.1.0 - "
56+
reason: "closed indices are replicated starting version 7.1.0"
5757

5858
- do:
5959
indices.create:
@@ -93,8 +93,8 @@
9393
---
9494
"Test cat indices output for closed index":
9595
- skip:
96-
version: " - 7.99.99"
97-
reason: "closed indices are replicated starting version 8.0"
96+
version: " - 7.0.99"
97+
reason: "closed indices are replicated starting version 7.1.0"
9898

9999
- do:
100100
indices.create:

rest-api-spec/src/main/resources/rest-api-spec/test/cat.recovery/10_basic.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
---
8080
"Test cat recovery output for closed index":
8181
- skip:
82-
version: " - 7.99.99"
83-
reason: closed indices are replicated starting version 8.0.0
82+
version: " - 7.0.99"
83+
reason: closed indices are replicated starting version 7.1.0
8484

8585
- do:
8686
indices.create:

rest-api-spec/src/main/resources/rest-api-spec/test/cluster.allocation_explain/10_basic.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
---
5959
"Cluster shard allocation explanation test with a closed index":
6060
- skip:
61-
version: " - 7.99.99"
62-
reason: closed indices are replicated starting version 8.0.0
61+
version: " - 7.0.99"
62+
reason: closed indices are replicated starting version 7.1.0
6363

6464
- do:
6565
indices.create:

rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/10_basic.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@
133133
- is_true: indices.test_index.shards
134134

135135
---
136-
"cluster health with closed index (pre 8.0)":
136+
"cluster health with closed index (pre 7.1.0)":
137137
- skip:
138-
version: "8.0.0 - "
139-
reason: "closed indices are replicated starting version 8.0"
138+
version: "7.1.0 - "
139+
reason: "closed indices are replicated starting version 7.1.0"
140140

141141
- do:
142142
indices.create:
@@ -209,8 +209,8 @@
209209
---
210210
"cluster health with closed index":
211211
- skip:
212-
version: " - 7.99.99"
213-
reason: "closed indices are replicated starting version 8.0"
212+
version: " - 7.0.99"
213+
reason: "closed indices are replicated starting version 7.1.0"
214214

215215
- do:
216216
indices.create:

rest-api-spec/src/main/resources/rest-api-spec/test/cluster.health/30_indices_options.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ setup:
3131
---
3232
"cluster health with expand_wildcards":
3333
- skip:
34-
version: " - 7.99.99"
35-
reason: "indices options has been introduced in cluster health request starting version 8.0"
34+
version: " - 7.0.99"
35+
reason: "indices options has been introduced in cluster health request starting version 7.1.0"
3636

3737
- do:
3838
cluster.health:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.open/10_basic.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
---
6666
"Close index with wait_for_active_shards set to all":
6767
- skip:
68-
version: " - 7.99.99"
69-
reason: "closed indices are replicated starting version 8.0"
68+
version: " - 7.0.99"
69+
reason: "closed indices are replicated starting version 7.1.0"
7070

7171
- do:
7272
indices.create:

rest-api-spec/src/main/resources/rest-api-spec/test/indices.recovery/10_basic.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
---
4343
"Indices recovery test for closed index":
4444
- skip:
45-
version: " - 7.99.99"
46-
reason: closed indices are replicated starting version 8.0.0
45+
version: " - 7.0.99"
46+
reason: closed indices are replicated starting version 7.1.0
4747

4848
- do:
4949
indices.create:

server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public ClusterHealthRequest(StreamInput in) throws IOException {
8484
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
8585
waitForNoInitializingShards = in.readBoolean();
8686
}
87-
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
87+
if (in.getVersion().onOrAfter(Version.V_7_1_0)) {
8888
indicesOptions = IndicesOptions.readIndicesOptions(in);
8989
} else {
9090
indicesOptions = IndicesOptions.lenientExpandOpen();
@@ -121,7 +121,7 @@ public void writeTo(StreamOutput out) throws IOException {
121121
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
122122
out.writeBoolean(waitForNoInitializingShards);
123123
}
124-
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
124+
if (out.getVersion().onOrAfter(Version.V_7_1_0)) {
125125
indicesOptions.writeIndicesOptions(out);
126126
}
127127
}

server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class CloseIndexRequest extends AcknowledgedRequest<CloseIndexRequest> im
4040

4141
private String[] indices;
4242
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen();
43-
private ActiveShardCount waitForActiveShards = ActiveShardCount.DEFAULT; // Changes this to NONE on 7.x to keep previous behavior
43+
private ActiveShardCount waitForActiveShards = ActiveShardCount.DEFAULT;
4444

4545
public CloseIndexRequest() {
4646
}
@@ -118,7 +118,7 @@ public void readFrom(StreamInput in) throws IOException {
118118
super.readFrom(in);
119119
indices = in.readStringArray();
120120
indicesOptions = IndicesOptions.readIndicesOptions(in);
121-
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
121+
if (in.getVersion().onOrAfter(Version.V_7_1_0)) {
122122
waitForActiveShards = ActiveShardCount.readFrom(in);
123123
} else {
124124
waitForActiveShards = ActiveShardCount.NONE;
@@ -130,7 +130,7 @@ public void writeTo(StreamOutput out) throws IOException {
130130
super.writeTo(out);
131131
out.writeStringArray(indices);
132132
indicesOptions.writeIndicesOptions(out);
133-
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
133+
if (out.getVersion().onOrAfter(Version.V_7_1_0)) {
134134
waitForActiveShards.writeTo(out);
135135
}
136136
}

server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ public CloseIndexResponse(final boolean acknowledged, final boolean shardsAcknow
3737
@Override
3838
public void readFrom(StreamInput in) throws IOException {
3939
super.readFrom(in);
40-
if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
40+
if (in.getVersion().onOrAfter(Version.V_7_1_0)) {
4141
readShardsAcknowledged(in);
4242
}
4343
}
4444

4545
@Override
4646
public void writeTo(StreamOutput out) throws IOException {
4747
super.writeTo(out);
48-
if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
48+
if (out.getVersion().onOrAfter(Version.V_7_1_0)) {
4949
writeShardsAcknowledged(out);
5050
}
5151
}

server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexStateService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ static ClusterState closeRoutingTable(final ClusterState currentState,
402402

403403
// Remove the index routing table of closed indices if the cluster is in a mixed version
404404
// that does not support the replication of closed indices
405-
final boolean removeRoutingTable = currentState.nodes().getMinNodeVersion().before(Version.V_8_0_0);
405+
final boolean removeRoutingTable = currentState.nodes().getMinNodeVersion().before(Version.V_7_1_0);
406406

407407
final MetaData.Builder metadata = MetaData.builder(currentState.metaData());
408408
final ClusterBlocks.Builder blocks = ClusterBlocks.builder().blocks(currentState.blocks());

server/src/test/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public void testSerialize() throws Exception {
5757

5858
public void testBwcSerialization() throws Exception {
5959
for (int runs = 0; runs < randomIntBetween(5, 20); runs++) {
60-
// Generate a random cluster health request in version < 8.0.0 and serializes it
60+
// Generate a random cluster health request in version < 7.1.0 and serializes it
6161
final BytesStreamOutput out = new BytesStreamOutput();
62-
out.setVersion(randomVersionBetween(random(), Version.V_6_3_0, getPreviousVersion(Version.V_8_0_0)));
62+
out.setVersion(randomVersionBetween(random(), Version.V_6_3_0, getPreviousVersion(Version.V_7_1_0)));
6363

6464
final ClusterHealthRequest expected = randomRequest();
6565
{
@@ -112,9 +112,9 @@ public void testBwcSerialization() throws Exception {
112112
// Generate a random cluster health request in current version
113113
final ClusterHealthRequest expected = randomRequest();
114114

115-
// Serialize to node in version < 8.0.0
115+
// Serialize to node in version < 7.1.0
116116
final BytesStreamOutput out = new BytesStreamOutput();
117-
out.setVersion(randomVersionBetween(random(), Version.V_6_3_0, getPreviousVersion(Version.V_8_0_0)));
117+
out.setVersion(randomVersionBetween(random(), Version.V_6_3_0, getPreviousVersion(Version.V_7_1_0)));
118118
expected.writeTo(out);
119119

120120
// Deserialize and check the cluster health request

server/src/test/java/org/elasticsearch/action/admin/indices/close/CloseIndexRequestTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void testBwcSerialization() throws Exception {
5454
{
5555
final CloseIndexRequest request = randomRequest();
5656
try (BytesStreamOutput out = new BytesStreamOutput()) {
57-
out.setVersion(randomVersionBetween(random(), Version.V_6_4_0, VersionUtils.getPreviousVersion(Version.V_8_0_0)));
57+
out.setVersion(randomVersionBetween(random(), Version.V_6_4_0, VersionUtils.getPreviousVersion(Version.V_7_1_0)));
5858
request.writeTo(out);
5959

6060
try (StreamInput in = out.bytes().streamInput()) {
@@ -77,7 +77,7 @@ public void testBwcSerialization() throws Exception {
7777

7878
final CloseIndexRequest deserializedRequest = new CloseIndexRequest();
7979
try (StreamInput in = out.bytes().streamInput()) {
80-
in.setVersion(randomVersionBetween(random(), Version.V_6_4_0, VersionUtils.getPreviousVersion(Version.V_8_0_0)));
80+
in.setVersion(randomVersionBetween(random(), Version.V_6_4_0, VersionUtils.getPreviousVersion(Version.V_7_1_0)));
8181
deserializedRequest.readFrom(in);
8282
}
8383
assertEquals(sample.getParentTask(), deserializedRequest.getParentTask());

server/src/test/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponseTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void testBwcSerialization() throws Exception {
4848
{
4949
final CloseIndexResponse response = randomResponse();
5050
try (BytesStreamOutput out = new BytesStreamOutput()) {
51-
out.setVersion(randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_8_0_0)));
51+
out.setVersion(randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_1_0)));
5252
response.writeTo(out);
5353

5454
final AcknowledgedResponse deserializedResponse = new AcknowledgedResponse();
@@ -65,7 +65,7 @@ public void testBwcSerialization() throws Exception {
6565

6666
final CloseIndexResponse deserializedResponse = new CloseIndexResponse();
6767
try (StreamInput in = out.bytes().streamInput()) {
68-
in.setVersion(randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_8_0_0)));
68+
in.setVersion(randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_1_0)));
6969
deserializedResponse.readFrom(in);
7070
}
7171
assertThat(deserializedResponse.isAcknowledged(), equalTo(response.isAcknowledged()));

server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataIndexStateServiceTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ public void testCloseRoutingTableRemovesRoutingTable() {
138138
state = ClusterState.builder(state)
139139
.nodes(DiscoveryNodes.builder(state.nodes())
140140
.add(new DiscoveryNode("old_node", buildNewFakeTransportAddress(), emptyMap(),
141-
new HashSet<>(Arrays.asList(DiscoveryNode.Role.values())), Version.V_7_1_0))
141+
new HashSet<>(Arrays.asList(DiscoveryNode.Role.values())), Version.V_7_0_0))
142142
.add(new DiscoveryNode("new_node", buildNewFakeTransportAddress(), emptyMap(),
143-
new HashSet<>(Arrays.asList(DiscoveryNode.Role.values())), Version.V_8_0_0)))
143+
new HashSet<>(Arrays.asList(DiscoveryNode.Role.values())), Version.V_7_1_0)))
144144
.build();
145145

146146
state = MetaDataIndexStateService.closeRoutingTable(state, blockedIndices, results);

server/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerIT.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package org.elasticsearch.indices;
2020

2121
import org.elasticsearch.ElasticsearchException;
22-
import org.elasticsearch.Version;
2322
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
2423
import org.elasticsearch.cluster.ClusterState;
2524
import org.elasticsearch.cluster.metadata.IndexMetaData;
@@ -212,13 +211,8 @@ public void testIndexStateShardChanged() throws Throwable {
212211
assertThat(stateChangeListenerNode1.afterCloseSettings.getAsInt(SETTING_NUMBER_OF_SHARDS, -1), equalTo(6));
213212
assertThat(stateChangeListenerNode1.afterCloseSettings.getAsInt(SETTING_NUMBER_OF_REPLICAS, -1), equalTo(1));
214213

215-
if (Version.CURRENT.onOrAfter(Version.V_8_0_0)) {
216-
assertShardStatesMatch(stateChangeListenerNode1, 6, CLOSED, CREATED, RECOVERING, POST_RECOVERY, STARTED);
217-
assertShardStatesMatch(stateChangeListenerNode2, 6, CLOSED, CREATED, RECOVERING, POST_RECOVERY, STARTED);
218-
} else {
219-
assertShardStatesMatch(stateChangeListenerNode1, 6, CLOSED);
220-
assertShardStatesMatch(stateChangeListenerNode2, 6, CLOSED);
221-
}
214+
assertShardStatesMatch(stateChangeListenerNode1, 6, CLOSED, CREATED, RECOVERING, POST_RECOVERY, STARTED);
215+
assertShardStatesMatch(stateChangeListenerNode2, 6, CLOSED, CREATED, RECOVERING, POST_RECOVERY, STARTED);
222216
}
223217

224218
private static void assertShardStatesMatch(final IndexShardStateChangeListener stateChangeListener,

0 commit comments

Comments
 (0)