Search in sources :

Example 6 with Neighbor

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor in project bgpcep by opendaylight.

the class NeighborStateCliUtilsTest method testEmptyNeighborStateCli.

@Test
public void testEmptyNeighborStateCli() throws IOException {
    final Neighbor neighbor = createBasicNeighbor();
    NeighborStateCliUtils.displayNeighborOperationalState(NEIGHBOR_ADDRESS, neighbor, this.stream);
    final String expected = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("empty-neighbor.txt"), UTF8);
    assertEquals(expected, this.output.toString());
}
Also used : Neighbor(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor) Test(org.junit.Test)

Example 7 with Neighbor

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor 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();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Neighbor(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) NeighborBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 8 with Neighbor

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor in project bgpcep by opendaylight.

the class OpenConfigMappingUtilTest method toPeerRole.

@Test
public void toPeerRole() {
    Neighbor neighbor = new NeighborBuilder().setConfig(new ConfigBuilder().setPeerType(PeerType.EXTERNAL).build()).build();
    PeerRole peerRoleResult = OpenConfigMappingUtil.toPeerRole(neighbor);
    Assert.assertEquals(PeerRole.Ebgp, peerRoleResult);
    neighbor = new NeighborBuilder().setConfig(new ConfigBuilder().setPeerType(PeerType.INTERNAL).build()).build();
    peerRoleResult = OpenConfigMappingUtil.toPeerRole(neighbor);
    Assert.assertEquals(PeerRole.Ibgp, peerRoleResult);
    neighbor = new NeighborBuilder().setRouteReflector(new RouteReflectorBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.route.reflector.ConfigBuilder().setRouteReflectorClient(true).build()).build()).build();
    peerRoleResult = OpenConfigMappingUtil.toPeerRole(neighbor);
    Assert.assertEquals(PeerRole.RrClient, peerRoleResult);
}
Also used : PeerRole(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole) Neighbor(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor) NeighborBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder) RouteReflectorBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.RouteReflectorBuilder) NeighborPeerGroupConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborPeerGroupConfigBuilder) ConfigBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder) PeerGroupTransportConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupTransportConfigBuilder) NeighborAddPathsConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAddPathsConfigBuilder) NeighborTransportConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTransportConfigBuilder) GlobalAddPathsConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAddPathsConfigBuilder) NeighborClusterIdConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborClusterIdConfigBuilder) Test(org.junit.Test)

Example 9 with Neighbor

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor in project bgpcep by opendaylight.

the class OpenConfigMappingUtilTest method testGetNeighborKey.

@Test
public void testGetNeighborKey() {
    assertArrayEquals(MD5_PASSWORD.getBytes(StandardCharsets.US_ASCII), OpenConfigMappingUtil.getNeighborKey(NEIGHBOR).get(INSTANCE.inetAddressFor(NEIGHBOR_ADDRESS)));
    assertNull(OpenConfigMappingUtil.getNeighborKey(new NeighborBuilder().build()));
    assertNull(OpenConfigMappingUtil.getNeighborKey(new NeighborBuilder().setConfig(new ConfigBuilder().build()).build()));
}
Also used : NeighborPeerGroupConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborPeerGroupConfigBuilder) ConfigBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder) PeerGroupTransportConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupTransportConfigBuilder) NeighborAddPathsConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAddPathsConfigBuilder) NeighborTransportConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTransportConfigBuilder) GlobalAddPathsConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAddPathsConfigBuilder) NeighborClusterIdConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborClusterIdConfigBuilder) NeighborBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder) Test(org.junit.Test)

Example 10 with Neighbor

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor in project bgpcep by opendaylight.

the class OpenConfigMappingUtilTest method testGetRetryTimer.

@Test
public void testGetRetryTimer() {
    assertEquals(DEFAULT_TIMERS.toBigInteger().intValue(), OpenConfigMappingUtil.getRetryTimer(NEIGHBOR, null));
    assertEquals(DEFAULT_TIMERS.toBigInteger().intValue(), OpenConfigMappingUtil.getRetryTimer(new NeighborBuilder().build(), null));
    TimersBuilder builder = new TimersBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers.ConfigBuilder().setConnectRetry(BigDecimal.TEN).build());
    assertEquals(BigDecimal.TEN.intValue(), OpenConfigMappingUtil.getRetryTimer(new NeighborBuilder().setTimers(builder.build()).build(), null));
    assertEquals(DEFAULT_TIMERS.toBigInteger().intValue(), OpenConfigMappingUtil.getRetryTimer(NEIGHBOR, new PeerGroupBuilder().build()));
    assertEquals(BigDecimal.TEN.intValue(), OpenConfigMappingUtil.getRetryTimer(NEIGHBOR, new PeerGroupBuilder().setTimers(builder.build()).build()));
}
Also used : PeerGroupBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder) TimersBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.TimersBuilder) NeighborBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)20 NeighborBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder)10 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)6 ConfigBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder)5 Neighbor (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor)5 GlobalAddPathsConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAddPathsConfigBuilder)5 NeighborAddPathsConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborAddPathsConfigBuilder)5 NeighborClusterIdConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborClusterIdConfigBuilder)5 NeighborPeerGroupConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborPeerGroupConfigBuilder)5 NeighborTransportConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.NeighborTransportConfigBuilder)5 PeerGroupTransportConfigBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.PeerGroupTransportConfigBuilder)5 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)4 AfiSafi (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi)4 PeerGroupBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder)4 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)4 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)4 TransmitPacketInput (org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput)4 PeerId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId)4 BigInteger (java.math.BigInteger)3 StateBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.StateBuilder)3