Search in sources :

Example 1 with BgpRib

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

the class ParserToSalTest method assertTablesExists.

private void assertTablesExists(final List<BgpTableType> expectedTables) throws InterruptedException, ExecutionException {
    readDataOperational(getDataBroker(), BGP_IID, bgpRib -> {
        final var tables = bgpRib.nonnullRib().values().iterator().next().getLocRib().getTables();
        assertNotNull(tables);
        for (final BgpTableType tableType : expectedTables) {
            boolean found = false;
            for (final Tables table : tables.values()) {
                if (table.getAfi().equals(tableType.getAfi()) && table.getSafi().equals(tableType.getSafi())) {
                    found = true;
                    assertEquals(Boolean.TRUE, table.getAttributes().getUptodate());
                }
            }
            assertTrue(found);
        }
        return bgpRib;
    });
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables)

Example 2 with BgpRib

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

the class AbstractAddPathTest method checkLocRib.

private void checkLocRib(final int expectedRoutesOnDS) throws Exception {
    // FIXME: remove this sleep
    Thread.sleep(100);
    readDataOperational(getDataBroker(), BGP_IID, bgpRib -> {
        final Ipv4RoutesCase routes = (Ipv4RoutesCase) bgpRib.getRib().values().iterator().next().getLocRib().nonnullTables().values().iterator().next().getRoutes();
        final int size;
        if (routes != null) {
            final Ipv4Routes routesCase = routes.getIpv4Routes();
            if (routesCase != null) {
                final Map<Ipv4RouteKey, Ipv4Route> routeList = routesCase.getIpv4Route();
                size = routeList == null ? 0 : routeList.size();
            } else {
                size = 0;
            }
        } else {
            size = 0;
        }
        assertEquals(expectedRoutesOnDS, size);
        return bgpRib;
    });
}
Also used : Ipv4RouteKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4RouteKey) Ipv4RoutesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.bgp.rib.rib.loc.rib.tables.routes.Ipv4RoutesCase) Ipv4Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.Ipv4Routes) Ipv4Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route)

Example 3 with BgpRib

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.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();
    try (StateProviderImpl stateProvider = // FIXME: use a properly-controlled executor service
    new StateProviderImpl(getDataBroker(), 1, tableTypeRegistry, this.stateProvider, "global-bgp")) {
        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);
            assertNull(bgpRib.getNeighbors());
            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(), bgpInstanceIdentifier, bgpRib -> {
            final Neighbors neighbors = bgpRib.getNeighbors();
            assertNotNull(neighbors);
            assertEquals(peerGroupExpected, bgpRib.getPeerGroups().nonnullPeerGroup().values().iterator().next());
            final Neighbor neighborResult = neighbors.nonnullNeighbor().values().iterator().next();
            assertEquals(new IpAddress(neighborAddress.getIpv4AddressNoZone()), 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.augmentation(BgpNeighborStateAugmentation.class));
            assertEquals(BgpNeighborState.SessionState.ESTABLISHED, stateResult.augmentation(NeighborStateAugmentation.class).getSessionState());
            final List<Class<? extends BgpCapability>> supportedCapabilitiesResult = stateResult.augmentation(NeighborStateAugmentation.class).getSupportedCapabilities();
            assertTrue(supportedCapabilitiesResult.containsAll(this.supportedCap));
            return bgpRib;
        });
        this.bgpRibStates.clear();
        checkNotPresentOperational(getDataBroker(), this.bgpInstanceIdentifier);
    }
}
Also used : ErrorHandling(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ErrorHandling) PeerGroup(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroup) Neighbors(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors) Neighbor(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor) BgpCapability(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.BgpCapability) AfiSafis(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis) BgpNeighborStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.BgpNeighborStateAugmentation) Global(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global) GracefulRestart(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestart) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Transport(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport) BgpNeighborStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.BgpNeighborStateAugmentation) NeighborStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborStateAugmentation) Timers(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Timers) AbstractDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 AbstractDataBrokerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTest)1 GracefulRestart (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestart)1 AfiSafis (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis)1 ErrorHandling (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ErrorHandling)1 Timers (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Timers)1 Transport (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport)1 Neighbor (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor)1 PeerGroup (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroup)1 Global (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global)1 Neighbors (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors)1 BgpCapability (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.BgpCapability)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 Ipv4RoutesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.bgp.rib.rib.loc.rib.tables.routes.Ipv4RoutesCase)1 Ipv4Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.Ipv4Routes)1 Ipv4Route (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route)1 Ipv4RouteKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4RouteKey)1 BgpTableType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType)1 BgpNeighborStateAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.BgpNeighborStateAugmentation)1 NeighborStateAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborStateAugmentation)1