Search in sources :

Example 11 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 testTimeoutWhileScheduledTransaction.

@Test(timeout = 30 * 1000)
public void testTimeoutWhileScheduledTransaction() 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);
    this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
    future.get();
    this.mockedNotificationServiceWrapper.assertNotificationsCount(2);
    this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.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 12 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 testCloseProgrammingService.

@Test
public void testCloseProgrammingService() throws Exception {
    final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1");
    this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
    final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2", "mockedSubmit1");
    this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
    this.testedProgrammingService.close();
    this.mockedNotificationServiceWrapper.assertNotificationsCount(1 + /* First scheduled */
    2);
}
Also used : SubmitInstructionInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput) Test(org.junit.Test)

Example 13 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 getMockedSubmitInstructionInput.

private static SubmitInstructionInput getMockedSubmitInstructionInput(final String id, final Optional<Nanotime> deadline, final String... dependencyIds) {
    final SubmitInstructionInput mockedSubmitInstruction = mock(SubmitInstructionInput.class);
    doReturn(PcepUpdateTunnelInput.class).when(mockedSubmitInstruction).getImplementedInterface();
    final List<InstructionId> dependencies = Lists.newArrayList();
    for (final String dependencyId : dependencyIds) {
        dependencies.add(new InstructionId(dependencyId));
    }
    doReturn(dependencies).when(mockedSubmitInstruction).getPreconditions();
    doReturn(new InstructionId(id)).when(mockedSubmitInstruction).getId();
    doReturn(deadline.isPresent() ? deadline.get() : new Nanotime(BigInteger.valueOf(Long.MAX_VALUE))).when(mockedSubmitInstruction).getDeadline();
    return mockedSubmitInstruction;
}
Also used : InstructionId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) 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)

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