Search in sources :

Example 11 with Rib

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

the class AppPeerTest method testAppPeer.

@Test
public void testAppPeer() throws ExecutionException, InterruptedException {
    appPeer.start(rib, neighbor, null, peerGroupLoader, tableTypeRegistry);
    verify(rib).getYangRibId();
    verify(rib).getService();
    verify(rib).createPeerDOMChain(any(DOMTransactionChainListener.class));
    verify(rib, times(1)).getLocalTablesKeys();
    appPeer.instantiateServiceInstance();
    verify(rib, times(3)).getYangRibId();
    verify(rib, times(2)).getRibSupportContext();
    verify(rib, times(2)).getLocalTablesKeys();
    verify(rib, times(2)).createPeerDOMChain(any(DOMTransactionChainListener.class));
    verify(domTx).newWriteOnlyTransaction();
    appPeer.closeServiceInstance();
    verify(domTx, times(2)).close();
    appPeer.stop().get();
    appPeer.start(rib, appPeer.getCurrentConfiguration(), null, peerGroupLoader, tableTypeRegistry);
    appPeer.instantiateServiceInstance();
    verify(rib, times(6)).getYangRibId();
    verify(rib, times(4)).getService();
    verify(rib, times(4)).createPeerDOMChain(any(DOMTransactionChainListener.class));
    verify(listener, times(2)).close();
    assertTrue(appPeer.containsEqualConfiguration(neighbor));
    assertFalse(appPeer.containsEqualConfiguration(new NeighborBuilder().setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.2"))).build()));
    appPeer.closeServiceInstance();
    verify(domTx, times(4)).close();
    appPeer.instantiateServiceInstance();
    verify(rib, times(6)).createPeerDOMChain(any(DOMTransactionChainListener.class));
    appPeer.closeServiceInstance();
    verify(domTx, times(6)).close();
    appPeer.stop().get();
}
Also used : DOMTransactionChainListener(org.opendaylight.mdsal.dom.api.DOMTransactionChainListener) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) NeighborBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 12 with Rib

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

the class BgpPeerTest method testBgpPeer.

@Test
public void testBgpPeer() throws ExecutionException, InterruptedException {
    final Neighbor neighbor = new NeighborBuilder().setAfiSafis(createAfiSafi()).setConfig(createConfig()).setNeighborAddress(NEIGHBOR_ADDRESS).setRouteReflector(createRR()).setTimers(createTimers()).setTransport(createTransport()).setAddPaths(createAddPath()).build();
    bgpPeer.start(rib, neighbor, null, peerGroupLoader, tableTypeRegistry);
    verify(rib).createPeerDOMChain(any());
    verify(rib, times(2)).getLocalAs();
    verify(rib).getLocalTables();
    bgpPeer.instantiateServiceInstance();
    verify(bgpPeerRegistry).addPeer(any(), any(), any());
    verify(dispatcher).createReconnectingClient(any(InetSocketAddress.class), any(), anyInt(), any(KeyMapping.class));
    final var ex = assertThrows(IllegalStateException.class, () -> bgpPeer.start(rib, neighbor, null, peerGroupLoader, tableTypeRegistry));
    assertEquals("Previous peer instance was not closed.", ex.getMessage());
    bgpPeer.closeServiceInstance();
    verify(bgpPeerRegistry).removePeer(any());
    verify(future).cancel(true);
    bgpPeer.stop().get();
    bgpPeer.start(rib, bgpPeer.getCurrentConfiguration(), null, peerGroupLoader, tableTypeRegistry);
    bgpPeer.instantiateServiceInstance();
    verify(rib, times(2)).createPeerDOMChain(any());
    verify(rib, times(4)).getLocalAs();
    verify(rib, times(2)).getLocalTables();
    verify(bgpPeerRegistry, times(2)).addPeer(any(), any(), any());
    verify(dispatcher, times(2)).createReconnectingClient(any(InetSocketAddress.class), any(), anyInt(), any(KeyMapping.class));
    final Neighbor neighborExpected = createNeighborExpected(NEIGHBOR_ADDRESS);
    assertTrue(bgpPeer.containsEqualConfiguration(neighborExpected));
    assertFalse(bgpPeer.containsEqualConfiguration(createNeighborExpected(new IpAddress(new Ipv4Address("127.0.0.2")))));
    bgpPeer.closeServiceInstance();
    verify(bgpPeerRegistry, times(2)).removePeer(any());
    verify(future, times(2)).cancel(true);
    bgpPeer.instantiateServiceInstance();
    verify(bgpPeerRegistry, times(3)).addPeer(any(), any(), any());
    verify(dispatcher, times(3)).createReconnectingClient(any(InetSocketAddress.class), any(), anyInt(), any(KeyMapping.class));
    bgpPeer.closeServiceInstance();
    verify(bgpPeerRegistry, times(3)).removePeer(any());
    verify(future, times(3)).cancel(true);
    verify(rib, times(3)).createPeerDOMChain(any());
    bgpPeer.stop().get();
    bgpPeer.start(rib, bgpPeer.getCurrentConfiguration(), null, peerGroupLoader, tableTypeRegistry);
    bgpPeer.instantiateServiceInstance();
    verify(rib, times(4)).createPeerDOMChain(any());
    verify(rib, times(6)).getLocalAs();
    verify(rib, times(3)).getLocalTables();
    verify(bgpPeerRegistry, times(4)).addPeer(any(), any(), any());
    verify(dispatcher, times(4)).createReconnectingClient(any(InetSocketAddress.class), any(), anyInt(), any(KeyMapping.class));
    bgpPeer.closeServiceInstance();
    verify(bgpPeerRegistry, times(4)).removePeer(any());
    verify(future, times(4)).cancel(true);
    bgpPeer.stop().get();
    final Neighbor neighborDiffConfig = new NeighborBuilder().setNeighborAddress(NEIGHBOR_ADDRESS).setAfiSafis(createAfiSafi()).build();
    bgpPeer.start(rib, neighborDiffConfig, null, peerGroupLoader, tableTypeRegistry);
    assertTrue(bgpPeer.containsEqualConfiguration(neighborDiffConfig));
    bgpPeer.stop().get();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Neighbor(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) NeighborBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 13 with Rib

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

the class GracefulRestartTest method performLocalGracefulRestart.

/**
 * Perform local graceful restart and verify routes are preserved.
 *
 * @throws Exception on reading Rib failure
 */
@Test
public void performLocalGracefulRestart() throws Exception {
    final List<Ipv4Prefix> ipv4prefixes = Arrays.asList(new Ipv4Prefix(PREFIX1), new Ipv4Prefix(PREFIX2));
    final List<Ipv6Prefix> ipv6prefixes = Arrays.asList(new Ipv6Prefix(PREFIX3));
    insertRoutes(ipv4prefixes, ipv6prefixes);
    checkLocRibIpv4Routes(2);
    checkLocRibIpv6Routes(1);
    this.peer.restartGracefully(DEFERRAL_TIMER).get();
    this.session = createPeerSession(PEER1, this.parameters, this.listener);
    checkUpState(this.listener);
    checkUpState(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 14 with Rib

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

the class GracefulRestartTest method waitForEORonLocalGracefulRestart.

/**
 * Wait with route selection until EOT is received.
 *
 * @throws Exception on reading Rib failure
 */
@Test
public void waitForEORonLocalGracefulRestart() 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);
    insertRoutes(null, null);
    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 15 with Rib

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

the class GlobalUtil method buildAfiSafi.

/**
 * Build Afi Safi containing State.
 *
 * @param ribState             containing RIb Operational State
 * @param tablesKey            table Key
 * @param bgpTableTypeRegistry BGP TableType Registry
 * @return Afi Safi Operational State
 */
public static AfiSafi buildAfiSafi(final BGPRibState ribState, final TablesKey tablesKey, final BGPTableTypeRegistryConsumer bgpTableTypeRegistry) {
    final Optional<Class<? extends AfiSafiType>> optAfiSafi = bgpTableTypeRegistry.getAfiSafiType(tablesKey);
    if (!optAfiSafi.isPresent()) {
        return null;
    }
    final State state = new StateBuilder().addAugmentation(GlobalAfiSafiStateAugmentation.class, new GlobalAfiSafiStateAugmentationBuilder().setTotalPaths(ribState.getPathCount(tablesKey)).setTotalPrefixes(ribState.getPrefixesCount(tablesKey)).build()).build();
    return new AfiSafiBuilder().setAfiSafiName(optAfiSafi.get()).setState(state).build();
}
Also used : GlobalAfiSafiStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAfiSafiStateAugmentation) AfiSafiBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder) GlobalAfiSafiStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAfiSafiStateAugmentationBuilder) BGPRibState(org.opendaylight.protocol.bgp.rib.spi.state.BGPRibState) State(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.State) StateBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder) AfiSafiType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType)

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