Search in sources :

Example 11 with PCEPSession

use of org.opendaylight.protocol.pcep.PCEPSession in project bgpcep by opendaylight.

the class TopologyProgrammingTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    doReturn(true).when(this.instruction).checkedExecutionStart();
    doNothing().when(this.instruction).executionCompleted(InstructionStatus.Failed, null);
    doAnswer(invocation -> {
        final Runnable callback = (Runnable) invocation.getArguments()[0];
        callback.run();
        return null;
    }).when(this.instructionFuture).addListener(any(Runnable.class), any(Executor.class));
    doAnswer(invocation -> {
        final Runnable callback = (Runnable) invocation.getArguments()[0];
        callback.run();
        return null;
    }).when(this.futureAddLspOutput).addListener(any(Runnable.class), any(Executor.class));
    doAnswer(invocation -> {
        final Runnable callback = (Runnable) invocation.getArguments()[0];
        callback.run();
        return null;
    }).when(this.futureUpdateLspOutput).addListener(any(Runnable.class), any(Executor.class));
    doAnswer(invocation -> {
        final Runnable callback = (Runnable) invocation.getArguments()[0];
        callback.run();
        return null;
    }).when(this.futureRemoveLspOutput).addListener(any(Runnable.class), any(Executor.class));
    doAnswer(invocation -> {
        final Runnable callback = (Runnable) invocation.getArguments()[0];
        callback.run();
        return null;
    }).when(this.futureTriggerSyncOutput).addListener(any(Runnable.class), any(Executor.class));
    doAnswer(invocation -> {
        final Runnable callback = (Runnable) invocation.getArguments()[0];
        callback.run();
        return null;
    }).when(this.futureEnsureLspOutput).addListener(any(Runnable.class), any(Executor.class));
    doAnswer(invocation -> {
        TopologyProgrammingTest.this.addLspArgs = (AddLspArgs) invocation.getArguments()[0];
        return TopologyProgrammingTest.this.futureAddLspOutput;
    }).when(listener).addLsp(any(AddLspInput.class));
    doAnswer(invocation -> {
        TopologyProgrammingTest.this.updateLspArgs = (UpdateLspArgs) invocation.getArguments()[0];
        return TopologyProgrammingTest.this.futureUpdateLspOutput;
    }).when(listener).updateLsp(any(UpdateLspInput.class));
    doAnswer(invocation -> {
        TopologyProgrammingTest.this.removeLspArgs = (RemoveLspArgs) invocation.getArguments()[0];
        return TopologyProgrammingTest.this.futureRemoveLspOutput;
    }).when(listener).removeLsp(any(RemoveLspInput.class));
    doAnswer(invocation -> {
        TopologyProgrammingTest.this.triggerSyncArgs = (TriggerSyncArgs) invocation.getArguments()[0];
        return TopologyProgrammingTest.this.futureTriggerSyncOutput;
    }).when(listener).triggerSync(any(TriggerSyncInput.class));
    doAnswer(invocation -> {
        TopologyProgrammingTest.this.ensureLspInput = (EnsureLspOperationalInput) invocation.getArguments()[0];
        return TopologyProgrammingTest.this.futureEnsureLspOutput;
    }).when(listener).ensureLspOperational(any(EnsureLspOperationalInput.class));
    doNothing().when(listener).close();
    doReturn(this.instruction).when(this.instructionFuture).get();
    doReturn(true).when(this.instructionFuture).isDone();
    doNothing().when(this.instruction).executionCompleted(any(InstructionStatus.class), any(Details.class));
    doReturn(this.instructionFuture).when(this.scheduler).scheduleInstruction(any(SubmitInstructionInput.class));
    this.topologyProgramming = new TopologyProgramming(this.scheduler, this.manager);
    final PCEPSession session = getPCEPSession(getLocalPref(), getRemotePref());
    listener.onSessionUp(session);
}
Also used : PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Executor(java.util.concurrent.Executor) InstructionStatus(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionStatus) Details(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.status.changed.Details) RemoveLspInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.RemoveLspInput) EnsureLspOperationalInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.EnsureLspOperationalInput) AddLspInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.AddLspInput) TriggerSyncInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TriggerSyncInput) UpdateLspInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.UpdateLspInput) SubmitInstructionInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput) Before(org.junit.Before)

Example 12 with PCEPSession

use of org.opendaylight.protocol.pcep.PCEPSession in project bgpcep by opendaylight.

the class PCCMockCommon method checkSynchronizedSession.

static void checkSynchronizedSession(final int numberOfLsp, final TestingSessionListener pceSessionListener, final BigInteger expectedeInitialDb) throws Exception {
    assertTrue(pceSessionListener.isUp());
    // Send Open with LspDBV = 1
    final int numberOfSyncMessage = 1;
    int numberOfLspExpected = numberOfLsp;
    if (!expectedeInitialDb.equals(BigInteger.ZERO)) {
        checkEquals(() -> checkSequequenceDBVersionSync(pceSessionListener, expectedeInitialDb));
        numberOfLspExpected += numberOfSyncMessage;
    }
    checkReceivedMessages(pceSessionListener, numberOfLspExpected);
    final PCEPSession session = pceSessionListener.getSession();
    checkSession(session, DEAD_TIMER, KEEP_ALIVE);
    assertTrue(session.getRemoteTlvs().getAugmentation(Tlvs1.class).getStateful().getAugmentation(Stateful1.class).isInitiation());
    assertNull(session.getLocalTlvs().getAugmentation(Tlvs3.class).getLspDbVersion().getLspDbVersionValue());
}
Also used : PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Tlvs3(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3)

Example 13 with PCEPSession

use of org.opendaylight.protocol.pcep.PCEPSession in project bgpcep by opendaylight.

the class PCCTriggeredLspResyncTest method testSessionTriggeredLspReSync.

@Test
public void testSessionTriggeredLspReSync() throws Exception {
    final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
    final int lspQuantity = 3;
    final BigInteger numberOflspAndDBv = BigInteger.valueOf(lspQuantity);
    final Channel channel = createServer(factory, this.remoteAddress, new PCCPeerProposal());
    final PCEPSession session = createPCCSession(numberOflspAndDBv).get();
    assertNotNull(session);
    final TestingSessionListener pceSessionListener = getListener(factory);
    assertNotNull(pceSessionListener);
    checkSynchronizedSession(lspQuantity, pceSessionListener, numberOflspAndDBv);
    this.pccSessionListener.onMessage(session, createTriggerLspResync());
    final TestingSessionListener sessionListenerAfterReconnect = getListener(factory);
    checkResyncSession(Optional.of(lspQuantity), 2, 6, null, numberOflspAndDBv, sessionListenerAfterReconnect);
    channel.close().get();
}
Also used : PCCPeerProposal(org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCPeerProposal) PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Channel(io.netty.channel.Channel) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Aggregations

PCEPSession (org.opendaylight.protocol.pcep.PCEPSession)13 Test (org.junit.Test)10 Channel (io.netty.channel.Channel)5 LspDbVersionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder)5 BigInteger (java.math.BigInteger)4 PCCPeerProposal (org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCPeerProposal)4 LspDbVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion)4 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt)4 Collections (java.util.Collections)2 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)2 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)2 ChannelFuture (io.netty.channel.ChannelFuture)1 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 Executor (java.util.concurrent.Executor)1 Before (org.junit.Before)1 PCEPDispatcherImpl (org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl)1 PathComputationClient1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.PathComputationClient1)1 Tlvs3 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3)1 SymbolicPathName (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SymbolicPathName)1 LspIdentifiersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiersBuilder)1