[TEST] wait for all shards to be allocated before IndexStatsTests runs

This commit is contained in:
Simon Willnauer 2014-11-29 20:11:21 +01:00
parent 539faf4e65
commit ca9abb1caf
1 changed files with 3 additions and 0 deletions

View File

@ -81,6 +81,7 @@ public class IndexStatsTests extends ElasticsearchIntegrationTest {
@Test
public void testClearCacheFilterKeys() {
client().admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("index.number_of_shards", 2)).execute().actionGet();
ensureGreen();
client().prepareIndex("test", "type", "1").setSource("field", "value").execute().actionGet();
client().admin().indices().prepareRefresh().execute().actionGet();
@ -106,6 +107,7 @@ public class IndexStatsTests extends ElasticsearchIntegrationTest {
@Test
public void testFieldDataStats() {
client().admin().indices().prepareCreate("test").setSettings(ImmutableSettings.settingsBuilder().put("index.number_of_shards", 2)).execute().actionGet();
ensureGreen();
client().prepareIndex("test", "type", "1").setSource("field", "value1", "field2", "value1").execute().actionGet();
client().prepareIndex("test", "type", "2").setSource("field", "value2", "field2", "value2").execute().actionGet();
client().admin().indices().prepareRefresh().execute().actionGet();
@ -152,6 +154,7 @@ public class IndexStatsTests extends ElasticsearchIntegrationTest {
client().admin().indices().prepareCreate("test")
.setSettings(ImmutableSettings.settingsBuilder().put("index.number_of_replicas", 0).put("index.number_of_shards", 2))
.execute().actionGet();
ensureGreen();
client().admin().cluster().prepareHealth().setWaitForGreenStatus().execute().actionGet();
client().prepareIndex("test", "type", "1").setSource("field", "value1").execute().actionGet();
client().prepareIndex("test", "type", "2").setSource("field", "value2").execute().actionGet();