Search in sources :

Example 1 with PCEPSession

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

the class IncrementalSynchronizationProcedureTest method testStateSynchronizationPerformed.

@Test
public void testStateSynchronizationPerformed() throws Exception {
    PCEPSession session = getPCEPSession(getOpen(null), getOpen(null));
    this.listener.onSessionUp(session);
    // report LSP + LSP-DB version number
    final Pcrpt pcRpt = getPcrpt(1L, "test");
    this.listener.onMessage(session, pcRpt);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertFalse(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
    this.listener.onSessionDown(session, new IllegalArgumentException());
    this.listener = (Stateful07TopologySessionListener) getSessionListener();
    // session up - expect sync (LSP-DBs do not match)
    final LspDbVersion localDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(2L)).build();
    session = getPCEPSession(getOpen(localDbVersion), getOpen(null));
    this.listener.onSessionUp(session);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - IncrementalSync state
        assertEquals(PccSyncState.IncrementalSync, pcc.getStateSync());
        // check reported LSP - persisted from previous session
        assertFalse(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
    // report LSP2 + LSP-DB version number 2
    final Pcrpt pcRpt2 = getPcrpt(2L, "testsecond");
    this.listener.onMessage(session, pcRpt2);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - synchronized
        assertEquals(PccSyncState.IncrementalSync, pcc.getStateSync());
        // check reported LSP is not empty
        assertEquals(2, pcc.getReportedLsp().size());
        return pcc;
    });
    // sync rpt + LSP-DB
    final Pcrpt syncMsg = getSyncPcrt();
    this.listener.onMessage(session, syncMsg);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - synchronized
        assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
        // check reported LSP is empty, LSP state from previous session was purged
        assertEquals(2, pcc.getReportedLsp().size());
        return pcc;
    });
    // report LSP3 + LSP-DB version number 4
    final Pcrpt pcRpt3 = getPcrpt(3L, "testthird");
    this.listener.onMessage(session, pcRpt3);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - synchronized
        assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
        assertEquals(3, pcc.getReportedLsp().size());
        return pcc;
    });
}
Also used : PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion) LspDbVersionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder) Test(org.junit.Test)

Example 2 with PCEPSession

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

the class PCETriggeredInitialSyncProcedureTest method testPcepTriggeredInitialSyncPerformed.

/**
 * Test Triggered Initial Sync procedure.
 */
@Test
public void testPcepTriggeredInitialSyncPerformed() throws Exception {
    this.listener = (Stateful07TopologySessionListener) getSessionListener();
    // session up - expect triggered sync (LSP-DBs do not match)
    final LspDbVersion localDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.ONE).build();
    final LspDbVersion localDbVersion2 = new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(2L)).build();
    final PCEPSession session = getPCEPSession(getOpen(localDbVersion, Boolean.FALSE), getOpen(localDbVersion2, Boolean.FALSE));
    this.listener.onSessionUp(session);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - not synchronized and TriggeredInitialSync state
        assertEquals(PccSyncState.TriggeredInitialSync, pcc.getStateSync());
        return pcc;
    });
    // sync rpt + LSP-DB
    final Pcrpt syncMsg = getsyncMsg();
    this.listener.onMessage(session, syncMsg);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - synchronized
        assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
        // check reported LSP is empty, LSP state from previous session was purged
        assertTrue(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
    // report LSP + LSP-DB version number
    final Pcrpt pcRpt = getPcrpt();
    this.listener.onMessage(session, pcRpt);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertFalse(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
}
Also used : PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion) LspDbVersionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder) Test(org.junit.Test)

Example 3 with PCEPSession

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

the class StateSynchronizationAvoidanceProcedureTest method testStateSynchronizationPerformed.

