Implementation test for All/N Paths Selection Mode.
Change-Id: Ia4b263ebe23c7d470685b0452e7098b21b25f0f6
Signed-off-by: Claudio D. Gasparini <cgaspari@cisco.com>
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.yang.bgp.path.selection.mode;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
+
+public class AdvertiseAllPathsModuleTest extends AbstractConfigTest {
+ private static final String FACTORY_NAME = AdvertiseAllPathsModuleFactory.NAME;
+ private static final String INSTANCE_NAME = "advertise-all-paths-module";
+
+ @Before
+ public void setUp() throws Exception {
+ super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext, new AdvertiseAllPathsModuleFactory()));
+ }
+
+ @Test
+ public void testCreateBean() throws Exception {
+ final CommitStatus status = createInstance();
+ assertBeanCount(1, FACTORY_NAME);
+ assertStatus(status, 1, 0, 0);
+ }
+
+ @Test
+ public void testReusingOldInstance() throws Exception {
+ createInstance();
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ assertBeanCount(1, FACTORY_NAME);
+ final CommitStatus status = transaction.commit();
+ assertBeanCount(1, FACTORY_NAME);
+ assertStatus(status, 0, 0, 1);
+ }
+
+ @Test
+ public void testReconfigureInstance() throws Exception {
+ createInstance();
+ ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+ assertBeanCount(1, FACTORY_NAME);
+ CommitStatus status = transaction.commit();
+ assertBeanCount(1, FACTORY_NAME);
+ assertStatus(status, 0, 0, 1);
+ }
+
+ private CommitStatus createInstance() throws Exception {
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
+ return transaction.commit();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.yang.bgp.path.selection.mode;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
+
+public class AdvertiseNPathsModuleTest extends AbstractConfigTest {
+ private static final String FACTORY_NAME = AdvertiseNPathsModuleFactory.NAME;
+ private static final String INSTANCE_NAME = "advertise-n-paths-module";
+
+ @Before
+ public void setUp() throws Exception {
+ super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext, new AdvertiseNPathsModuleFactory()));
+ }
+
+ @Test
+ public void testCreateBean() throws Exception {
+ final CommitStatus status = createInstance();
+ assertBeanCount(1, FACTORY_NAME);
+ assertStatus(status, 1, 0, 0);
+ }
+
+ @Test
+ public void testReusingOldInstance() throws Exception {
+ createInstance();
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ assertBeanCount(1, FACTORY_NAME);
+ final CommitStatus status = transaction.commit();
+ assertBeanCount(1, FACTORY_NAME);
+ assertStatus(status, 0, 0, 1);
+ }
+
+ @Test
+ public void testReconfigureInstance() throws Exception {
+ createInstance();
+ ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+ assertBeanCount(1, FACTORY_NAME);
+ CommitStatus status = transaction.commit();
+ assertBeanCount(1, FACTORY_NAME);
+ assertStatus(status, 0, 0, 1);
+ }
+
+ private CommitStatus createInstance() throws Exception {
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+ transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
+ return transaction.commit();
+ }
+}
\ No newline at end of file
public class AbstractRouteEntryTest {
protected static final long REMOTE_PATH_ID = 1;
- protected final static PeerId PEER_ID = new PeerId("bgp://42.42.42.42");
- protected final static YangInstanceIdentifier PEER_YII2 = YangInstanceIdentifier.of(QName.create
- ("urn:opendaylight:params:xml:ns:yang:bgp-inet:test", "2015-03-05", "peer2"));
+ protected static final PeerId PEER_ID = new PeerId("bgp://42.42.42.42");
+ protected static final YangInstanceIdentifier PEER_YII2 = YangInstanceIdentifier.of(QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet:test", "2015-03-05", "peer2"));
protected static final long AS = 64444;
protected static final UnsignedInteger ROUTER_ID = UnsignedInteger.ONE;
protected static final TablesKey TABLES_KEY = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
- protected static final YangInstanceIdentifier LOC_RIB_TARGET = YangInstanceIdentifier.create(YangInstanceIdentifier.of(BgpRib.QNAME).node(LocRib
- .QNAME).node(Tables.QNAME)
- .node(RibSupportUtils.toYangTablesKey(TABLES_KEY)).getPathArguments());
- private final static PeerId PEER_ID2 = new PeerId("bgp://43.43.43.43");
- private final static PeerId PEER_DISCONNECTED = new PeerId("bgp://44.44.44.44");
- private final static YangInstanceIdentifier PEER_YII = YangInstanceIdentifier.of(QName.create
- ("urn:opendaylight:params:xml:ns:yang:bgp-inet:test", "2015-03-05", "peer1"));
+ protected static final YangInstanceIdentifier LOC_RIB_TARGET = YangInstanceIdentifier.create(YangInstanceIdentifier.of(BgpRib.QNAME)
+ .node(LocRib.QNAME).node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(TABLES_KEY)).getPathArguments());
+ private static final long PATH_ID = 1;
+ private static final PeerId PEER_ID2 = new PeerId("bgp://43.43.43.43");
+ private static final PeerId PEER_DISCONNECTED = new PeerId("bgp://44.44.44.44");
private static final String PREFIX = "1.2.3.4/32";
private static final String PREFIX2 = "2.2.2.2/32";
- private static final long PATH_ID = 1;
+ private static final YangInstanceIdentifier PEER_YII = YangInstanceIdentifier.of(QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet:test", "2015-03-05", "peer1"));
private static final NodeIdentifier ROUTES_IDENTIFIER = new NodeIdentifier(Routes.QNAME);
private static final NodeIdentifier ORIGIN_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q, Origin.QNAME.getLocalName()).intern());
private static final NodeIdentifier ORIGIN_VALUE_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q, "value").intern());
private static final NodeIdentifier ATOMIC_NID = new NodeIdentifier(QName.create(ATTRS_EXTENSION_Q, AtomicAggregate.QNAME.getLocalName()));
private static final Function<YangInstanceIdentifier, Map.Entry<PeerId, YangInstanceIdentifier>> GENERATE_PEER_ID =
input -> PEER_YII.equals(input) ? new AbstractMap.SimpleImmutableEntry<>(PEER_ID, input) : new AbstractMap.SimpleImmutableEntry<>(PEER_ID2, input);
- private final static QName Q_NAME = BindingReflections.findQName(Ipv4Routes.class).intern();
+ private static final QName Q_NAME = BindingReflections.findQName(Ipv4Routes.class).intern();
private static final NodeIdentifier ROUTE_ATTRIBUTES_IDENTIFIER = new NodeIdentifier(QName.create(Q_NAME, Attributes.QNAME.getLocalName().intern()));
- private static final NodeIdentifier ROUTES_LIST_IDENTIFIER = new NodeIdentifier(BindingReflections.findQName(Ipv4Route.class).intern());
- private static final NodeIdentifier ROUTES_CONTAINER_IDENTIFIER = new NodeIdentifier(Q_NAME);
private static final QName PREFIX_QNAME = QName.create(Ipv4Route.QNAME, "prefix").intern();
protected static final NodeIdentifierWithPredicates ROUTE_ID_PA = new NodeIdentifierWithPredicates(Ipv4Route.QNAME, ImmutableMap.of(PREFIX_QNAME, PREFIX));
private static final QName PATHID_QNAME = QName.create(Ipv4Route.QNAME, "path-id").intern();
- protected static final NodeIdentifierWithPredicates ROUTE_ID_PA_ADD_PATH = new NodeIdentifierWithPredicates(Ipv4Route.QNAME,
- ImmutableMap.of(PATHID_QNAME, PATH_ID, PREFIX_QNAME, PREFIX2));
+ protected static final NodeIdentifierWithPredicates ROUTE_ID_PA_ADD_PATH = new NodeIdentifierWithPredicates(Ipv4Route.QNAME, ImmutableMap.of(PATHID_QNAME, PATH_ID, PREFIX_QNAME, PREFIX2));
@Mock
protected RIBSupport ribSupport;
@Mock
protected CacheDisconnectedPeers discCache;
protected List<YangInstanceIdentifier> yIIChanges;
protected NormalizedNode<?, ?> attributes;
- @Mock
- private PeerExportGroup pegNot;
- private YangInstanceIdentifier locRibTargetYii;
- private YangInstanceIdentifier locRibOutTargetYii;
protected YangInstanceIdentifier routePaYii;
protected YangInstanceIdentifier routePaAddPathYii;
protected YangInstanceIdentifier routeRiboutYii;
protected YangInstanceIdentifier routeAddRiboutYii;
protected YangInstanceIdentifier routeRiboutAttYii;
protected YangInstanceIdentifier routeAddRiboutAttYii;
- private YangInstanceIdentifier locRibOutTargetYiiPeer2;
protected YangInstanceIdentifier routeRiboutAttYiiPeer2;
protected YangInstanceIdentifier routeRiboutYiiPeer2;
+ protected YangInstanceIdentifier routeAddRiboutYiiPeer2;
+ @Mock
+ private PeerExportGroup pegNot;
+ private YangInstanceIdentifier locRibTargetYii;
+ private YangInstanceIdentifier locRibOutTargetYii;
+ private YangInstanceIdentifier locRibOutTargetYiiPeer2;
protected void setUp() {
MockitoAnnotations.initMocks(this);
this.routeAddRiboutYii = locRibOutTargetYii.node(ROUTE_ID_PA_ADD_PATH);
this.routeRiboutAttYii = locRibOutTargetYii.node(ROUTE_ID_PA).node(ATTRS_EXTENSION_Q);
this.routeAddRiboutAttYii = locRibOutTargetYii.node(ROUTE_ID_PA_ADD_PATH).node(ATTRS_EXTENSION_Q);
-
this.locRibOutTargetYiiPeer2 = PEER_YII2.node(AdjRibOut.QNAME).node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(TABLES_KEY)).node(ROUTES_IDENTIFIER);
this.routeRiboutYiiPeer2 = locRibOutTargetYiiPeer2.node(ROUTE_ID_PA);
this.routeRiboutAttYiiPeer2 = locRibOutTargetYiiPeer2.node(ROUTE_ID_PA).node(ATTRS_EXTENSION_Q);
+ this.routeAddRiboutYiiPeer2 = locRibOutTargetYiiPeer2.node(ROUTE_ID_PA_ADD_PATH);
mockRibSupport();
mockExportPolicies();
mockExportGroup();
final Object[] args = invocation.getArguments();
if (routePaYii.equals(args[1])) {
yIIChanges.remove(routePaYii);
- } else if(routeRiboutYii.equals(args[1])) {
+ } else if (routePaAddPathYii.equals(args[1])) {
+ yIIChanges.remove(routePaAddPathYii);
+ } else if (routeRiboutYii.equals(args[1])) {
yIIChanges.remove(routeRiboutYii);
yIIChanges.remove(routeAddRiboutAttYii);
-
+ } else if (routeAddRiboutYii.equals(args[1])) {
+ yIIChanges.remove(routeAddRiboutYii);
+ yIIChanges.remove(routeAddRiboutAttYii);
}
return args[1];
}
}
}
}).when(this.peerPT).getPeerGroup(Mockito.any(PeerRole.class));
+
+ Mockito.doReturn(true).when(this.peerPT).isAddPathSupportedByPeer(PEER_ID);
+ Mockito.doReturn(false).when(this.peerPT).isAddPathSupportedByPeer(PEER_ID2);
}
private void mockRibSupport() {
final YangInstanceIdentifier yii = (YangInstanceIdentifier) args[0];
final PathArgument paa = (PathArgument) args[1];
- if (ROUTE_ID_PA.equals(paa) && yii.equals(locRibTargetYii)) {
- return routePaYii;
- } else if (ROUTE_ID_PA_ADD_PATH.equals(paa) && yii.equals(locRibTargetYii)) {
- return routePaAddPathYii;
- } else if (ROUTE_ID_PA.equals(paa) && yii.equals(locRibOutTargetYii)) {
- return routeRiboutYii;
- } else if (ROUTE_ID_PA_ADD_PATH.equals(paa) && yii.equals(locRibOutTargetYii)) {
- return routeAddRiboutYii;
- } else if (ROUTE_ID_PA.equals(paa) && yii.equals(locRibOutTargetYiiPeer2)) {
- return routeRiboutYiiPeer2;
+ if (ROUTE_ID_PA.equals(paa)) {
+ if (yii.equals(locRibTargetYii)) {
+ return routePaYii;
+ } else if (yii.equals(locRibOutTargetYii)) {
+ return routeRiboutYii;
+ } else if (yii.equals(locRibOutTargetYiiPeer2)) {
+ return routeRiboutYiiPeer2;
+ }
+ } else if (ROUTE_ID_PA_ADD_PATH.equals(paa)) {
+ if (yii.equals(locRibTargetYii)) {
+ return routePaAddPathYii;
+ } else if (yii.equals(locRibOutTargetYii)) {
+ return routeAddRiboutYii;
+ } else if (yii.equals(locRibOutTargetYiiPeer2)) {
+ return routeAddRiboutYiiPeer2;
+ }
}
-
return null;
}
}).when(this.ribSupport).routePath(Mockito.any(YangInstanceIdentifier.class), Mockito.any(PathArgument.class));
private NormalizedNode<?, ?> createAttr() {
final ContainerNode attributes = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(ATTRS_EXTENSION_Q))
.addChild(Builders.containerBuilder().withNodeIdentifier(ORIGIN_NID)
- .addChild(Builders.leafBuilder().withNodeIdentifier(ORIGIN_VALUE_NID).withValue("igp").build())
- .build())
+ .addChild(Builders.leafBuilder().withNodeIdentifier(ORIGIN_VALUE_NID).withValue("igp").build()).build())
.addChild(Builders.containerBuilder().withNodeIdentifier(AS_PATH_NID)
- .addChild(Builders.unkeyedListBuilder().withNodeIdentifier(SEGMENTS_NID).build())
- .build())
- .addChild(Builders.containerBuilder().withNodeIdentifier(ATOMIC_NID).build())
- .build();
+ .addChild(Builders.unkeyedListBuilder().withNodeIdentifier(SEGMENTS_NID).build()).build())
+ .addChild(Builders.containerBuilder().withNodeIdentifier(ATOMIC_NID).build()).build();
return ImmutableContainerNodeBuilder.create().withNodeIdentifier(ROUTE_ATTRIBUTES_IDENTIFIER)
.withChild(attributes).build();
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.mode.impl.add.all.paths;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.protocol.bgp.mode.api.PathSelectionMode;
+
+public class PathSelectionModeFactoryTest {
+ @Test
+ public void testCreateBestPathSelectionStrategy() throws Exception {
+ final PathSelectionMode psm = new AllPathSelection();
+ Assert.assertTrue(psm.createRouteEntry(true) instanceof ComplexRouteEntry);
+ Assert.assertTrue(psm.createRouteEntry(false) instanceof SimpleRouteEntry);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.mode.impl.add.all.paths;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.protocol.bgp.mode.impl.AbstractRouteEntryTest;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+public final class SimpleRouteEntryTest extends AbstractRouteEntryTest {
+ private SimpleRouteEntry testBARE;
+
+ @Before
+ public void setUp() {
+ super.setUp();
+ }
+
+ @Test
+ public void testSimpleRouteEntry() throws Exception {
+ this.testBARE = (SimpleRouteEntry) new AllPathSelection().createRouteEntry(false);
+ testAddRouteSelectBestAndWriteOnDS();
+ testRemoveRoute();
+ }
+
+ private void testAddRouteSelectBestAndWriteOnDS() {
+ this.testBARE.addRoute(ROUTER_ID, REMOTE_PATH_ID, this.ribSupport.routeAttributesIdentifier(), this.attributes);
+ assertFalse(this.testBARE.isEmpty());
+ assertTrue(this.testBARE.selectBest(AS));
+ /** Add AddPath Route **/
+ this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport, this.discCache, this.tx, ROUTE_ID_PA_ADD_PATH);
+ Map<YangInstanceIdentifier, Long> yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+ assertEquals(3, yiiCount.size());
+ assertEquals(1, (long) yiiCount.get(this.routePaAddPathYii));
+ assertEquals(1, (long) yiiCount.get(this.routeAddRiboutYii));
+ assertEquals(1, (long) yiiCount.get(this.routeAddRiboutAttYii));
+ }
+
+ private void testRemoveRoute() {
+ Map<YangInstanceIdentifier, Long> yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+ assertEquals(3, yiiCount.size());
+ assertEquals(1, (long) yiiCount.get(this.routePaAddPathYii));
+ assertTrue(this.testBARE.removeRoute(ROUTER_ID, REMOTE_PATH_ID));
+ assertTrue(this.testBARE.selectBest(AS));
+ this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport, this.discCache, this.tx, ROUTE_ID_PA_ADD_PATH);
+ yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+ assertEquals(0, yiiCount.size());
+ assertFalse(yiiCount.containsKey(this.routePaAddPathYii));
+ assertFalse(yiiCount.containsKey(this.routeAddRiboutYii));
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.mode.impl.add.n.paths;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.protocol.bgp.mode.api.PathSelectionMode;
+
+public class PathSelectionModeFactoryTest {
+ @Test
+ public void testCreateBestPathSelectionStrategy() throws Exception {
+ final PathSelectionMode psm = new AddPathBestNPathSelection(2L);
+ Assert.assertTrue(psm.createRouteEntry(true) instanceof ComplexRouteEntry);
+ Assert.assertTrue(psm.createRouteEntry(false) instanceof SimpleRouteEntry);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.mode.impl.add.n.paths;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.protocol.bgp.mode.impl.AbstractRouteEntryTest;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+public final class SimpleRouteEntryTest extends AbstractRouteEntryTest {
+ private final static long N_PATHS = 2;
+ private SimpleRouteEntry testBARE;
+
+ @Before
+ public void setUp() {
+ super.setUp();
+ }
+
+ @Test
+ public void testSimpleRouteEntry() throws Exception {
+ this.testBARE = (SimpleRouteEntry) new AddPathBestNPathSelection(N_PATHS).createRouteEntry(false);
+ testWriteEmptyBestPath();
+ testAddRouteSelectBestAndWriteOnDS();
+ testRewriteSameRoute();
+ testInitializePeerWithExistentRoute();
+ testRemoveRoute();
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAddRouteSelectBestAndWriteOnDSs() {
+ /** Add non Add Path Route **/
+ this.testBARE.addRoute(ROUTER_ID, REMOTE_PATH_ID, this.ribSupport.routeAttributesIdentifier(), this.attributes);
+ }
+
+ private void testWriteEmptyBestPath() {
+ this.testBARE.writeRoute(PEER_ID, ROUTE_ID_PA, PEER_YII2, this.peg, TABLES_KEY, this.peerPT, this.ribSupport, this.discCache, this.tx);
+ assertEquals(0, this.yIIChanges.size());
+ }
+
+ private void testAddRouteSelectBestAndWriteOnDS() {
+ this.testBARE.addRoute(ROUTER_ID, REMOTE_PATH_ID, this.ribSupport.routeAttributesIdentifier(), this.attributes);
+ assertFalse(this.testBARE.isEmpty());
+ assertTrue(this.testBARE.selectBest(AS));
+ /** Add AddPath Route **/
+ this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport, this.discCache, this.tx, ROUTE_ID_PA_ADD_PATH);
+ Map<YangInstanceIdentifier, Long> yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+ assertEquals(3, yiiCount.size());
+ assertEquals(1, (long) yiiCount.get(this.routePaAddPathYii));
+ assertEquals(1, (long) yiiCount.get(this.routeAddRiboutYii));
+ assertEquals(1, (long) yiiCount.get(this.routeAddRiboutAttYii));
+ }
+
+ private void testRewriteSameRoute() {
+ this.testBARE.addRoute(ROUTER_ID, REMOTE_PATH_ID, this.ribSupport.routeAttributesIdentifier(), this.attributes);
+ assertFalse(this.testBARE.selectBest(AS));
+ }
+
+ private void testInitializePeerWithExistentRoute() {
+ assertEquals(3, this.yIIChanges.size());
+ this.testBARE.writeRoute(PEER_ID, ROUTE_ID_PA_ADD_PATH, PEER_YII2, this.peg, TABLES_KEY, this.peerPT, this.ribSupport, this.discCache, this.tx);
+ assertEquals(5, this.yIIChanges.size());
+ final Map<YangInstanceIdentifier, Long> yiiCount = this.yIIChanges.stream()
+ .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+ assertEquals(1, (long) yiiCount.get(this.routeAddRiboutYiiPeer2));
+ assertEquals(1, (long) yiiCount.get(this.routeAddRiboutYiiPeer2));
+ }
+
+ private void testRemoveRoute() {
+ Map<YangInstanceIdentifier, Long> yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+ assertEquals(5, yiiCount.size());
+ assertEquals(1, (long) yiiCount.get(this.routePaAddPathYii));
+ assertTrue(this.testBARE.removeRoute(ROUTER_ID, REMOTE_PATH_ID));
+ assertTrue(this.testBARE.selectBest(AS));
+ this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport, this.discCache, this.tx, ROUTE_ID_PA_ADD_PATH);
+ yiiCount = this.yIIChanges.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
+ assertEquals(2, yiiCount.size());
+ assertFalse(yiiCount.containsKey(this.routePaAddPathYii));
+ assertFalse(yiiCount.containsKey(this.routeAddRiboutYii));
+ }
+}