@@ -165,10 +165,8 @@ public void testClusterHealthGreen() throws IOException {
165
165
assertThat (response .isTimedOut (), equalTo (false ));
166
166
assertThat (response .status (), equalTo (RestStatus .OK ));
167
167
assertThat (response .getStatus (), equalTo (ClusterHealthStatus .GREEN ));
168
- assertNoIndices (response );
169
168
}
170
169
171
- @ AwaitsFix (bugUrl ="https://github.com/elastic/elasticsearch/issues/35450" )
172
170
public void testClusterHealthYellowClusterLevel () throws IOException {
173
171
createIndex ("index" , Settings .EMPTY );
174
172
createIndex ("index2" , Settings .EMPTY );
@@ -178,15 +176,21 @@ public void testClusterHealthYellowClusterLevel() throws IOException {
178
176
179
177
logger .info ("Shard stats\n {}" , EntityUtils .toString (
180
178
client ().performRequest (new Request ("GET" , "/_cat/shards" )).getEntity ()));
181
- assertYellowShards (response );
182
179
assertThat (response .getIndices ().size (), equalTo (0 ));
183
180
}
184
181
185
- @ AwaitsFix (bugUrl ="https://github.com/elastic/elasticsearch/issues/35450" )
186
182
public void testClusterHealthYellowIndicesLevel () throws IOException {
187
- createIndex ("index" , Settings .EMPTY );
188
- createIndex ("index2" , Settings .EMPTY );
189
- ClusterHealthRequest request = new ClusterHealthRequest ();
183
+ String firstIndex = "index" ;
184
+ String secondIndex = "index2" ;
185
+ // including another index that we do not assert on, to ensure that we are not
186
+ // accidentally asserting on entire cluster state
187
+ String ignoredIndex = "tasks" ;
188
+ createIndex (firstIndex , Settings .EMPTY );
189
+ createIndex (secondIndex , Settings .EMPTY );
190
+ if (randomBoolean ()) {
191
+ createIndex (ignoredIndex , Settings .EMPTY );
192
+ }
193
+ ClusterHealthRequest request = new ClusterHealthRequest (firstIndex , secondIndex );
190
194
request .timeout ("5s" );
191
195
request .level (ClusterHealthRequest .Level .INDICES );
192
196
ClusterHealthResponse response = execute (request , highLevelClient ().cluster ()::health , highLevelClient ().cluster ()::healthAsync );
@@ -212,11 +216,9 @@ private static void assertYellowShards(ClusterHealthResponse response) {
212
216
assertThat (response .getDelayedUnassignedShards (), equalTo (0 ));
213
217
assertThat (response .getInitializingShards (), equalTo (0 ));
214
218
assertThat (response .getUnassignedShards (), equalTo (2 ));
215
- assertThat (response .getActiveShardsPercent (), equalTo (50d ));
216
219
}
217
220
218
-
219
- @ AwaitsFix (bugUrl ="https://github.com/elastic/elasticsearch/issues/35450" )
221
+
220
222
public void testClusterHealthYellowSpecificIndex () throws IOException {
221
223
createIndex ("index" , Settings .EMPTY );
222
224
createIndex ("index2" , Settings .EMPTY );
@@ -236,7 +238,6 @@ public void testClusterHealthYellowSpecificIndex() throws IOException {
236
238
assertThat (response .getDelayedUnassignedShards (), equalTo (0 ));
237
239
assertThat (response .getInitializingShards (), equalTo (0 ));
238
240
assertThat (response .getUnassignedShards (), equalTo (1 ));
239
- assertThat (response .getActiveShardsPercent (), equalTo (50d ));
240
241
assertThat (response .getIndices ().size (), equalTo (1 ));
241
242
Map .Entry <String , ClusterIndexHealth > index = response .getIndices ().entrySet ().iterator ().next ();
242
243
assertYellowIndex (index .getKey (), index .getValue (), false );
@@ -272,7 +273,19 @@ private static void assertYellowShard(int shardId, ClusterShardHealth shardHealt
272
273
assertThat (shardHealth .getRelocatingShards (), equalTo (0 ));
273
274
}
274
275
276
+ private static void assertNoIndices (ClusterHealthResponse response ) {
277
+ assertThat (response .getIndices (), equalTo (emptyMap ()));
278
+ assertThat (response .getActivePrimaryShards (), equalTo (0 ));
279
+ assertThat (response .getNumberOfDataNodes (), equalTo (1 ));
280
+ assertThat (response .getNumberOfNodes (), equalTo (1 ));
281
+ assertThat (response .getActiveShards (), equalTo (0 ));
282
+ assertThat (response .getDelayedUnassignedShards (), equalTo (0 ));
283
+ assertThat (response .getInitializingShards (), equalTo (0 ));
284
+ assertThat (response .getUnassignedShards (), equalTo (0 ));
285
+ }
286
+
275
287
public void testClusterHealthNotFoundIndex () throws IOException {
288
+ createIndex ("index" , Settings .EMPTY );
276
289
ClusterHealthRequest request = new ClusterHealthRequest ("notexisted-index" );
277
290
request .timeout ("5s" );
278
291
ClusterHealthResponse response = execute (request , highLevelClient ().cluster ()::health , highLevelClient ().cluster ()::healthAsync );
@@ -284,15 +297,4 @@ public void testClusterHealthNotFoundIndex() throws IOException {
284
297
assertNoIndices (response );
285
298
}
286
299
287
- private static void assertNoIndices (ClusterHealthResponse response ) {
288
- assertThat (response .getIndices (), equalTo (emptyMap ()));
289
- assertThat (response .getActivePrimaryShards (), equalTo (0 ));
290
- assertThat (response .getNumberOfDataNodes (), equalTo (1 ));
291
- assertThat (response .getNumberOfNodes (), equalTo (1 ));
292
- assertThat (response .getActiveShards (), equalTo (0 ));
293
- assertThat (response .getDelayedUnassignedShards (), equalTo (0 ));
294
- assertThat (response .getInitializingShards (), equalTo (0 ));
295
- assertThat (response .getUnassignedShards (), equalTo (0 ));
296
- assertThat (response .getActiveShardsPercent (), equalTo (100d ));
297
- }
298
300
}
0 commit comments