From 5c2043278ea7bdb70fe6baea78dba0198b6dca83 Mon Sep 17 00:00:00 2001 From: Sam Hague Date: Fri, 9 Oct 2015 15:25:47 -0400 Subject: [PATCH] Add southbound to sfc it Change-Id: I1627b92af8a919063d9214d57117741809525134 Signed-off-by: Sam Hague --- openstack/net-virt-sfc/features/pom.xml | 134 +++++------------- .../net-virt-sfc/features/production/pom.xml | 124 ++++++++++++++++ .../src/main/features/features.xml | 2 + openstack/net-virt-sfc/features/test/pom.xml | 45 ++++++ .../test/src/main/features/features.xml | 19 +++ openstack/net-virt-sfc/it/pom.xml | 11 +- .../openstack/netvirt/sfc/NetvirtSfcIT.java | 117 ++++++++++----- openstack/net-virt-sfc/karaf/pom.xml | 16 +-- utils/pom.xml | 1 + 9 files changed, 323 insertions(+), 146 deletions(-) create mode 100644 openstack/net-virt-sfc/features/production/pom.xml rename openstack/net-virt-sfc/features/{ => production}/src/main/features/features.xml (93%) create mode 100644 openstack/net-virt-sfc/features/test/pom.xml create mode 100644 openstack/net-virt-sfc/features/test/src/main/features/features.xml diff --git a/openstack/net-virt-sfc/features/pom.xml b/openstack/net-virt-sfc/features/pom.xml index 9aab23084..d9607aea7 100644 --- a/openstack/net-virt-sfc/features/pom.xml +++ b/openstack/net-virt-sfc/features/pom.xml @@ -1,117 +1,55 @@ - + + org.opendaylight.odlparent - features-parent + odlparent 1.6.0-SNAPSHOT + org.opendaylight.ovsdb - openstack.net-virt-sfc-features + openstack.net-virt-sfc-features-aggregator 1.2.1-SNAPSHOT - ${project.artifactId} + pom 4.0.0 3.1.1 - - 0.8.0-SNAPSHOT - 1.3.0-SNAPSHOT - 1.3.0-SNAPSHOT - 0.8.0-SNAPSHOT - 0.3.0-SNAPSHOT - etc/opendaylight/karaf - - - - - - org.opendaylight.controller - mdsal-artifacts - ${mdsal.version} - pom - import - - - org.opendaylight.netconf - restconf-artifacts - ${restconf.version} - pom - import - - - - - - org.opendaylight.yangtools - features-yangtools - features - ${yangtools.version} - xml - runtime - - - org.opendaylight.mdsal.model - features-mdsal-model - ${mdsal.model.version} - features - xml - runtime - - - org.opendaylight.controller - features-mdsal - features - ${mdsal.version} - xml - runtime - - - org.opendaylight.netconf - features-restconf - features - ${restconf.version} - xml - runtime - - - org.opendaylight.dlux - features-dlux - features - ${dlux.version} - xml - runtime - - - ${project.groupId} - openstack.net-virt-sfc-impl - ${project.version} - - - ${project.groupId} - openstack.net-virt-sfc-impl - ${project.version} - xml - config - - - ${project.groupId} - openstack.net-virt-sfc-api - ${project.version} - - - ${project.groupId} - utils.mdsal-utils - ${project.version} - - + + production + test + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + org.apache.maven.plugins + maven-install-plugin + + true + + + + + + + scm:git:ssh://git.opendaylight.org:29418/ovsdb.git + scm:git:ssh://git.opendaylight.org:29418/ovsdb.git + HEAD + https://wiki.opendaylight.org/view/OVSDB_Integration:Main + diff --git a/openstack/net-virt-sfc/features/production/pom.xml b/openstack/net-virt-sfc/features/production/pom.xml new file mode 100644 index 000000000..6953792d3 --- /dev/null +++ b/openstack/net-virt-sfc/features/production/pom.xml @@ -0,0 +1,124 @@ + + + + + org.opendaylight.odlparent + features-parent + 1.6.0-SNAPSHOT + + + org.opendaylight.ovsdb + openstack.net-virt-sfc-features + 1.2.1-SNAPSHOT + ${project.artifactId} + 4.0.0 + + 3.1.1 + + + 0.8.0-SNAPSHOT + 1.3.0-SNAPSHOT + 1.3.0-SNAPSHOT + 0.8.0-SNAPSHOT + 0.3.0-SNAPSHOT + etc/opendaylight/karaf + + + + + + org.opendaylight.controller + mdsal-artifacts + ${mdsal.version} + pom + import + + + org.opendaylight.netconf + restconf-artifacts + ${restconf.version} + pom + import + + + + + + org.opendaylight.yangtools + features-yangtools + features + ${yangtools.version} + xml + runtime + + + org.opendaylight.mdsal.model + features-mdsal-model + ${mdsal.model.version} + features + xml + runtime + + + org.opendaylight.controller + features-mdsal + features + ${mdsal.version} + xml + runtime + + + org.opendaylight.netconf + features-restconf + features + ${restconf.version} + xml + runtime + + + org.opendaylight.dlux + features-dlux + features + ${dlux.version} + xml + runtime + + + ${project.groupId} + openstack.net-virt-sfc-impl + ${project.version} + + + ${project.groupId} + openstack.net-virt-sfc-impl + ${project.version} + xml + config + + + ${project.groupId} + openstack.net-virt-sfc-api + ${project.version} + + + ${project.groupId} + southbound-features + ${project.version} + xml + features + + + ${project.groupId} + utils.mdsal-utils + ${project.version} + + + diff --git a/openstack/net-virt-sfc/features/src/main/features/features.xml b/openstack/net-virt-sfc/features/production/src/main/features/features.xml similarity index 93% rename from openstack/net-virt-sfc/features/src/main/features/features.xml rename to openstack/net-virt-sfc/features/production/src/main/features/features.xml index afcfc64ca..09cff5347 100644 --- a/openstack/net-virt-sfc/features/src/main/features/features.xml +++ b/openstack/net-virt-sfc/features/production/src/main/features/features.xml @@ -15,6 +15,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html mvn:org.opendaylight.mdsal.model/features-mdsal-model/${mdsal.model.version}/xml/features mvn:org.opendaylight.netconf/features-restconf/${restconf.version}/xml/features mvn:org.opendaylight.dlux/features-dlux/${dlux.version}/xml/features + mvn:org.opendaylight.ovsdb/southbound-features/1.2.1-SNAPSHOT/xml/features odl-mdsal-models mvn:org.opendaylight.ovsdb/openstack.net-virt-sfc-api/${project.version} @@ -22,6 +23,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html odl-mdsal-broker odl-ovsdb-sfc-api + odl-ovsdb-southbound-impl mvn:org.opendaylight.ovsdb/openstack.net-virt-sfc-impl/${project.version} mvn:org.opendaylight.ovsdb/utils.mdsal-utils/${project.version} mvn:org.opendaylight.ovsdb/openstack.net-virt-sfc-impl/${project.version}/xml/config diff --git a/openstack/net-virt-sfc/features/test/pom.xml b/openstack/net-virt-sfc/features/test/pom.xml new file mode 100644 index 000000000..f1c49bf15 --- /dev/null +++ b/openstack/net-virt-sfc/features/test/pom.xml @@ -0,0 +1,45 @@ + + + + + org.opendaylight.odlparent + features-parent + 1.6.0-SNAPSHOT + + + org.opendaylight.ovsdb + openstack.net-virt-sfc-features-test + 1.2.1-SNAPSHOT + ${project.artifactId} + 4.0.0 + + 3.1.1 + + + + ${project.groupId} + openstack.net-virt-sfc-features + ${project.version} + xml + features + + + ${project.groupId} + utils.mdsal-utils + ${project.version} + + + ${project.groupId} + utils.southbound-utils + ${project.version} + + + diff --git a/openstack/net-virt-sfc/features/test/src/main/features/features.xml b/openstack/net-virt-sfc/features/test/src/main/features/features.xml new file mode 100644 index 000000000..ebeccf789 --- /dev/null +++ b/openstack/net-virt-sfc/features/test/src/main/features/features.xml @@ -0,0 +1,19 @@ + + + + + mvn:org.opendaylight.ovsdb/openstack.net-virt-sfc-features/1.2.1-SNAPSHOT/xml/features + + mvn:org.opendaylight.ovsdb/utils.mdsal-utils/${project.version} + mvn:org.opendaylight.ovsdb/utils.southbound-utils/${project.version} + odl-ovsdb-southbound-impl-ui + + diff --git a/openstack/net-virt-sfc/it/pom.xml b/openstack/net-virt-sfc/it/pom.xml index 0ecf05e30..386fbe551 100644 --- a/openstack/net-virt-sfc/it/pom.xml +++ b/openstack/net-virt-sfc/it/pom.xml @@ -27,7 +27,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.ovsdb openstack.net-virt-sfc-karaf - 1.0.0-SNAPSHOT + ${project.version} zip @@ -54,6 +54,15 @@ and is available at http://www.eclipse.org/legal/epl-v10.html utils.mdsal-utils ${project.version} + + ${project.groupId} + utils.southbound-utils + ${project.version} + + + org.opendaylight.yangtools + concepts + org.codehaus.sonar-plugins.java sonar-jacoco-listeners diff --git a/openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/NetvirtSfcIT.java b/openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/NetvirtSfcIT.java index cb5e49f3e..7ee684de8 100644 --- a/openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/NetvirtSfcIT.java +++ b/openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/NetvirtSfcIT.java @@ -11,12 +11,15 @@ package org.opendaylight.ovsdb.openstack.netvirt.sfc; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import static org.ops4j.pax.exam.CoreOptions.composite; import static org.ops4j.pax.exam.CoreOptions.maven; +import static org.ops4j.pax.exam.CoreOptions.propagateSystemProperties; import static org.ops4j.pax.exam.CoreOptions.vmOption; import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut; import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder; +import java.util.Properties; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.Before; import org.junit.Test; @@ -26,10 +29,10 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.AclUtils; -//import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.SfcUtils; import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.ClassifierUtils; import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.SfcUtils; import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils; +import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.AccessLists; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.AccessListsBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.acl.rev141010.access.lists.AccessListBuilder; @@ -44,7 +47,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt. import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.SffBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.rev150105.Sfc; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.rev150105.SfcBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo; import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.ops4j.pax.exam.Configuration; @@ -66,6 +71,16 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase { private static SfcUtils sfcUtils = new SfcUtils(); private static MdsalUtils mdsalUtils; private static AtomicBoolean setup = new AtomicBoolean(false); + private static SouthboundUtils southboundUtils; + private static String addressStr; + private static String portStr; + private static String connectionType; + public static final String SERVER_IPADDRESS = "ovsdbserver.ipaddress"; + public static final String SERVER_PORT = "ovsdbserver.port"; + public static final String CONNECTION_TYPE = "ovsdbserver.connection"; + public static final String CONNECTION_TYPE_ACTIVE = "active"; + public static final String CONNECTION_TYPE_PASSIVE = "passive"; + public static final String DEFAULT_SERVER_PORT = "6640"; @Override public String getModuleName() { @@ -95,13 +110,16 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase { @Configuration @Override public Option[] config() { - Option[] parentOptions = super.config(); - Option[] otherOptions = getOtherOptions(); - Option[] options = new Option[parentOptions.length + otherOptions.length]; - System.arraycopy(parentOptions, 0, options, 0, parentOptions.length); - System.arraycopy(otherOptions, 0, options, parentOptions.length, otherOptions.length); - return options; - } + Option[] parentOptions = super.config(); + Option[] propertiesOptions = getPropertiesOptions(); + Option[] otherOptions = getOtherOptions(); + Option[] options = new Option[parentOptions.length + propertiesOptions.length + otherOptions.length]; + System.arraycopy(parentOptions, 0, options, 0, parentOptions.length); + System.arraycopy(propertiesOptions, 0, options, parentOptions.length, propertiesOptions.length); + System.arraycopy(otherOptions, 0, options, parentOptions.length + propertiesOptions.length, + otherOptions.length); + return options; + } private Option[] getOtherOptions() { return new Option[] { @@ -110,6 +128,12 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase { }; } + public Option[] getPropertiesOptions() { + return new Option[] { + propagateSystemProperties(SERVER_IPADDRESS, SERVER_PORT, CONNECTION_TYPE), + }; + } + @Override public Option getLoggingOption() { Option option = editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG, @@ -119,6 +143,26 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase { return option; } + protected String usage() { + return "Integration Test needs a valid connection configuration as follows :\n" + + "active connection : mvn -Dovsdbserver.ipaddress=x.x.x.x -Dovsdbserver.port=yyyy verify\n" + + "passive connection : mvn -Dovsdbserver.connection=passive verify\n"; + } + + private void getProperties() { + Properties props = System.getProperties(); + addressStr = props.getProperty(SERVER_IPADDRESS); + portStr = props.getProperty(SERVER_PORT, DEFAULT_SERVER_PORT); + connectionType = props.getProperty(CONNECTION_TYPE, "active"); + LOG.info("setUp: Using the following properties: mode= {}, ip:port= {}:{}", + connectionType, addressStr, portStr); + if (connectionType.equalsIgnoreCase(CONNECTION_TYPE_ACTIVE)) { + if (addressStr == null) { + fail(usage()); + } + } + } + @Before @Override public void setup() { @@ -136,6 +180,8 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase { DataBroker dataBroker = getDatabroker(getProviderContext()); mdsalUtils = new MdsalUtils(dataBroker); assertNotNull("mdsalUtils should not be null", mdsalUtils); + southboundUtils = new SouthboundUtils(mdsalUtils); + getProperties(); setup.set(true); } @@ -190,15 +236,8 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase { } @Test - public void testAcl() { - AccessListsBuilder accessListsBuilder = setAccessLists(); - InstanceIdentifier path = InstanceIdentifier.create(AccessLists.class); - assertTrue(mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, path, accessListsBuilder.build())); - AccessLists accessLists = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path); - assertNotNull("AccessLists should not be null", accessLists); - assertTrue("Failed to remove AccessLists", mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, path)); - accessLists = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path); - assertNull("AccessLists should be null", accessLists); + public void testAccessLists() { + testModel(setAccessLists(), AccessLists.class); } private ClassifiersBuilder setClassifiers() { @@ -213,26 +252,36 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase { } @Test - public void testClassifier() { - ClassifiersBuilder classifiersBuilder = setClassifiers(); - InstanceIdentifier path = InstanceIdentifier.create(Classifiers.class); - assertTrue(mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, path, classifiersBuilder.build())); - Classifiers classifiers = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path); - assertNotNull("Classifiers should not be null", classifiers); - assertTrue("Failed to remove Classifiers", mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, path)); - classifiers = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path); - assertNull("Classifiers should be null", classifiers); + public void testClassifiers() { + testModel(setClassifiers(), Classifiers.class); + } + + private SfcBuilder setSfc() { + SfcBuilder sfcBuilder = sfcUtils.createSfc(new SfcBuilder(), "sfc"); + return sfcBuilder; } @Test public void testSfc() { - SfcBuilder sfcBuilder = sfcUtils.createSfc(new SfcBuilder(), "sfc"); - InstanceIdentifier path = InstanceIdentifier.create(Sfc.class); - assertTrue(mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, path, sfcBuilder.build())); - Sfc sfc = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path); - assertNotNull("SfcUtils should not be null", sfc); - assertTrue("Failed to remove Sfc", mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, path)); - sfc = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path); - assertNull("Sfc should be null", sfc); + testModel(setSfc(), Sfc.class); + } + + private void testModel(Builder builder, Class clazz) { + InstanceIdentifier path = InstanceIdentifier.create(clazz); + assertTrue(mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, path, builder.build())); + T result = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path); + assertNotNull(clazz.getSimpleName() + " should not be null", result); + assertTrue("Failed to remove " + clazz.getSimpleName(), + mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, path)); + result = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path); + assertNull(clazz.getSimpleName() + " should be null", result); + } + + @Test + public void testDoIt() throws InterruptedException { + ConnectionInfo connectionInfo = southboundUtils.getConnectionInfo(addressStr, portStr); + southboundUtils.connectOvsdbNode(connectionInfo); + Thread.sleep(1000); + southboundUtils.disconnectOvsdbNode(connectionInfo); } } diff --git a/openstack/net-virt-sfc/karaf/pom.xml b/openstack/net-virt-sfc/karaf/pom.xml index 28ff3edcd..b7c0375e2 100644 --- a/openstack/net-virt-sfc/karaf/pom.xml +++ b/openstack/net-virt-sfc/karaf/pom.xml @@ -23,19 +23,8 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL 3.1.1 - odl-ovsdb-sfc-ui + odl-ovsdb-sfc-test - - - - ${project.groupId} - openstack.net-virt-sfc-artifacts - ${project.version} - pom - import - - -