use of org.elasticsearch.action.bulk.byscroll.ScrollableHitSource.Response in project elasticsearch by elastic.
the class RemoteScrollableHitSourceTests method testParseRejection.
public void testParseRejection() throws Exception {
// The rejection comes through in the handler because the mocked http response isn't marked as an error
AtomicBoolean called = new AtomicBoolean();
// Handling a scroll rejection is the same as handling a search rejection so we reuse the verification code
Consumer<Response> checkResponse = r -> {
assertFalse(r.isTimedOut());
assertEquals(FAKE_SCROLL_ID, r.getScrollId());
assertEquals(4, r.getTotalHits());
assertThat(r.getFailures(), hasSize(1));
assertEquals("test", r.getFailures().get(0).getIndex());
assertEquals((Integer) 0, r.getFailures().get(0).getShardId());
assertEquals("87A7NvevQxSrEwMbtRCecg", r.getFailures().get(0).getNodeId());
assertThat(r.getFailures().get(0).getReason(), instanceOf(EsRejectedExecutionException.class));
assertEquals("rejected execution of org.elasticsearch.transport.TransportService$5@52d06af2 on " + "EsThreadPoolExecutor[search, queue capacity = 1000, org.elasticsearch.common.util.concurrent." + "EsThreadPoolExecutor@778ea553[Running, pool size = 7, active threads = 7, queued tasks = 1000, " + "completed tasks = 4182]]", r.getFailures().get(0).getReason().getMessage());
assertThat(r.getHits(), hasSize(1));
assertEquals("test", r.getHits().get(0).getIndex());
assertEquals("test", r.getHits().get(0).getType());
assertEquals("AVToMiC250DjIiBO3yJ_", r.getHits().get(0).getId());
assertEquals("{\"test\":\"test1\"}", r.getHits().get(0).getSource().utf8ToString());
called.set(true);
};
sourceWithMockedRemoteCall("rejection.json").doStart(checkResponse);
assertTrue(called.get());
called.set(false);
sourceWithMockedRemoteCall("rejection.json").doStartNextScroll("scroll", timeValueMillis(0), checkResponse);
assertTrue(called.get());
}
Aggregations