Fix FullClusterRestartIT.testHistoryUUIDIsAdded
This test failed once because the index wasn't fully ready
(ie, engine opened). This commit changes the test so that
it waits for the index to be green before checking the history
UUID.
Closes
@@ -57,6 +57,7 @@ import static org.elasticsearch.rest.BaseRestHandler.INCLUDE_TYPE_NAME_PARAMETER
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.notNullValue;
/**
@@ -934,10 +935,14 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
createIndex.setJsonEntity(Strings.toString(mappingsAndSettings));
client().performRequest(createIndex);
} else {
+ ensureGreenLongWait(index);
+
Request statsRequest = new Request("GET", index + "/_stats");
statsRequest.addParameter("level", "shards");
Response response = client().performRequest(statsRequest);
List<Object> shardStats = ObjectPath.createFromResponse(response).evaluate("indices." + index + ".shards.0");
+ assertThat(shardStats, notNullValue());
+ assertThat("Expected stats for 2 shards", shardStats, hasSize(2));
String globalHistoryUUID = null;
for (Object shard : shardStats) {
final String nodeId = ObjectPath.evaluate(shard, "routing.node");
