Search in sources :

Example 1 with TestingAccessExecution

use of org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution 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));
    }
}
Also used : TestingAccessExecution(org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution) TaskExecutionStateTransition(org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Example 2 with TestingAccessExecution

use of org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution 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));
    }
}
Also used : TestingAccessExecution(org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution) TaskExecutionStateTransition(org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) FlinkException(org.apache.flink.util.FlinkException) CompletableFuture(java.util.concurrent.CompletableFuture) CheckpointScheduling(org.apache.flink.runtime.checkpoint.CheckpointScheduling) Test(org.junit.Test)

Example 3 with TestingAccessExecution

use of org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution 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();
    }
}
Also used : TestingAccessExecution(org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution) TaskExecutionStateTransition(org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) Test(org.junit.Test)

Example 4 with TestingAccessExecution

use of org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution in project flink by apache.

the class ExecutingTest method testFailureReportedViaUpdateTaskExecutionStateCausesRestart.

@Test
public void testFailureReportedViaUpdateTaskExecutionStateCausesRestart() throws Exception {
    try (MockExecutingContext ctx = new MockExecutingContext()) {
        StateTrackingMockExecutionGraph returnsFailedStateExecutionGraph = new StateTrackingMockExecutionGraph();
        Executing exec = new ExecutingStateBuilder().setExecutionGraph(returnsFailedStateExecutionGraph).build(ctx);
        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();
        returnsFailedStateExecutionGraph.registerExecution(execution);
        TaskExecutionStateTransition taskExecutionStateTransition = createFailingStateTransition(execution.getAttemptId(), exception);
        exec.updateTaskExecutionState(taskExecutionStateTransition);
    }
}
Also used : TestingAccessExecution(org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution) TaskExecutionStateTransition(org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) JobException(org.apache.flink.runtime.JobException) JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) Test(org.junit.Test)

Example 5 with TestingAccessExecution

use of org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution in project flink by apache.

the class ExecutingTest method testFalseReportsViaUpdateTaskExecutionStateAreIgnored.

@Test
public void testFalseReportsViaUpdateTaskExecutionStateAreIgnored() throws Exception {
    try (MockExecutingContext ctx = new MockExecutingContext()) {
        MockExecutionGraph returnsFailedStateExecutionGraph = new MockExecutionGraph(false, Collections::emptyList);
        Executing exec = new ExecutingStateBuilder().setExecutionGraph(returnsFailedStateExecutionGraph).build(ctx);
        Exception exception = new RuntimeException();
        TestingAccessExecution execution = TestingAccessExecution.newBuilder().withExecutionState(ExecutionState.FAILED).withErrorInfo(new ErrorInfo(exception, System.currentTimeMillis())).build();
        returnsFailedStateExecutionGraph.registerExecution(execution);
        TaskExecutionStateTransition taskExecutionStateTransition = createFailingStateTransition(execution.getAttemptId(), exception);
        exec.updateTaskExecutionState(taskExecutionStateTransition);
        ctx.assertNoStateTransition();
    }
}
Also used : TestingAccessExecution(org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution) TaskExecutionStateTransition(org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) Collections(java.util.Collections) JobException(org.apache.flink.runtime.JobException) JobExecutionException(org.apache.flink.runtime.client.JobExecutionException) Test(org.junit.Test)

Aggregations

ErrorInfo (org.apache.flink.runtime.executiongraph.ErrorInfo)8 TaskExecutionStateTransition (org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition)8 TestingAccessExecution (org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution)8 Test (org.junit.Test)8 JobException (org.apache.flink.runtime.JobException)3 JobExecutionException (org.apache.flink.runtime.client.JobExecutionException)3 FlinkException (org.apache.flink.util.FlinkException)3 Collections (java.util.Collections)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CheckpointScheduling (org.apache.flink.runtime.checkpoint.CheckpointScheduling)1