From: Kalvin Hom Date: Wed, 1 May 2013 20:24:40 +0000 (-0700) Subject: pom changes for FRM integration X-Git-Tag: releasepom-0.1.0~504^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=1c782da84939df7d201f88cd19f0017682c4ed39 pom changes for FRM integration tests; added integrationtest bundle with a small simple test Change-Id: I1c0591286cb8cea4dcb1ff72f02d2d3a25ba922d Signed-off-by: Kalvin Hom --- diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index cf481b7f4b..c26b38843b 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -42,6 +42,7 @@ ../../arphandler ../../forwardingrulesmanager/api ../../forwardingrulesmanager/implementation + ../../forwardingrulesmanager/integrationtest ../../hosttracker/api ../../hosttracker/implementation ../../hosttracker/integrationtest diff --git a/opendaylight/forwardingrulesmanager/implementation/pom.xml b/opendaylight/forwardingrulesmanager/implementation/pom.xml index 2c0bc9319c..0031773029 100644 --- a/opendaylight/forwardingrulesmanager/implementation/pom.xml +++ b/opendaylight/forwardingrulesmanager/implementation/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 org.opendaylight.controller @@ -14,22 +15,39 @@ 0.4.0-SNAPSHOT bundle + + + jacoco + reuseReports + target/jacoco.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.clustering.services, - org.opendaylight.controller.configuration, + org.apache.felix + maven-bundle-plugin + 2.3.6 + true + + + + + + + + org.opendaylight.controller.clustering.services, + org.opendaylight.controller.configuration, org.opendaylight.controller.hosttracker, org.opendaylight.controller.hosttracker.hostAware, org.opendaylight.controller.switchmanager, @@ -37,9 +55,9 @@ org.opendaylight.controller.sal.core, org.opendaylight.controller.sal.flowprogrammer, org.opendaylight.controller.sal.match, - org.opendaylight.controller.sal.utils, + org.opendaylight.controller.sal.utils, org.opendaylight.controller.sal.packet, - org.opendaylight.controller.forwardingrulesmanager, + org.opendaylight.controller.forwardingrulesmanager, javax.xml.bind.annotation, javax.xml.bind, org.apache.felix.dm, @@ -47,11 +65,11 @@ org.osgi.service.component, org.slf4j, org.eclipse.osgi.framework.console, - org.osgi.framework - - - org.opendaylight.controller.forwardingrulesmanager.internal.Activator - + org.osgi.framework + + + org.opendaylight.controller.forwardingrulesmanager.internal.Activator + org.opendaylight.controller.hosttracker @@ -60,6 +78,28 @@ + + org.jacoco + jacoco-maven-plugin + + org.opendaylight.controller.* + + + + pre-test + + prepare-agent + + + + post-test + test + + report + + + + @@ -72,7 +112,7 @@ org.opendaylight.controller configuration 0.4.0-SNAPSHOT - + org.opendaylight.controller clustering.services @@ -83,16 +123,16 @@ switchmanager 0.4.0-SNAPSHOT - - org.opendaylight.controller - sal - 0.4.0-SNAPSHOT - - - org.opendaylight.controller - forwardingrulesmanager - 0.4.0-SNAPSHOT - + + org.opendaylight.controller + sal + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + forwardingrulesmanager + 0.4.0-SNAPSHOT + junit junit diff --git a/opendaylight/forwardingrulesmanager/integrationtest/pom.xml b/opendaylight/forwardingrulesmanager/integrationtest/pom.xml new file mode 100644 index 0000000000..7967d6f969 --- /dev/null +++ b/opendaylight/forwardingrulesmanager/integrationtest/pom.xml @@ -0,0 +1,148 @@ + + + 4.0.0 + + org.opendaylight.controller + commons.opendaylight + 1.4.0-SNAPSHOT + ../../commons/opendaylight + + + org.opendaylight.controller + forwardingrulesmanager.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 + configuration + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + configuration.implementation + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + clustering.services + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + clustering.stub + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + switchmanager + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + switchmanager.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 + forwardingrulesmanager + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + forwardingrulesmanager.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 + protocol_plugins.stub + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + topologymanager + 0.4.0-SNAPSHOT + + + junit + junit + 4.8.1 + test + + + + + 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 + + + + + + + \ No newline at end of file diff --git a/opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/FRMIntegrationTest.java b/opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/FRMIntegrationTest.java new file mode 100644 index 0000000000..73c6d79d6a --- /dev/null +++ b/opendaylight/forwardingrulesmanager/integrationtest/src/test/java/org/opendaylight/controller/forwardingrulesmanager/internal/FRMIntegrationTest.java @@ -0,0 +1,204 @@ +package org.opendaylight.controller.forwardingrulesmanager.internal; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.Bundle; +import javax.inject.Inject; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.opendaylight.controller.forwardingrulesmanager.FlowEntry; +import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager; +import org.opendaylight.controller.sal.action.Action; +import org.opendaylight.controller.sal.action.Drop; +import org.opendaylight.controller.sal.core.Node; +import org.opendaylight.controller.sal.core.NodeConnector; +import org.opendaylight.controller.sal.flowprogrammer.Flow; +import org.opendaylight.controller.sal.match.Match; +import org.opendaylight.controller.sal.match.MatchType; +import org.opendaylight.controller.sal.reader.FlowOnNode; +import org.opendaylight.controller.sal.reader.NodeConnectorStatistics; +import org.opendaylight.controller.sal.reader.NodeDescription; +import org.opendaylight.controller.sal.utils.NodeCreator; +import org.opendaylight.controller.sal.utils.Status; +import org.opendaylight.controller.sal.utils.StatusCode; +import org.ops4j.pax.exam.junit.PaxExam; +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; + +@RunWith(PaxExam.class) +public class FRMIntegrationTest { + private Logger log = LoggerFactory.getLogger(FRMIntegrationTest.class); + // get the OSGI bundle context + @Inject + private BundleContext bc; + + private IForwardingRulesManager manager = 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"), + + mavenBundle("org.opendaylight.controller", + "protocol_plugins.stub", "0.4.0-SNAPSHOT"), + + mavenBundle("org.opendaylight.controller", "containermanager", + "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", + "containermanager.implementation", "0.4.0-SNAPSHOT"), + + mavenBundle("org.opendaylight.controller", + "forwardingrulesmanager", "0.4.0-SNAPSHOT"), + + mavenBundle("org.opendaylight.controller", + "forwardingrulesmanager.implementation", + "0.4.0-SNAPSHOT"), + + mavenBundle("org.opendaylight.controller", + "clustering.services", "0.4.0-SNAPSHOT"), + mavenBundle("org.opendaylight.controller", "clustering.stub", + "0.4.0-SNAPSHOT"), + 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.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); + + ServiceReference r = bc + .getServiceReference(IForwardingRulesManager.class.getName()); + if (r != null) { + this.manager = (IForwardingRulesManager) bc.getService(r); + } + // If StatisticsManager is null, cannot run tests. + assertNotNull(this.manager); + + } + + @Test + public void testFlowEntries() { + Flow flow = new Flow(); + + Match match = new Match(); + try { + match.setField(MatchType.NW_DST, InetAddress.getByName("1.1.1.1")); + } catch (UnknownHostException e) { + } + flow.setMatch(match); + Action action = new Drop(); + + List actions = new ArrayList(); + actions.add(action); + flow.setActions(actions); + + Node node = NodeCreator.createOFNode(1L); + FlowEntry fe = new FlowEntry("g1", "f1", flow, node); + + Status stat = manager.installFlowEntry(null); + Assert.assertTrue(stat.getCode().equals(StatusCode.NOTACCEPTABLE)); + } + +} \ No newline at end of file diff --git a/opendaylight/forwardingrulesmanager/integrationtest/src/test/resources/logback.xml b/opendaylight/forwardingrulesmanager/integrationtest/src/test/resources/logback.xml new file mode 100644 index 0000000000..2d63ce5744 --- /dev/null +++ b/opendaylight/forwardingrulesmanager/integrationtest/src/test/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + +