use of org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition in project flink by apache.
the class StopWithSavepointTest method testRestartingOnUpdateTaskExecutionStateWithRestart.
@Test
public void testRestartingOnUpdateTaskExecutionStateWithRestart() throws Exception {
try (MockStopWithSavepointContext ctx = new MockStopWithSavepointContext()) {
StateTrackingMockExecutionGraph executionGraph = new StateTrackingMockExecutionGraph();
StopWithSavepoint sws = createStopWithSavepoint(ctx, executionGraph);
ctx.setStopWithSavepoint(sws);
ctx.setHowToHandleFailure(failure -> FailureResult.canRestart(failure, Duration.ZERO));
ctx.setExpectRestarting(assertNonNull());
Exception exception = new RuntimeException();
TestingAccessExecution execution = TestingAccessExecution.newBuilder().withExecutionState(ExecutionState.FAILED).withErrorInfo(new ErrorInfo(exception, System.currentTimeMillis())).build();
executionGraph.registerExecution(execution);
TaskExecutionStateTransition taskExecutionStateTransition = ExecutingTest.createFailingStateTransition(execution.getAttemptId(), exception);
assertThat(sws.updateTaskExecutionState(taskExecutionStateTransition), is(true));
}
}
use of org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition in project flink by apache.
the class StopWithSavepointTest method testRestartOnTaskFailureAfterSavepointCompletion.
@Test
public void testRestartOnTaskFailureAfterSavepointCompletion() throws Exception {
try (MockStopWithSavepointContext ctx = new MockStopWithSavepointContext()) {
CheckpointScheduling mockStopWithSavepointOperations = new MockCheckpointScheduling();
CompletableFuture<String> savepointFuture = new CompletableFuture<>();
StateTrackingMockExecutionGraph executionGraph = new StateTrackingMockExecutionGraph();
StopWithSavepoint sws = createStopWithSavepoint(ctx, mockStopWithSavepointOperations, executionGraph, savepointFuture);
ctx.setStopWithSavepoint(sws);
ctx.setHowToHandleFailure(failure -> FailureResult.canRestart(failure, Duration.ZERO));
ctx.setExpectRestarting(assertNonNull());
// 1. complete savepoint future
savepointFuture.complete(SAVEPOINT_PATH);
ctx.triggerExecutors();
// 2. fail task
Exception exception = new RuntimeException();
TestingAccessExecution execution = TestingAccessExecution.newBuilder().withExecutionState(ExecutionState.FAILED).withErrorInfo(new ErrorInfo(exception, System.currentTimeMillis())).build();
executionGraph.registerExecution(execution);
TaskExecutionStateTransition taskExecutionStateTransition = ExecutingTest.createFailingStateTransition(execution.getAttemptId(), exception);
assertThat(sws.updateTaskExecutionState(taskExecutionStateTransition), is(true));
}
}
use of org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition in project flink by apache.
the class AdaptiveSchedulerTest method testExceptionHistoryWithTaskFailure.
@Test
public void testExceptionHistoryWithTaskFailure() throws Exception {
final Exception expectedException = new Exception("Expected Local Exception");
BiConsumer<AdaptiveScheduler, List<ExecutionAttemptID>> testLogic = (scheduler, attemptIds) -> {
final ExecutionAttemptID attemptId = attemptIds.get(1);
scheduler.updateTaskExecutionState(new TaskExecutionStateTransition(new TaskExecutionState(attemptId, ExecutionState.FAILED, expectedException)));
};
final Iterable<RootExceptionHistoryEntry> actualExceptionHistory = runExceptionHistoryTests(testLogic);
assertThat(actualExceptionHistory).hasSize(1);
final RootExceptionHistoryEntry failure = actualExceptionHistory.iterator().next();
assertThat(failure.getException().deserializeError(classLoader)).isEqualTo(expectedException);
}
use of org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition in project flink by apache.
the class AdaptiveSchedulerTest method testExceptionHistoryWithTaskFailureFromStopWithSavepoint.
@Test
public void testExceptionHistoryWithTaskFailureFromStopWithSavepoint() throws Exception {
final Exception expectedException = new Exception("Expected Local Exception");
Consumer<JobGraph> setupJobGraph = jobGraph -> jobGraph.setSnapshotSettings(new JobCheckpointingSettings(CheckpointCoordinatorConfiguration.builder().build(), null));
final CompletedCheckpointStore completedCheckpointStore = new StandaloneCompletedCheckpointStore(1);
final CheckpointIDCounter checkpointIDCounter = new StandaloneCheckpointIDCounter();
final CheckpointsCleaner checkpointCleaner = new CheckpointsCleaner();
TestingCheckpointRecoveryFactory checkpointRecoveryFactory = new TestingCheckpointRecoveryFactory(completedCheckpointStore, checkpointIDCounter);
Consumer<AdaptiveSchedulerBuilder> setupScheduler = builder -> builder.setCheckpointRecoveryFactory(checkpointRecoveryFactory).setCheckpointCleaner(checkpointCleaner);
BiConsumer<AdaptiveScheduler, List<ExecutionAttemptID>> testLogic = (scheduler, attemptIds) -> {
final ExecutionAttemptID attemptId = attemptIds.get(1);
scheduler.stopWithSavepoint("file:///tmp/target", true, SavepointFormatType.CANONICAL);
scheduler.updateTaskExecutionState(new TaskExecutionStateTransition(new TaskExecutionState(attemptId, ExecutionState.FAILED, expectedException)));
};
final Iterable<RootExceptionHistoryEntry> actualExceptionHistory = runExceptionHistoryTests(testLogic, setupScheduler, setupJobGraph);
assertThat(actualExceptionHistory).hasSize(1);
final RootExceptionHistoryEntry failure = actualExceptionHistory.iterator().next();
assertThat(failure.getException().deserializeError(classLoader)).isEqualTo(expectedException);
}
use of org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition in project flink by apache.
the class CancelingTest method testTaskFailuresAreIgnored.
@Test
public void testTaskFailuresAreIgnored() throws Exception {
try (MockStateWithExecutionGraphContext ctx = new MockStateWithExecutionGraphContext()) {
StateTrackingMockExecutionGraph meg = new StateTrackingMockExecutionGraph();
Canceling canceling = createCancelingState(ctx, meg);
// register execution at EG
Exception exception = new RuntimeException();
TestingAccessExecution execution = TestingAccessExecution.newBuilder().withExecutionState(ExecutionState.FAILED).withErrorInfo(new ErrorInfo(exception, System.currentTimeMillis())).build();
meg.registerExecution(execution);
TaskExecutionStateTransition update = ExecutingTest.createFailingStateTransition(execution.getAttemptId(), exception);
canceling.updateTaskExecutionState(update);
ctx.assertNoStateTransition();
}
}
Aggregations