use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink by splunk.
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());
}
}
use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink by splunk.
the class ExecutionVertexDeploymentTest method testDeployWithSynchronousAnswer.
@Test
public void testDeployWithSynchronousAnswer() {
try {
final ExecutionVertex vertex = getExecutionVertex();
final LogicalSlot slot = new TestingLogicalSlotBuilder().createTestingLogicalSlot();
assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
vertex.getCurrentExecutionAttempt().transitionState(ExecutionState.SCHEDULED);
vertex.deployToSlot(slot);
assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState());
// no repeated scheduling
try {
vertex.deployToSlot(slot);
fail("Scheduled from wrong state");
} catch (IllegalStateException e) {
// as expected
}
assertFalse(vertex.getFailureInfo().isPresent());
assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.RUNNING) == 0);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink by splunk.
the class ExecutionVertexDeploymentTest method testDeployWithAsynchronousAnswer.
@Test
public void testDeployWithAsynchronousAnswer() {
try {
final ExecutionVertex vertex = getExecutionVertex();
final LogicalSlot slot = new TestingLogicalSlotBuilder().createTestingLogicalSlot();
assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
vertex.getCurrentExecutionAttempt().transitionState(ExecutionState.SCHEDULED);
vertex.deployToSlot(slot);
// no repeated scheduling
try {
vertex.deployToSlot(slot);
fail("Scheduled from wrong state");
} catch (IllegalStateException e) {
// as expected
}
assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState());
// no repeated scheduling
try {
vertex.deployToSlot(slot);
fail("Scheduled from wrong state");
} catch (IllegalStateException e) {
// as expected
}
assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.RUNNING) == 0);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink by splunk.
the class DefaultSchedulerTest method testExceptionHistoryWithRestartableFailure.
@Test
public void testExceptionHistoryWithRestartableFailure() {
final JobGraph jobGraph = singleNonParallelJobVertexJobGraph();
final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
final TestingLogicalSlotBuilder logicalSlotBuilder = new TestingLogicalSlotBuilder();
logicalSlotBuilder.setTaskManagerLocation(taskManagerLocation);
executionSlotAllocatorFactory = new TestExecutionSlotAllocatorFactory(logicalSlotBuilder);
final DefaultScheduler scheduler = createSchedulerAndStartScheduling(jobGraph);
// initiate restartable failure
final ArchivedExecutionVertex taskFailureExecutionVertex = Iterables.getOnlyElement(scheduler.requestJob().getArchivedExecutionGraph().getAllExecutionVertices());
final RuntimeException restartableException = new RuntimeException("restartable exception");
final long updateStateTriggeringRestartTimestamp = initiateFailure(scheduler, taskFailureExecutionVertex.getCurrentExecutionAttempt().getAttemptId(), restartableException);
taskRestartExecutor.triggerNonPeriodicScheduledTask();
// initiate job failure
testRestartBackoffTimeStrategy.setCanRestart(false);
final ExecutionAttemptID failingAttemptId = Iterables.getOnlyElement(scheduler.requestJob().getArchivedExecutionGraph().getAllExecutionVertices()).getCurrentExecutionAttempt().getAttemptId();
final RuntimeException failingException = new RuntimeException("failing exception");
final long updateStateTriggeringJobFailureTimestamp = initiateFailure(scheduler, failingAttemptId, failingException);
final Iterable<RootExceptionHistoryEntry> actualExceptionHistory = scheduler.getExceptionHistory();
// assert restarted attempt
assertThat(actualExceptionHistory, IsIterableContainingInOrder.contains(ExceptionHistoryEntryMatcher.matchesFailure(restartableException, updateStateTriggeringRestartTimestamp, taskFailureExecutionVertex.getTaskNameWithSubtaskIndex(), taskFailureExecutionVertex.getCurrentAssignedResourceLocation()), ExceptionHistoryEntryMatcher.matchesGlobalFailure(failingException, updateStateTriggeringJobFailureTimestamp)));
}
use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink by splunk.
the class DeploymentHandleTest method getLogicalSlotReturnsSlotIfFutureCompletedNormally.
@Test
public void getLogicalSlotReturnsSlotIfFutureCompletedNormally() {
final LogicalSlot logicalSlot = new TestingLogicalSlotBuilder().createTestingLogicalSlot();
logicalSlotFuture.complete(logicalSlot);
assertTrue(deploymentHandle.getLogicalSlot().isPresent());
assertSame(logicalSlot, deploymentHandle.getLogicalSlot().get());
}
Aggregations