From: taochang Date: Mon, 29 Apr 2013 17:20:23 +0000 (-0700) Subject: Resubmitted with source code synchronized. Added integration test for hosttracker... X-Git-Tag: releasepom-0.1.0~516 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=9e43cfabdc83df4c5db51ce6e22e0cecca12aa9a Resubmitted with source code synchronized. Added integration test for hosttracker, split switchmanager into api and implementation bundles. Change-Id: I04d5d89562316cafa89a5ee46e08eb724733711a Signed-off-by: taochang --- diff --git a/opendaylight/arphandler/src/test/java/org/opendaylight/controller/arphandler/internal/ArphandlerTest.java b/opendaylight/arphandler/src/test/java/org/opendaylight/controller/arphandler/internal/ArphandlerTest.java index b863d2b923..e4e17cb2d6 100644 --- a/opendaylight/arphandler/src/test/java/org/opendaylight/controller/arphandler/internal/ArphandlerTest.java +++ b/opendaylight/arphandler/src/test/java/org/opendaylight/controller/arphandler/internal/ArphandlerTest.java @@ -15,11 +15,8 @@ import org.junit.Test; import junit.framework.TestCase; import org.opendaylight.controller.hosttracker.IfIptoHost; -import org.opendaylight.controller.hosttracker.HostTracker; import org.opendaylight.controller.switchmanager.ISwitchManager; -import org.opendaylight.controller.switchmanager.internal.SwitchManagerImpl; - public class ArphandlerTest extends TestCase { @@ -30,23 +27,6 @@ public class ArphandlerTest extends TestCase { ah = new ArpHandler(); Assert.assertTrue(ah != null); - HostTracker hostTracker = null; - hostTracker = new HostTracker(); - ah.setHostTracker(hostTracker); - IfIptoHost ht= ah.getHostTracker(); - Assert.assertTrue(ht.equals(hostTracker)); - ah.unsetHostTracker(hostTracker); - ht= ah.getHostTracker(); - Assert.assertTrue(ht == null); - - ah.setHostListener(hostTracker); - ah.unsetHostListener(hostTracker); - - ISwitchManager swManager = new SwitchManagerImpl(); - ah.setSwitchManager(swManager); - ah.unsetSwitchManager(swManager); - } - } diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index f05c95bb8c..cf481b7f4b 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -42,13 +42,16 @@ ../../arphandler ../../forwardingrulesmanager/api ../../forwardingrulesmanager/implementation - ../../hosttracker + ../../hosttracker/api + ../../hosttracker/implementation + ../../hosttracker/integrationtest ../../containermanager/api ../../containermanager/implementation - ../../switchmanager + ../../switchmanager/api + ../../switchmanager/implementation ../../statisticsmanager/api ../../statisticsmanager/implementation - ../../statisticsmanager/integrationtest + ../../statisticsmanager/integrationtest ../../topologymanager ../../usermanager ../../security diff --git a/opendaylight/hosttracker/pom.xml b/opendaylight/hosttracker/api/pom.xml similarity index 77% rename from opendaylight/hosttracker/pom.xml rename to opendaylight/hosttracker/api/pom.xml index b7628dde20..59290efbd5 100644 --- a/opendaylight/hosttracker/pom.xml +++ b/opendaylight/hosttracker/api/pom.xml @@ -1,80 +1,72 @@ - - - 4.0.0 - - org.opendaylight.controller - commons.opendaylight - 1.4.0-SNAPSHOT - ../commons/opendaylight - - org.opendaylight.controller - hosttracker - 0.4.0-SNAPSHOT - bundle - - - - - org.apache.felix - maven-bundle-plugin - 2.3.6 - true - - - - org.opendaylight.controller.hosttracker, - org.opendaylight.controller.hosttracker.hostAware - - - org.opendaylight.controller.sal.core, - org.opendaylight.controller.sal.utils, - org.opendaylight.controller.hosttracker, - org.opendaylight.controller.hosttracker.hostAware, - org.opendaylight.controller.topologymanager, - org.opendaylight.controller.sal.packet.address, - org.opendaylight.controller.switchmanager, - org.opendaylight.controller.clustering.services, - javax.xml.bind.annotation, - javax.xml.bind, - org.apache.felix.dm, - org.apache.commons.lang3.builder, - org.osgi.service.component, - org.slf4j, - org.eclipse.osgi.framework.console, - org.osgi.framework - - - org.opendaylight.controller.hosttracker.internal.Activator - - - - - - - - - - - org.opendaylight.controller - topologymanager - 0.4.0-SNAPSHOT - - - org.opendaylight.controller - switchmanager - 0.4.0-SNAPSHOT - - - org.opendaylight.controller - clustering.services - 0.4.0-SNAPSHOT - - - org.opendaylight.controller - sal - 0.4.0-SNAPSHOT - - - + + + 4.0.0 + + org.opendaylight.controller + commons.opendaylight + 1.4.0-SNAPSHOT + ../../commons/opendaylight + + org.opendaylight.controller + hosttracker + 0.4.0-SNAPSHOT + bundle + + + + + org.apache.felix + maven-bundle-plugin + 2.3.6 + true + + + + org.opendaylight.controller.hosttracker, + org.opendaylight.controller.hosttracker.hostAware + + + org.opendaylight.controller.sal.core, + org.opendaylight.controller.sal.utils, + org.opendaylight.controller.topologymanager, + org.opendaylight.controller.sal.packet.address, + org.opendaylight.controller.switchmanager, + org.opendaylight.controller.clustering.services, + javax.xml.bind.annotation, + javax.xml.bind, + org.apache.felix.dm, + org.apache.commons.lang3.builder, + org.osgi.service.component, + org.slf4j, + org.eclipse.osgi.framework.console, + org.osgi.framework + + + + + + + + + org.opendaylight.controller + topologymanager + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + switchmanager + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + clustering.services + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + sal + 0.4.0-SNAPSHOT + + + diff --git a/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/IfHostListener.java b/opendaylight/hosttracker/api/src/main/java/org/opendaylight/controller/hosttracker/IfHostListener.java similarity index 100% rename from opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/IfHostListener.java rename to opendaylight/hosttracker/api/src/main/java/org/opendaylight/controller/hosttracker/IfHostListener.java diff --git a/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/IfIptoHost.java b/opendaylight/hosttracker/api/src/main/java/org/opendaylight/controller/hosttracker/IfIptoHost.java similarity index 100% rename from opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/IfIptoHost.java rename to opendaylight/hosttracker/api/src/main/java/org/opendaylight/controller/hosttracker/IfIptoHost.java diff --git a/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/IfNewHostNotify.java b/opendaylight/hosttracker/api/src/main/java/org/opendaylight/controller/hosttracker/IfNewHostNotify.java similarity index 100% rename from opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/IfNewHostNotify.java rename to opendaylight/hosttracker/api/src/main/java/org/opendaylight/controller/hosttracker/IfNewHostNotify.java diff --git a/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnector.java b/opendaylight/hosttracker/api/src/main/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnector.java similarity index 100% rename from opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnector.java rename to opendaylight/hosttracker/api/src/main/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnector.java diff --git a/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/hostAware/IHostFinder.java b/opendaylight/hosttracker/api/src/main/java/org/opendaylight/controller/hosttracker/hostAware/IHostFinder.java similarity index 94% rename from opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/hostAware/IHostFinder.java rename to opendaylight/hosttracker/api/src/main/java/org/opendaylight/controller/hosttracker/hostAware/IHostFinder.java index f7151f705e..5ea7fb0e49 100644 --- a/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/hostAware/IHostFinder.java +++ b/opendaylight/hosttracker/api/src/main/java/org/opendaylight/controller/hosttracker/hostAware/IHostFinder.java @@ -10,6 +10,8 @@ package org.opendaylight.controller.hosttracker.hostAware; import java.net.InetAddress; +import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector; + /** * This Interface defines the methods to trigger the discovery of diff --git a/opendaylight/hosttracker/src/test/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnectorTest.java b/opendaylight/hosttracker/api/src/test/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnectorTest.java similarity index 100% rename from opendaylight/hosttracker/src/test/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnectorTest.java rename to opendaylight/hosttracker/api/src/test/java/org/opendaylight/controller/hosttracker/hostAware/HostNodeConnectorTest.java diff --git a/opendaylight/hosttracker/implementation/pom.xml b/opendaylight/hosttracker/implementation/pom.xml new file mode 100644 index 0000000000..1f24e06bad --- /dev/null +++ b/opendaylight/hosttracker/implementation/pom.xml @@ -0,0 +1,123 @@ + + + 4.0.0 + + org.opendaylight.controller + commons.opendaylight + 1.4.0-SNAPSHOT + ../../commons/opendaylight + + org.opendaylight.controller + hosttracker.implementation + 0.4.0-SNAPSHOT + bundle + + + + jacoco + reuseReports + target/jacobo.exec + target/jacoco-it.exec + java + + + + + + + org.jacoco + jacoco-maven-plugin + 0.5.3.201107060350 + + + + + + org.apache.felix + maven-bundle-plugin + 2.3.6 + true + + + + + + org.opendaylight.controller.sal.core, + org.opendaylight.controller.sal.utils, + org.opendaylight.controller.hosttracker, + org.opendaylight.controller.topologymanager, + org.opendaylight.controller.sal.packet.address, + org.opendaylight.controller.switchmanager, + org.opendaylight.controller.clustering.services, + org.opendaylight.controller.hosttracker.hostAware, + javax.xml.bind.annotation, + javax.xml.bind, + org.apache.felix.dm, + org.apache.commons.lang3.builder, + org.osgi.service.component, + org.slf4j, + org.eclipse.osgi.framework.console, + org.osgi.framework + + + org.opendaylight.controller.hosttracker.internal.Activator + + + + + + + + org.jacoco + jacoco-maven-plugin + + org.opendaylight.controller.* + + + + pre-test + + prepare-agent + + + + post-test + test + + report + + + + + + + + + org.opendaylight.controller + topologymanager + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + switchmanager + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + clustering.services + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + sal + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + hosttracker + 0.4.0-SNAPSHOT + + + diff --git a/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/internal/Activator.java b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/Activator.java similarity index 98% rename from opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/internal/Activator.java rename to opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/Activator.java index 25fe1f24fb..ef88fa2e16 100644 --- a/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/internal/Activator.java +++ b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/Activator.java @@ -10,7 +10,7 @@ package org.opendaylight.controller.hosttracker.internal; import org.apache.felix.dm.Component; -import org.opendaylight.controller.hosttracker.HostTracker; +import org.opendaylight.controller.hosttracker.internal.HostTracker; import org.opendaylight.controller.hosttracker.IfHostListener; import org.opendaylight.controller.hosttracker.IfIptoHost; import org.opendaylight.controller.hosttracker.IfNewHostNotify; diff --git a/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/HostTracker.java b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java similarity index 99% rename from opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/HostTracker.java rename to opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java index 45f3cedacb..d0f8bb5736 100644 --- a/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/HostTracker.java +++ b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTracker.java @@ -7,7 +7,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.hosttracker; +package org.opendaylight.controller.hosttracker.internal; import java.net.InetAddress; import java.net.UnknownHostException; @@ -37,6 +37,9 @@ import org.opendaylight.controller.clustering.services.IClusterContainerServices import org.opendaylight.controller.clustering.services.IClusterServices; import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector; import org.opendaylight.controller.hosttracker.hostAware.IHostFinder; +import org.opendaylight.controller.hosttracker.IfHostListener; +import org.opendaylight.controller.hosttracker.IfIptoHost; +import org.opendaylight.controller.hosttracker.IfNewHostNotify; import org.opendaylight.controller.sal.core.ConstructionException; import org.opendaylight.controller.sal.core.Edge; import org.opendaylight.controller.sal.core.Host; diff --git a/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/HostTrackerCallable.java b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTrackerCallable.java similarity index 96% rename from opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/HostTrackerCallable.java rename to opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTrackerCallable.java index f6f2c6d393..0af523aaa9 100644 --- a/opendaylight/hosttracker/src/main/java/org/opendaylight/controller/hosttracker/HostTrackerCallable.java +++ b/opendaylight/hosttracker/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/HostTrackerCallable.java @@ -11,7 +11,7 @@ * Provides a mechanism for applications to do an inline Host Discovery as opposed * to a delayed discovery */ -package org.opendaylight.controller.hosttracker; +package org.opendaylight.controller.hosttracker.internal; /** * This Class provides methods to discover Host through a blocking call diff --git a/opendaylight/hosttracker/src/test/java/org/opendaylight/controller/hosttracker/HostTrackerTest.java b/opendaylight/hosttracker/implementation/src/test/java/org/opendaylight/controller/hosttracker/HostTrackerTest.java similarity index 93% rename from opendaylight/hosttracker/src/test/java/org/opendaylight/controller/hosttracker/HostTrackerTest.java rename to opendaylight/hosttracker/implementation/src/test/java/org/opendaylight/controller/hosttracker/HostTrackerTest.java index 482e0645b6..9bd28c8e45 100644 --- a/opendaylight/hosttracker/src/test/java/org/opendaylight/controller/hosttracker/HostTrackerTest.java +++ b/opendaylight/hosttracker/implementation/src/test/java/org/opendaylight/controller/hosttracker/HostTrackerTest.java @@ -7,7 +7,7 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.hosttracker; +package org.opendaylight.controller.hosttracker.internal; import java.net.InetAddress; diff --git a/opendaylight/hosttracker/implementation/src/test/resources/logback.xml b/opendaylight/hosttracker/implementation/src/test/resources/logback.xml new file mode 100644 index 0000000000..5fa21fecfc --- /dev/null +++ b/opendaylight/hosttracker/implementation/src/test/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + diff --git a/opendaylight/hosttracker/integrationtest/pom.xml b/opendaylight/hosttracker/integrationtest/pom.xml new file mode 100644 index 0000000000..ff08cf334c --- /dev/null +++ b/opendaylight/hosttracker/integrationtest/pom.xml @@ -0,0 +1,139 @@ + + + 4.0.0 + + org.opendaylight.controller + commons.opendaylight + 1.4.0-SNAPSHOT + ../../../opendaylight/commons/opendaylight + + + org.opendaylight.controller + hosttracker.integrationtest + 0.4.0-SNAPSHOT + + + + org.opendaylight.controller + hosttracker + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + hosttracker.implementation + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + sal + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + sal.implementation + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + containermanager + 0.4.0-SNAPSHOT + + + + org.opendaylight.controller + containermanager.implementation + 0.4.0-SNAPSHOT + + + + org.opendaylight.controller + arphandler + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + clustering.services + 0.4.0-SNAPSHOT + + + + org.opendaylight.controller + clustering.services-implementation + 0.4.0-SNAPSHOT + + + + org.opendaylight.controller + switchmanager + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + switchmanager.implementation + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + configuration + 0.4.0-SNAPSHOT + + + + org.opendaylight.controller + configuration.implementation + 0.4.0-SNAPSHOT + + + + org.opendaylight.controller + topologymanager + 0.4.0-SNAPSHOT + + + + + jacoco + ../implementation/target/jacoco.exec + ../implementaiton/target/jacoco-it.exec + java + + + + + + + org.jacoco + jacoco-maven-plugin + 0.5.3.201107060350 + + + + + + org.jacoco + jacoco-maven-plugin + 0.5.3.201107060350 + + ../implementation/target/jacoco-it.exec + org.opendaylight.controller.* + + + + pre-test + + prepare-agent + + + + post-test + + true + + + + + + + + diff --git a/opendaylight/hosttracker/integrationtest/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerIntegrationTest.java b/opendaylight/hosttracker/integrationtest/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerIntegrationTest.java new file mode 100644 index 0000000000..f351d1afcb --- /dev/null +++ b/opendaylight/hosttracker/integrationtest/src/test/java/org/opendaylight/controller/hosttracker/internal/HostTrackerIntegrationTest.java @@ -0,0 +1,323 @@ + +/* + * Copyright (c) 2013 Cisco Systems, Inc. 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.controller.hosttracker.internal; + + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.Bundle; +import javax.inject.Inject; + +import org.eclipse.osgi.framework.console.CommandProvider; +import org.junit.Assert; +import org.junit.Test; +import org.junit.Before; +import org.junit.After; +import org.junit.runner.RunWith; +import org.opendaylight.controller.sal.core.Node; +import org.opendaylight.controller.sal.core.NodeConnector; +import org.opendaylight.controller.sal.core.UpdateType; +import org.opendaylight.controller.sal.utils.NodeConnectorCreator; +import org.opendaylight.controller.sal.utils.NodeCreator; +import org.opendaylight.controller.sal.utils.Status; +//import org.opendaylight.controller.hosttracker.*; +import org.opendaylight.controller.hosttracker.IfIptoHost; +import org.opendaylight.controller.hosttracker.IfHostListener; +import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector; +import org.opendaylight.controller.switchmanager.IInventoryListener; +import org.opendaylight.controller.switchmanager.ISwitchManager; +import org.opendaylight.controller.switchmanager.ISwitchManagerAware; +import org.opendaylight.controller.topologymanager.ITopologyManagerAware; + +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.util.Filter; +import org.osgi.framework.BundleContext; +import static org.junit.Assert.*; +import org.ops4j.pax.exam.junit.Configuration; +import static org.ops4j.pax.exam.CoreOptions.*; + +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.util.PathUtils; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerClass; + +@RunWith(PaxExam.class) +public class HostTrackerIntegrationTest { + private Logger log = LoggerFactory + .getLogger(HostTrackerIntegrationTest.class); + // get the OSGI bundle context + @Inject + private BundleContext bc; + + private IfIptoHost hosttracker = null; + private ISwitchManagerAware switchManagerAware = null; + private IInventoryListener invtoryListener = null; + private IfHostListener hostListener = null; + private ITopologyManagerAware topologyManagerAware = null; + + // Configure the OSGi container + @Configuration + public Option[] config() { + return options( + // + systemProperty("logback.configurationFile").value( + "file:" + PathUtils.getBaseDir() + + "/src/test/resources/logback.xml"), + // To start OSGi console for inspection remotely + systemProperty("osgi.console").value("2401"), + // Set the systemPackages (used by clustering) + systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"), + // List framework bundles + mavenBundle("equinoxSDK381", "org.eclipse.equinox.console", + "1.0.0.v20120522-1841"), + mavenBundle("equinoxSDK381", "org.eclipse.equinox.util", + "1.0.400.v20120522-2049"), + mavenBundle("equinoxSDK381", "org.eclipse.osgi.services", + "3.3.100.v20120522-1822"), + mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds", + "1.4.0.v20120522-1841"), + mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command", + "0.8.0.v201108120515"), + mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime", + "0.8.0.v201108120515"), + mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell", + "0.8.0.v201110170705"), + // List logger bundles + mavenBundle("org.slf4j", "slf4j-api", "1.7.2"), + mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.2"), + mavenBundle("ch.qos.logback", "logback-core", "1.0.9"), + mavenBundle("ch.qos.logback", "logback-classic", "1.0.9"), + + // List all the bundles on which the test case depends + mavenBundle("org.opendaylight.controller", "sal", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "sal.implementation", + "0.4.0-SNAPSHOT"), + + // needed by statisticsmanager + mavenBundle("org.opendaylight.controller", "containermanager", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "containermanager.implementation", + "0.4.0-SNAPSHOT"), + + mavenBundle("org.opendaylight.controller", + "clustering.services", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "clustering.services-implementation", "0.4.0-SNAPSHOT"), + + // needed by forwardingrulesmanager + mavenBundle("org.opendaylight.controller", "switchmanager", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "switchmanager.implementation", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "configuration", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "configuration.implementation", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "hosttracker", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "hosttracker.implementation", + "0.4.0-SNAPSHOT"), + + // needed by hosttracker + mavenBundle("org.opendaylight.controller", "topologymanager", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "arphandler", + "0.4.0-SNAPSHOT"), + + + mavenBundle("org.jboss.spec.javax.transaction", + "jboss-transaction-api_1.1_spec", "1.0.1.Final"), + mavenBundle("org.apache.commons", "commons-lang3", "3.1"), + mavenBundle("org.apache.felix", + "org.apache.felix.dependencymanager", "3.1.0"), + junitBundles()); + } + + private String stateToString(int state) { + switch (state) { + case Bundle.ACTIVE: + return "ACTIVE"; + case Bundle.INSTALLED: + return "INSTALLED"; + case Bundle.RESOLVED: + return "RESOLVED"; + case Bundle.UNINSTALLED: + return "UNINSTALLED"; + default: + return "Not CONVERTED"; + } + } + + @Before + public void areWeReady() { + assertNotNull(bc); + boolean debugit = false; + Bundle b[] = bc.getBundles(); + for (int i = 0; i < b.length; i++) { + int state = b[i].getState(); + if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) { + log.debug("Bundle:" + b[i].getSymbolicName() + " state:" + + stateToString(state)); + debugit = true; + } + } + if (debugit) { + log.debug("Do some debugging because some bundle is " + + "unresolved"); + } + + // Assert if true, if false we are good to go! + assertFalse(debugit); + + // Now lets create a hosttracker for testing purpose + ServiceReference s = bc + .getServiceReference(IfIptoHost.class.getName()); + if (s != null) { + this.hosttracker = (IfIptoHost)bc.getService(s); + this.switchManagerAware = (ISwitchManagerAware) this.hosttracker; + this.invtoryListener = (IInventoryListener) this.hosttracker; + this.hostListener = (IfHostListener) this.hosttracker; + this.topologyManagerAware = (ITopologyManagerAware) this.hosttracker; + } + + // If StatisticsManager is null, cannot run tests. + assertNotNull(this.hosttracker); + } + + + @Test + public void testStaticHost() throws UnknownHostException { + String ip; + + assertNotNull(this.hosttracker); + + // create one node and two node connectors + Node node1 = NodeCreator.createOFNode(1L); + NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector((short) 1, node1); + NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector((short) 2, node1); + + // test addStaticHost(), store into inactive host DB + Status st = this.hosttracker.addStaticHost("192.168.0.8", "11:22:33:44:55:66", + nc1_1, "0"); + Assert.assertTrue(st.isSuccess()); + st = this.hosttracker.addStaticHost("192.168.0.13", "11:22:33:44:55:77", + nc1_2, "0"); + Assert.assertTrue(st.isSuccess()); + + // check inactive DB + Iterator hnci = this.hosttracker.getInactiveStaticHosts().iterator(); + while (hnci.hasNext()) { + ip = hnci.next().getNetworkAddressAsString(); + Assert.assertTrue(ip.equals("192.168.0.8") || ip.equals("192.168.0.13")); + } + + // check active host DB + hnci = this.hosttracker.getActiveStaticHosts().iterator(); + Assert.assertFalse(hnci.hasNext()); + + // test removeStaticHost() + st = this.hosttracker.removeStaticHost("192.168.0.8"); + Assert.assertTrue(st.isSuccess()); + + hnci = this.hosttracker.getInactiveStaticHosts().iterator(); + while (hnci.hasNext()) { + ip = hnci.next().getNetworkAddressAsString(); + Assert.assertTrue(ip.equals("192.168.0.13")); + } + } + + + + @Test + public void testNotifyNodeConnector() throws UnknownHostException { + String ip; + + assertNotNull(this.invtoryListener); + + // create one node and two node connectors + Node node1 = NodeCreator.createOFNode(1L); + NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector((short) 1, node1); + NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector((short) 2, node1); + + // test addStaticHost(), put into inactive host DB if not verifiable + Status st = this.hosttracker.addStaticHost("192.168.0.8", "11:22:33:44:55:66", + nc1_1, "0"); + st = this.hosttracker.addStaticHost("192.168.0.13", "11:22:33:44:55:77", + nc1_2, "0"); + + this.invtoryListener.notifyNodeConnector(nc1_1, + UpdateType.ADDED, null); + + // check all host list + Iterator hnci = this.hosttracker + .getAllHosts().iterator(); + while (hnci.hasNext()) { + ip = hnci.next().getNetworkAddressAsString(); + Assert.assertTrue(ip.equals("192.168.0.8")); + } + + // check active host DB + hnci = this.hosttracker.getActiveStaticHosts().iterator(); + while (hnci.hasNext()) { + ip = hnci.next().getNetworkAddressAsString(); + Assert.assertTrue(ip.equals("192.168.0.8")); + } + + // check inactive host DB + hnci = this.hosttracker.getInactiveStaticHosts().iterator(); + while (hnci.hasNext()) { + ip = hnci.next().getNetworkAddressAsString(); + Assert.assertTrue(ip.equals("192.168.0.13")); + } + } + + + + @Test + public void testHostFind() throws UnknownHostException { + + assertNotNull(this.invtoryListener); + + // create one node and two node connectors + Node node1 = NodeCreator.createOFNode(1L); + NodeConnector nc1_1 = NodeConnectorCreator.createOFNodeConnector((short) 1, node1); + NodeConnector nc1_2 = NodeConnectorCreator.createOFNodeConnector((short) 2, node1); + + // test addStaticHost(), put into inactive host DB if not verifiable + Status st = this.hosttracker.addStaticHost( + "192.168.0.8", "11:22:33:44:55:66", nc1_1, "0"); + st = this.hosttracker.addStaticHost( + "192.168.0.13", "11:22:33:44:55:77", nc1_2, "0"); + + HostNodeConnector hnc_1 = this.hosttracker + .hostFind(InetAddress.getByName("192.168.0.8")); + assertNull(hnc_1); + + this.invtoryListener.notifyNodeConnector(nc1_1, + UpdateType.ADDED, null); + + hnc_1 = this.hosttracker.hostFind(InetAddress.getByName("192.168.0.8")); + assertNotNull(hnc_1); + + } + +} diff --git a/opendaylight/hosttracker/integrationtest/src/test/resources/logback.xml b/opendaylight/hosttracker/integrationtest/src/test/resources/logback.xml new file mode 100644 index 0000000000..5fa21fecfc --- /dev/null +++ b/opendaylight/hosttracker/integrationtest/src/test/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + diff --git a/opendaylight/switchmanager/api/pom.xml b/opendaylight/switchmanager/api/pom.xml new file mode 100644 index 0000000000..d57a2d4a01 --- /dev/null +++ b/opendaylight/switchmanager/api/pom.xml @@ -0,0 +1,104 @@ + + + 4.0.0 + + org.opendaylight.controller + commons.opendaylight + 1.4.0-SNAPSHOT + ../../commons/opendaylight + + + org.opendaylight.controller + switchmanager + 0.4.0-SNAPSHOT + bundle + + + + jacoco + reuseReports + target/jacobo.exec + target/jacoco-it.exec + java + + + + + + org.jacoco + jacoco-maven-plugin + 0.5.3.201107060350 + + + + + + org.apache.felix + maven-bundle-plugin + 2.3.6 + true + + + + org.opendaylight.controller.switchmanager + + + org.opendaylight.controller.clustering.services, + org.opendaylight.controller.configuration, + org.opendaylight.controller.sal.core, + org.opendaylight.controller.sal.utils, + org.opendaylight.controller.sal.packet, + org.opendaylight.controller.sal.inventory, + org.slf4j, + org.apache.felix.dm, + org.eclipse.osgi.framework.console, + org.osgi.framework, + javax.xml.bind.annotation, + org.apache.commons.lang3.builder + + + + + + org.jacoco + jacoco-maven-plugin + + org.opendaylight.controller.* + + + + pre-test + + prepare-agent + + + + post-test + test + + report + + + + + + + + + org.opendaylight.controller + clustering.services + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + configuration + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + sal + 0.4.0-SNAPSHOT + + + diff --git a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/IInventoryListener.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/IInventoryListener.java similarity index 100% rename from opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/IInventoryListener.java rename to opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/IInventoryListener.java diff --git a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/ISpanAware.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/ISpanAware.java similarity index 100% rename from opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/ISpanAware.java rename to opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/ISpanAware.java diff --git a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/ISwitchManager.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/ISwitchManager.java old mode 100755 new mode 100644 similarity index 100% rename from opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/ISwitchManager.java rename to opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/ISwitchManager.java diff --git a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/ISwitchManagerAware.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/ISwitchManagerAware.java similarity index 100% rename from opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/ISwitchManagerAware.java rename to opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/ISwitchManagerAware.java diff --git a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java similarity index 100% rename from opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java rename to opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SpanConfig.java diff --git a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java similarity index 100% rename from opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java rename to opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Subnet.java diff --git a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java similarity index 100% rename from opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java rename to opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SubnetConfig.java diff --git a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/Switch.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Switch.java old mode 100755 new mode 100644 similarity index 100% rename from opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/Switch.java rename to opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/Switch.java diff --git a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java b/opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java similarity index 100% rename from opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java rename to opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/SwitchConfig.java diff --git a/opendaylight/switchmanager/src/test/java/org/opendaylight/controller/switchmanager/SubnetTest.java b/opendaylight/switchmanager/api/src/test/java/org/openddaylight/controller/switchmanager/SubnetTest.java similarity index 100% rename from opendaylight/switchmanager/src/test/java/org/opendaylight/controller/switchmanager/SubnetTest.java rename to opendaylight/switchmanager/api/src/test/java/org/openddaylight/controller/switchmanager/SubnetTest.java diff --git a/opendaylight/switchmanager/src/test/java/org/opendaylight/controller/switchmanager/SwitchTest.java b/opendaylight/switchmanager/api/src/test/java/org/openddaylight/controller/switchmanager/SwitchTest.java similarity index 100% rename from opendaylight/switchmanager/src/test/java/org/opendaylight/controller/switchmanager/SwitchTest.java rename to opendaylight/switchmanager/api/src/test/java/org/openddaylight/controller/switchmanager/SwitchTest.java diff --git a/opendaylight/switchmanager/implementation/pom.xml b/opendaylight/switchmanager/implementation/pom.xml new file mode 100644 index 0000000000..5e9eb5f994 --- /dev/null +++ b/opendaylight/switchmanager/implementation/pom.xml @@ -0,0 +1,112 @@ + + + 4.0.0 + + org.opendaylight.controller + commons.opendaylight + 1.4.0-SNAPSHOT + ../../commons/opendaylight + + + org.opendaylight.controller + switchmanager.implementation + 0.4.0-SNAPSHOT + bundle + + + + jacoco + reuseReports + target/jacobo.exec + target/jacoco-it.exec + java + + + + + + org.jacoco + jacoco-maven-plugin + 0.5.3.201107060350 + + + + + + org.apache.felix + maven-bundle-plugin + 2.3.6 + true + + + + + + org.opendaylight.controller.switchmanager, + org.opendaylight.controller.clustering.services, + org.opendaylight.controller.configuration, + org.opendaylight.controller.sal.core, + org.opendaylight.controller.sal.utils, + org.opendaylight.controller.sal.packet, + org.opendaylight.controller.sal.inventory, + org.slf4j, + org.apache.felix.dm, + org.eclipse.osgi.framework.console, + org.osgi.framework, + javax.xml.bind.annotation, + org.apache.commons.lang3.builder + + + org.opendaylight.controller.switchmanager.internal.Activator + + + + + + org.jacoco + jacoco-maven-plugin + + org.opendaylight.controller.* + + + + pre-test + + prepare-agent + + + + post-test + test + + report + + + + + + + + + org.opendaylight.controller + clustering.services + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + configuration + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + sal + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + switchmanager + 0.4.0-SNAPSHOT + + + diff --git a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/internal/Activator.java b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/Activator.java similarity index 100% rename from opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/internal/Activator.java rename to opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/Activator.java diff --git a/opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java b/opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java old mode 100755 new mode 100644 similarity index 100% rename from opendaylight/switchmanager/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java rename to opendaylight/switchmanager/implementation/src/main/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImpl.java diff --git a/opendaylight/switchmanager/src/test/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImplTest.java b/opendaylight/switchmanager/implementation/src/test/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImplTest.java similarity index 100% rename from opendaylight/switchmanager/src/test/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImplTest.java rename to opendaylight/switchmanager/implementation/src/test/java/org/opendaylight/controller/switchmanager/internal/SwitchManagerImplTest.java diff --git a/opendaylight/switchmanager/implementation/src/test/resources/logback.xml b/opendaylight/switchmanager/implementation/src/test/resources/logback.xml new file mode 100644 index 0000000000..5fa21fecfc --- /dev/null +++ b/opendaylight/switchmanager/implementation/src/test/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + diff --git a/opendaylight/switchmanager/pom.xml b/opendaylight/switchmanager/pom.xml deleted file mode 100755 index 1d6f2e1381..0000000000 --- a/opendaylight/switchmanager/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - 4.0.0 - - org.opendaylight.controller - commons.opendaylight - 1.4.0-SNAPSHOT - ../commons/opendaylight - - - org.opendaylight.controller - switchmanager - 0.4.0-SNAPSHOT - bundle - - - - - org.apache.felix - maven-bundle-plugin - 2.3.6 - true - - - - org.opendaylight.controller.switchmanager - - - org.opendaylight.controller.clustering.services, - org.opendaylight.controller.configuration, - org.opendaylight.controller.sal.core, - org.opendaylight.controller.sal.utils, - org.opendaylight.controller.sal.packet, - org.opendaylight.controller.sal.inventory, - org.slf4j, - org.apache.felix.dm, - org.eclipse.osgi.framework.console, - org.osgi.framework, - javax.xml.bind.annotation, - org.apache.commons.lang3.builder - - - org.opendaylight.controller.switchmanager.internal.Activator - - - - - - - - - org.opendaylight.controller - clustering.services - 0.4.0-SNAPSHOT - - - org.opendaylight.controller - configuration - 0.4.0-SNAPSHOT - - - org.opendaylight.controller - sal - 0.4.0-SNAPSHOT - - -