use of org.apache.druid.query.QueryInterruptedException in project druid by druid-io.
the class DirectDruidClientTest method testQueryInterruptionExceptionLogMessage.
@Test
public void testQueryInterruptionExceptionLogMessage() {
SettableFuture<Object> interruptionFuture = SettableFuture.create();
Capture<Request> capturedRequest = EasyMock.newCapture();
final String hostName = "localhost:8080";
EasyMock.expect(httpClient.go(EasyMock.capture(capturedRequest), EasyMock.<HttpResponseHandler>anyObject(), EasyMock.anyObject(Duration.class))).andReturn(interruptionFuture).anyTimes();
EasyMock.replay(httpClient);
// test error
TimeBoundaryQuery query = Druids.newTimeBoundaryQueryBuilder().dataSource("test").build();
query = query.withOverriddenContext(ImmutableMap.of(DirectDruidClient.QUERY_FAIL_TIME, Long.MAX_VALUE));
interruptionFuture.set(new ByteArrayInputStream(StringUtils.toUtf8("{\"error\":\"testing1\",\"errorMessage\":\"testing2\"}")));
Sequence results = client.run(QueryPlus.wrap(query));
QueryInterruptedException actualException = null;
try {
results.toList();
} catch (QueryInterruptedException e) {
actualException = e;
}
Assert.assertNotNull(actualException);
Assert.assertEquals("testing1", actualException.getErrorCode());
Assert.assertEquals("testing2", actualException.getMessage());
Assert.assertEquals(hostName, actualException.getHost());
EasyMock.verify(httpClient);
}
use of org.apache.druid.query.QueryInterruptedException in project druid by druid-io.
the class ErrorHandlerTest method testErrorHandlerDefaultErrorResponseTransformStrategySanitizesErrorAsExpected.
@Test
public void testErrorHandlerDefaultErrorResponseTransformStrategySanitizesErrorAsExpected() {
ServerConfig serverConfig = new ServerConfig();
ErrorHandler errorHandler = new ErrorHandler(serverConfig);
QueryInterruptedException input = new QueryInterruptedException("error", "error messagez", "error class", "host");
RuntimeException output = errorHandler.sanitize(input);
Assert.assertEquals("error messagez", output.getMessage());
}
Aggregations