Skip to content

Commit b9fbe66

Browse files
authored
Drop pre-7.2.0 wire format in ClusterHealthRequest (#79551)
Removes some branches in `ClusterHealthRequest` that are never hit in 8.0.0 and beyond, except for tests, and also drops the tests that hit these branches. Closes #79454
1 parent b9ca755 commit b9fbe66

File tree

2 files changed

+2
-92
lines changed

2 files changed

+2
-92
lines changed

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
package org.elasticsearch.action.admin.cluster.health;
1010

11-
import org.elasticsearch.Version;
1211
import org.elasticsearch.action.ActionRequestValidationException;
1312
import org.elasticsearch.action.IndicesRequest;
1413
import org.elasticsearch.action.support.ActiveShardCount;
@@ -64,11 +63,7 @@ public ClusterHealthRequest(StreamInput in) throws IOException {
6463
waitForEvents = Priority.readFrom(in);
6564
}
6665
waitForNoInitializingShards = in.readBoolean();
67-
if (in.getVersion().onOrAfter(Version.V_7_2_0)) {
68-
indicesOptions = IndicesOptions.readIndicesOptions(in);
69-
} else {
70-
indicesOptions = IndicesOptions.lenientExpandOpen();
71-
}
66+
indicesOptions = IndicesOptions.readIndicesOptions(in);
7267
return200ForClusterHealthTimeout = in.readBoolean();
7368
}
7469

@@ -97,9 +92,7 @@ public void writeTo(StreamOutput out) throws IOException {
9792
Priority.writeTo(waitForEvents, out);
9893
}
9994
out.writeBoolean(waitForNoInitializingShards);
100-
if (out.getVersion().onOrAfter(Version.V_7_2_0)) {
101-
indicesOptions.writeIndicesOptions(out);
102-
}
95+
indicesOptions.writeIndicesOptions(out);
10396
out.writeBoolean(return200ForClusterHealthTimeout);
10497
}
10598

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

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,16 @@
88

99
package org.elasticsearch.action.admin.cluster.health;
1010

11-
import org.elasticsearch.Version;
1211
import org.elasticsearch.action.support.IndicesOptions;
1312
import org.elasticsearch.cluster.health.ClusterHealthStatus;
1413
import org.elasticsearch.common.Priority;
1514
import org.elasticsearch.common.Strings;
1615
import org.elasticsearch.common.io.stream.BytesStreamOutput;
1716
import org.elasticsearch.common.io.stream.StreamInput;
1817
import org.elasticsearch.test.ESTestCase;
19-
import org.elasticsearch.test.VersionUtils;
2018

2119
import java.util.Locale;
2220

23-
import static org.elasticsearch.test.VersionUtils.getPreviousVersion;
24-
import static org.elasticsearch.test.VersionUtils.randomVersionBetween;
2521
import static org.hamcrest.core.IsEqual.equalTo;
2622

2723
public class ClusterHealthRequestTests extends ESTestCase {
@@ -51,85 +47,6 @@ public void testRequestReturnsHiddenIndicesByDefault() {
5147
assertTrue(defaultRequest.indicesOptions().expandWildcardsHidden());
5248
}
5349

54-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/79454")
55-
public void testBwcSerialization() throws Exception {
56-
for (int runs = 0; runs < randomIntBetween(5, 20); runs++) {
57-
// Generate a random cluster health request in version < 7.2.0 and serializes it
58-
final BytesStreamOutput out = new BytesStreamOutput();
59-
out.setVersion(randomVersionBetween(random(), VersionUtils.getFirstVersion(), getPreviousVersion(Version.V_7_2_0)));
60-
61-
final ClusterHealthRequest expected = randomRequest();
62-
{
63-
expected.getParentTask().writeTo(out);
64-
out.writeTimeValue(expected.masterNodeTimeout());
65-
out.writeBoolean(expected.local());
66-
if (expected.indices() == null) {
67-
out.writeVInt(0);
68-
} else {
69-
out.writeVInt(expected.indices().length);
70-
for (String index : expected.indices()) {
71-
out.writeString(index);
72-
}
73-
}
74-
out.writeTimeValue(expected.timeout());
75-
if (expected.waitForStatus() == null) {
76-
out.writeBoolean(false);
77-
} else {
78-
out.writeBoolean(true);
79-
out.writeByte(expected.waitForStatus().value());
80-
}
81-
out.writeBoolean(expected.waitForNoRelocatingShards());
82-
expected.waitForActiveShards().writeTo(out);
83-
out.writeString(expected.waitForNodes());
84-
if (expected.waitForEvents() == null) {
85-
out.writeBoolean(false);
86-
} else {
87-
out.writeBoolean(true);
88-
Priority.writeTo(expected.waitForEvents(), out);
89-
}
90-
out.writeBoolean(expected.waitForNoInitializingShards());
91-
}
92-
93-
// Deserialize and check the cluster health request
94-
final StreamInput in = out.bytes().streamInput();
95-
in.setVersion(out.getVersion());
96-
final ClusterHealthRequest actual = new ClusterHealthRequest(in);
97-
98-
assertThat(actual.waitForStatus(), equalTo(expected.waitForStatus()));
99-
assertThat(actual.waitForNodes(), equalTo(expected.waitForNodes()));
100-
assertThat(actual.waitForNoInitializingShards(), equalTo(expected.waitForNoInitializingShards()));
101-
assertThat(actual.waitForNoRelocatingShards(), equalTo(expected.waitForNoRelocatingShards()));
102-
assertThat(actual.waitForActiveShards(), equalTo(expected.waitForActiveShards()));
103-
assertThat(actual.waitForEvents(), equalTo(expected.waitForEvents()));
104-
assertIndicesEquals(actual.indices(), expected.indices());
105-
assertThat(actual.indicesOptions(), equalTo(IndicesOptions.lenientExpandOpen()));
106-
}
107-
108-
for (int runs = 0; runs < randomIntBetween(5, 20); runs++) {
109-
// Generate a random cluster health request in current version
110-
final ClusterHealthRequest expected = randomRequest();
111-
112-
// Serialize to node in version < 7.2.0
113-
final BytesStreamOutput out = new BytesStreamOutput();
114-
out.setVersion(randomVersionBetween(random(), VersionUtils.getFirstVersion(), getPreviousVersion(Version.V_7_2_0)));
115-
expected.writeTo(out);
116-
117-
// Deserialize and check the cluster health request
118-
final StreamInput in = out.bytes().streamInput();
119-
in.setVersion(out.getVersion());
120-
final ClusterHealthRequest actual = new ClusterHealthRequest(in);
121-
122-
assertThat(actual.waitForStatus(), equalTo(expected.waitForStatus()));
123-
assertThat(actual.waitForNodes(), equalTo(expected.waitForNodes()));
124-
assertThat(actual.waitForNoInitializingShards(), equalTo(expected.waitForNoInitializingShards()));
125-
assertThat(actual.waitForNoRelocatingShards(), equalTo(expected.waitForNoRelocatingShards()));
126-
assertThat(actual.waitForActiveShards(), equalTo(expected.waitForActiveShards()));
127-
assertThat(actual.waitForEvents(), equalTo(expected.waitForEvents()));
128-
assertIndicesEquals(actual.indices(), expected.indices());
129-
assertThat(actual.indicesOptions(), equalTo(IndicesOptions.lenientExpandOpen()));
130-
}
131-
}
132-
13350
private ClusterHealthRequest randomRequest() {
13451
ClusterHealthRequest request = new ClusterHealthRequest();
13552
request.waitForStatus(randomFrom(ClusterHealthStatus.values()));

0 commit comments

Comments
 (0)