use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.
the class JobExceptionsHandlerTest method testOnlyRootCause.
@Test
public void testOnlyRootCause() throws HandlerRequestException {
final Throwable rootCause = new RuntimeException("root cause");
final long rootCauseTimestamp = System.currentTimeMillis();
final ExecutionGraphInfo executionGraphInfo = createExecutionGraphInfo(fromGlobalFailure(rootCause, rootCauseTimestamp));
final HandlerRequest<EmptyRequestBody> request = createRequest(executionGraphInfo.getJobId(), 10);
final JobExceptionsInfoWithHistory response = testInstance.handleRequest(request, executionGraphInfo);
assertThat(response.getRootException(), is(ExceptionUtils.stringifyException(rootCause)));
assertThat(response.getRootTimestamp(), is(rootCauseTimestamp));
assertFalse(response.isTruncated());
assertThat(response.getAllExceptions(), empty());
assertThat(response.getExceptionHistory().getEntries(), contains(historyContainsGlobalFailure(rootCause, rootCauseTimestamp)));
}
use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.
the class JobExceptionsHandlerTest method checkExceptionLimit.
private static void checkExceptionLimit(JobExceptionsHandler jobExceptionsHandler, ExecutionGraphInfo graph, int maxNumExceptions, int numExpectedException) throws HandlerRequestException {
final HandlerRequest<EmptyRequestBody> handlerRequest = createRequest(graph.getJobId(), numExpectedException);
final JobExceptionsInfo jobExceptionsInfo = jobExceptionsHandler.handleRequest(handlerRequest, graph);
final int numReportedException = Math.min(maxNumExceptions, numExpectedException);
assertEquals(jobExceptionsInfo.getAllExceptions().size(), numReportedException);
}
use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.
the class AggregatingMetricsHandlerTestBase method testListMetrics.
@Test
public void testListMetrics() throws Exception {
HandlerRequest<EmptyRequestBody> request = HandlerRequest.resolveParametersAndCreate(EmptyRequestBody.getInstance(), handler.getMessageHeaders().getUnresolvedMessageParameters(), pathParameters, Collections.emptyMap(), Collections.emptyList());
AggregatedMetricsResponseBody response = handler.handleRequest(request, MOCK_DISPATCHER_GATEWAY).get();
List<String> availableMetrics = response.getMetrics().stream().map(AggregatedMetric::getId).sorted().collect(Collectors.toList());
assertEquals(2, availableMetrics.size());
assertEquals("abc.metric1", availableMetrics.get(0));
assertEquals("abc.metric2", availableMetrics.get(1));
}
use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.
the class AggregatingMetricsHandlerTestBase method testDefaultAggregation.
@Test
public void testDefaultAggregation() throws Exception {
Map<String, List<String>> queryParams = new HashMap<>(4);
queryParams.put("get", Collections.singletonList("abc.metric1"));
HandlerRequest<EmptyRequestBody> request = HandlerRequest.resolveParametersAndCreate(EmptyRequestBody.getInstance(), handler.getMessageHeaders().getUnresolvedMessageParameters(), pathParameters, queryParams, Collections.emptyList());
AggregatedMetricsResponseBody response = handler.handleRequest(request, MOCK_DISPATCHER_GATEWAY).get();
Collection<AggregatedMetric> aggregatedMetrics = response.getMetrics();
assertEquals(1, aggregatedMetrics.size());
AggregatedMetric aggregatedMetric = aggregatedMetrics.iterator().next();
assertEquals("abc.metric1", aggregatedMetric.getId());
assertEquals(1.0, aggregatedMetric.getMin(), 0.1);
assertEquals(3.0, aggregatedMetric.getMax(), 0.1);
assertEquals(2.0, aggregatedMetric.getAvg(), 0.1);
assertEquals(4.0, aggregatedMetric.getSum(), 0.1);
}
use of org.apache.flink.runtime.rest.messages.EmptyRequestBody in project flink by apache.
the class TaskManagerDetailsHandlerTest method testTaskManagerMetricsInfoExtraction.
@Test
public void testTaskManagerMetricsInfoExtraction() throws RestHandlerException, ExecutionException, InterruptedException, JsonProcessingException, HandlerRequestException {
initializeMetricStore(metricFetcher.getMetricStore());
resourceManagerGateway.setRequestTaskManagerDetailsInfoFunction(taskManagerId -> CompletableFuture.completedFuture(new TaskManagerInfoWithSlots(createEmptyTaskManagerInfo(), Collections.emptyList())));
HandlerRequest<EmptyRequestBody> request = createRequest();
TaskManagerDetailsInfo taskManagerDetailsInfo = testInstance.handleRequest(request, resourceManagerGateway).get();
TaskManagerMetricsInfo actual = taskManagerDetailsInfo.getTaskManagerMetricsInfo();
TaskManagerMetricsInfo expected = new TaskManagerMetricsInfo(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 15L, 16L, 17L, 18L, 19L, 20L, Collections.emptyList());
ObjectMapper objectMapper = new ObjectMapper();
String actualJson = objectMapper.writeValueAsString(actual);
String expectedJson = objectMapper.writeValueAsString(expected);
assertThat(actualJson, is(expectedJson));
}
Aggregations