use of org.apache.flink.runtime.jobmaster.TestingLogicalSlot in project flink by apache.
the class ExecutionGraphToInputsLocationsRetrieverAdapterTest method testGetTaskManagerLocationWhenScheduled.
/**
* Tests that it can get the task manager location in an Execution.
*/
@Test
public void testGetTaskManagerLocationWhenScheduled() throws Exception {
final JobVertex jobVertex = ExecutionGraphTestUtils.createNoOpVertex(1);
final TestingLogicalSlot testingLogicalSlot = new TestingLogicalSlotBuilder().createTestingLogicalSlot();
final ExecutionGraph eg = ExecutionGraphTestUtils.createSimpleTestGraph(jobVertex);
final ExecutionGraphToInputsLocationsRetrieverAdapter inputsLocationsRetriever = new ExecutionGraphToInputsLocationsRetrieverAdapter(eg);
final ExecutionVertex onlyExecutionVertex = eg.getAllExecutionVertices().iterator().next();
onlyExecutionVertex.getCurrentExecutionAttempt().transitionState(ExecutionState.SCHEDULED);
onlyExecutionVertex.deployToSlot(testingLogicalSlot);
ExecutionVertexID executionVertexId = new ExecutionVertexID(jobVertex.getID(), 0);
Optional<CompletableFuture<TaskManagerLocation>> taskManagerLocationOptional = inputsLocationsRetriever.getTaskManagerLocation(executionVertexId);
assertTrue(taskManagerLocationOptional.isPresent());
final CompletableFuture<TaskManagerLocation> taskManagerLocationFuture = taskManagerLocationOptional.get();
assertThat(taskManagerLocationFuture.get(), is(testingLogicalSlot.getTaskManagerLocation()));
}
use of org.apache.flink.runtime.jobmaster.TestingLogicalSlot in project flink by apache.
the class ExecutionVertexDeploymentTest method testFailExternallyDuringDeploy.
@Test
public void testFailExternallyDuringDeploy() {
try {
final ExecutionVertex vertex = getExecutionVertex();
TestingLogicalSlot testingLogicalSlot = new TestingLogicalSlotBuilder().setTaskManagerGateway(new SubmitBlockingSimpleAckingTaskManagerGateway()).createTestingLogicalSlot();
assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
vertex.getCurrentExecutionAttempt().transitionState(ExecutionState.SCHEDULED);
vertex.deployToSlot(testingLogicalSlot);
assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState());
Exception testError = new Exception("test error");
vertex.fail(testError);
assertEquals(ExecutionState.FAILED, vertex.getExecutionState());
assertThat(vertex.getFailureInfo().map(ErrorInfo::getException).get().deserializeError(ClassLoader.getSystemClassLoader()), is(testError));
assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.FAILED) > 0);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations