Search in sources :

Example 71 with TestingLogicalSlotBuilder

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());
    }
}
Also used : TestingLogicalSlot(org.apache.flink.runtime.jobmaster.TestingLogicalSlot) TestingLogicalSlotBuilder(org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder) ExecutionGraphTestUtils.getExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex) Test(org.junit.Test)

Example 72 with TestingLogicalSlotBuilder

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());
    }
}
Also used : TestingLogicalSlotBuilder(org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder) ExecutionGraphTestUtils.getExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) TestingLogicalSlot(org.apache.flink.runtime.jobmaster.TestingLogicalSlot) Test(org.junit.Test)

Example 73 with TestingLogicalSlotBuilder

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());
    }
}
Also used : TestingLogicalSlotBuilder(org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder) ExecutionGraphTestUtils.getExecutionVertex(org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) TestingLogicalSlot(org.apache.flink.runtime.jobmaster.TestingLogicalSlot) Test(org.junit.Test)

Example 74 with TestingLogicalSlotBuilder

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)));
}
Also used : JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) ExecutionAttemptID(org.apache.flink.runtime.executiongraph.ExecutionAttemptID) RootExceptionHistoryEntry(org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) ArchivedExecutionVertex(org.apache.flink.runtime.executiongraph.ArchivedExecutionVertex) TestingLogicalSlotBuilder(org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder) AdaptiveSchedulerTest(org.apache.flink.runtime.scheduler.adaptive.AdaptiveSchedulerTest) Test(org.junit.Test)

Example 75 with TestingLogicalSlotBuilder

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());
}
Also used : TestingLogicalSlotBuilder(org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) Test(org.junit.Test)

Aggregations

TestingLogicalSlotBuilder (org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder)78 Test (org.junit.Test)57 LogicalSlot (org.apache.flink.runtime.jobmaster.LogicalSlot)48 ExecutionGraphTestUtils.getExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionGraphTestUtils.getExecutionVertex)30 ExecutionVertex (org.apache.flink.runtime.executiongraph.ExecutionVertex)21 TestingLogicalSlot (org.apache.flink.runtime.jobmaster.TestingLogicalSlot)21 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)18 IOException (java.io.IOException)15 SimpleAckingTaskManagerGateway (org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway)12 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)12 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)12 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)12 ArrayList (java.util.ArrayList)9 JobID (org.apache.flink.api.common.JobID)9 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)9 ExecutionGraph (org.apache.flink.runtime.executiongraph.ExecutionGraph)9 LocalTaskManagerLocation (org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation)9 List (java.util.List)6 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)6 CompletableFuture (java.util.concurrent.CompletableFuture)6