<artifactId>hwvtepsouthbound-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>utils.hwvtepsouthbound-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>utils.mdsal-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>library-features</artifactId>
<feature version="${mdsal.version}">odl-mdsal-xsql</feature>
<feature version="${dlux.version}">odl-dlux-yangui</feature>
</feature>
+ <feature name='odl-ovsdb-hwvtepsouthbound-test' version='${project.version}' description='OpenDaylight :: hwvtepsouthbound :: test'>
+ <feature version="${project.version}">odl-ovsdb-hwvtepsouthbound</feature>
+ <bundle>mvn:org.opendaylight.ovsdb/utils.mdsal-utils/{{VERSION}}</bundle>
+ <bundle>mvn:org.opendaylight.ovsdb/utils.hwvtepsouthbound-utils/{{VERSION}}</bundle>
+ </feature>
</features>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-it-parent</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- <relativePath/>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>it</artifactId>
+ <version>1.2.1-SNAPSHOT</version>
+ <relativePath>../../commons/it</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.opendaylight.ovsdb</groupId>
<artifactId>hwvtepsouthbound-it</artifactId>
<version>1.2.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
+ <packaging>jar</packaging>
- <properties>
- <karaf.distro.groupId>org.opendaylight.ovsdb</karaf.distro.groupId>
- <karaf.distro.artifactId>hwvtepsouthbound-karaf</karaf.distro.artifactId>
- <karaf.distro.version>1.2.0-SNAPSHOT</karaf.distro.version>
- <karaf.distro.type>zip</karaf.distro.type>
- </properties>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>hwvtepsouthbound-artifacts</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-artifacts</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>mdsal-artifacts</artifactId>
+ <version>${mdsal.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>hwvtepsouthbound-features</artifactId>
+ <classifier>features</classifier>
+ <type>xml</type>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-common-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>utils.hwvtepsouthbound-utils</artifactId>
<version>${project.version}</version>
</dependency>
+ <!-- Dependencies for pax exam karaf container -->
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-karaf</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit4</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.url</groupId>
+ <artifactId>pax-url-aether</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.features</groupId>
+ <artifactId>org.apache.karaf.features.core</artifactId>
+ <version>${karaf.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.sonar-plugins.java</groupId>
+ <artifactId>sonar-jacoco-listeners</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- AbstractConfigTestBase::getKarafDistro() needs this to find its version -->
+ <dependency>
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>hwvtepsouthbound-karaf</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
-
- <profiles>
- <profile>
- <id>default</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <properties>
- <skipITs>true</skipITs>
- </properties>
- </profile>
- <profile>
- <id>integrationtest</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <properties>
- <skipITs>false</skipITs>
- </properties>
- </profile>
- </profiles>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ </plugin>
+ <!-- Needed if you use versionAsInProject() -->
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>depends-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <id>generate-depends-file</id>
+ <goals>
+ <goal>generate-depends-file</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <failsOnError>true</failsOnError>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
\ No newline at end of file
import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.inject.Inject;
+
+import org.junit.After;
import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundConstants;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundProvider;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
import org.ops4j.pax.exam.options.MavenUrlReference;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class HwvtepSouthboundIT extends AbstractMdsalTestBase {
private static final Logger LOG = LoggerFactory.getLogger(HwvtepSouthboundIT.class);
+ private static MdsalUtils mdsalUtils = null;
+ private static boolean setup = false;
+ private static int testMethodsRemaining;
+
+ @Inject
+ private BundleContext bundleContext;
+
@Override
public String getModuleName() {
return "hwvtepsouthbound";
@Override
public String getFeatureName() {
- return "odl-ovsdb-hwvtepsouthbound-ui";
+ return "odl-ovsdb-hwvtepsouthbound-test";
}
@Override
return option;
}
+ @Override
+ public String getKarafDistro() {
+ return maven()
+ .groupId("org.opendaylight.ovsdb")
+ .artifactId("hwvtepsouthbound-karaf")
+ .versionAsInProject()
+ .type("zip")
+ .getURL();
+ }
+
+ @Before
+ @Override
+ public void setup() throws InterruptedException {
+ if (setup) {
+ LOG.info("Skipping setup, already initialized");
+ return;
+ }
+
+ try {
+ super.setup();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ //dataBroker = getSession().getSALService(DataBroker.class);
+ Thread.sleep(3000);
+ DataBroker dataBroker = HwvtepSouthboundProvider.getDb();
+ Assert.assertNotNull("db should not be null", dataBroker);
+
+
+ mdsalUtils = new MdsalUtils(dataBroker);
+
+ // Let's count the test methods (we need to use this instead of @AfterClass on teardown() since the latter is
+ // useless with pax-exam)
+ for (Method method : getClass().getMethods()) {
+ boolean testMethod = false;
+ boolean ignoreMethod = false;
+ for (Annotation annotation : method.getAnnotations()) {
+ if (Test.class.equals(annotation.annotationType())) {
+ testMethod = true;
+ }
+ if (Ignore.class.equals(annotation.annotationType())) {
+ ignoreMethod = true;
+ }
+ }
+ if (testMethod && !ignoreMethod) {
+ testMethodsRemaining++;
+ }
+ }
+ LOG.info("{} test methods to run", testMethodsRemaining);
+
+ setup = true;
+ }
+
+ @After
+ public void teardown() {
+ testMethodsRemaining--;
+ LOG.info("{} test methods remaining", testMethodsRemaining);
+ }
+
@Test
public void testhwvtepsouthboundFeatureLoad() {
Assert.assertTrue(true);
}
+
+ @Test
+ public void testNetworkTopology() throws InterruptedException {
+ NetworkTopology networkTopology = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION,
+ InstanceIdentifier.create(NetworkTopology.class));
+ Assert.assertNotNull("NetworkTopology could not be found in " + LogicalDatastoreType.CONFIGURATION,
+ networkTopology);
+
+ networkTopology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.create(NetworkTopology.class));
+ Assert.assertNotNull("NetworkTopology could not be found in " + LogicalDatastoreType.OPERATIONAL,
+ networkTopology);
+ }
+
+ @Test
+ public void testHwvtepTopology() throws InterruptedException {
+ InstanceIdentifier<Topology> path = InstanceIdentifier
+ .create(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID));
+
+ Topology topology = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path);
+ Assert.assertNotNull("Topology could not be found in " + LogicalDatastoreType.CONFIGURATION,
+ topology);
+
+ topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, path);
+
+ Assert.assertNotNull("Topology could not be found in " + LogicalDatastoreType.OPERATIONAL,
+ topology);
+ }
+
}
<module>hwvtepsouthbound-karaf</module>
<module>hwvtepsouthbound-features</module>
<module>hwvtepsouthbound-artifacts</module>
- <!--
<module>hwvtepsouthbound-it</module>
- -->
</modules>
<!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-parent</artifactId>
+ <version>0.4.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.opendaylight.ovsdb</groupId>
+ <artifactId>utils.hwvtepsouthbound-utils</artifactId>
+ <version>1.2.1-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <!-- project specific dependencies -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>hwvtepsouthbound-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>hwvtepsouthbound-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>utils.mdsal-utils</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- testing dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.ovsdb.utils.hwvtepsouthbound.utils;
+
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundConstants;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.ConnectionInfo;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HwvtepSouthboundUtils {
+ private static final Logger LOG = LoggerFactory.getLogger(HwvtepSouthboundUtils.class);
+ private static final int HWVTEP_UPDATE_TIMEOUT = 1000;
+ private final MdsalUtils mdsalUtils;
+
+ public HwvtepSouthboundUtils(MdsalUtils mdsalUtils) {
+ this.mdsalUtils = mdsalUtils;
+ }
+
+ public static NodeId createNodeId(IpAddress ip, PortNumber port) {
+ String uriString = HwvtepSouthboundConstants.HWVTEP_URI_PREFIX + "://"
+ + String.valueOf(ip.getValue()) + ":" + port.getValue();
+ Uri uri = new Uri(uriString);
+ return new NodeId(uri);
+ }
+
+ public static Node createNode(ConnectionInfo key) {
+ NodeBuilder nodeBuilder = new NodeBuilder();
+ nodeBuilder.setNodeId(createNodeId(key.getRemoteIp(), key.getRemotePort()));
+ nodeBuilder.addAugmentation(HwvtepGlobalAugmentation.class, createHwvtepAugmentation(key));
+ return nodeBuilder.build();
+ }
+
+ public static HwvtepGlobalAugmentation createHwvtepAugmentation(ConnectionInfo key) {
+ HwvtepGlobalAugmentationBuilder hwvtepGlobalBuilder = new HwvtepGlobalAugmentationBuilder();
+ hwvtepGlobalBuilder.setConnectionInfo(key);
+ return hwvtepGlobalBuilder.build();
+ }
+
+ public static InstanceIdentifier<Node> createInstanceIdentifier(ConnectionInfo key) {
+ return createInstanceIdentifier(key.getRemoteIp(), key.getRemotePort());
+ }
+
+ public static InstanceIdentifier<Node> createInstanceIdentifier(IpAddress ip, PortNumber port) {
+ InstanceIdentifier<Node> path = InstanceIdentifier
+ .create(NetworkTopology.class)
+ .child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID))
+ .child(Node.class,createNodeKey(ip,port));
+ LOG.debug("Created hwvtep path: {}",path);
+ return path;
+ }
+
+ public static NodeKey createNodeKey(IpAddress ip, PortNumber port) {
+ return new NodeKey(createNodeId(ip, port));
+ }
+
+}
<module>neutron-utils</module>
<module>servicehelper</module>
<module>southbound-utils</module>
+ <module>hwvtepsouthbound-utils</module>
</modules>
<!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->