Search in sources :

Example 11 with Rib

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.Rib in project bgpcep by opendaylight.

the class ParserToSalTest method testWithoutLinkstate.

@Test
public void testWithoutLinkstate() throws ReadFailedException {
    final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
    final RIBImpl rib = new RIBImpl(new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext1, this.dispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker, tables, Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker)));
    rib.instantiateServiceInstance();
    rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
    assertTablesExists(tables);
    final BGPPeer peer = new BGPPeer(this.localAddress, rib, PeerRole.Ibgp, null, Collections.emptySet(), Collections.emptySet());
    peer.instantiateServiceInstance();
    final ListenerRegistration<?> reg = this.mock.registerUpdateListener(peer);
    reg.close();
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily) Test(org.junit.Test)

Example 12 with Rib

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.Rib in project bgpcep by opendaylight.

the class PeerTest method testClassicPeer.

@Test
public void testClassicPeer() throws Exception {
    this.classic = new BGPPeer(this.neighborAddress, getRib(), PeerRole.Ibgp, null, Collections.emptySet(), Collections.emptySet());
    this.classic.instantiateServiceInstance();
    this.mockSession();
    assertEquals(this.neighborAddress.getIpv4Address().getValue(), this.classic.getName());
    this.classic.onSessionUp(this.session);
    Assert.assertArrayEquals(new byte[] { 1, 1, 1, 1 }, this.classic.getRawIdentifier());
    assertEquals("BGPPeer{name=127.0.0.1, tables=[TablesKey{_afi=interface org.opendaylight.yang.gen.v1.urn" + ".opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily," + " _safi=interface org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types" + ".rev130919.UnicastSubsequentAddressFamily}]}", this.classic.toString());
    final Nlri n1 = new NlriBuilder().setPrefix(new Ipv4Prefix("8.0.1.0/28")).build();
    final Nlri n2 = new NlriBuilder().setPrefix(new Ipv4Prefix("127.0.0.1/32")).build();
    final Nlri n3 = new NlriBuilder().setPrefix(new Ipv4Prefix("2.2.2.2/24")).build();
    final List<Nlri> nlris = Lists.newArrayList(n1, n2, n3);
    final UpdateBuilder ub = new UpdateBuilder();
    ub.setNlri(nlris);
    final Origin origin = new OriginBuilder().setValue(BgpOrigin.Igp).build();
    final AsPath asPath = new AsPathBuilder().setSegments(Collections.emptyList()).build();
    final CNextHop nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("127.0.0.1")).build()).build();
    final AttributesBuilder ab = new AttributesBuilder();
    ub.setAttributes(ab.setOrigin(origin).setAsPath(asPath).setCNextHop(nextHop).build());
    try {
        this.classic.onMessage(this.session, ub.build());
        fail();
    } catch (final BGPDocumentedException e) {
        assertEquals(BGPError.MANDATORY_ATTR_MISSING_MSG + "LOCAL_PREF", e.getMessage());
        assertEquals(BGPError.WELL_KNOWN_ATTR_MISSING.getCode(), e.getError().getCode());
        assertEquals(BGPError.WELL_KNOWN_ATTR_MISSING.getSubcode(), e.getError().getSubcode());
        assertArrayEquals(new byte[] { LocalPreferenceAttributeParser.TYPE }, e.getData());
    }
    assertEquals(0, this.routes.size());
    final LocalPref localPref = new LocalPrefBuilder().setPref((long) 100).build();
    ub.setAttributes(ab.setLocalPref(localPref).build());
    this.classic.onMessage(this.session, ub.build());
    assertEquals(3, this.routes.size());
    // create new peer so that it gets advertized routes from RIB
    final BGPPeer testingPeer = new BGPPeer(this.neighborAddress, getRib(), PeerRole.Ibgp, null, Collections.emptySet(), Collections.emptySet());
    testingPeer.instantiateServiceInstance();
    testingPeer.onSessionUp(this.session);
    assertEquals(3, this.routes.size());
    final Nlri n11 = new NlriBuilder().setPrefix(new Ipv4Prefix("8.0.1.0/28")).build();
    final Nlri n22 = new NlriBuilder().setPrefix(new Ipv4Prefix("8.0.1.16/28")).build();
    final List<Nlri> nlris2 = Lists.newArrayList(n11, n22);
    ub.setNlri(nlris2);
    final WithdrawnRoutes w1 = new WithdrawnRoutesBuilder().setPrefix(new Ipv4Prefix("8.0.1.0/28")).build();
    final WithdrawnRoutes w2 = new WithdrawnRoutesBuilder().setPrefix(new Ipv4Prefix("127.0.0.1/32")).build();
    final WithdrawnRoutes w3 = new WithdrawnRoutesBuilder().setPrefix(new Ipv4Prefix("2.2.2.2/24")).build();
    final List<WithdrawnRoutes> wrs = Lists.newArrayList(w1, w2, w3);
    ub.setWithdrawnRoutes(wrs);
    this.classic.onMessage(this.session, ub.build());
    assertEquals(2, this.routes.size());
    this.classic.onMessage(this.session, new KeepaliveBuilder().build());
    this.classic.onMessage(this.session, new UpdateBuilder().setAttributes(new AttributesBuilder().addAugmentation(Attributes2.class, new Attributes2Builder().setMpUnreachNlri(new MpUnreachNlriBuilder().setAfi(AFI).setSafi(SAFI).build()).build()).build()).build());
    this.classic.onMessage(this.session, new RouteRefreshBuilder().setAfi(AFI).setSafi(SAFI).build());
    this.classic.onMessage(this.session, new RouteRefreshBuilder().setAfi(Ipv6AddressFamily.class).setSafi(SAFI).build());
    assertEquals(2, this.routes.size());
    this.classic.releaseConnection();
}
Also used : BgpOrigin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin) Origin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.Origin) LocalPrefBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.LocalPrefBuilder) Ipv6AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily) OriginBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.OriginBuilder) UpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder) WithdrawnRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.update.message.WithdrawnRoutes) WithdrawnRoutesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.update.message.WithdrawnRoutesBuilder) AsPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder) Ipv4NextHopCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCaseBuilder) LocalPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.LocalPref) KeepaliveBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.KeepaliveBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) RouteRefreshBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.RouteRefreshBuilder) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlriBuilder) CNextHop(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop) Nlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.update.message.Nlri) Attributes2Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes2Builder) AsPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPath) Ipv4NextHopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder) BGPDocumentedException(org.opendaylight.protocol.bgp.parser.BGPDocumentedException) NlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.update.message.NlriBuilder) MpUnreachNlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpUnreachNlriBuilder) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder) Test(org.junit.Test)

