diff --git a/core/src/test/java/org/elasticsearch/script/IndexLookupIT.java b/core/src/test/java/org/elasticsearch/script/IndexLookupIT.java index 981aab15ea4..c4558707794 100644 --- a/core/src/test/java/org/elasticsearch/script/IndexLookupIT.java +++ b/core/src/test/java/org/elasticsearch/script/IndexLookupIT.java @@ -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