From ca9abb1caf50335e88d0846dcdbaf711450cd3a8 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Sat, 29 Nov 2014 20:11:21 +0100 Subject: [PATCH] [TEST] wait for all shards to be allocated before IndexStatsTests runs --- .../java/org/elasticsearch/indices/stats/IndexStatsTests.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/java/org/elasticsearch/indices/stats/IndexStatsTests.java b/src/test/java/org/elasticsearch/indices/stats/IndexStatsTests.java index 7acbbdfb12a..6feb41c9faf 100644 --- a/src/test/java/org/elasticsearch/indices/stats/IndexStatsTests.java +++ b/src/test/java/org/elasticsearch/indices/stats/IndexStatsTests.java @@ -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();