Wait for reloctations in utility methods

This commit is contained in:
Simon Willnauer 2013-06-14 21:59:43 +02:00
parent a4fc11b3d1
commit 25f19f8b87
2 changed files with 5 additions and 2 deletions

View File

@ -275,7 +275,7 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase {
public ClusterHealthStatus ensureGreen() {
ClusterHealthResponse actionGet = client().admin().cluster()
.health(Requests.clusterHealthRequest().waitForGreenStatus().waitForEvents(Priority.LANGUID)).actionGet();
.health(Requests.clusterHealthRequest().waitForGreenStatus().waitForEvents(Priority.LANGUID).waitForRelocatingShards(0)).actionGet();
assertThat(actionGet.isTimedOut(), equalTo(false));
assertThat(actionGet.getStatus(), equalTo(ClusterHealthStatus.GREEN));
return actionGet.getStatus();
@ -324,6 +324,7 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase {
}
protected RefreshResponse refresh() {
waitForRelocation();
// TODO RANDOMIZE with flush?
RefreshResponse actionGet = client().admin().indices().prepareRefresh().execute().actionGet();
assertNoFailures(actionGet);
@ -331,12 +332,14 @@ public abstract class AbstractSharedClusterTest extends ElasticsearchTestCase {
}
protected FlushResponse flush() {
waitForRelocation();
FlushResponse actionGet = client().admin().indices().prepareFlush().setRefresh(true).execute().actionGet();
assertNoFailures(actionGet);
return actionGet;
}
protected OptimizeResponse optimize() {
waitForRelocation();
OptimizeResponse actionGet = client().admin().indices().prepareOptimize().execute().actionGet();
assertNoFailures(actionGet);
return actionGet;

View File

@ -297,7 +297,7 @@ public class HighlighterSearchTests extends AbstractSharedClusterTest {
.endObject())
.execute().actionGet();
refresh();
ensureYellow();
ensureGreen();
SearchResponse search = client().prepareSearch().setQuery(matchQuery("name", "logica m")).addHighlightedField("name").execute().actionGet();
assertHighlight(search, 0, "name", 0, equalTo("<em>logica</em>c<em>m</em>g ehe<em>m</em>als avinci - the know how co<em>m</em>pany"));