From 257eddd8f09b74f33a1d9ee7b1cdc64ca682d69e Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Tue, 1 Apr 2014 16:57:27 +0200 Subject: [PATCH] [TEST] Expect all shards to fail if full refresh failed --- .../search/basic/SearchWithRandomExceptionsTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/elasticsearch/search/basic/SearchWithRandomExceptionsTests.java b/src/test/java/org/elasticsearch/search/basic/SearchWithRandomExceptionsTests.java index 5a076adcb30..c2489a6ba10 100644 --- a/src/test/java/org/elasticsearch/search/basic/SearchWithRandomExceptionsTests.java +++ b/src/test/java/org/elasticsearch/search/basic/SearchWithRandomExceptionsTests.java @@ -151,7 +151,7 @@ public class SearchWithRandomExceptionsTests extends ElasticsearchIntegrationTes } NumShards test = getNumShards("test"); logger.info("Start Refresh"); - RefreshResponse refreshResponse = client().admin().indices().prepareRefresh("test").execute().get(); // don't assert on failures here + final RefreshResponse refreshResponse = client().admin().indices().prepareRefresh("test").execute().get(); // don't assert on failures here final boolean refreshFailed = refreshResponse.getShardFailures().length != 0 || refreshResponse.getFailedShards() != 0; logger.info("Refresh failed [{}] numShardsFailed: [{}], shardFailuresLength: [{}], successfulShards: [{}], totalShards: [{}] ", refreshFailed, refreshResponse.getFailedShards(), refreshResponse.getShardFailures().length, refreshResponse.getSuccessfulShards(), refreshResponse.getTotalShards()); final int numSearches = scaledRandomIntBetween(10, 20); @@ -165,10 +165,10 @@ public class SearchWithRandomExceptionsTests extends ElasticsearchIntegrationTes // check match all searchResponse = client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).get(); } catch (SearchPhaseExecutionException ex) { - if (!expectAllShardsFailed) { - throw ex; - } else { + if (expectAllShardsFailed || refreshResponse.getSuccessfulShards() == 0) { logger.info("expected SearchPhaseException: [{}]", ex.getMessage()); + } else { + throw ex; } } }