@Test
public void testStateSynchronizationPerformed() throws Exception {
    PCEPSession session = getPCEPSession(getOpen(null), getOpen(null));
    this.listener.onSessionUp(session);
    // report LSP + LSP-DB version number
    final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder().setPlspId(new PlspId(1L)).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder().setLspId(new LspId(1L)).build()).setSymbolicPathName(new SymbolicPathNameBuilder().setPathName(new SymbolicPathName("test".getBytes())).build()).addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.ONE).build()).build()).build()).setPlspId(new PlspId(1L)).setSync(true).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.absent(), createPath(Collections.emptyList()));
    this.listener.onMessage(session, pcRpt);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertFalse(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
    this.listener.onSessionDown(session, new IllegalArgumentException("Simulate Exception"));
    this.listener = (Stateful07TopologySessionListener) getSessionListener();
    // session up - expect sync (LSP-DBs do not match)
    final LspDbVersion localDbVersion = new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(2L)).build();
    session = getPCEPSession(getOpen(localDbVersion), getOpen(null));
    this.listener.onSessionUp(session);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - not synchronized
        assertEquals(PccSyncState.InitialResync, pcc.getStateSync());
        // check reported LSP - persisted from previous session
        assertFalse(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
    // sync rpt + LSP-DB
    final Pcrpt syncMsg = MsgBuilderUtil.createPcRtpMessage(createLsp(0, false, Optional.of(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.valueOf(2L)).build()).build()).build()), true, false), Optional.absent(), createPath(Collections.emptyList()));
    this.listener.onMessage(session, syncMsg);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        // check node - synchronized
        assertEquals(PccSyncState.Synchronized, pcc.getStateSync());
        // check reported LSP is empty, LSP state from previous session was purged
        assertTrue(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
}
Also used : LspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId) LspIdentifiersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiersBuilder) Collections(java.util.Collections) SymbolicPathNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathNameBuilder) LspDbVersionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder) PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) SymbolicPathName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SymbolicPathName) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId) Test(org.junit.Test)

Example 4 with PCEPSession

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

the class StateSynchronizationAvoidanceProcedureTest method testNodePersisted.

@Test
public void testNodePersisted() throws ReadFailedException {
    final PCEPSession session = getPCEPSession(getOpen(null), getOpen(null));
    this.listener.onSessionUp(session);
    // report LSP + LSP-DB version number
    final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder().setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.TlvsBuilder().addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs1Builder().setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(BigInteger.ONE).build()).build()).build()).setPlspId(new PlspId(1L)).setSync(false).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(1L)), null);
    this.listener.onMessage(session, pcRpt);
    // check topology
    readDataOperational(getDataBroker(), this.pathComputationClientIId.builder().augmentation(PathComputationClient1.class).child(LspDbVersion.class).build(), dbVersion -> {
        assertEquals(1L, dbVersion.getLspDbVersionValue().longValue());
        return dbVersion;
    });
    // drop session
    this.listener.onSessionDown(session, new IllegalStateException());
    readDataOperational(getDataBroker(), TOPO_IID, topology -> {
        assertFalse(topology.getNode().isEmpty());
        return topology;
    });
// check topology - node is persisted
}
Also used : Collections(java.util.Collections) LspDbVersionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder) PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) PathComputationClient1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.PathComputationClient1) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId) Test(org.junit.Test)

Example 5 with PCEPSession

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

the class PCCMockCommon method checkResyncSession.

static void checkResyncSession(final Optional<Integer> startAtNumberLsp, final int expectedNumberOfLsp, final int expectedTotalMessages, final BigInteger startingDBVersion, final BigInteger expectedDBVersion, final TestingSessionListener pceSessionListener) throws Exception {
    assertNotNull(pceSessionListener.getSession());
    assertTrue(pceSessionListener.isUp());
    final List<Message> messages;
    checkReceivedMessages(pceSessionListener, expectedTotalMessages);
    if (startAtNumberLsp.isPresent()) {
        messages = pceSessionListener.messages().subList(startAtNumberLsp.get(), startAtNumberLsp.get() + expectedNumberOfLsp);
    } else {
        messages = pceSessionListener.messages();
    }
    checkEquals(() -> checkSequequenceDBVersionSync(pceSessionListener, expectedDBVersion));
    assertEquals(expectedNumberOfLsp, messages.size());
    final PCEPSession session = pceSessionListener.getSession();
    checkSession(session, DEAD_TIMER, KEEP_ALIVE);
    assertTrue(session.getRemoteTlvs().getAugmentation(Tlvs1.class).getStateful().getAugmentation(Stateful1.class).isInitiation());
    final BigInteger pceDBVersion = session.getLocalTlvs().getAugmentation(Tlvs3.class).getLspDbVersion().getLspDbVersionValue();
    assertEquals(startingDBVersion, pceDBVersion);
}
Also used : PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message) BigInteger(java.math.BigInteger)

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