[TEST] Expect all shards failed in SearchWithRandomExceptionsTests
This commit is contained in:
parent
8076a31ac1
commit
ec5dbbaf51
|
@ -152,7 +152,7 @@ public class SearchWithRandomExceptionsTests extends ElasticsearchIntegrationTes
|
|||
}
|
||||
|
||||
}
|
||||
NumShards test = getNumShards("test");
|
||||
NumShards numShards = getNumShards("test");
|
||||
logger.info("Start Refresh");
|
||||
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;
|
||||
|
@ -165,20 +165,20 @@ public class SearchWithRandomExceptionsTests extends ElasticsearchIntegrationTes
|
|||
long expectedResults = added[docToQuery] ? 1 : 0;
|
||||
logger.info("Searching for [test:{}]", English.intToEnglish(docToQuery));
|
||||
SearchResponse searchResponse = client().prepareSearch().setTypes("type").setQuery(QueryBuilders.matchQuery("test", English.intToEnglish(docToQuery))).get();
|
||||
logger.info("Successful shards: [{}] numShards: [{}]", searchResponse.getSuccessfulShards(), test.numPrimaries);
|
||||
if (searchResponse.getSuccessfulShards() == test.numPrimaries && !refreshFailed) {
|
||||
logger.info("Successful shards: [{}] numShards: [{}]", searchResponse.getSuccessfulShards(), numShards.numPrimaries);
|
||||
if (searchResponse.getSuccessfulShards() == numShards.numPrimaries && !refreshFailed) {
|
||||
assertThat(searchResponse.getHits().getTotalHits(), Matchers.equalTo(expectedResults));
|
||||
}
|
||||
// check match all
|
||||
searchResponse = client().prepareSearch().setTypes("type").setQuery(QueryBuilders.matchAllQuery()).get();
|
||||
logger.info("Match all Successful shards: [{}] numShards: [{}]", searchResponse.getSuccessfulShards(), test.numPrimaries);
|
||||
if (searchResponse.getSuccessfulShards() == test.numPrimaries && !refreshFailed) {
|
||||
logger.info("Match all Successful shards: [{}] numShards: [{}]", searchResponse.getSuccessfulShards(), numShards.numPrimaries);
|
||||
if (searchResponse.getSuccessfulShards() == numShards.numPrimaries && !refreshFailed) {
|
||||
assertThat(searchResponse.getHits().getTotalHits(), Matchers.equalTo(numCreated));
|
||||
}
|
||||
} catch (SearchPhaseExecutionException ex) {
|
||||
if (expectAllShardsFailed || refreshResponse.getSuccessfulShards() == 0) {
|
||||
logger.info("expected SearchPhaseException: [{}]", ex.getMessage());
|
||||
} else {
|
||||
logger.info("SearchPhaseException: [{}]", ex.getMessage());
|
||||
// if a scheduled refresh or flush fails all shards we see all shards failed here
|
||||
if (!(expectAllShardsFailed || refreshResponse.getSuccessfulShards() == 0 || ex.getMessage().contains("all shards failed"))) {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue