Search in sources :

Example 56 with TestingLogicalSlotBuilder

use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink-mirror by flink-ci.

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 57 with TestingLogicalSlotBuilder

use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink-mirror by flink-ci.

the class ExecutionVertexDeploymentTest method testDeployCall.

@Test
public void testDeployCall() {
    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);
    } 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 58 with TestingLogicalSlotBuilder

use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink-mirror by flink-ci.

the class ExecutionVertexDeploymentTest method testDeployFailedSynchronous.

@Test
public void testDeployFailedSynchronous() {
    try {
        final ExecutionVertex vertex = getExecutionVertex();
        final LogicalSlot slot = new TestingLogicalSlotBuilder().setTaskManagerGateway(new SubmitFailingSimpleAckingTaskManagerGateway()).createTestingLogicalSlot();
        assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
        vertex.getCurrentExecutionAttempt().transitionState(ExecutionState.SCHEDULED);
        vertex.deployToSlot(slot);
        assertEquals(ExecutionState.FAILED, vertex.getExecutionState());
        assertTrue(vertex.getFailureInfo().isPresent());
        assertThat(vertex.getFailureInfo().map(ErrorInfo::getExceptionAsString).get(), containsString(ERROR_MESSAGE));
        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 : 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 59 with TestingLogicalSlotBuilder

use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink-mirror by flink-ci.

the class ExecutionVertexCancelTest method testCancelFromRunning.

@Test
public void testCancelFromRunning() {
    try {
        final ExecutionVertex vertex = getExecutionVertex();
        LogicalSlot slot = new TestingLogicalSlotBuilder().setTaskManagerGateway(new CancelSequenceSimpleAckingTaskManagerGateway(1)).createTestingLogicalSlot();
        setVertexResource(vertex, slot);
        setVertexState(vertex, ExecutionState.RUNNING);
        assertEquals(ExecutionState.RUNNING, vertex.getExecutionState());
        vertex.cancel();
        vertex.getCurrentExecutionAttempt().completeCancelling();
        assertEquals(ExecutionState.CANCELED, vertex.getExecutionState());
        assertFalse(slot.isAlive());
        assertFalse(vertex.getFailureInfo().isPresent());
        assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
        assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 0);
        assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELED) > 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) IOException(java.io.IOException) Test(org.junit.Test)

Example 60 with TestingLogicalSlotBuilder

use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink-mirror by flink-ci.

the class ExecutionVertexCancelTest method testCancelCallFails.

@Test
public void testCancelCallFails() {
    try {
        final ExecutionVertex vertex = getExecutionVertex();
        LogicalSlot slot = new TestingLogicalSlotBuilder().setTaskManagerGateway(new CancelSequenceSimpleAckingTaskManagerGateway(0)).createTestingLogicalSlot();
        setVertexResource(vertex, slot);
        setVertexState(vertex, ExecutionState.RUNNING);
        assertEquals(ExecutionState.RUNNING, vertex.getExecutionState());
        vertex.cancel();
        // Callback fails, leading to CANCELED
        assertEquals(ExecutionState.CANCELED, vertex.getExecutionState());
        assertFalse(slot.isAlive());
        assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
        assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 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) IOException(java.io.IOException) 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