Search in sources :

Example 11 with RibId

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

the class ParserToSalTest method testWithLinkstate.

@Test
public void testWithLinkstate() throws InterruptedException, ExecutionException {
    final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
    final RIBImpl rib = new RIBImpl(this.tableRegistry, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext2, this.dispatcher, this.codecsRegistry, getDomBroker(), this.policies, tables, Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory.createBestPathSelectionStrategy()));
    rib.instantiateServiceInstance();
    assertTablesExists(tables);
    final BGPPeer peer = AbstractAddPathTest.configurePeer(this.tableRegistry, this.localAddress.getIpv4AddressNoZone(), rib, null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
    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.rev180329.BgpTableType) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId) LinkstateSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.LinkstateSubsequentAddressFamily) LinkstateAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.LinkstateAddressFamily) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) Test(org.junit.Test)

Example 12 with RibId

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

the class ParserToSalTest method testWithoutLinkstate.

@Test
public void testWithoutLinkstate() throws InterruptedException, ExecutionException {
    final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
    final RIBImpl rib = new RIBImpl(this.tableRegistry, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext1, this.dispatcher, this.codecsRegistry, getDomBroker(), this.policies, tables, Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory.createBestPathSelectionStrategy()));
    rib.instantiateServiceInstance();
    assertTablesExists(tables);
    final BGPPeer peer = AbstractAddPathTest.configurePeer(this.tableRegistry, this.localAddress.getIpv4AddressNoZone(), rib, null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
    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.rev180329.BgpTableType) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily) Test(org.junit.Test)

Example 13 with RibId

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

the class SynchronizationAndExceptionTest method testHandleMessageAfterException.

@Test
public void testHandleMessageAfterException() {
    final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(TABLES_KEY, BasePathSelectionModeFactory.createBestPathSelectionStrategy());
    final RIBImpl ribImpl = new RIBImpl(this.tableRegistry, new RibId(RIB_ID), AS_NUMBER, new BgpId(RIB_ID), this.ribExtension, this.serverDispatcher, this.codecsRegistry, this.domBroker, this.policies, ImmutableList.of(this.ipv4tt), pathTables);
    ribImpl.instantiateServiceInstance();
    final BGPPeer bgpPeer = AbstractAddPathTest.configurePeer(this.tableRegistry, neighbor.getIpv4AddressNoZone(), ribImpl, null, PeerRole.Ibgp, this.serverRegistry, AFI_SAFIS_ADVERTIZED, Collections.emptySet());
    bgpPeer.instantiateServiceInstance();
    final BGPSessionImpl bgpSession = new BGPSessionImpl(bgpPeer, this.speakerListener, this.classicOpen, this.classicOpen.getHoldTimer().toJava(), null);
    bgpSession.setChannelExtMsgCoder(this.classicOpen);
    bgpPeer.onSessionUp(bgpSession);
    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 wrongMessage = new UpdateBuilder();
    wrongMessage.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 Ipv4AddressNoZone("127.0.0.1")).build()).build();
    final AttributesBuilder ab = new AttributesBuilder();
    wrongMessage.setAttributes(ab.setOrigin(origin).setAsPath(asPath).setCNextHop(nextHop).build());
    final UpdateBuilder correct = new UpdateBuilder(wrongMessage.build());
    correct.setAttributes(ab.setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(100)).build()).build());
    bgpSession.handleMessage(correct.build());
    verify(this.tx, times(2)).merge(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
    bgpSession.handleMessage(wrongMessage.build());
    verify(this.tx, times(2)).merge(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
    bgpSession.handleMessage(new UpdateBuilder().build());
    verify(this.tx, times(2)).merge(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class), any(NormalizedNode.class));
    verify(this.tx).delete(eq(LogicalDatastoreType.OPERATIONAL), eq(PEER_PATH));
    verify(this.tx, times(0)).merge(eq(LogicalDatastoreType.OPERATIONAL), eq(TABLE_PATH), eq(ImmutableNodes.leafNode(UPTODATE_NID, Boolean.TRUE)));
}
Also used : Origin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Origin) BgpOrigin(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpOrigin) LocalPrefBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.LocalPrefBuilder) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) OriginBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.OriginBuilder) UpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.UpdateBuilder) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId) AsPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPathBuilder) Ipv4NextHopCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.Ipv4NextHopCaseBuilder) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) CNextHop(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.CNextHop) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Nlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri) AsPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.AsPath) Ipv4NextHopBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpId) PathSelectionMode(org.opendaylight.protocol.bgp.mode.api.PathSelectionMode) NlriBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.NlriBuilder) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Test(org.junit.Test)

Example 14 with RibId

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

the class AddPathAllPathsTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(TABLES_KEY, new AllPathSelection());
    this.ribImpl = new RIBImpl(this.tableRegistry, new RibId("test-rib"), AS_NUMBER, BGP_ID, this.ribExtension, this.serverDispatcher, this.codecsRegistry, getDomBroker(), this.policies, TABLES_TYPE, pathTables);
    this.ribImpl.instantiateServiceInstance();
    final ChannelFuture channelFuture = this.serverDispatcher.createServer(new InetSocketAddress(RIB_ID, PORT.toJava()));
    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.rev180329.RibId) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.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 15 with RibId

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

the class AddPathNPathsTest method setUp.

@Override
@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(2));
    this.ribImpl = new RIBImpl(this.tableRegistry, new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID), this.ribExtension, this.serverDispatcher, this.codecsRegistry, getDomBroker(), this.policies, TABLES_TYPE, pathTables);
    this.ribImpl.instantiateServiceInstance();
    final ChannelFuture channelFuture = this.serverDispatcher.createServer(new InetSocketAddress(RIB_ID, PORT.toJava()));
    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.rev180329.RibId) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.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

RibId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId)11 PathSelectionMode (org.opendaylight.protocol.bgp.mode.api.PathSelectionMode)8 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)6 Before (org.junit.Before)5 ChannelFuture (io.netty.channel.ChannelFuture)4 InetSocketAddress (java.net.InetSocketAddress)4 Test (org.junit.Test)4 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)4 Global (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global)4 BgpTableType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType)4 BgpId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpId)4 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)4 Futures (com.google.common.util.concurrent.Futures)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 AllPathSelection (org.opendaylight.protocol.bgp.mode.impl.add.all.paths.AllPathSelection)2 BGPRibRoutingPolicyFactory (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.BGPRibRoutingPolicyFactory)2