Search in sources :

Example 11 with PCCTunnelManager

use of org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager in project bgpcep by opendaylight.

the class PCCTunnelManagerImplTest method testReturnDelegationPccLsp.

@Test
public void testReturnDelegationPccLsp() throws InterruptedException {
    final PCCTunnelManager tunnelManager = new PCCTunnelManagerImpl(1, ADDRESS, 1, -1, TIMER, this.timerHandler);
    tunnelManager.onSessionUp(this.session1);
    tunnelManager.onSessionUp(this.session2);
    tunnelManager.onMessagePcupd(createUpdate(1), this.session1);
    Mockito.verify(this.session1, Mockito.times(3)).sendReport(Mockito.any(Pcrpt.class));
    Mockito.verify(this.session2, Mockito.times(2)).sendReport(Mockito.any(Pcrpt.class));
    // wait for re-delegation timer expires
    Thread.sleep(1200);
    Mockito.verify(this.session2, Mockito.times(3)).sendReport(Mockito.any(Pcrpt.class));
}
Also used : PCCTunnelManager(org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) Test(org.junit.Test)

Example 12 with PCCTunnelManager

use of org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager in project bgpcep by opendaylight.

the class PCCTunnelManagerImplTest method testReturnDelegationNoRetake.

@Test
public void testReturnDelegationNoRetake() throws InterruptedException {
    final PCCTunnelManager tunnelManager = new PCCTunnelManagerImpl(0, ADDRESS, 0, 0, TIMER, this.timerHandler);
    tunnelManager.onSessionUp(this.session1);
    tunnelManager.onSessionUp(this.session2);
    tunnelManager.onMessagePcInitiate(createRequests(1), this.session1);
    tunnelManager.onMessagePcupd(createUpdate(1), this.session1);
    // wait for state timeout expires
    Thread.sleep(500);
    Mockito.verify(this.session1, Mockito.times(3)).sendReport(Mockito.any(Pcrpt.class));
    Mockito.verify(this.session2, Mockito.times(2)).sendReport(Mockito.any(Pcrpt.class));
}
Also used : PCCTunnelManager(org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) Test(org.junit.Test)

Example 13 with PCCTunnelManager

use of org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager in project bgpcep by opendaylight.

the class PCCsBuilder method createPCCs.

void createPCCs(final BigInteger initialDBVersion, final Optional<TimerHandler> timerHandler) {
    InetAddress currentAddress = this.localAddress.getAddress();
    this.pccDispatcher = new PCCDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry());
    if (timerHandler.isPresent()) {
        timerHandler.get().setPCCDispatcher(this.pccDispatcher);
    }
    for (int i = 0; i < this.pccCount; i++) {
        final PCCTunnelManager tunnelManager = new PCCTunnelManagerImpl(this.lsps, currentAddress, this.redelegationTimeout, this.stateTimeout, this.timer, timerHandler);
        createPCC(new InetSocketAddress(currentAddress, this.localAddress.getPort()), tunnelManager, initialDBVersion);
        currentAddress = InetAddresses.increment(currentAddress);
    }
}
Also used : PCCDispatcherImpl(org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl) PCCTunnelManager(org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager) InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress)

Example 14 with PCCTunnelManager

use of org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager in project bgpcep by opendaylight.

the class PCCTunnelManagerImplTest method testTakeDelegation.

@Test
public void testTakeDelegation() throws InterruptedException {
    final PCCTunnelManager tunnelManager = new PCCTunnelManagerImpl(0, ADDRESS, 0, -1, TIMER, this.timerHandler);
    tunnelManager.onSessionUp(this.session1);
    tunnelManager.onSessionUp(this.session2);
    // AddTunel
    tunnelManager.onMessagePcInitiate(createRequests(1), this.session1);
    // returnDelegation
    tunnelManager.onMessagePcupd(createUpdate(1), this.session1);
    Mockito.verify(this.session1, Mockito.times(2)).sendReport(Mockito.any(Pcrpt.class));
    Mockito.verify(this.session2, Mockito.times(1)).sendReport(Mockito.any(Pcrpt.class));
    Thread.sleep(500);
    // takeDelegation
    tunnelManager.onMessagePcInitiate(createRequestsDelegate(1), this.session2);
    Mockito.verify(this.session1, Mockito.times(2)).sendReport(Mockito.any(Pcrpt.class));
    Mockito.verify(this.session2, Mockito.times(2)).sendReport(Mockito.any(Pcrpt.class));
}
Also used : PCCTunnelManager(org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) Test(org.junit.Test)

Example 15 with PCCTunnelManager

use of org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager in project bgpcep by opendaylight.

the class PCCTunnelManagerImplTest method testRemoveTunnelNotPceInitiatedLsp.

@Test
public void testRemoveTunnelNotPceInitiatedLsp() {
    final PCCTunnelManager tunnelManager = new PCCTunnelManagerImpl(1, ADDRESS, 0, 0, TIMER, this.timerHandler);
    tunnelManager.onSessionUp(this.session1);
    tunnelManager.onMessagePcInitiate(createRequestsRemove(1), this.session1);
    Mockito.verify(this.session1, Mockito.times(1)).sendError(Mockito.any(Pcerr.class));
    assertEquals(PCEPErrors.LSP_NOT_PCE_INITIATED, this.errorsSession1.get(0));
}
Also used : PCCTunnelManager(org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager) Pcerr(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcerr) Test(org.junit.Test)

Aggregations

PCCTunnelManager (org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager)20 Test (org.junit.Test)18 Pcerr (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcerr)9 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt)8 PCCDispatcherImpl (org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl)2 HashedWheelTimer (io.netty.util.HashedWheelTimer)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 PCEPSessionImpl (org.opendaylight.protocol.pcep.impl.PCEPSessionImpl)1 PCCSessionListener (org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCSessionListener)1