try {
// a slot than cannot be deployed to
final TaskOperationProtocol taskManager = mock(TaskOperationProtocol.class);
final Instance instance = getInstance(taskManager);
final AllocatedSlot slot = instance.allocateSlot(new JobID());
slot.cancel();
assertFalse(slot.isReleased());
final SlotAllocationFuture future = new SlotAllocationFuture();
final ExecutionJobVertex ejv = getJobVertexNotExecuting(new JobVertexID());
final ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0]);
Scheduler scheduler = mock(Scheduler.class);
when(scheduler.scheduleQueued(Matchers.any(ScheduledUnit.class))).thenReturn(future);
assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
// try to deploy to the slot
vertex.scheduleForExecution(scheduler, true);
// future has not yet a slot
assertEquals(ExecutionState.SCHEDULED, vertex.getExecutionState());
future.setSlot(slot);
// will have failed
assertEquals(ExecutionState.FAILED, vertex.getExecutionState());
assertTrue(slot.isReleased());
verify(taskManager, times(0)).submitTask(Matchers.any(TaskDeploymentDescriptor.class));
}
catch (Exception e) {
e.printStackTrace();