diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramTests.java index 954813916f4..3a23e9b10bd 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/DateHistogramTests.java @@ -83,6 +83,7 @@ public class DateHistogramTests extends ElasticsearchIntegrationTest { indexDoc(3, 2, 4), // date: Mar 2, dates: Mar 2, Apr 3 indexDoc(3, 15, 5), // date: Mar 15, dates: Mar 15, Apr 16 indexDoc(3, 23, 6)); // date: Mar 23, dates: Mar 23, Apr 24 + ensureSearchable(); } @Test @@ -828,8 +829,6 @@ public class DateHistogramTests extends ElasticsearchIntegrationTest { @Test public void unmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForGreenStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx_unmapped") .addAggregation(dateHistogram("histo").field("date").interval(DateHistogram.Interval.MONTH)) .execute().actionGet(); @@ -845,8 +844,6 @@ public class DateHistogramTests extends ElasticsearchIntegrationTest { @Test public void partiallyUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForGreenStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx", "idx_unmapped") .addAggregation(dateHistogram("histo").field("date").interval(DateHistogram.Interval.MONTH)) .execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/DateRangeTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/DateRangeTests.java index 67ab2b522b8..f6b702c5a0e 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/DateRangeTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/DateRangeTests.java @@ -98,6 +98,7 @@ public class DateRangeTests extends ElasticsearchIntegrationTest { } indexRandom(true, docs); + ensureSearchable(); } @Test @@ -890,8 +891,6 @@ public class DateRangeTests extends ElasticsearchIntegrationTest { @Test public void unmapped_WithStringDates() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForGreenStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx_unmapped") .addAggregation(dateRange("range") .field("date") @@ -938,8 +937,6 @@ public class DateRangeTests extends ElasticsearchIntegrationTest { @Test public void partiallyUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForGreenStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx", "idx_unmapped") .addAggregation(dateRange("range") .field("date") diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/DoubleTermsTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/DoubleTermsTests.java index e569f57975f..49514c029ce 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/DoubleTermsTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/DoubleTermsTests.java @@ -82,7 +82,7 @@ public class DoubleTermsTests extends ElasticsearchIntegrationTest { indexRandom(true, highCardBuilders); createIndex("idx_unmapped"); - + ensureSearchable(); } @Test @@ -544,8 +544,6 @@ public class DoubleTermsTests extends ElasticsearchIntegrationTest { @Test public void unmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx_unmapped").setTypes("type") .addAggregation(terms("terms") .field("value")) @@ -562,8 +560,6 @@ public class DoubleTermsTests extends ElasticsearchIntegrationTest { @Test public void partiallyUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForGreenStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx_unmapped", "idx").setTypes("type") .addAggregation(terms("terms") .field("value")) diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterTests.java index 3b21f44d67d..4870d2af914 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/FilterTests.java @@ -84,6 +84,7 @@ public class FilterTests extends ElasticsearchIntegrationTest { } indexRandom(true, builders.toArray(new IndexRequestBuilder[builders.size()])); ensureGreen(); + ensureSearchable(); } @Test diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceTests.java index 8c2a3c055b4..5d8924e027e 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceTests.java @@ -96,6 +96,7 @@ public class GeoDistanceTests extends ElasticsearchIntegrationTest { } indexRandom(true, cities); + ensureSearchable(); } @Test @@ -228,8 +229,6 @@ public class GeoDistanceTests extends ElasticsearchIntegrationTest { @Test public void partiallyUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx", "idx_unmapped") .addAggregation(geoDistance("amsterdam_rings") .field("location") diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/GlobalTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/GlobalTests.java index 73365630818..704773a88b2 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/GlobalTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/GlobalTests.java @@ -79,6 +79,7 @@ public class GlobalTests extends ElasticsearchIntegrationTest { .endObject())); } indexRandom(true, builders); + ensureSearchable(); } @Test diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramTests.java index bc4d0942fcc..3bab2429feb 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/HistogramTests.java @@ -99,7 +99,7 @@ public class HistogramTests extends ElasticsearchIntegrationTest { .endObject()); } indexRandom(true, builders); - + ensureSearchable(); } @Test @@ -708,8 +708,6 @@ public class HistogramTests extends ElasticsearchIntegrationTest { @Test public void unmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx_unmapped") .addAggregation(histogram("histo").field("value").interval(interval)) .execute().actionGet(); @@ -725,8 +723,6 @@ public class HistogramTests extends ElasticsearchIntegrationTest { @Test public void partiallyUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx", "idx_unmapped") .addAggregation(histogram("histo").field("value").interval(interval)) .execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/IPv4RangeTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/IPv4RangeTests.java index 84c7b415875..866bb793b5a 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/IPv4RangeTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/IPv4RangeTests.java @@ -75,7 +75,7 @@ public class IPv4RangeTests extends ElasticsearchIntegrationTest { } indexRandom(true, builders); createIndex("idx_unmapped"); - + ensureSearchable(); } @Test @@ -738,8 +738,6 @@ public class IPv4RangeTests extends ElasticsearchIntegrationTest { @Test public void unmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx_unmapped") .addAggregation(ipRange("range") .field("ip") @@ -786,8 +784,6 @@ public class IPv4RangeTests extends ElasticsearchIntegrationTest { @Test public void partiallyUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx", "idx_unmapped") .addAggregation(ipRange("range") .field("ip") diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/LongTermsTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/LongTermsTests.java index 0fc6049459c..40bf69e2aba 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/LongTermsTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/LongTermsTests.java @@ -27,7 +27,6 @@ import org.elasticsearch.search.aggregations.bucket.histogram.Histogram; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.metrics.sum.Sum; import org.elasticsearch.test.ElasticsearchIntegrationTest; -import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; @@ -81,6 +80,7 @@ public class LongTermsTests extends ElasticsearchIntegrationTest { } indexRandom(true, highCardBuilders); createIndex("idx_unmapped"); + ensureSearchable(); } @Test @@ -538,8 +538,6 @@ public class LongTermsTests extends ElasticsearchIntegrationTest { @Test public void unmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx_unmapped").setTypes("type") .addAggregation(terms("terms") .field("value")) @@ -556,8 +554,6 @@ public class LongTermsTests extends ElasticsearchIntegrationTest { @Test public void partiallyUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx_unmapped", "idx").setTypes("type") .addAggregation(terms("terms") .field("value")) diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingTests.java index d5e3908b886..90712b42e54 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/MissingTests.java @@ -88,13 +88,11 @@ public class MissingTests extends ElasticsearchIntegrationTest { indexRandom(true, builders.toArray(new IndexRequestBuilder[builders.size()])); ensureGreen(); // wait until we are ready to serve requests - + ensureSearchable(); } @Test public void unmapped() throws Exception { - client().admin().cluster().prepareHealth("unmapped_idx").setWaitForYellowStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("unmapped_idx") .addAggregation(missing("missing_tag").field("tag")) .execute().actionGet(); @@ -110,8 +108,6 @@ public class MissingTests extends ElasticsearchIntegrationTest { @Test public void partiallyUnmapped() throws Exception { - client().admin().cluster().prepareHealth("unmapped_idx").setWaitForYellowStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx", "unmapped_idx") .addAggregation(missing("missing_tag").field("tag")) .execute().actionGet(); diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedTests.java index 6ee8f2b36ea..e3ec48b707b 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/NestedTests.java @@ -98,6 +98,7 @@ public class NestedTests extends ElasticsearchIntegrationTest { builders.add(client().prepareIndex("idx", "type", ""+i+1).setSource(source)); } indexRandom(true, builders); + ensureSearchable(); } @Test @@ -141,7 +142,6 @@ public class NestedTests extends ElasticsearchIntegrationTest { @Test public void onNonNestedField() throws Exception { - try { client().prepareSearch("idx") .addAggregation(nested("nested").path("value") @@ -156,7 +156,6 @@ public class NestedTests extends ElasticsearchIntegrationTest { @Test public void nestedWithSubTermsAgg() throws Exception { - SearchResponse response = client().prepareSearch("idx") .addAggregation(nested("nested").path("nested") .subAggregation(terms("values").field("nested.value").size(100))) diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/RangeTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/RangeTests.java index 36ae457beb2..c07c76a03a7 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/RangeTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/RangeTests.java @@ -73,7 +73,7 @@ public class RangeTests extends ElasticsearchIntegrationTest { } indexRandom(true, builders); createIndex("idx_unmapped"); - + ensureSearchable(); } @Test @@ -729,8 +729,6 @@ public class RangeTests extends ElasticsearchIntegrationTest { @Test public void unmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx_unmapped") .addAggregation(range("range") .field("value") diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTermsTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTermsTests.java index 11a13976819..ad965c6c517 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTermsTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/ShardSizeTermsTests.java @@ -65,7 +65,6 @@ public class ShardSizeTermsTests extends ElasticsearchIntegrationTest { @Test public void noShardSize_string() throws Exception { - client().admin().indices().prepareCreate("idx") .addMapping("type", "key", "type=string,index=not_analyzed") .execute().actionGet(); @@ -348,6 +347,7 @@ public class ShardSizeTermsTests extends ElasticsearchIntegrationTest { assertThat(totalOnOne, is(15l)); long totalOnTwo = client().prepareSearch("idx").setTypes("type").setRouting("2").setQuery(matchAllQuery()).execute().actionGet().getHits().getTotalHits(); assertThat(totalOnTwo, is(12l)); + ensureSearchable(); } private void indexDoc(String shard, String key, int times, List indexOps) throws Exception { diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/StringTermsTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/StringTermsTests.java index f61853e1f23..bb5121a0754 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/StringTermsTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/StringTermsTests.java @@ -81,7 +81,7 @@ public class StringTermsTests extends ElasticsearchIntegrationTest { } indexRandom(true, highCardBuilders); createIndex("idx_unmapped"); - + ensureSearchable(); } @Test @@ -654,8 +654,6 @@ public class StringTermsTests extends ElasticsearchIntegrationTest { @Test public void unmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx_unmapped").setTypes("type") .addAggregation(terms("terms") .field("value")) @@ -671,8 +669,6 @@ public class StringTermsTests extends ElasticsearchIntegrationTest { @Test public void partiallyUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().execute().actionGet(); - SearchResponse response = client().prepareSearch("idx", "idx_unmapped").setTypes("type") .addAggregation(terms("terms") .field("value")) diff --git a/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTests.java b/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTests.java index 244ae66c5b0..69969e49a71 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/metrics/AbstractNumericTests.java @@ -72,6 +72,7 @@ public abstract class AbstractNumericTests extends ElasticsearchIntegrationTest .endObject())); } indexRandom(true, builders); + ensureSearchable(); } public abstract void testEmptyAggregation() throws Exception; diff --git a/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgTests.java b/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgTests.java index 9cfd36fa7c8..a6ca9dc41ec 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/metrics/AvgTests.java @@ -57,8 +57,6 @@ public class AvgTests extends AbstractNumericTests { @Test public void testUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForGreenStatus().execute().actionGet(); - SearchResponse searchResponse = client().prepareSearch("idx_unmapped") .setQuery(matchAllQuery()) .addAggregation(avg("avg").field("value")) diff --git a/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsTests.java b/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsTests.java index 806bcc0f438..f29c07b0f4e 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsTests.java @@ -77,8 +77,6 @@ public class ExtendedStatsTests extends AbstractNumericTests { @Test public void testUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForGreenStatus().execute().actionGet(); - SearchResponse searchResponse = client().prepareSearch("idx_unmapped") .setQuery(matchAllQuery()) .addAggregation(extendedStats("stats").field("value")) diff --git a/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxTests.java b/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxTests.java index 7867dc52089..e8b86349cd8 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/metrics/MaxTests.java @@ -56,7 +56,6 @@ public class MaxTests extends AbstractNumericTests { } @Test public void testUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForGreenStatus().execute().actionGet(); SearchResponse searchResponse = client().prepareSearch("idx_unmapped") .setQuery(matchAllQuery()) diff --git a/src/test/java/org/elasticsearch/search/aggregations/metrics/MinTests.java b/src/test/java/org/elasticsearch/search/aggregations/metrics/MinTests.java index ca87ce93853..5036135aec1 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/metrics/MinTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/metrics/MinTests.java @@ -57,8 +57,6 @@ public class MinTests extends AbstractNumericTests { @Test public void testUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForGreenStatus().execute().actionGet(); - SearchResponse searchResponse = client().prepareSearch("idx_unmapped") .setQuery(matchAllQuery()) .addAggregation(min("min").field("value")) diff --git a/src/test/java/org/elasticsearch/search/aggregations/metrics/StatsTests.java b/src/test/java/org/elasticsearch/search/aggregations/metrics/StatsTests.java index 21989fbb60b..c1177d753e8 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/metrics/StatsTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/metrics/StatsTests.java @@ -64,8 +64,6 @@ public class StatsTests extends AbstractNumericTests { @Test public void testUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForGreenStatus().execute().actionGet(); - SearchResponse searchResponse = client().prepareSearch("idx_unmapped") .setQuery(matchAllQuery()) .addAggregation(stats("stats").field("value")) diff --git a/src/test/java/org/elasticsearch/search/aggregations/metrics/SumTests.java b/src/test/java/org/elasticsearch/search/aggregations/metrics/SumTests.java index f0a1216d217..0740af9268d 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/metrics/SumTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/metrics/SumTests.java @@ -57,8 +57,6 @@ public class SumTests extends AbstractNumericTests { @Test public void testUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForGreenStatus().execute().actionGet(); - SearchResponse searchResponse = client().prepareSearch("idx_unmapped") .setQuery(matchAllQuery()) .addAggregation(sum("sum").field("value")) diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java index 983504d9a49..80e8a4cb1c0 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java @@ -438,9 +438,9 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase * It is useful to ensure that all action on the cluster have finished and all shards that were currently relocating * are now allocated and started. */ - public ClusterHealthStatus ensureGreen() { + public ClusterHealthStatus ensureGreen(String...indices) { ClusterHealthResponse actionGet = client().admin().cluster() - .health(Requests.clusterHealthRequest().waitForGreenStatus().waitForEvents(Priority.LANGUID).waitForRelocatingShards(0)).actionGet(); + .health(Requests.clusterHealthRequest(indices).waitForGreenStatus().waitForEvents(Priority.LANGUID).waitForRelocatingShards(0)).actionGet(); if (actionGet.isTimedOut()) { logger.info("ensureGreen timed out, cluster state:\n{}\n{}", client().admin().cluster().prepareState().get().getState().prettyPrint(), client().admin().cluster().preparePendingClusterTasks().get().prettyPrint()); assertThat("timed out waiting for green state", actionGet.isTimedOut(), equalTo(false)); @@ -480,9 +480,9 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase /** * Ensures the cluster has a yellow state via the cluster health API. */ - public ClusterHealthStatus ensureYellow() { + public ClusterHealthStatus ensureYellow(String...indices) { ClusterHealthResponse actionGet = client().admin().cluster() - .health(Requests.clusterHealthRequest().waitForRelocatingShards(0).waitForYellowStatus().waitForEvents(Priority.LANGUID)).actionGet(); + .health(Requests.clusterHealthRequest(indices).waitForRelocatingShards(0).waitForYellowStatus().waitForEvents(Priority.LANGUID)).actionGet(); if (actionGet.isTimedOut()) { logger.info("ensureYellow timed out, cluster state:\n{}\n{}", client().admin().cluster().prepareState().get().getState().prettyPrint(), client().admin().cluster().preparePendingClusterTasks().get().prettyPrint()); assertThat("timed out waiting for yellow", actionGet.isTimedOut(), equalTo(false)); @@ -490,6 +490,16 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase return actionGet.getStatus(); } + + /** + * Ensures the cluster is in a searchable state for the given indices. This means a searchable copy of each + * shard is available on the cluster. + */ + protected ClusterHealthStatus ensureSearchable(String...indices) { + // this is just a temporary thing but it's easier to change if it is encapsulated. + return ensureYellow(indices); + } + /** * Syntactic sugar for: *