use of com.metamx.http.client.Request in project druid by druid-io.
the class KafkaIndexTaskClientTest method testResume.
@Test
public void testResume() throws Exception {
Capture<Request> captured = Capture.newInstance();
expect(responseHolder.getStatus()).andReturn(HttpResponseStatus.OK).anyTimes();
expect(httpClient.go(capture(captured), anyObject(FullResponseHandler.class), eq(TEST_HTTP_TIMEOUT))).andReturn(Futures.immediateFuture(responseHolder));
replayAll();
client.resume(TEST_ID);
verifyAll();
Request request = captured.getValue();
Assert.assertEquals(HttpMethod.POST, request.getMethod());
Assert.assertEquals(new URL("http://test-host:1234/druid/worker/v1/chat/test-id/resume"), request.getUrl());
Assert.assertTrue(request.getHeaders().get("X-Druid-Task-Id").contains("test-id"));
}
use of com.metamx.http.client.Request in project druid by druid-io.
the class KafkaIndexTaskClientTest method testGetEndOffsets.
@Test
public void testGetEndOffsets() throws Exception {
Capture<Request> captured = Capture.newInstance();
expect(responseHolder.getStatus()).andReturn(HttpResponseStatus.OK);
expect(responseHolder.getContent()).andReturn("{\"0\":1, \"1\":10}");
expect(httpClient.go(capture(captured), anyObject(FullResponseHandler.class), eq(TEST_HTTP_TIMEOUT))).andReturn(Futures.immediateFuture(responseHolder));
replayAll();
Map<Integer, Long> results = client.getEndOffsets(TEST_ID);
verifyAll();
Request request = captured.getValue();
Assert.assertEquals(HttpMethod.GET, request.getMethod());
Assert.assertEquals(new URL("http://test-host:1234/druid/worker/v1/chat/test-id/offsets/end"), request.getUrl());
Assert.assertTrue(request.getHeaders().get("X-Druid-Task-Id").contains("test-id"));
Assert.assertEquals(2, results.size());
Assert.assertEquals(1, (long) results.get(0));
Assert.assertEquals(10, (long) results.get(1));
}
use of com.metamx.http.client.Request in project druid by druid-io.
the class KafkaIndexTaskClientTest method testPause.
@Test
public void testPause() throws Exception {
Capture<Request> captured = Capture.newInstance();
expect(responseHolder.getStatus()).andReturn(HttpResponseStatus.OK).times(2);
expect(responseHolder.getContent()).andReturn("{\"0\":1, \"1\":10}").anyTimes();
expect(httpClient.go(capture(captured), anyObject(FullResponseHandler.class), eq(TEST_HTTP_TIMEOUT))).andReturn(Futures.immediateFuture(responseHolder));
replayAll();
Map<Integer, Long> results = client.pause(TEST_ID);
verifyAll();
Request request = captured.getValue();
Assert.assertEquals(HttpMethod.POST, request.getMethod());
Assert.assertEquals(new URL("http://test-host:1234/druid/worker/v1/chat/test-id/pause"), request.getUrl());
Assert.assertTrue(request.getHeaders().get("X-Druid-Task-Id").contains("test-id"));
Assert.assertEquals(2, results.size());
Assert.assertEquals(1, (long) results.get(0));
Assert.assertEquals(10, (long) results.get(1));
}
use of com.metamx.http.client.Request in project druid by druid-io.
the class KafkaIndexTaskClientTest method testPauseWithTimeout.
@Test
public void testPauseWithTimeout() throws Exception {
Capture<Request> captured = Capture.newInstance();
expect(responseHolder.getStatus()).andReturn(HttpResponseStatus.OK).times(2);
expect(responseHolder.getContent()).andReturn("{\"0\":1, \"1\":10}").anyTimes();
expect(httpClient.go(capture(captured), anyObject(FullResponseHandler.class), eq(TEST_HTTP_TIMEOUT))).andReturn(Futures.immediateFuture(responseHolder));
replayAll();
Map<Integer, Long> results = client.pause(TEST_ID, 101);
verifyAll();
Request request = captured.getValue();
Assert.assertEquals(HttpMethod.POST, request.getMethod());
Assert.assertEquals(new URL("http://test-host:1234/druid/worker/v1/chat/test-id/pause?timeout=101"), request.getUrl());
Assert.assertTrue(request.getHeaders().get("X-Druid-Task-Id").contains("test-id"));
Assert.assertEquals(2, results.size());
Assert.assertEquals(1, (long) results.get(0));
Assert.assertEquals(10, (long) results.get(1));
}
use of com.metamx.http.client.Request in project druid by druid-io.
the class KafkaIndexTaskClientTest method testSetEndOffsetsAndResume.
@Test
public void testSetEndOffsetsAndResume() throws Exception {
Map<Integer, Long> endOffsets = ImmutableMap.of(0, 15L, 1, 120L);
Capture<Request> captured = Capture.newInstance();
expect(responseHolder.getStatus()).andReturn(HttpResponseStatus.OK).anyTimes();
expect(httpClient.go(capture(captured), anyObject(FullResponseHandler.class), eq(TEST_HTTP_TIMEOUT))).andReturn(Futures.immediateFuture(responseHolder));
replayAll();
client.setEndOffsets(TEST_ID, endOffsets, true);
verifyAll();
Request request = captured.getValue();
Assert.assertEquals(HttpMethod.POST, request.getMethod());
Assert.assertEquals(new URL("http://test-host:1234/druid/worker/v1/chat/test-id/offsets/end?resume=true"), request.getUrl());
Assert.assertTrue(request.getHeaders().get("X-Druid-Task-Id").contains("test-id"));
Assert.assertEquals("{\"0\":15,\"1\":120}", new String(request.getContent().array()));
}
Aggregations