X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=bgp%2Frib-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fprotocol%2Fbgp%2Frib%2Fimpl%2FAddPathNPathsTest.java;fp=bgp%2Frib-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fprotocol%2Fbgp%2Frib%2Fimpl%2FAddPathNPathsTest.java;h=46e02e9a42c68f5c45c93ef45751d3107d80f72c;hb=0148d933a5325bd4495c51715f8494508b02af62;hp=8333c727b873493d192d029d7a12f6e8cf79d8b2;hpb=259f2849339461f4a1e5c88b93741b3cffa9160d;p=bgpcep.git diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathNPathsTest.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathNPathsTest.java index 8333c727b8..46e02e9a42 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathNPathsTest.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathNPathsTest.java @@ -12,17 +12,18 @@ import static org.junit.Assert.assertEquals; import static org.opendaylight.protocol.bgp.rib.impl.CheckUtil.checkReceivedMessages; import static org.opendaylight.protocol.bgp.rib.impl.CheckUtil.waitFutureSuccess; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; import java.net.InetSocketAddress; -import java.util.List; import java.util.Map; +import java.util.concurrent.ExecutionException; +import org.junit.After; +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.protocol.bgp.parser.BgpTableTypeImpl; 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.multiprotocol.rev130919.BgpTableType; 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; @@ -31,7 +32,33 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily; public class AddPathNPathsTest extends AbstractAddPathTest { + private RIBImpl ribImpl; + private Channel serverChannel; + @Before + public void setUp() throws Exception { + super.setUp(); + final TablesKey tk = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class); + final Map pathTables = ImmutableMap.of(tk, new AddPathBestNPathSelection(2L)); + + this.ribImpl = new RIBImpl(this.clusterSingletonServiceProvider, new RibId("test-rib"), + AS_NUMBER, new BgpId(RIB_ID), null, this.ribExtension, this.dispatcher, + this.mappingService.getCodecFactory(), getDomBroker(), TABLES_TYPE, pathTables, + this.ribExtension.getClassLoadingStrategy(), null); + + this.ribImpl.instantiateServiceInstance(); + this.ribImpl.onGlobalContextUpdated(this.schemaContext); + final ChannelFuture channelFuture = this.dispatcher.createServer(StrictBGPPeerRegistry.GLOBAL, + new InetSocketAddress(RIB_ID, PORT)); + waitFutureSuccess(channelFuture); + this.serverChannel = channelFuture.channel(); + } + + @After + public void tearDown() throws ExecutionException, InterruptedException { + waitFutureSuccess(this.serverChannel.close()); + super.tearDown(); + } /* * N-Paths * ___________________ @@ -44,28 +71,25 @@ public class AddPathNPathsTest extends AbstractAddPathTest { */ @Test public void testUseCase1() throws Exception { + final BgpParameters nonAddPathParams = createParameter(false); + final BgpParameters addPathParams = createParameter(true); - final List tables = ImmutableList.of(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class)); - final TablesKey tk = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class); - final Map pathTables = ImmutableMap.of(tk, new AddPathBestNPathSelection(2L)); - - final RIBImpl ribImpl = new RIBImpl(this.clusterSingletonServiceProvider, new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID), null, this.ribExtension, - this.dispatcher, this.mappingService.getCodecFactory(), getDomBroker(), tables, pathTables, this.ribExtension.getClassLoadingStrategy(), null); + configurePeer(PEER1, this.ribImpl, nonAddPathParams, PeerRole.Ibgp); + final BGPSessionImpl session1 = createPeerSession(PEER1, nonAddPathParams, new SimpleSessionListener()); - ribImpl.instantiateServiceInstance(); - ribImpl.onGlobalContextUpdated(this.schemaContext); + configurePeer(PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp); + final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener()); - waitFutureSuccess(this.dispatcher.createServer(StrictBGPPeerRegistry.GLOBAL, new InetSocketAddress(RIB_ID, PORT))); - final BgpParameters nonAddPathParams = createParameter(false); - final BgpParameters addPathParams = createParameter(true); + configurePeer(PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp); + final BGPSessionImpl session3 = createPeerSession(PEER3, nonAddPathParams, new SimpleSessionListener()); - final BGPSessionImpl session1 = createPeerSession(PEER1, PeerRole.Ibgp, nonAddPathParams, ribImpl, new SimpleSessionListener()); - final BGPSessionImpl session2 = createPeerSession(PEER2, PeerRole.Ibgp, nonAddPathParams, ribImpl, new SimpleSessionListener()); - final BGPSessionImpl session3 = createPeerSession(PEER3, PeerRole.Ibgp, nonAddPathParams, ribImpl, new SimpleSessionListener()); final SimpleSessionListener listener4 = new SimpleSessionListener(); - final BGPSessionImpl session4 = createPeerSession(PEER4, PeerRole.RrClient, nonAddPathParams, ribImpl, listener4); + configurePeer(PEER4, this.ribImpl, nonAddPathParams, PeerRole.RrClient); + final BGPSessionImpl session4 = createPeerSession(PEER4, nonAddPathParams, listener4); + final SimpleSessionListener listener5 = new SimpleSessionListener(); - final BGPSessionImpl session5 = createPeerSession(PEER5, PeerRole.RrClient, addPathParams, ribImpl, listener5); + configurePeer(PEER5, this.ribImpl, addPathParams, PeerRole.RrClient); + final BGPSessionImpl session5 = createPeerSession(PEER5, addPathParams, listener5); checkPeersPresentOnDataStore(5); //new best route so far @@ -75,7 +99,8 @@ public class AddPathNPathsTest extends AbstractAddPathTest { assertEquals(UPD_100, listener5.getListMsg().get(0)); final SimpleSessionListener listener6 = new SimpleSessionListener(); - final BGPSessionImpl session6 = createPeerSession(PEER6, PeerRole.RrClient, nonAddPathParams, ribImpl, listener6); + configurePeer(PEER6, this.ribImpl, nonAddPathParams, PeerRole.RrClient); + final BGPSessionImpl session6 = createPeerSession(PEER6, nonAddPathParams, listener6); checkPeersPresentOnDataStore(6); checkReceivedMessages(listener6, 1); assertEquals(UPD_NA_100, listener6.getListMsg().get(0));