diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2017-03-31 11:24:24 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2017-05-26 13:05:06 +0200 |
commit | 46589c652a58b1cd56dab268b59d96bc20b5dd1f (patch) | |
tree | 502d68e9deeff2f0d08a41feb43df830b23ca6dd /infra/minimal-distribution/src/test | |
parent | 9cb05be1e97448550b60ff694c0c33dcbea702fb (diff) |
Include ODL's BGP to HC minimal distro
Features:
- static bgp instance
- static peer registry (both remote & app peers supported)
- bgp operational state exposed via RESTCONF/NETCONF
- bgp-inet support
- postman collection with examples
TODOs:
- make bgp disabled by default in honeycomb.json (probably bgp should be build using profile
or allow to filter yangs loaded by SchemaCtx, otherwise footprint will grow)
- update asciidocs for infra module
- SPI for VPP integration:
- allow RIB changes listeners
- or writers (that can reject changes) to mirror netconf/restconf design
- expose bgp server & peer cfg via netconf/restconf (currently read from json files)
- test support for all BGP extensions (flowspec BGP needs additional care)
- make bgp extensions fully configurable (probably requires changes in ODL)
Testing
1) start hc distro:
./infra/minimal-distribution/target/minimal-distribution-1.17.07-SNAPSHOT-hc/minimal-distribution-1.17.07-SNAPSHOT/honeycomb
2) run bgp-testtool:
java -jar ./target/bgp-testtool-0.6.3-Boron-SR3-executable.jar
-ra 127.0.0.1:1790 -la 127.0.0.2:17900 -pr 2 -ll DEBUG --active true -as 65000 -mp true
then GET http://localhost:8183/restconf/operational/bgp-rib:bgp-rib
Change-Id: I156d6a1c79174279db8c8936c40ac1f28e14794c
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'infra/minimal-distribution/src/test')
3 files changed, 139 insertions, 8 deletions
diff --git a/infra/minimal-distribution/src/test/java/io/fd/honeycomb/infra/distro/BaseMinimalDistributionTest.java b/infra/minimal-distribution/src/test/java/io/fd/honeycomb/infra/distro/BaseMinimalDistributionTest.java index 8a8ddc3ef..fdd265b79 100644 --- a/infra/minimal-distribution/src/test/java/io/fd/honeycomb/infra/distro/BaseMinimalDistributionTest.java +++ b/infra/minimal-distribution/src/test/java/io/fd/honeycomb/infra/distro/BaseMinimalDistributionTest.java @@ -18,6 +18,7 @@ package io.fd.honeycomb.infra.distro; import static com.google.common.collect.ImmutableSet.of; import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @@ -30,6 +31,10 @@ import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; +import io.fd.honeycomb.infra.distro.bgp.BgpExtensionsModule; +import io.fd.honeycomb.infra.distro.bgp.BgpModule; +import io.fd.honeycomb.infra.distro.bgp.BgpReadersModule; +import io.fd.honeycomb.infra.distro.bgp.BgpWritersModule; import io.fd.honeycomb.infra.distro.cfgattrs.CfgAttrsModule; import io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule; import io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule; @@ -41,8 +46,8 @@ import io.fd.honeycomb.infra.distro.schema.SchemaModule; import io.fd.honeycomb.infra.distro.schema.YangBindingProviderModule; import java.io.IOException; import java.io.InputStream; +import java.net.InetAddress; import java.net.Socket; -import java.util.List; import java.util.Properties; import java.util.Set; import javax.net.ssl.SSLContext; @@ -68,7 +73,11 @@ public class BaseMinimalDistributionTest { private static final int NETCONF_TCP_PORT = 7778; private static final int NETCONF_SSH_PORT = 2832; private static final String NETCONF_NAMESPACE = "urn:ietf:params:xml:ns:netconf:base:1.0"; - private static final int NETCONF_HELLO_WAIT = 2500; + private static final int HELLO_WAIT = 2500; + + private static final int BGP_MSG_TYPE_OFFSET = 18; // 16 (MARKER) + 2 (LENGTH); + private static final byte BGP_OPEN_MSG_TYPE = 1; + private static final int BGP_PORT = 1790; public static final Set<Module> BASE_MODULES = of( new YangBindingProviderModule(), @@ -79,6 +88,10 @@ public class BaseMinimalDistributionTest { new NetconfModule(), new NetconfReadersModule(), new RestconfModule(), + new BgpModule(), + new BgpExtensionsModule(), + new BgpReadersModule(), + new BgpWritersModule(), new CfgAttrsModule()); @Before @@ -111,13 +124,15 @@ public class BaseMinimalDistributionTest { assertRestconfHttp(); LOG.info("Testing RESTCONF HTTPS"); assertRestconfHttps(); + LOG.info("Testing BGP"); + assertBgp(); } private void assertNetconfTcp() throws Exception { try (final Socket localhost = new Socket("127.0.0.1", NETCONF_TCP_PORT); final InputStream inputStream = localhost.getInputStream()) { // Wait until hello msg is sent from server - Thread.sleep(NETCONF_HELLO_WAIT); + Thread.sleep(HELLO_WAIT); final String helloMessage = inputStreamToString(inputStream); LOG.info("NETCONF TCP sent hello: {}", helloMessage); @@ -127,11 +142,14 @@ public class BaseMinimalDistributionTest { } } - private String inputStreamToString(final InputStream inputStream) throws IOException { + private byte[] readMessage(final InputStream inputStream) throws IOException { final int available = inputStream.available(); - final byte[] helloBytes = new byte[available]; - ByteStreams.read(inputStream, helloBytes, 0, available); - return new String(helloBytes, Charsets.UTF_8); + final byte[] msg = new byte[available]; + ByteStreams.read(inputStream, msg, 0, available); + return msg; + } + private String inputStreamToString(final InputStream inputStream) throws IOException { + return new String(readMessage(inputStream), Charsets.UTF_8); } private void assertNetconfSsh() throws Exception { @@ -151,7 +169,7 @@ public class BaseMinimalDistributionTest { channel.connect(20000); // Wait until hello msg is sent from server - Thread.sleep(NETCONF_HELLO_WAIT); + Thread.sleep(HELLO_WAIT); final String helloMessage = inputStreamToString(inputStream); LOG.info("NETCONF SSH sent hello: {}", helloMessage); @@ -199,4 +217,19 @@ public class BaseMinimalDistributionTest { assertTrue(jsonNodeHttpResponse.getStatus() >= 200); assertTrue(jsonNodeHttpResponse.getStatus() < 400); } + + private void assertBgp() throws Exception { + final InetAddress bgpHost = InetAddress.getByName("127.0.0.1"); + final InetAddress bgpPeerAddress = InetAddress.getByName("127.0.0.2"); + try (final Socket localhost = new Socket(bgpHost, BGP_PORT, bgpPeerAddress, 0); + final InputStream inputStream = localhost.getInputStream()) { + // wait until bgp message is sent + Thread.sleep(HELLO_WAIT); + + final byte[] msg = readMessage(inputStream); + LOG.info("Received BGP message: {}", msg); + + assertEquals(BGP_OPEN_MSG_TYPE, msg[BGP_MSG_TYPE_OFFSET]); + } + } }
\ No newline at end of file diff --git a/infra/minimal-distribution/src/test/resources/bgp-peers.json b/infra/minimal-distribution/src/test/resources/bgp-peers.json new file mode 100644 index 000000000..3a7e01060 --- /dev/null +++ b/infra/minimal-distribution/src/test/resources/bgp-peers.json @@ -0,0 +1,90 @@ +{ + "bgp-openconfig-extensions:neighbors": { + "neighbor": [ + { + "neighbor-address": "10.25.1.9", + "config": { + "peer-group": "application-peers" + }, + "afi-safis": { + "afi-safi": [ + { + "afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST", + "receive": true, + "send-max": 0 + } + ] + } + }, + { + "neighbor-address": "10.25.1.10", + "config": { + "peer-group": "application-peers" + }, + "afi-safis": { + "afi-safi": [ + { + "afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST", + "receive": true, + "send-max": 0 + } + ] + } + }, + { + "neighbor-address": "127.0.0.2", + "config": { + "peer-type": "INTERNAL" + }, + "timers": { + "config": { + "connect-retry": 10, + "hold-time": 90 + } + }, + "transport": { + "config": { + "remote-port": 17900, + "passive-mode": false + } + }, + "afi-safis": { + "afi-safi": [ + { + "afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST", + "receive": true, + "send-max": 0 + } + ] + } + }, + { + "neighbor-address": "127.0.0.3", + "config": { + "peer-type": "EXTERNAL" + }, + "timers": { + "config": { + "connect-retry": 10, + "hold-time": 90 + } + }, + "transport": { + "config": { + "remote-port": 17900, + "passive-mode": false + } + }, + "afi-safis": { + "afi-safi": [ + { + "afi-safi-name": "openconfig-bgp-types:IPV4-UNICAST", + "receive": true, + "send-max": 0 + } + ] + } + } + ] + } +}
\ No newline at end of file diff --git a/infra/minimal-distribution/src/test/resources/honeycomb.json b/infra/minimal-distribution/src/test/resources/honeycomb.json index a0b2a633c..be627747b 100644 --- a/infra/minimal-distribution/src/test/resources/honeycomb.json +++ b/infra/minimal-distribution/src/test/resources/honeycomb.json @@ -35,6 +35,14 @@ "netconf-ssh-binding-port": 2832, "netconf-notification-stream-name": "honeycomb", + "bgp-enabled": "true", + "bgp-binding-address": "127.0.0.1", + "bgp-port": 1790, + "bgp-as-number": 65000, + "bgp-receive-multiple-paths": "true", + "bgp-send-max-paths": 0, + "bgp-netty-threads": 2, + "username": "admin", "password": "admin" }
\ No newline at end of file |