Example 13 with Rib

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.Rib in project bgpcep by opendaylight.

the class AddPathAllPathsTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(TABLES_KEY, new AllPathSelection(this.peerTracker));
    this.ribImpl = new RIBImpl(new RibId("test-rib"), AS_NUMBER, BGP_ID, this.ribExtension, this.serverDispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker, TABLES_TYPE, pathTables);
    this.ribImpl.instantiateServiceInstance();
    this.ribImpl.onGlobalContextUpdated(this.schemaContext);
    final ChannelFuture channelFuture = this.serverDispatcher.createServer(new InetSocketAddress(RIB_ID, PORT));
    waitFutureSuccess(channelFuture);
    this.serverChannel = channelFuture.channel();
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) InetSocketAddress(java.net.InetSocketAddress) AllPathSelection(org.opendaylight.protocol.bgp.mode.impl.add.all.paths.AllPathSelection) PathSelectionMode(org.opendaylight.protocol.bgp.mode.api.PathSelectionMode) Before(org.junit.Before)

Example 14 with Rib

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.Rib in project bgpcep by opendaylight.

the class AddPathBasePathsTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    final TablesKey tk = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
    final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(tk, BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker));
    this.ribImpl = new RIBImpl(new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID), this.ribExtension, this.serverDispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker, TABLES_TYPE, pathTables);
    this.ribImpl.instantiateServiceInstance();
    this.ribImpl.onGlobalContextUpdated(this.schemaContext);
    final ChannelFuture channelFuture = this.serverDispatcher.createServer(new InetSocketAddress(RIB_ID, PORT));
    waitFutureSuccess(channelFuture);
    this.serverChannel = channelFuture.channel();
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId) InetSocketAddress(java.net.InetSocketAddress) PathSelectionMode(org.opendaylight.protocol.bgp.mode.api.PathSelectionMode) Before(org.junit.Before)

Example 15 with Rib

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.Rib in project bgpcep by opendaylight.

the class AddPathNPathsTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    final TablesKey tk = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
    final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(tk, new AddPathBestNPathSelection(2L, this.peerTracker));
    this.ribImpl = new RIBImpl(new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID), this.ribExtension, this.serverDispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies, this.peerTracker, TABLES_TYPE, pathTables);
    this.ribImpl.instantiateServiceInstance();
    this.ribImpl.onGlobalContextUpdated(this.schemaContext);
    final ChannelFuture channelFuture = this.serverDispatcher.createServer(new InetSocketAddress(RIB_ID, PORT));
    waitFutureSuccess(channelFuture);
    this.serverChannel = channelFuture.channel();
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId) AddPathBestNPathSelection(org.opendaylight.protocol.bgp.mode.impl.add.n.paths.AddPathBestNPathSelection) InetSocketAddress(java.net.InetSocketAddress) PathSelectionMode(org.opendaylight.protocol.bgp.mode.api.PathSelectionMode) Before(org.junit.Before)

Aggregations

Test (org.junit.Test)7 RibId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId)6 ByteBuf (io.netty.buffer.ByteBuf)4 Before (org.junit.Before)4 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)4 ChannelFuture (io.netty.channel.ChannelFuture)3 InetSocketAddress (java.net.InetSocketAddress)3 PathSelectionMode (org.opendaylight.protocol.bgp.mode.api.PathSelectionMode)3 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)3 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update)3 BgpTableType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType)3 ExecutionException (java.util.concurrent.ExecutionException)2 BGPRouteEntryExportParametersImpl (org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl)2 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)2 Peer (org.opendaylight.protocol.bgp.rib.spi.Peer)2 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)2 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)2 BgpId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId)2 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1