Search in sources :

Example 1 with ExceptionsHelper

use of org.opensearch.ExceptionsHelper in project OpenSearch by opensearch-project.

the class AsyncBulkByScrollActionTests method testStartNextScrollRetriesOnRejectionAndSucceeds.

public void testStartNextScrollRetriesOnRejectionAndSucceeds() throws Exception {
    // this test primarily tests ClientScrollableHitSource but left it to test integration to status
    client.scrollsToReject = randomIntBetween(0, testRequest.getMaxRetries() - 1);
    // use fail() onResponse handler because mocked search never fires on listener.
    ClientScrollableHitSource hitSource = new ClientScrollableHitSource(logger, buildTestBackoffPolicy(), threadPool, testTask.getWorkerState()::countSearchRetry, r -> fail(), ExceptionsHelper::reThrowIfNotNull, new ParentTaskAssigningClient(client, localNode, testTask), testRequest.getSearchRequest());
    hitSource.setScroll(scrollId());
    hitSource.startNextScroll(TimeValue.timeValueSeconds(0));
    assertBusy(() -> assertEquals(client.scrollsToReject + 1, client.scrollAttempts.get()));
    if (listener.isDone()) {
        Object result = listener.get();
        fail("Expected listener not to be done but it was and had " + result);
    }
    assertBusy(() -> assertNotNull("There should be a scroll attempt pending that we didn't reject", client.lastScroll.get()));
    assertEquals(client.scrollsToReject, testTask.getStatus().getSearchRetries());
}
Also used : ExceptionsHelper(org.opensearch.ExceptionsHelper) ParentTaskAssigningClient(org.opensearch.client.ParentTaskAssigningClient)

Aggregations

ExceptionsHelper (org.opensearch.ExceptionsHelper)1 ParentTaskAssigningClient (org.opensearch.client.ParentTaskAssigningClient)1