use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput in project bgpcep by opendaylight.
the class ProgrammingServiceImplTest method testCancelInstruction.
@Test
public void testCancelInstruction() throws Exception {
final SubmitInstructionInput mockedSubmit = getMockedSubmitInstructionInput("mockedSubmit");
this.testedProgrammingService.scheduleInstruction(mockedSubmit);
checkPresentOperational(getDataBroker(), buildInstructionIID(mockedSubmit.getId()));
final CancelInstructionInput mockedCancel = getCancelInstruction("mockedSubmit");
this.testedProgrammingService.cancelInstruction(mockedCancel);
checkPresentOperational(getDataBroker(), buildInstructionIID(mockedSubmit.getId()));
this.mockedExecutorWrapper.assertSubmittedTasksSize(2);
this.mockedNotificationServiceWrapper.assertNotificationsCount(2);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit.getId(), InstructionStatus.Cancelled);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput in project bgpcep by opendaylight.
the class ProgrammingServiceImplTest method testSuccessExecutingWithDependenciesTransaction.
// TODO test deadline with state Queued
@Test
public void testSuccessExecutingWithDependenciesTransaction() throws Exception {
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1");
final ListenableFuture<Instruction> future = this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2", "mockedSubmit1");
final ListenableFuture<Instruction> future2 = this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
Instruction instruction = future.get();
instruction.checkedExecutionStart();
instruction.executionCompleted(InstructionStatus.Successful, getDetails());
this.mockedNotificationServiceWrapper.assertNotificationsCount(4);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(), InstructionStatus.Executing);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(), InstructionStatus.Successful);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit2.getId(), InstructionStatus.Scheduled);
instruction = future2.get();
instruction.checkedExecutionStart();
instruction.executionCompleted(InstructionStatus.Successful, getDetails());
this.mockedNotificationServiceWrapper.assertNotificationsCount(6);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(4, mockedSubmit2.getId(), InstructionStatus.Executing);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(5, mockedSubmit2.getId(), InstructionStatus.Successful);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput in project bgpcep by opendaylight.
the class ProgrammingServiceImplTest method testTimeoutWhileExecutingWithDependenciesTransaction.
@Test(timeout = 30 * 1000)
public void testTimeoutWhileExecutingWithDependenciesTransaction() throws Exception {
final BigInteger deadlineOffset = BigInteger.valueOf(1000L * 1000 * 1000 * INSTRUCTION_DEADLINE_OFFSET_IN_SECONDS);
final Nanotime current = NanotimeUtil.currentTime();
final Nanotime deadlineNano = new Nanotime(current.getValue().add(deadlineOffset));
final Optional<Nanotime> deadline = Optional.of(deadlineNano);
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1", deadline);
final ListenableFuture<Instruction> future = this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2", "mockedSubmit1");
this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
final Instruction i = future.get();
i.checkedExecutionStart();
this.mockedNotificationServiceWrapper.assertNotificationsCount(4);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(), InstructionStatus.Executing);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(), InstructionStatus.Unknown);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit2.getId(), InstructionStatus.Cancelled);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput in project bgpcep by opendaylight.
the class ProgrammingServiceImpl method collectDependencies.
private List<InstructionImpl> collectDependencies(final SubmitInstructionInput input) throws SchedulerException {
final List<InstructionImpl> dependencies = new ArrayList<>();
for (final InstructionId pid : input.getPreconditions()) {
final InstructionImpl instruction = this.insns.get(pid);
if (instruction == null) {
LOG.info("Instruction {} depends on {}, which is not a known instruction", input.getId(), pid);
throw new SchedulerException("Unknown dependency ID specified", new FailureBuilder().setType(UnknownPreconditionId.class).build());
}
dependencies.add(instruction);
}
return dependencies;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput in project bgpcep by opendaylight.
the class ProgrammingServiceImplTest method testScheduleInstruction.
@Test
public void testScheduleInstruction() throws Exception {
final SubmitInstructionInput mockedSubmit = getMockedSubmitInstructionInput("mockedSubmit");
this.testedProgrammingService.scheduleInstruction(mockedSubmit);
checkPresentOperational(getDataBroker(), buildInstructionIID(mockedSubmit.getId()));
// assert Schedule to executor
this.mockedExecutorWrapper.assertSubmittedTasksSize(1);
// assert Notification
this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(0, mockedSubmit.getId(), InstructionStatus.Scheduled);
}
Aggregations