Test fix - faulty assumptions about when exceptions are thrown in relation to number of failing shards. (#23205)

Search exceptions are thrown only when all shards report failure. Fix changes assertion logic to reflect this.

Closes #23203
This commit is contained in:
markharwood 2017-02-16 13:48:17 +00:00 committed by GitHub
parent ced99dde50
commit 1cd1ff6010
1 changed files with 7 additions and 3 deletions

View File

@ -580,15 +580,19 @@ public class IndexLookupIT extends ESIntegTestCase {
.addScriptField("tvtest", script)
.get();
assertThat(numPrimaries, greaterThan(1));
// (partial) success when at least one shard succeeds
assertThat(numPrimaries, greaterThan(response.getShardFailures().length));
assertThat(response.getFailedShards(), greaterThanOrEqualTo(1));
for (ShardSearchFailure failure : response.getShardFailures()) {
assertThat(failure.reason(), containsString(expectedError));
}
} catch (SearchPhaseExecutionException e) {
assertThat(numPrimaries, equalTo(1));
assertThat(e.toString(), containsString(expectedError));
// Exception thrown when *all* shards fail
assertThat(numPrimaries, equalTo(e.shardFailures().length));
for (ShardSearchFailure failure : e.shardFailures()) {
assertThat(failure.reason(), containsString(expectedError));
}
}
// Should not throw an exception this way round