[TEST] Account for relocating primary in SearchWhileCreatingIndexIT

The test verifies that search on the primary works by executing a search with preference _primary. If the primary is relocating, however, it
does not take the primary relocation target into account. The test only makes sense, however, if balancing is not happening yet, i.e., the
cluster is not green.
This commit is contained in:
Yannick Welsch 2017-08-23 14:23:14 +09:30
parent cfff71aa64
commit 4b813adf52
1 changed files with 3 additions and 1 deletions

View File

@ -73,7 +73,7 @@ public class SearchWhileCreatingIndexIT extends ESIntegTestCase {
logger.info("using preference {}", preference);
// we want to make sure that while recovery happens, and a replica gets recovered, its properly refreshed
ClusterHealthStatus status = ClusterHealthStatus.RED;
ClusterHealthStatus status = client().admin().cluster().prepareHealth("test").get().getStatus();;
while (status != ClusterHealthStatus.GREEN) {
// first, verify that search on the primary search works
SearchResponse searchResponse = client().prepareSearch("test").setPreference("_primary").setQuery(QueryBuilders.termQuery("field", "test")).execute().actionGet();
@ -93,6 +93,8 @@ public class SearchWhileCreatingIndexIT extends ESIntegTestCase {
status = client().admin().cluster().prepareHealth("test").get().getStatus();
internalCluster().ensureAtLeastNumDataNodes(numberOfReplicas + 1);
}
SearchResponse searchResponse = client().prepareSearch("test").setQuery(QueryBuilders.termQuery("field", "test")).execute().actionGet();
assertHitCount(searchResponse, 1);
cluster().wipeIndices("test");
}
}