use of org.jboss.netty.buffer.BigEndianHeapChannelBuffer in project druid by druid-io.
the class HttpIndexingServiceClientTest method testGetTaskReport.
@Test
public void testGetTaskReport() throws Exception {
String taskId = "testTaskId";
HttpResponse response = EasyMock.createMock(HttpResponse.class);
EasyMock.expect(response.getStatus()).andReturn(HttpResponseStatus.OK).anyTimes();
EasyMock.expect(response.getContent()).andReturn(new BigEndianHeapChannelBuffer(0));
EasyMock.replay(response);
Map<String, Object> dummyResponse = ImmutableMap.of("test", "value");
StringFullResponseHolder responseHolder = new StringFullResponseHolder(response, StandardCharsets.UTF_8).addChunk(jsonMapper.writeValueAsString(dummyResponse));
EasyMock.expect(druidLeaderClient.go(EasyMock.anyObject(Request.class))).andReturn(responseHolder).anyTimes();
EasyMock.expect(druidLeaderClient.makeRequest(HttpMethod.GET, "/druid/indexer/v1/task/testTaskId/reports")).andReturn(new Request(HttpMethod.GET, new URL("http://localhost:8090/druid/indexer/v1/task/testTaskId/reports"))).anyTimes();
EasyMock.replay(druidLeaderClient);
final Map<String, Object> actualResponse = httpIndexingServiceClient.getTaskReport(taskId);
Assert.assertEquals(dummyResponse, actualResponse);
EasyMock.verify(druidLeaderClient, response);
}
use of org.jboss.netty.buffer.BigEndianHeapChannelBuffer in project druid by druid-io.
the class HttpIndexingServiceClientTest method testSampleError.
@Test
public void testSampleError() throws Exception {
expectedException.expect(RuntimeException.class);
expectedException.expectMessage("Failed to sample with sampler spec");
expectedException.expectMessage("Please check overlord log");
final SamplerResponse samplerResponse = new SamplerResponse(2, 2, ImmutableList.of(new SamplerResponse.SamplerResponseRow(ImmutableMap.of("time", "2020-01-01", "x", "123", "y", "456"), ImmutableMap.of("time", "2020-01-01", "x", "123", "y", "456"), false, null)));
final SamplerSpec samplerSpec = new SamplerSpec() {
@Override
public SamplerResponse sample() {
return samplerResponse;
}
};
HttpResponse response = EasyMock.createMock(HttpResponse.class);
EasyMock.expect(response.getStatus()).andReturn(HttpResponseStatus.INTERNAL_SERVER_ERROR).anyTimes();
EasyMock.expect(response.getContent()).andReturn(new BigEndianHeapChannelBuffer(0));
EasyMock.replay(response);
StringFullResponseHolder responseHolder = new StringFullResponseHolder(response, StandardCharsets.UTF_8).addChunk("");
EasyMock.expect(druidLeaderClient.go(EasyMock.anyObject(Request.class))).andReturn(responseHolder).anyTimes();
EasyMock.expect(druidLeaderClient.makeRequest(HttpMethod.POST, "/druid/indexer/v1/sampler")).andReturn(new Request(HttpMethod.POST, new URL("http://localhost:8090/druid/indexer/v1/sampler"))).anyTimes();
EasyMock.replay(druidLeaderClient);
httpIndexingServiceClient.sample(samplerSpec);
EasyMock.verify(druidLeaderClient, response);
}
use of org.jboss.netty.buffer.BigEndianHeapChannelBuffer in project druid by druid-io.
the class RemoteTaskActionClientTest method testSubmitSimple.
@Test
public void testSubmitSimple() throws Exception {
Request request = new Request(HttpMethod.POST, new URL("http://localhost:1234/xx"));
EasyMock.expect(druidLeaderClient.makeRequest(HttpMethod.POST, "/druid/indexer/v1/action")).andReturn(request);
// return status code 200 and a list with size equals 1
Map<String, Object> responseBody = new HashMap<>();
final List<TaskLock> expectedLocks = Collections.singletonList(new TimeChunkLock(TaskLockType.SHARED, "groupId", "dataSource", Intervals.of("2019/2020"), "version", 0));
responseBody.put("result", expectedLocks);
String strResult = objectMapper.writeValueAsString(responseBody);
final HttpResponse response = EasyMock.createNiceMock(HttpResponse.class);
EasyMock.expect(response.getStatus()).andReturn(HttpResponseStatus.OK).anyTimes();
EasyMock.expect(response.getContent()).andReturn(new BigEndianHeapChannelBuffer(0));
EasyMock.replay(response);
StringFullResponseHolder responseHolder = new StringFullResponseHolder(response, StandardCharsets.UTF_8).addChunk(strResult);
// set up mocks
EasyMock.expect(druidLeaderClient.go(request)).andReturn(responseHolder);
EasyMock.replay(druidLeaderClient);
Task task = NoopTask.create("id", 0);
RemoteTaskActionClient client = new RemoteTaskActionClient(task, druidLeaderClient, new RetryPolicyFactory(new RetryPolicyConfig()), objectMapper);
final List<TaskLock> locks = client.submit(new LockListAction());
Assert.assertEquals(expectedLocks, locks);
EasyMock.verify(druidLeaderClient);
}
use of org.jboss.netty.buffer.BigEndianHeapChannelBuffer in project druid by druid-io.
the class RemoteTaskActionClientTest method testSubmitWithIllegalStatusCode.
@Test
public void testSubmitWithIllegalStatusCode() throws Exception {
// return status code 400 and a list with size equals 1
Request request = new Request(HttpMethod.POST, new URL("http://localhost:1234/xx"));
EasyMock.expect(druidLeaderClient.makeRequest(HttpMethod.POST, "/druid/indexer/v1/action")).andReturn(request);
// return status code 200 and a list with size equals 1
final HttpResponse response = EasyMock.createNiceMock(HttpResponse.class);
EasyMock.expect(response.getStatus()).andReturn(HttpResponseStatus.BAD_REQUEST).anyTimes();
EasyMock.expect(response.getContent()).andReturn(new BigEndianHeapChannelBuffer(0));
EasyMock.replay(response);
StringFullResponseHolder responseHolder = new StringFullResponseHolder(response, StandardCharsets.UTF_8).addChunk("testSubmitWithIllegalStatusCode");
// set up mocks
EasyMock.expect(druidLeaderClient.go(request)).andReturn(responseHolder);
EasyMock.replay(druidLeaderClient);
Task task = NoopTask.create("id", 0);
RemoteTaskActionClient client = new RemoteTaskActionClient(task, druidLeaderClient, new RetryPolicyFactory(objectMapper.readValue("{\"maxRetryCount\":0}", RetryPolicyConfig.class)), objectMapper);
expectedException.expect(IOException.class);
expectedException.expectMessage("Error with status[400 Bad Request] and message[testSubmitWithIllegalStatusCode]. " + "Check overlord logs for details.");
client.submit(new LockListAction());
}
Aggregations