From 4b813adf522a76128736658ac69e2731363abd77 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Wed, 23 Aug 2017 14:23:14 +0930 Subject: [PATCH] [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. --- .../search/basic/SearchWhileCreatingIndexIT.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java b/core/src/test/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java index c83b3ccc9e5..1ed396672b5 100644 --- a/core/src/test/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java +++ b/core/src/test/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java @@ -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"); } }