use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType in project bgpcep by opendaylight.
the class OpenConfigMappingUtilTest method toPathSelectionMode.
@Test
public void toPathSelectionMode() {
final List<AfiSafi> families = new ArrayList<>();
families.add(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).addAugmentation(new GlobalAddPathsConfigBuilder().setSendMax(N_PATHS).build()).build());
families.add(new AfiSafiBuilder().setAfiSafiName(IPV6UNICAST.class).addAugmentation(new GlobalAddPathsConfigBuilder().setSendMax(ALL_PATHS).build()).build());
final Map<BgpTableType, PathSelectionMode> result = OpenConfigMappingUtil.toPathSelectionMode(families, tableTypeRegistry);
final Map<BgpTableType, PathSelectionMode> expected = new HashMap<>();
expected.put(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class), ADD_PATH_BEST_N_PATH_SELECTION);
expected.put(new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class), ADD_PATH_BEST_ALL_PATH_SELECTION);
// FIXME: these assertions are wrong, as they perform lookup on non-existing keys
assertEquals(expected.get(0), result.get(0));
assertEquals(expected.get(1), result.get(1));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType in project bgpcep by opendaylight.
the class AbstractRIBTestSetup method mockRib.
public void mockRib() throws Exception {
final RIBExtensionProviderContext context = new SimpleRIBExtensionProviderContext();
final List<BgpTableType> localTables = new ArrayList<>();
localTables.add(new BgpTableTypeImpl(IPV4_AFI, SAFI));
localTables.add(new BgpTableTypeImpl(IPV6_AFI, SAFI));
final CurrentAdapterSerializer serializer = mappingService.currentSerializer();
this.a1.startRIBExtensionProvider(context, serializer);
mockedMethods();
doReturn(mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider).registerClusterSingletonService(any(ClusterSingletonService.class));
this.rib = new RIBImpl(this.tableRegistry, new RibId("test"), new AsNumber(Uint32.valueOf(5)), RIB_ID, context, this.dispatcher, new ConstantCodecsRegistry(serializer), this.dom, this.policies, localTables, Collections.singletonMap(KEY, BasePathSelectionModeFactory.createBestPathSelectionStrategy()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType in project bgpcep by opendaylight.
the class EventBusRegistration method sendMessage.
private static void sendMessage(final BGPSessionListener listener, final Notification message) {
if (BGPMock.CONNECTION_LOST_MAGIC_MSG.equals(message)) {
listener.onSessionTerminated(null, new BGPTerminationReason(BGPError.CEASE));
} else if (message instanceof Open) {
final Set<BgpTableType> tts = new HashSet<>();
final List<AddressFamilies> addPathCapabilitiesList = new ArrayList<>();
for (final BgpParameters param : ((Open) message).getBgpParameters()) {
for (final OptionalCapabilities capa : param.getOptionalCapabilities()) {
final CParameters cParam = capa.getCParameters();
final CParameters1 aug = cParam.augmentation(CParameters1.class);
if (aug == null) {
continue;
}
if (aug.getMultiprotocolCapability() != null) {
final MultiprotocolCapability p = aug.getMultiprotocolCapability();
LOG.debug("Adding open parameter {}", p);
final BgpTableType type = new BgpTableTypeImpl(p.getAfi(), p.getSafi());
tts.add(type);
} else if (aug.getAddPathCapability() != null) {
final AddPathCapability addPathCap = aug.getAddPathCapability();
addPathCapabilitiesList.addAll(addPathCap.getAddressFamilies());
}
}
}
listener.onSessionUp(new MockBGPSession(tts, addPathCapabilitiesList));
} else if (!(message instanceof Keepalive)) {
try {
listener.onMessage(new MockBGPSession(), message);
} catch (BGPDocumentedException e) {
LOG.warn("Exception encountered while handling message", e);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType in project bgpcep by opendaylight.
the class SimpleBGPTableTypeRegistryProviderTest method testBGPTableTypeRegistryProvider.
@Test
public void testBGPTableTypeRegistryProvider() {
final Optional<Class<? extends AfiSafiType>> afiSafiType = this.provider.getAfiSafiType(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
Assert.assertTrue(afiSafiType.isPresent());
final Optional<Class<? extends AfiSafiType>> afiSafiType2 = this.provider.getAfiSafiType(new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class));
Assert.assertFalse(afiSafiType2.isPresent());
final Optional<BgpTableType> tableType = this.provider.getTableType(IPV4UNICAST.class);
Assert.assertTrue(tableType.isPresent());
final Optional<BgpTableType> tableType2 = this.provider.getTableType(IPV6UNICAST.class);
Assert.assertFalse(tableType2.isPresent());
this.registration.close();
final Optional<BgpTableType> tableType3 = this.provider.getTableType(IPV4UNICAST.class);
Assert.assertFalse(tableType3.isPresent());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType in project bgpcep by opendaylight.
the class TableTypeActivatorTest method testActivator.
@Test
public void testActivator() {
final TableTypeActivator tableTypeActivator = new TableTypeActivator();
final SimpleBGPTableTypeRegistryProvider registry = new SimpleBGPTableTypeRegistryProvider();
tableTypeActivator.startBGPTableTypeRegistryProvider(registry);
final Optional<Class<? extends AfiSafiType>> afiSafiType = registry.getAfiSafiType(EVPN);
Assert.assertEquals(L2VPNEVPN.class, afiSafiType.get());
final Optional<BgpTableType> tableType = registry.getTableType(L2VPNEVPN.class);
Assert.assertEquals(EVPN, tableType.get());
tableTypeActivator.stopBGPTableTypeRegistryProvider();
tableTypeActivator.close();
}
Aggregations