Search in sources :

Example 16 with Pcinitiate

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Pcinitiate in project bgpcep by opendaylight.

the class PCEPTopologySessionListenerTest method testDelegatedLspsCountWithoutDelegation.

@Test
public void testDelegatedLspsCountWithoutDelegation() throws Exception {
    listener.onSessionUp(session);
    topologyRpcs.addLsp(createAddLspInput());
    assertEquals(1, receivedMsgs.size());
    assertTrue(receivedMsgs.get(0) instanceof Pcinitiate);
    final Pcinitiate pcinitiate = (Pcinitiate) receivedMsgs.get(0);
    final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
    final Uint32 srpId = req.getSrp().getOperationId().getValue();
    final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, testAddress, testAddress, testAddress, Optional.empty());
    // delegate set to false
    final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setPlspId(new PlspId(Uint32.ONE)).setSync(FALSE).setRemove(FALSE).setOperational(OperationalStatus.Active).setDelegate(FALSE).build(), Optional.of(MsgBuilderUtil.createSrp(srpId)), MsgBuilderUtil.createPath(req.getEro().getSubobject()));
    listener.onMessage(session, pcRpt);
    checkEquals(() -> assertEquals(0, listener.listenerState.getDelegatedLspsCount().intValue()));
}
Also used : Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.Tlvs) MsgBuilderUtil.createLspTlvs(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcrpt) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Pcinitiate(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Pcinitiate) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId) Test(org.junit.Test)

Example 17 with Pcinitiate

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Pcinitiate in project bgpcep by opendaylight.

the class PCEPTopologySessionListenerTest method testOnServerSessionManagerRestartAndSessionRecovery.

@Test
public void testOnServerSessionManagerRestartAndSessionRecovery() throws Exception {
    // close server session manager first
    stopSessionManager();
    assertFalse(session.isClosed());
    listener.onSessionUp(session);
    // verify the session was NOT added to topology
    checkNotPresentOperational(getDataBroker(), TOPO_IID);
    // verify the session is closed due to server session manager is closed
    assertTrue(session.isClosed());
    // send request
    final Future<RpcResult<AddLspOutput>> futureOutput = topologyRpcs.addLsp(createAddLspInput());
    final AddLspOutput output = futureOutput.get().getResult();
    // deal with unsent request after session down
    assertEquals(FailureType.Unsent, output.getFailure());
    // PCC client is not there
    checkNotPresentOperational(getDataBroker(), pathComputationClientIId);
    // reset received message queue
    receivedMsgs.clear();
    // now we restart the session manager
    startSessionManager();
    // try to start the session again
    // notice since the session was terminated before, it is not usable anymore.
    // we need to get a new session instance. the new session will have the same local / remote preference
    session = getPCEPSession(getLocalPref(), getRemotePref());
    assertFalse(session.isClosed());
    listener.onSessionUp(session);
    assertFalse(session.isClosed());
    // create node
    topologyRpcs.addLsp(createAddLspInput());
    final Pcinitiate pcinitiate = (Pcinitiate) receivedMsgs.get(0);
    final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
    final Uint32 srpId = req.getSrp().getOperationId().getValue();
    final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, testAddress, testAddress, testAddress, Optional.empty());
    final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setSync(TRUE).setRemove(FALSE).setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(srpId)), MsgBuilderUtil.createPath(req.getEro().getSubobject()));
    listener.onMessage(session, pcRpt);
    readDataOperational(getDataBroker(), TOPO_IID, topology -> {
        assertEquals(1, topology.nonnullNode().size());
        return topology;
    });
}
Also used : AddLspOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.AddLspOutput) Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.Tlvs) MsgBuilderUtil.createLspTlvs(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcrpt) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Pcinitiate(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Pcinitiate) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 MsgBuilderUtil.createLspTlvs (org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs)14 Pcinitiate (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Pcinitiate)9 Pcinitiate (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Pcinitiate)8 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests)8 Requests (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.Requests)8 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt)7 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)7 Tlvs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs)7 Pcrpt (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcrpt)7 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder)7 Tlvs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.lsp.Tlvs)7 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)7 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)4 PlspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.PlspId)4 ByteBuf (io.netty.buffer.ByteBuf)2 Collections (java.util.Collections)2 PCEPCloseTermination (org.opendaylight.protocol.pcep.PCEPCloseTermination)2 NetworkTopologyRef (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.topology.rev140113.NetworkTopologyRef)2 Pcupd (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Pcupd)2