Fix sporadic failures in testCorruptedShards
Add assertBusy() to retry in case the shards are not yet all failed, and remove `@AwaitsFix`.
Resolves
@@ -151,7 +151,6 @@ public class IndicesShardStoreRequestIT extends ESIntegTestCase {
assertThat(shardStatuses.get(index1).size(), equalTo(2));
}
- @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/12416")
public void testCorruptedShards() throws Exception {
String index = "test";
internalCluster().ensureAtLeastNumDataNodes(2);
@@ -186,6 +185,7 @@ public class IndicesShardStoreRequestIT extends ESIntegTestCase {
}
}
+ assertBusy(() -> { // IndicesClusterStateService#failAndRemoveShard() called asynchronously but we need it to have completed here.
IndicesShardStoresResponse rsp = client().admin().indices().prepareShardStores(index).setShardStatuses("all").get();
ImmutableOpenIntMap<List<IndicesShardStoresResponse.StoreStatus>> shardStatuses = rsp.getStoreStatuses().get(index);
assertNotNull(shardStatuses);
@@ -194,12 +194,15 @@ public class IndicesShardStoreRequestIT extends ESIntegTestCase {
for (IndicesShardStoresResponse.StoreStatus status : shardStatus.value) {
if (corruptedShardIDMap.containsKey(shardStatus.key)
&& corruptedShardIDMap.get(shardStatus.key).contains(status.getNode().getName())) {
- assertThat(status.getStoreException(), notNullValue());
+ assertThat("shard [" + shardStatus.key + "] is failed on node [" + status.getNode().getName() + "]",
+ status.getStoreException(), notNullValue());
} else {
- assertNull(status.getStoreException());
+ assertNull("shard [" + shardStatus.key + "] is not failed on node [" + status.getNode().getName() + "]",
+ status.getStoreException());
}
}
}
+ });
logger.info("--> enable allocation");
enableAllocation(index);
}
