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();
}
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();
}
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);
}
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);
}
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();
}
Aggregations