Search in sources :

Example 26 with Rib

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

the class AddPathBasePathsTest 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, BasePathSelectionModeFactory.createBestPathSelectionStrategy());
    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) InetSocketAddress(java.net.InetSocketAddress) PathSelectionMode(org.opendaylight.protocol.bgp.mode.api.PathSelectionMode) Before(org.junit.Before)

Example 27 with Rib

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

the class GracefulRestartTest method retainRoutesOnPeerRestartTest.

/**
 * Test that routes from peer that has advertised the Graceful Restart Capability MUST be retained
 * for all the address families that were previously received in the Graceful Restart Capability.
 *
 * @throws Exception on reading Rib failure
 */
@Test
public void retainRoutesOnPeerRestartTest() throws Exception {
    final List<Ipv4Prefix> ipv4Prefixes = Arrays.asList(new Ipv4Prefix(PREFIX1), new Ipv4Prefix(PREFIX2));
    final List<Ipv6Prefix> ipv6Prefixes = Collections.singletonList(new Ipv6Prefix(PREFIX3));
    insertRoutes(ipv4Prefixes, ipv6Prefixes);
    checkLocRibIpv4Routes(2);
    checkLocRibIpv6Routes(1);
    this.session.close();
    checkIdleState(this.peer);
    checkLocRibIpv4Routes(2);
    checkLocRibIpv6Routes(0);
}
Also used : Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) Test(org.junit.Test)

Example 28 with Rib

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

the class GracefulRestartTest method verifySendEORafterRestartTest.

/**
 * After graceful restart is performed from peer side we have to re-advertise routes followed by
 * End-of-RIB marker.
 *
 * @throws Exception on reading Rib failure
 */
@Test
public void verifySendEORafterRestartTest() throws Exception {
    final SimpleSessionListener listener2 = new SimpleSessionListener();
    configurePeer(this.tableRegistry, PEER2, this.ribImpl, this.parameters, PeerRole.Ebgp, this.serverRegistry, afiSafiAdvertised, gracefulAfiSafiAdvertised);
    final BGPSessionImpl session2 = createPeerSession(PEER2, this.parameters, listener2);
    final List<Ipv4Prefix> ipv4Prefixes = Arrays.asList(new Ipv4Prefix(PREFIX1));
    final List<Ipv4Prefix> ipv4Prefixes2 = Arrays.asList(new Ipv4Prefix(PREFIX2));
    final List<Ipv6Prefix> ipv6Prefixes = Collections.singletonList(new Ipv6Prefix(PREFIX3));
    insertRoutes(ipv4Prefixes, ipv6Prefixes);
    insertRoutes(ipv4Prefixes2, PEER2, null, null, session2, BgpOrigin.Egp);
    checkLocRibIpv4Routes(2);
    checkLocRibIpv6Routes(1);
    org.opendaylight.protocol.util.CheckUtil.checkReceivedMessages(this.listener, 3);
    // verify sending of Ipv4 EOT, Ipv6 EOT and Ipv4 update with route
    checkReceivedMessages(this.listener, 3);
    assertTrue(this.listener.getListMsg().get(0) instanceof Update);
    assertTrue(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(0)));
    assertTrue(this.listener.getListMsg().get(1) instanceof Update);
    assertTrue(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(1)));
    assertTrue(this.listener.getListMsg().get(2) instanceof Update);
    assertFalse(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(2)));
    this.session.close();
    checkIdleState(this.peer);
    checkLocRibIpv4Routes(2);
    checkLocRibIpv6Routes(0);
    // verify nothing new was sent
    checkReceivedMessages(this.listener, 3);
    this.session = createPeerSession(PEER1, createParameter(false, true, Collections.singletonMap(TABLES_KEY, true)), this.listener);
    checkUpState(listener);
    checkUpState(this.peer);
    org.opendaylight.protocol.util.CheckUtil.checkReceivedMessages(this.listener, 6);
    // verify sending of Ipv4 update with route, Ipv4 EOT and Ipv6 EOT; order can vary based on ODTC order
    final List<Notification> subList = this.listener.getListMsg().subList(3, 6);
    int eotCount = 0;
    int routeUpdateCount = 0;
    for (Notification message : subList) {
        if (BgpPeerUtil.isEndOfRib((Update) message)) {
            eotCount++;
        } else {
            routeUpdateCount++;
        }
    }
    assertEquals(2, eotCount);
    assertEquals(1, routeUpdateCount);
}
Also used : Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Notification(org.opendaylight.yangtools.yang.binding.Notification) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) Test(org.junit.Test)

Example 29 with Rib

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

the class GracefulRestartTest method waitForDeferralTimerOnLocalGracefulRestart.

/**
 * Wait with route selection until deferral time is expired.
 *
 * @throws Exception on reading Rib failure
 */
@Test
public void waitForDeferralTimerOnLocalGracefulRestart() throws Exception {
    performLocalGracefulRestart();
    final List<Ipv4Prefix> ipv4prefixes = Arrays.asList(new Ipv4Prefix(PREFIX1));
    final List<Ipv6Prefix> ipv6prefixes = Arrays.asList(new Ipv6Prefix(PREFIX3));
    insertRoutes(ipv4prefixes, ipv6prefixes);
    checkLocRibIpv4Routes(2);
    checkLocRibIpv6Routes(0);
    checkStateIsNotRestarting(this.peer, DEFERRAL_TIMER);
    checkLocRibIpv4Routes(2);
    checkLocRibIpv6Routes(1);
}
Also used : Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) Test(org.junit.Test)

Example 30 with Rib

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

the class GracefulRestartTest method removeStaleRoutesAfterRestartTest.

/**
 * Once the End-of-RIB marker for an address family is received from the peer, it MUST
 * immediately remove any routes from the peer that are still marked as stale for that
 * address family.
 *
 * @throws Exception on reading Rib failure
 */
@Test
public void removeStaleRoutesAfterRestartTest() throws Exception {
    retainRoutesOnPeerRestartTest();
    this.session = createPeerSession(PEER1, createParameter(false, true, Collections.singletonMap(TABLES_KEY, true)), this.listener);
    checkUpState(this.listener);
    final List<Ipv4Prefix> ipv4prefixes = Arrays.asList(new Ipv4Prefix(PREFIX1));
    insertRoutes(ipv4prefixes, null);
    insertRoutes(null, null);
    checkLocRibIpv4Routes(1);
    checkLocRibIpv6Routes(0);
}
Also used : Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)7 InetSocketAddress (java.net.InetSocketAddress)5 Before (org.junit.Before)5 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)5 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)5 RibId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId)5 ByteBuf (io.netty.buffer.ByteBuf)4 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)4 ChannelFuture (io.netty.channel.ChannelFuture)3 ExecutionException (java.util.concurrent.ExecutionException)3 PathSelectionMode (org.opendaylight.protocol.bgp.mode.api.PathSelectionMode)3 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)3 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)3 BgpTableType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType)3 ArrayList (java.util.ArrayList)2 BGPRouteEntryExportParametersImpl (org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl)2 NeighborBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder)2 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)2