use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib in project bgpcep by opendaylight.
the class StateProviderImplTest method testActiveStateProvider.
@Test
public void testActiveStateProvider() throws Exception {
doReturn(true).when(this.bgpRibState).isActive();
doReturn(true).when(this.bgpPeerState).isActive();
final StateProviderImpl stateProvider = new StateProviderImpl(getDataBroker(), 1, this.tableTypeRegistry, this.stateCollector, "global-bgp");
stateProvider.init();
final Global globalExpected = buildGlobalExpected(0);
this.bgpRibStates.add(this.bgpRibState);
readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
final Global global = bgpRib.getGlobal();
assertEquals(globalExpected, global);
return bgpRib;
});
this.totalPathsCounter.increment();
this.totalPrefixesCounter.increment();
final Global globalExpected2 = buildGlobalExpected(1);
readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
final Global global = bgpRib.getGlobal();
assertEquals(globalExpected2, global);
return bgpRib;
});
this.totalPathsCounter.decrement();
this.totalPrefixesCounter.decrement();
final Global globalExpected3 = buildGlobalExpected(0);
readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
final Global global = bgpRib.getGlobal();
assertEquals(globalExpected3, global);
Assert.assertNull(bgpRib.getNeighbors());
Assert.assertNull(bgpRib.getPeerGroups());
return bgpRib;
});
this.bgpPeerStates.add(this.bgpPeerState);
final PeerGroup peerGroupExpected = buildGroupExpected();
this.totalPathsCounter.increment();
this.totalPrefixesCounter.increment();
final AfiSafis expectedAfiSafis = buildAfiSafis();
final ErrorHandling expectedErrorHandling = buildErrorHandling();
final GracefulRestart expectedGracefulRestart = buildGracefulRestart();
final Transport expectedTransport = buildTransport();
final Timers expectedTimers = buildTimers();
final BgpNeighborStateAugmentation expectedBgpNeighborState = buildBgpNeighborStateAugmentation();
readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
final Neighbors neighbors = bgpRib.getNeighbors();
Assert.assertNotNull(neighbors);
assertEquals(peerGroupExpected, bgpRib.getPeerGroups().getPeerGroup().get(0));
final Neighbor neighborResult = neighbors.getNeighbor().get(0);
assertEquals(this.neighborAddress, neighborResult.getNeighborAddress());
assertEquals(expectedAfiSafis, neighborResult.getAfiSafis());
assertEquals(expectedErrorHandling, neighborResult.getErrorHandling());
assertEquals(expectedGracefulRestart, neighborResult.getGracefulRestart());
assertEquals(expectedTransport, neighborResult.getTransport());
assertEquals(expectedTimers, neighborResult.getTimers());
final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State stateResult = neighborResult.getState();
assertEquals(expectedBgpNeighborState, stateResult.getAugmentation(BgpNeighborStateAugmentation.class));
assertEquals(BgpNeighborState.SessionState.ESTABLISHED, stateResult.getAugmentation(NeighborStateAugmentation.class).getSessionState());
final List<Class<? extends BgpCapability>> supportedCapabilitiesResult = stateResult.getAugmentation(NeighborStateAugmentation.class).getSupportedCapabilities();
Assert.assertTrue(supportedCapabilitiesResult.containsAll(this.supportedCap));
return bgpRib;
});
this.bgpRibStates.clear();
checkNotPresentOperational(getDataBroker(), this.bgpInstanceIdentifier);
stateProvider.close();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib in project bgpcep by opendaylight.
the class ParserToSalTest method assertTablesExists.
private void assertTablesExists(final List<BgpTableType> expectedTables) throws ReadFailedException {
readDataOperational(getDataBroker(), BGP_IID, bgpRib -> {
final List<Tables> tables = bgpRib.getRib().get(0).getLocRib().getTables();
assertFalse(tables.isEmpty());
for (final BgpTableType tableType : expectedTables) {
boolean found = false;
for (final Tables table : tables) {
if (table.getAfi().equals(tableType.getAfi()) && table.getSafi().equals(tableType.getSafi())) {
found = true;
assertTrue(Boolean.valueOf(true).equals(table.getAttributes().isUptodate()));
}
}
assertTrue(found);
}
return bgpRib;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib in project bgpcep by opendaylight.
the class AbstractAddPathTest method checkLocRib.
private void checkLocRib(final int expectedRoutesOnDS) throws Exception {
Thread.sleep(100);
readDataOperational(getDataBroker(), BGP_IID, bgpRib -> {
final Ipv4RoutesCase routes = (Ipv4RoutesCase) bgpRib.getRib().get(0).getLocRib().getTables().get(0).getRoutes();
final List<Ipv4Route> routeList = routes.getIpv4Routes().getIpv4Route();
Assert.assertEquals(expectedRoutesOnDS, routeList.size());
return bgpRib;
});
}
Aggregations