Search in sources :

Example 6 with SubmitInstructionInput

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);
}
Also used : CancelInstructionInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CancelInstructionInput) SubmitInstructionInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput) Test(org.junit.Test)

Example 7 with SubmitInstructionInput

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);
}
Also used : Instruction(org.opendaylight.bgpcep.programming.spi.Instruction) SubmitInstructionInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput) Test(org.junit.Test)

Example 8 with SubmitInstructionInput

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);
}
Also used : BigInteger(java.math.BigInteger) Instruction(org.opendaylight.bgpcep.programming.spi.Instruction) SubmitInstructionInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput) Nanotime(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.Nanotime) Test(org.junit.Test)

Example 9 with SubmitInstructionInput

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;
}
Also used : FailureBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.submit.instruction.output.result.failure._case.FailureBuilder) SchedulerException(org.opendaylight.bgpcep.programming.spi.SchedulerException) InstructionId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId) DuplicateInstructionId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.DuplicateInstructionId) ArrayList(java.util.ArrayList)

Example 10 with SubmitInstructionInput

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);
}
Also used : SubmitInstructionInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput) Test(org.junit.Test)

Aggregations

SubmitInstructionInput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput)11 Test (org.junit.Test)10 Instruction (org.opendaylight.bgpcep.programming.spi.Instruction)5 Nanotime (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.Nanotime)5 BigInteger (java.math.BigInteger)4 InstructionId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId)3 SchedulerException (org.opendaylight.bgpcep.programming.spi.SchedulerException)2 DuplicateInstructionId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.DuplicateInstructionId)2 FailureBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.submit.instruction.output.result.failure._case.FailureBuilder)2 Timeout (io.netty.util.Timeout)1 ArrayList (java.util.ArrayList)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 CancelInstructionInput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CancelInstructionInput)1 CleanInstructionsInput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CleanInstructionsInput)1 CleanInstructionsInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CleanInstructionsInputBuilder)1 UnknownInstruction (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.UnknownInstruction)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1