Add LLGR restart utilities
[bgpcep.git] / bgp / rib-impl / src / test / java / org / opendaylight / protocol / bgp / rib / impl / AddPathNPathsTest.java
index a22d9de6dd6da0886b2315829351740f1d06475b..2c2f42f89bd79e2792fb0b0cb2d6d1f5696f0b74 100644 (file)
@@ -23,36 +23,38 @@ import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.protocol.bgp.mode.api.PathSelectionMode;
 import org.opendaylight.protocol.bgp.mode.impl.add.n.paths.AddPathBestNPathSelection;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.message.BgpParameters;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerRole;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.RibId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.BgpParameters;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerRole;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.BgpId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.UnicastSubsequentAddressFamily;
 
 public class AddPathNPathsTest extends AbstractAddPathTest {
     private RIBImpl ribImpl;
     private Channel serverChannel;
 
+    @Override
     @Before
     public void setUp() throws Exception {
         super.setUp();
         final TablesKey tk = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
-        final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(tk, new AddPathBestNPathSelection(2L));
+        final Map<TablesKey, PathSelectionMode> pathTables = ImmutableMap.of(tk, new AddPathBestNPathSelection(2));
 
-        this.ribImpl = new RIBImpl(this.clusterSingletonServiceProvider, new RibId("test-rib"),
-            AS_NUMBER, new BgpId(RIB_ID), null, this.ribExtension, this.serverDispatcher,
-            this.mappingService.getCodecFactory(), getDomBroker(), TABLES_TYPE, pathTables,
-            this.ribExtension.getClassLoadingStrategy());
+        this.ribImpl = new RIBImpl(this.tableRegistry, new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID),
+                this.ribExtension,
+                this.serverDispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies,
+                TABLES_TYPE,  pathTables);
 
         this.ribImpl.instantiateServiceInstance();
-        this.ribImpl.onGlobalContextUpdated(this.schemaContext);
+        this.ribImpl.onGlobalContextUpdated(this.schemaService.getGlobalContext());
         final ChannelFuture channelFuture = this.serverDispatcher.createServer(new InetSocketAddress(RIB_ID, PORT));
         waitFutureSuccess(channelFuture);
         this.serverChannel = channelFuture.channel();
     }
 
+    @Override
     @After
     public void tearDown() throws ExecutionException, InterruptedException {
         waitFutureSuccess(this.serverChannel.close());
@@ -73,70 +75,73 @@ public class AddPathNPathsTest extends AbstractAddPathTest {
         final BgpParameters nonAddPathParams = createParameter(false);
         final BgpParameters addPathParams = createParameter(true);
 
-        configurePeer(PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
         final BGPSessionImpl session1 = createPeerSession(PEER1, nonAddPathParams, new SimpleSessionListener());
 
-        configurePeer(PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
        final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener());
 
-        configurePeer(PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry);
         final BGPSessionImpl session3 = createPeerSession(PEER3, nonAddPathParams, new SimpleSessionListener());
 
         final SimpleSessionListener listener4 = new SimpleSessionListener();
-        configurePeer(PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient,
+                this.serverRegistry);
         final BGPSessionImpl session4 = createPeerSession(PEER4, nonAddPathParams, listener4);
 
         final SimpleSessionListener listener5 = new SimpleSessionListener();
-        configurePeer(PEER5, this.ribImpl, addPathParams, PeerRole.RrClient, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER5, this.ribImpl, addPathParams, PeerRole.RrClient, this.serverRegistry);
         final BGPSessionImpl session5 = createPeerSession(PEER5, addPathParams, listener5);
         checkPeersPresentOnDataStore(5);
 
         //new best route so far
         sendRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 1);
-        checkReceivedMessages(listener4, 1);
-        checkReceivedMessages(listener5, 1);
-        assertEquals(UPD_100, listener5.getListMsg().get(0));
+        checkReceivedMessages(listener4, 2);
+        checkReceivedMessages(listener5, 2);
+        assertEquals(UPD_100, listener5.getListMsg().get(1));
 
         final SimpleSessionListener listener6 = new SimpleSessionListener();
-        configurePeer(PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient, this.serverRegistry);
+        configurePeer(this.tableRegistry, PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient,
+                this.serverRegistry);
         final BGPSessionImpl session6 = createPeerSession(PEER6, nonAddPathParams, listener6);
         checkPeersPresentOnDataStore(6);
-        checkReceivedMessages(listener6, 1);
-        assertEquals(UPD_NA_100, listener6.getListMsg().get(0));
+        checkReceivedMessages(listener6, 2);
+        assertEquals(UPD_NA_100, listener6.getListMsg().get(1));
         session6.close();
         checkPeersPresentOnDataStore(5);
 
         //the second best route
         sendRouteAndCheckIsOnLocRib(session2, PREFIX1, 50, 2);
-        checkReceivedMessages(listener4, 1);
-        checkReceivedMessages(listener5, 2);
-        assertEquals(UPD_50, listener5.getListMsg().get(1));
+        checkReceivedMessages(listener4, 2);
+        checkReceivedMessages(listener5, 3);
+        assertEquals(UPD_50, listener5.getListMsg().get(2));
 
         //new best route
         sendRouteAndCheckIsOnLocRib(session3, PREFIX1, 200, 2);
-        checkReceivedMessages(listener4, 2);
-        checkReceivedMessages(listener5, 3);
-        assertEquals(UPD_200, listener5.getListMsg().get(2));
+        checkReceivedMessages(listener4, 3);
+        checkReceivedMessages(listener5, 4);
+        assertEquals(UPD_200, listener5.getListMsg().get(3));
 
         //the worst prefix, no changes
         sendRouteAndCheckIsOnLocRib(session2, PREFIX1, 20, 2);
-        checkReceivedMessages(listener4, 2);
-        checkReceivedMessages(listener5, 3);
+        checkReceivedMessages(listener4, 3);
+        checkReceivedMessages(listener5, 4);
 
         //withdraw second best route, 2 advertisement (1 withdrawal) for add-path supported, none for non add path
         sendWithdrawalRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 2);
-        checkReceivedMessages(listener4, 2);
-        checkReceivedMessages(listener5, 5);
+        checkReceivedMessages(listener4, 3);
+        checkReceivedMessages(listener5, 6);
 
         //we advertise again to try new test
         sendRouteAndCheckIsOnLocRib(session1, PREFIX1, 100, 2);
-        checkReceivedMessages(listener4, 2);
-        checkReceivedMessages(listener5, 6);
+        checkReceivedMessages(listener4, 3);
+        checkReceivedMessages(listener5, 7);
 
-        //withdraw second best route, 2 advertisement (1 withdrawal) for add-path supported, 1 withdrawal for non add path
+        //withdraw second best route, 2 advertisement (1 withdrawal) for add-path supported,
+        // 1 withdrawal for non add path
         sendWithdrawalRouteAndCheckIsOnLocRib(session3, PREFIX1, 200, 2);
-        checkReceivedMessages(listener4, 3);
-        checkReceivedMessages(listener5, 8);
+        checkReceivedMessages(listener4, 4);
+        checkReceivedMessages(listener5, 9);
 
         session1.close();
         session2.close();