Search in sources :

Example 1 with RetryPolicyConfig

use of io.druid.indexing.common.RetryPolicyConfig in project druid by druid-io.

the class RemoteTaskActionClientTest method testSubmitSimple.

@Test
public void testSubmitSimple() throws JsonProcessingException {
    // return status code 200 and a list with size equals 1
    Map<String, Object> responseBody = new HashMap<String, Object>();
    responseBody.put("result", result);
    String strResult = objectMapper.writeValueAsString(responseBody);
    StatusResponseHolder responseHolder = new StatusResponseHolder(HttpResponseStatus.OK, new StringBuilder().append(strResult));
    // set up mocks
    expect(selector.pick()).andReturn(server);
    replay(selector);
    expect(httpClient.go(anyObject(Request.class), anyObject(StatusResponseHandler.class))).andReturn(Futures.immediateFuture(responseHolder));
    replay(httpClient);
    Task task = new NoopTask("id", 0, 0, null, null, null);
    RemoteTaskActionClient client = new RemoteTaskActionClient(task, httpClient, selector, new RetryPolicyFactory(new RetryPolicyConfig()), objectMapper);
    try {
        result = client.submit(new LockListAction());
    } catch (IOException e) {
        Assert.fail("unexpected IOException");
    }
    Assert.assertEquals(1, result.size());
    EasyMock.verify(selector, httpClient);
}
Also used : Task(io.druid.indexing.common.task.Task) NoopTask(io.druid.indexing.common.task.NoopTask) RetryPolicyConfig(io.druid.indexing.common.RetryPolicyConfig) HashMap(java.util.HashMap) Request(com.metamx.http.client.Request) IOException(java.io.IOException) NoopTask(io.druid.indexing.common.task.NoopTask) RetryPolicyFactory(io.druid.indexing.common.RetryPolicyFactory) StatusResponseHolder(com.metamx.http.client.response.StatusResponseHolder) EasyMock.anyObject(org.easymock.EasyMock.anyObject) StatusResponseHandler(com.metamx.http.client.response.StatusResponseHandler) Test(org.junit.Test)

Aggregations

Request (com.metamx.http.client.Request)1 StatusResponseHandler (com.metamx.http.client.response.StatusResponseHandler)1 StatusResponseHolder (com.metamx.http.client.response.StatusResponseHolder)1 RetryPolicyConfig (io.druid.indexing.common.RetryPolicyConfig)1 RetryPolicyFactory (io.druid.indexing.common.RetryPolicyFactory)1 NoopTask (io.druid.indexing.common.task.NoopTask)1 Task (io.druid.indexing.common.task.Task)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 EasyMock.anyObject (org.easymock.EasyMock.anyObject)1 Test (org.junit.Test)1