|
8 | 8 |
|
9 | 9 | package org.elasticsearch.action.admin.cluster.health; |
10 | 10 |
|
11 | | -import org.elasticsearch.Version; |
12 | 11 | import org.elasticsearch.action.support.IndicesOptions; |
13 | 12 | import org.elasticsearch.cluster.health.ClusterHealthStatus; |
14 | 13 | import org.elasticsearch.common.Priority; |
15 | 14 | import org.elasticsearch.common.Strings; |
16 | 15 | import org.elasticsearch.common.io.stream.BytesStreamOutput; |
17 | 16 | import org.elasticsearch.common.io.stream.StreamInput; |
18 | 17 | import org.elasticsearch.test.ESTestCase; |
19 | | -import org.elasticsearch.test.VersionUtils; |
20 | 18 |
|
21 | 19 | import java.util.Locale; |
22 | 20 |
|
23 | | -import static org.elasticsearch.test.VersionUtils.getPreviousVersion; |
24 | | -import static org.elasticsearch.test.VersionUtils.randomVersionBetween; |
25 | 21 | import static org.hamcrest.core.IsEqual.equalTo; |
26 | 22 |
|
27 | 23 | public class ClusterHealthRequestTests extends ESTestCase { |
@@ -51,85 +47,6 @@ public void testRequestReturnsHiddenIndicesByDefault() { |
51 | 47 | assertTrue(defaultRequest.indicesOptions().expandWildcardsHidden()); |
52 | 48 | } |
53 | 49 |
|
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 | | - |
133 | 50 | private ClusterHealthRequest randomRequest() { |
134 | 51 | ClusterHealthRequest request = new ClusterHealthRequest(); |
135 | 52 | request.waitForStatus(randomFrom(ClusterHealthStatus.values())); |
|
0 commit comments