From: Moiz Raja Date: Mon, 7 Oct 2013 23:22:34 +0000 (-0700) Subject: Sanity test to verify that the bundles that are included as plugins in the controller... X-Git-Tag: jenkins-controller-bulk-release-prepare-only-2-1~647 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=8d915206151c33f682ff630b4036ba14158ce84d;hp=75b3d0205b31e0ad18f2519aa10f5baa4f10daff Sanity test to verify that the bundles that are included as plugins in the controller load properly Change-Id: Id472ab9f17f7a604e473177096b8a5045af913d3 Signed-off-by: Moiz Raja --- diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index f718621b26..74d2b74f11 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -457,7 +457,6 @@ - org.opendaylight.controller protocol_plugins.openflow @@ -481,15 +480,6 @@ ${controller.version} - - @@ -982,9 +972,15 @@ yang-model-api + + org.opendaylight.controller + sanitytest + ${controller.version} + + @@ -1024,7 +1020,32 @@ - diff --git a/opendaylight/distribution/opendaylight/run.bat b/opendaylight/distribution/opendaylight/run.bat new file mode 100644 index 0000000000..8981709bb1 --- /dev/null +++ b/opendaylight/distribution/opendaylight/run.bat @@ -0,0 +1 @@ +REM This is where the sanity test execution for windows needs to go (see run.sh) diff --git a/opendaylight/distribution/opendaylight/run.sh b/opendaylight/distribution/opendaylight/run.sh new file mode 100755 index 0000000000..4ee9555b97 --- /dev/null +++ b/opendaylight/distribution/opendaylight/run.sh @@ -0,0 +1,24 @@ +# Inject the sanitytest jar as a controller plugin +cp ./target/dependency/sanitytest*.jar ./target/distribution.opendaylight-osgipackage/opendaylight/plugins + +# Store the current working directory in a variable so that we can get back to it later +cwd=`pwd` + +# Switch to the distribution folder +cd ./target/distribution.opendaylight-osgipackage/opendaylight/ + +# Run the controller +./run.sh + +# Store the exit value of the controller in a variable +success=`echo $?` + +# Switch back to the directory from which this script was invoked +cd $cwd + +# Remove the sanitytest jar from the plugins directory +rm ./target/distribution.opendaylight-osgipackage/opendaylight/plugins/sanitytest*.jar + +# Exit using the exit code that we had captured earlier after running the controller +exit $success + diff --git a/opendaylight/distribution/sanitytest/src/main/java/org/opendaylight/controller/distribution/Sanity.java b/opendaylight/distribution/sanitytest/src/main/java/org/opendaylight/controller/distribution/Sanity.java new file mode 100644 index 0000000000..378ea8a52d --- /dev/null +++ b/opendaylight/distribution/sanitytest/src/main/java/org/opendaylight/controller/distribution/Sanity.java @@ -0,0 +1,47 @@ +package org.opendaylight.controller.distribution; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +public class Sanity { + + static void copy(InputStream in, OutputStream out) throws IOException { + while (true) { + int c = in.read(); + if (c == -1) break; + out.write((char)c); + } + } + + public static void main(String[] args) throws IOException, InterruptedException { + String cwd = System.getProperty("user.dir"); + + System.out.println("Current working directory = " + cwd); + + // We assume that the program is being run from the sanitytest directory + // We need to specify the opendaylight directory as the working directory for the shell/batch scripts + File processWorkingDir = new File(cwd, "../opendaylight"); + + String os = System.getProperty("os.name").toLowerCase(); + String script = "./run.sh"; + + if(os.contains("windows")){ + script = "run.bat"; + } + + ProcessBuilder processBuilder = new ProcessBuilder(); + processBuilder.directory(processWorkingDir.getCanonicalFile()); + processBuilder.command(script); + Process p = processBuilder.start(); + + copy(p.getInputStream(), System.out); + + p.waitFor(); + + System.out.println("Test exited with exitValue = " + p.exitValue()); + + System.exit(p.exitValue()); + } +} diff --git a/opendaylight/distribution/sanitytest/src/main/java/org/opendaylight/controller/sanitytest/internal/Activator.java b/opendaylight/distribution/sanitytest/src/main/java/org/opendaylight/controller/sanitytest/internal/Activator.java index 262884fa35..65bc380031 100644 --- a/opendaylight/distribution/sanitytest/src/main/java/org/opendaylight/controller/sanitytest/internal/Activator.java +++ b/opendaylight/distribution/sanitytest/src/main/java/org/opendaylight/controller/sanitytest/internal/Activator.java @@ -27,14 +27,13 @@ public class Activator implements BundleActivator { public void start(final BundleContext bundleContext) throws Exception { Timer monitorTimer = new Timer("monitor timer", true); - monitorTimer.schedule(new TimerTask() { @Override public void run() { boolean failed = false; for(Bundle bundle : bundleContext.getBundles()){ if(bundle.getState() != Bundle.ACTIVE && bundle.getState() != Bundle.RESOLVED) { - System.out.println("Failed to activate/resolve bundle = " + bundle.getSymbolicName() + " state = " + stateToString(bundle.getState())); + System.out.println("------ Failed to activate/resolve bundle = " + bundle.getSymbolicName() + " state = " + stateToString(bundle.getState())); failed = true; } } diff --git a/pom.xml b/pom.xml index d1b65d5902..4d0d2ee52b 100644 --- a/pom.xml +++ b/pom.xml @@ -123,9 +123,8 @@ opendaylight/samples/loadbalancer opendaylight/samples/northbound/loadbalancer - + opendaylight/commons/concepts opendaylight/commons/httpclient