use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address in project bgpcep by opendaylight.
the class AbstractBGPDispatcherTest method setUp.
@Before
public void setUp() {
if (!Epoll.isAvailable()) {
this.boss = new NioEventLoopGroup();
this.worker = new NioEventLoopGroup();
}
this.registry = new StrictBGPPeerRegistry();
this.clientListener = new SimpleSessionListener();
this.serverListener = new SimpleSessionListener();
final BGPExtensionProviderContext ctx = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance();
this.serverDispatcher = new BGPDispatcherImpl(ctx.getMessageRegistry(), this.boss, this.worker, this.registry);
this.clientAddress = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
final IpAddress clientPeerIp = new IpAddress(new Ipv4Address(this.clientAddress.getAddress().getHostAddress()));
this.registry.addPeer(clientPeerIp, this.clientListener, createPreferences(this.clientAddress));
this.clientDispatcher = new BGPDispatcherImpl(ctx.getMessageRegistry(), this.boss, this.worker, this.registry);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address in project bgpcep by opendaylight.
the class AppPeerTest method testAppPeer.
@Test
public void testAppPeer() {
APP_PEER.start(this.rib, this.neighbor, null, this.peerGroupLoader, this.tableTypeRegistry);
Mockito.verify(this.rib).getYangRibId();
Mockito.verify(this.rib).getService();
Mockito.verify(this.rib, times(1)).getLocalTablesKeys();
APP_PEER.instantiateServiceInstance();
Mockito.verify(this.rib, times(2)).getYangRibId();
Mockito.verify(this.rib, times(2)).getRibSupportContext();
Mockito.verify(this.rib, times(2)).getLocalTablesKeys();
Mockito.verify(this.domTx).newWriteOnlyTransaction();
APP_PEER.closeServiceInstance();
APP_PEER.close();
APP_PEER.restart(this.rib, null, this.peerGroupLoader, this.tableTypeRegistry);
APP_PEER.instantiateServiceInstance();
Mockito.verify(this.rib, times(4)).getYangRibId();
Mockito.verify(this.rib, times(2)).getService();
Mockito.verify(this.listener).close();
assertTrue(APP_PEER.containsEqualConfiguration(this.neighbor));
assertFalse(APP_PEER.containsEqualConfiguration(new NeighborBuilder().setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.2"))).build()));
APP_PEER.closeServiceInstance();
APP_PEER.close();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address in project bgpcep by opendaylight.
the class BgpPeerTest method testBgpPeer.
@Test
public void testBgpPeer() {
final Neighbor neighbor = new NeighborBuilder().setAfiSafis(createAfiSafi()).setConfig(createConfig()).setNeighborAddress(NEIGHBOR_ADDRESS).setRouteReflector(createRR()).setTimers(createTimers()).setTransport(createTransport()).setAddPaths(createAddPath()).build();
this.bgpPeer.start(this.rib, neighbor, null, this.peerGroupLoader, this.tableTypeRegistry);
Mockito.verify(this.rib).createPeerDOMChain(any());
Mockito.verify(this.rib, times(2)).getLocalAs();
Mockito.verify(this.rib).getLocalTables();
this.bgpPeer.instantiateServiceInstance();
Mockito.verify(this.bgpPeerRegistry).addPeer(any(), any(), any());
Mockito.verify(this.dispatcher).createReconnectingClient(any(InetSocketAddress.class), anyInt(), any(KeyMapping.class));
try {
this.bgpPeer.start(this.rib, neighbor, null, this.peerGroupLoader, this.tableTypeRegistry);
fail("Expected Exception");
} catch (final IllegalStateException expected) {
assertEquals("Previous peer instance was not closed.", expected.getMessage());
}
this.bgpPeer.setServiceRegistration(this.serviceRegistration);
this.bgpPeer.closeServiceInstance();
this.bgpPeer.close();
Mockito.verify(this.future).cancel(true);
this.bgpPeer.restart(this.rib, null, this.peerGroupLoader, this.tableTypeRegistry);
this.bgpPeer.instantiateServiceInstance();
Mockito.verify(this.rib, times(2)).createPeerDOMChain(any());
Mockito.verify(this.rib, times(4)).getLocalAs();
Mockito.verify(this.rib, times(2)).getLocalTables();
final Neighbor neighborExpected = createNeighborExpected(NEIGHBOR_ADDRESS);
assertTrue(this.bgpPeer.containsEqualConfiguration(neighborExpected));
assertFalse(this.bgpPeer.containsEqualConfiguration(createNeighborExpected(new IpAddress(new Ipv4Address("127.0.0.2")))));
Mockito.verify(this.bgpPeerRegistry).removePeer(any(IpAddress.class));
this.bgpPeer.closeServiceInstance();
this.bgpPeer.close();
Mockito.verify(this.serviceRegistration).unregister();
Mockito.verify(this.future, times(2)).cancel(true);
final Neighbor neighborDiffConfig = new NeighborBuilder().setNeighborAddress(NEIGHBOR_ADDRESS).setAfiSafis(createAfiSafi()).build();
this.bgpPeer.start(this.rib, neighborDiffConfig, null, this.peerGroupLoader, this.tableTypeRegistry);
assertTrue(this.bgpPeer.containsEqualConfiguration(neighborDiffConfig));
this.bgpPeer.close();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address in project bgpcep by opendaylight.
the class PeerTest method mockSession.
private void mockSession() {
final EventLoop eventLoop = mock(EventLoop.class);
final Channel channel = mock(Channel.class);
final ChannelPipeline pipeline = mock(ChannelPipeline.class);
doReturn(null).when(eventLoop).schedule(any(Runnable.class), any(long.class), any(TimeUnit.class));
doReturn(eventLoop).when(channel).eventLoop();
doReturn(Boolean.TRUE).when(channel).isWritable();
doReturn(null).when(channel).close();
doReturn(pipeline).when(channel).pipeline();
doCallRealMethod().when(channel).toString();
doReturn(pipeline).when(pipeline).addLast(any(ChannelHandler.class));
doReturn(new DefaultChannelPromise(channel)).when(channel).writeAndFlush(any(Notification.class));
doReturn(new InetSocketAddress("localhost", 12345)).when(channel).remoteAddress();
doReturn(new InetSocketAddress("localhost", 12345)).when(channel).localAddress();
final List<BgpParameters> params = Lists.newArrayList(new BgpParametersBuilder().setOptionalCapabilities(Lists.newArrayList(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build()).build()).build()).build())).build());
final Open openObj = new OpenBuilder().setBgpIdentifier(new Ipv4Address("1.1.1.1")).setHoldTimer(50).setMyAsNumber(72).setBgpParameters(params).build();
this.session = new BGPSessionImpl(this.classic, channel, openObj, 30, null);
this.session.setChannelExtMsgCoder(openObj);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address in project bgpcep by opendaylight.
the class StrictBGPPeerRegistryTest method testPeerConnectionSuccessfull.
@Test
public void testPeerConnectionSuccessfull() throws Exception {
final Ipv4Address to2 = new Ipv4Address("255.255.255.254");
final IpAddress remoteIp2 = new IpAddress(to2);
this.peerRegistry.addPeer(REMOTE_IP, this.peer1, this.mockPreferences);
final BGPSessionListener session2 = getMockSession();
this.peerRegistry.addPeer(remoteIp2, session2, this.mockPreferences);
final BGPSessionListener returnedSession1 = this.peerRegistry.getPeer(REMOTE_IP, FROM, TO, this.classicOpen);
assertSame(this.peer1, returnedSession1);
final BGPSessionListener returnedSession2 = this.peerRegistry.getPeer(remoteIp2, FROM, to2, this.classicOpen);
assertSame(session2, returnedSession2);
Mockito.verifyZeroInteractions(this.peer1);
Mockito.verifyZeroInteractions(session2);
}
Aggregations