You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whirr.apache.org by as...@apache.org on 2012/03/01 18:58:30 UTC
svn commit: r1295715 - in /whirr/trunk: ./ platforms/karaf/commands/
platforms/karaf/commands/src/main/java/org/apache/whirr/karaf/command/support/
platforms/karaf/feature/ platforms/karaf/itests/
platforms/karaf/itests/src/test/java/org/apache/whirr/k...
Author: asavu
Date: Thu Mar 1 17:58:29 2012
New Revision: 1295715
URL: http://svn.apache.org/viewvc?rev=1295715&view=rev
Log:
WHIRR-509. Provide live OSGi integration tests (Ioannis Canellos, Andrei Savu)
Added:
whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/integration/
whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/integration/WhirrKarafZookeeperServiceTest.java
whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/integration/WhirrLiveTestSupport.java
whirr/trunk/platforms/karaf/itests/src/test/resources/whirr-zookeeper-test.properties
Removed:
whirr/trunk/platforms/karaf/itests/src/test/resources/whirr-karaf-itests.properties
Modified:
whirr/trunk/CHANGES.txt
whirr/trunk/platforms/karaf/commands/pom.xml
whirr/trunk/platforms/karaf/commands/src/main/java/org/apache/whirr/karaf/command/support/ConfigurationReader.java
whirr/trunk/platforms/karaf/commands/src/main/java/org/apache/whirr/karaf/command/support/WhirrCommandSupport.java
whirr/trunk/platforms/karaf/feature/pom.xml
whirr/trunk/platforms/karaf/itests/pom.xml
whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrInstallationTest.java
whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrKarafTestSupport.java
whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrServicesTest.java
whirr/trunk/pom.xml
Modified: whirr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/whirr/trunk/CHANGES.txt?rev=1295715&r1=1295714&r2=1295715&view=diff
==============================================================================
--- whirr/trunk/CHANGES.txt (original)
+++ whirr/trunk/CHANGES.txt Thu Mar 1 17:58:29 2012
@@ -55,6 +55,8 @@ Trunk (unreleased changes)
WHIRR-35. Include .pac file for browsing to Hadoop clusters
started on EC2 (asavu)
+ WHIRR-509. Provide live OSGi integration tests (Ioannis Canellos, Andrei Savu)
+
BUG FIXES
WHIRR-473. HadoopServiceController.getInstance(String config) does
Modified: whirr/trunk/platforms/karaf/commands/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/commands/pom.xml?rev=1295715&r1=1295714&r2=1295715&view=diff
==============================================================================
--- whirr/trunk/platforms/karaf/commands/pom.xml (original)
+++ whirr/trunk/platforms/karaf/commands/pom.xml Thu Mar 1 17:58:29 2012
@@ -39,7 +39,8 @@
*
</osgi.import>
<osgi.dynamic.import>javax.*,org.jclouds.*</osgi.dynamic.import>
- <osgi.export>org.apache.whirr.karaf.command*;version="${project.version}"</osgi.export>
+ <osgi.export>org.apache.whirr.karaf.command*;version="${project.version}"
+ </osgi.export>
</properties>
<dependencies>
<dependency>
Modified: whirr/trunk/platforms/karaf/commands/src/main/java/org/apache/whirr/karaf/command/support/ConfigurationReader.java
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/commands/src/main/java/org/apache/whirr/karaf/command/support/ConfigurationReader.java?rev=1295715&r1=1295714&r2=1295715&view=diff
==============================================================================
--- whirr/trunk/platforms/karaf/commands/src/main/java/org/apache/whirr/karaf/command/support/ConfigurationReader.java (original)
+++ whirr/trunk/platforms/karaf/commands/src/main/java/org/apache/whirr/karaf/command/support/ConfigurationReader.java Thu Mar 1 17:58:29 2012
@@ -41,13 +41,13 @@ public class ConfigurationReader {
//Utility Class
}
-
- /**
+ /**
* Builds Configuration from a File.
*
* @param fileName
* @return
* @throws org.apache.commons.configuration.ConfigurationException
+ *
*/
public static PropertiesConfiguration fromFile(String fileName) {
PropertiesConfiguration config = null;
Modified: whirr/trunk/platforms/karaf/commands/src/main/java/org/apache/whirr/karaf/command/support/WhirrCommandSupport.java
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/commands/src/main/java/org/apache/whirr/karaf/command/support/WhirrCommandSupport.java?rev=1295715&r1=1295714&r2=1295715&view=diff
==============================================================================
--- whirr/trunk/platforms/karaf/commands/src/main/java/org/apache/whirr/karaf/command/support/WhirrCommandSupport.java (original)
+++ whirr/trunk/platforms/karaf/commands/src/main/java/org/apache/whirr/karaf/command/support/WhirrCommandSupport.java Thu Mar 1 17:58:29 2012
@@ -108,4 +108,5 @@ public abstract class WhirrCommandSuppor
public void setComputeServices(List<ComputeService> computeServices) {
this.computeServices = computeServices;
}
+
}
Modified: whirr/trunk/platforms/karaf/feature/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/feature/pom.xml?rev=1295715&r1=1295714&r2=1295715&view=diff
==============================================================================
--- whirr/trunk/platforms/karaf/feature/pom.xml (original)
+++ whirr/trunk/platforms/karaf/feature/pom.xml Thu Mar 1 17:58:29 2012
@@ -50,7 +50,8 @@
<jclouds.karaf.version>1.3.1</jclouds.karaf.version>
<jopt.simple.bundle.version>4.3_1</jopt.simple.bundle.version>
<jsch.bundle.version>0.1.44_2</jsch.bundle.version>
- <not-yet-commons-ssl.bundle.version>0.3.11_1</not-yet-commons-ssl.bundle.version>
+ <not-yet-commons-ssl.bundle.version>0.3.11_1
+ </not-yet-commons-ssl.bundle.version>
<servlet.spec.version>1.2</servlet.spec.version>
</properties>
<build>
@@ -121,7 +122,8 @@
</goals>
<configuration>
<descriptors>
- <descriptor>file:${basedir}/target/classes/features.xml</descriptor>
+ <descriptor>file:${basedir}/target/classes/features.xml
+ </descriptor>
</descriptors>
<features>
<feature>whirr</feature>
Modified: whirr/trunk/platforms/karaf/itests/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/itests/pom.xml?rev=1295715&r1=1295714&r2=1295715&view=diff
==============================================================================
--- whirr/trunk/platforms/karaf/itests/pom.xml (original)
+++ whirr/trunk/platforms/karaf/itests/pom.xml Thu Mar 1 17:58:29 2012
@@ -69,55 +69,51 @@
<version>10.0.1</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.ops4j.pax.url</groupId>
<artifactId>pax-url-mvn</artifactId>
+ <scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.ops4j.pax.url</groupId>
<artifactId>pax-url-aether</artifactId>
+ <scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.karaf</groupId>
<artifactId>apache-karaf</artifactId>
<version>${karaf.version}</version>
<type>tar.gz</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.whirr.karaf</groupId>
+ <artifactId>apache-whirr</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ <scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.openengsb.labs.paxexam.karaf</groupId>
<artifactId>paxexam-karaf-container</artifactId>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- <version>3.0.9</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit4</artifactId>
- <version>2.3.0.M1</version>
- </dependency>
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ <version>${commons.configuration.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
-</project>
+</project>
\ No newline at end of file
Modified: whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrInstallationTest.java
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrInstallationTest.java?rev=1295715&r1=1295714&r2=1295715&view=diff
==============================================================================
--- whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrInstallationTest.java (original)
+++ whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrInstallationTest.java Thu Mar 1 17:58:29 2012
@@ -22,6 +22,7 @@ import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openengsb.labs.paxexam.karaf.options.LogLevelOption;
+import org.ops4j.pax.exam.MavenUtils;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -29,9 +30,9 @@ import org.ops4j.pax.exam.junit.JUnit4Te
import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
import org.osgi.framework.Bundle;
-
import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.logLevel;
+import static org.ops4j.pax.exam.CoreOptions.scanFeatures;
@RunWith(JUnit4TestRunner.class)
@ExamReactorStrategy(AllConfinedStagedReactorFactory.class)
@@ -39,18 +40,18 @@ public class WhirrInstallationTest exten
@Test
public void testInstallation() throws InterruptedException {
- //Install Whirr and check if it has been properly installed.
- installWhirr();
System.err.println(executeCommand("osgi:list"));
-
Bundle commandsBundle = getInstalledBundle("org.apache.whirr.karaf.commands");
- Assert.assertEquals("Expected bundle to be started",Bundle.ACTIVE,commandsBundle.getState());
+ Assert.assertEquals("Expected bundle to be started", Bundle.ACTIVE, commandsBundle.getState());
}
@Configuration
public Option[] config() {
return new Option[]{
- whirrDistributionConfiguration(), keepRuntimeFolder(),logLevel(LogLevelOption.LogLevel.ERROR)};
+ whirrDistributionConfiguration(), keepRuntimeFolder(), logLevel(LogLevelOption.LogLevel.ERROR),
+ scanFeatures(String.format(WHIRR_FEATURE_URL,
+ MavenUtils.getArtifactVersion(WHIRR_KARAF_GROUP_ID, WHIRR_KARAF_ARTIFACT_ID)), "whirr").start()
+ };
}
}
Modified: whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrKarafTestSupport.java
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrKarafTestSupport.java?rev=1295715&r1=1295714&r2=1295715&view=diff
==============================================================================
--- whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrKarafTestSupport.java (original)
+++ whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrKarafTestSupport.java Thu Mar 1 17:58:29 2012
@@ -18,12 +18,9 @@
package org.apache.whirr.karaf.itest;
-import java.io.IOException;
-
-import java.util.Properties;
-
import org.apache.felix.service.command.CommandProcessor;
import org.apache.felix.service.command.CommandSession;
+import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.editConfigurationFileExtend;
import org.ops4j.pax.exam.MavenUtils;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.TestProbeBuilder;
@@ -57,31 +54,22 @@ import static org.ops4j.pax.exam.CoreOpt
public class WhirrKarafTestSupport {
- static final Long COMMAND_TIMEOUT = 300000L;
- static final Long SERVICE_TIMEOUT = 30000L;
- static final Long DEFAULT_WAIT = 20000L;
-
- private static final String UNINSTALLED = "[uninstalled]";
- private static final String INSTALLED = "[installed ]";
+ public static final Long COMMAND_TIMEOUT = 300000L;
+ public static final Long SERVICE_TIMEOUT = 30000L;
- static final String GROUP_ID = "org.apache.karaf";
- static final String ARTIFACT_ID = "apache-karaf";
+ public final String GROUP_ID = "org.apache.karaf";
+ public final String ARTIFACT_ID = "apache-karaf";
- static final String WHIRR_VERSION = getWhirrVersion();
+ public static final String WHIRR_FEATURE_URL = "mvn:org.apache.whirr.karaf/apache-whirr/%s/xml/features";
- static final String WHIRR_FEATURE_URL = String.format("mvn:org.apache.whirr.karaf/apache-whirr/%s/xml/features", WHIRR_VERSION);
-
- static final String DEBUG_OPTS = " --java-opts \"-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%s\"";
+ public final String WHIRR_KARAF_GROUP_ID = "org.apache.whirr.karaf";
+ public final String WHIRR_KARAF_ARTIFACT_ID = "apache-whirr";
ExecutorService executor = Executors.newCachedThreadPool();
@Inject
protected BundleContext bundleContext;
- /**
- * @param probe
- * @return
- */
@ProbeBuilder
public TestProbeBuilder probeConfiguration(TestProbeBuilder probe) {
probe.setHeader(Constants.DYNAMICIMPORT_PACKAGE, "*,org.apache.felix.service.*;status=provisional");
@@ -89,19 +77,6 @@ public class WhirrKarafTestSupport {
return probe;
}
- /**
- * Installs the Whiir feature
- */
- protected void installWhirr() {
- System.err.println(executeCommand("features:addurl " + WHIRR_FEATURE_URL));
- System.err.println(executeCommand("features:listurl"));
- System.err.println(executeCommand("features:list"));
- executeCommand("features:install whirr");
- }
-
- protected void unInstallWhirr() {
- System.err.println(executeCommand("features:uninstall whirr"));
- }
/**
* Create an {@link org.ops4j.pax.exam.Option} for using a .
@@ -110,8 +85,9 @@ public class WhirrKarafTestSupport {
*/
protected Option whirrDistributionConfiguration() {
return karafDistributionConfiguration().frameworkUrl(
- maven().groupId(GROUP_ID).artifactId(ARTIFACT_ID).versionAsInProject().type("tar.gz"))
- .karafVersion(MavenUtils.getArtifactVersion(GROUP_ID, ARTIFACT_ID)).name("Apache Karaf").unpackDirectory(new File("target/paxexam/"));
+ maven().groupId(GROUP_ID).artifactId(ARTIFACT_ID).versionAsInProject().type("tar.gz"))
+ .karafVersion(MavenUtils.getArtifactVersion(GROUP_ID, ARTIFACT_ID))
+ .name("Apache Karaf").unpackDirectory(new File("target/paxexam/"));
}
/**
@@ -141,20 +117,21 @@ public class WhirrKarafTestSupport {
final CommandProcessor commandProcessor = getOsgiService(CommandProcessor.class);
final CommandSession commandSession = commandProcessor.createSession(System.in, printStream, System.err);
FutureTask<String> commandFuture = new FutureTask<String>(
- new Callable<String>() {
- public String call() {
- try {
- if (!silent) {
- System.err.println(command);
+ new Callable<String>() {
+ @Override
+ public String call() {
+ try {
+ if (!silent) {
+ System.err.println(command);
+ }
+ commandSession.execute(command);
+ } catch (Exception e) {
+ e.printStackTrace(System.err);
}
- commandSession.execute(command);
- } catch (Exception e) {
- e.printStackTrace(System.err);
+ printStream.flush();
+ return byteArrayOutputStream.toString();
}
- printStream.flush();
- return byteArrayOutputStream.toString();
- }
- });
+ });
try {
executor.submit(commandFuture);
@@ -181,19 +158,19 @@ public class WhirrKarafTestSupport {
final CommandProcessor commandProcessor = getOsgiService(CommandProcessor.class);
final CommandSession commandSession = commandProcessor.createSession(System.in, printStream, System.err);
FutureTask<String> commandFuture = new FutureTask<String>(
- new Callable<String>() {
- public String call() {
- try {
- for (String command : commands) {
- System.err.println(command);
- commandSession.execute(command);
+ new Callable<String>() {
+ public String call() {
+ try {
+ for (String command : commands) {
+ System.err.println(command);
+ commandSession.execute(command);
+ }
+ } catch (Exception e) {
+ e.printStackTrace(System.err);
}
- } catch (Exception e) {
- e.printStackTrace(System.err);
+ return byteArrayOutputStream.toString();
}
- return byteArrayOutputStream.toString();
- }
- });
+ });
try {
executor.submit(commandFuture);
@@ -234,14 +211,10 @@ public class WhirrKarafTestSupport {
return result.toString();
}
- protected <T> T getOsgiService(Class<T> type, long timeout) {
- return getOsgiService(type, null, timeout);
- }
-
protected <T> T getOsgiService(Class<T> type) {
return getOsgiService(type, null, SERVICE_TIMEOUT);
}
-
+
protected <T> T getOsgiService(Class<T> type, String filter, long timeout) {
return type.cast(getOsgiService(type.getName(), filter, timeout));
}
@@ -262,8 +235,10 @@ public class WhirrKarafTestSupport {
Filter osgiFilter = FrameworkUtil.createFilter(flt);
tracker = new ServiceTracker(bundleContext, osgiFilter, null);
tracker.open(true);
+
// Note that the tracker is not closed to keep the reference
// This is buggy, as the service reference may change i think
+
Object svc = tracker.waitForService(timeout);
if (svc == null) {
Dictionary dic = bundleContext.getBundle().getHeaders();
@@ -301,14 +276,25 @@ public class WhirrKarafTestSupport {
return references != null ? Arrays.asList(references) : Collections.<ServiceReference>emptyList();
}
- private static String getWhirrVersion() {
- Properties props = new Properties();
- try {
- props.load(WhirrKarafTestSupport.class.getResourceAsStream("/whirr-karaf-itests.properties"));
- return props.getProperty("version");
- } catch (IOException e) {
- throw new RuntimeException("Could not load properties containing whirr version number from classpath:/whirr-karaf-itests.properties");
- }
+ /**
+ * Sets a System property.
+ *
+ * @param propertyName
+ * @return
+ */
+ public static Option systemProperty(String propertyName, String propertyValue) {
+ return editConfigurationFileExtend("etc/system.properties", propertyName, propertyValue != null ? propertyValue : "");
+ }
+
+ /**
+ * Copies the actual System property to the container properties.
+ *
+ * @param propertyName
+ * @return
+ */
+ public static Option systemProperty(String propertyName) {
+ return systemProperty(propertyName, System.getProperty(propertyName));
}
+
}
Modified: whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrServicesTest.java
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrServicesTest.java?rev=1295715&r1=1295714&r2=1295715&view=diff
==============================================================================
--- whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrServicesTest.java (original)
+++ whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/WhirrServicesTest.java Thu Mar 1 17:58:29 2012
@@ -22,6 +22,7 @@ package org.apache.whirr.karaf.itest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openengsb.labs.paxexam.karaf.options.LogLevelOption;
+import org.ops4j.pax.exam.MavenUtils;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
import org.ops4j.pax.exam.junit.ExamReactorStrategy;
@@ -30,6 +31,7 @@ import org.ops4j.pax.exam.spi.reactors.A
import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.logLevel;
+import static org.ops4j.pax.exam.CoreOptions.scanFeatures;
@RunWith(JUnit4TestRunner.class)
@ExamReactorStrategy(AllConfinedStagedReactorFactory.class)
@@ -37,9 +39,6 @@ public class WhirrServicesTest extends W
@Test
public void testServices() throws InterruptedException {
- //Install Whirr
- installWhirr();
- System.err.println(executeCommand("osgi:list"));
//Install all services
executeCommand("features:install whirr-cassandra");
executeCommand("features:install whirr-chef");
@@ -50,7 +49,6 @@ public class WhirrServicesTest extends W
executeCommand("features:install whirr-hbase");
executeCommand("features:install whirr-puppet");
executeCommand("features:install whirr-mahout");
- //executeCommand("features:install whirr-voldemort");
executeCommand("features:install whirr-zookeeper");
System.err.println(executeCommand("osgi:list"));
@@ -67,7 +65,6 @@ public class WhirrServicesTest extends W
testService("hbase-master", "hbase-regionserver", "hbase-restserver", "hbase-avroserver", "hbase-thriftserver");
testService("puppet-install");
testService("mahout-client");
- //testService("voldemort");
testService("zookeeper");
}
@@ -88,6 +85,9 @@ public class WhirrServicesTest extends W
@Configuration
public Option[] config() {
return new Option[]{
- whirrDistributionConfiguration(), keepRuntimeFolder(), logLevel(LogLevelOption.LogLevel.ERROR)};
+ whirrDistributionConfiguration(), keepRuntimeFolder(), logLevel(LogLevelOption.LogLevel.ERROR),
+ scanFeatures(String.format(WHIRR_FEATURE_URL, MavenUtils
+ .getArtifactVersion(WHIRR_KARAF_GROUP_ID, WHIRR_KARAF_ARTIFACT_ID)), "whirr").start()
+ };
}
}
Added: whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/integration/WhirrKarafZookeeperServiceTest.java
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/integration/WhirrKarafZookeeperServiceTest.java?rev=1295715&view=auto
==============================================================================
--- whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/integration/WhirrKarafZookeeperServiceTest.java (added)
+++ whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/integration/WhirrKarafZookeeperServiceTest.java Thu Mar 1 17:58:29 2012
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.whirr.karaf.itest.integration;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openengsb.labs.paxexam.karaf.options.LogLevelOption;
+import org.ops4j.pax.exam.MavenUtils;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.ExamReactorStrategy;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory;
+
+import java.io.IOException;
+
+import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
+import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.logLevel;
+import static org.ops4j.pax.exam.CoreOptions.scanFeatures;
+
+@RunWith(JUnit4TestRunner.class)
+@ExamReactorStrategy(AllConfinedStagedReactorFactory.class)
+public class WhirrKarafZookeeperServiceTest extends WhirrLiveTestSupport {
+
+ @Before
+ public void setUp() {
+ lookupConfigurationAdmin();
+ }
+
+ @After
+ public void tearDown() {
+ if (isLiveConfigured()) {
+ releaseConfigurationAdmin();
+ System.err.println(executeCommand("whirr:destroy-cluster --pid " + ZOOKEEPER_RECIPE_PID, 10 * 60 * 1000L, false));
+ }
+ }
+
+ @Test
+ public void testLive() throws IOException, ConfigurationException {
+ if (isLiveConfigured()) {
+ loadConfiguration("whirr-zookeeper-test.properties", ZOOKEEPER_RECIPE_PID);
+
+ System.err.println(executeCommands("config:edit " + ZOOKEEPER_RECIPE_PID, "config:proplist", "config:cancel"));
+ System.err.println(executeCommand("whirr:launch-cluster --pid " + ZOOKEEPER_RECIPE_PID, 20 * 60 * 1000L, false));
+
+ // TODO: connect to the launched cluster to make sure it works (we need a karaf
+ // aware cluster state store to be able to retrieve the cluster IP addresses)
+
+ } else {
+ System.err.println("Live test not properly configured, please add whirr.test.provider, " +
+ "whirr.test.identity & whirr.test.credential as system properties.\n" +
+ "Also note that currently only aws-ec2, clouservers-us, cloudservers-uk are the supported providers " +
+ "for this integration test.");
+ }
+ }
+
+ @Configuration
+ public Option[] config() {
+ return new Option[]{
+ whirrDistributionConfiguration(), keepRuntimeFolder(), logLevel(LogLevelOption.LogLevel.ERROR),
+ systemProperty("whirr.test.provider"),
+ systemProperty("whirr.test.identity"),
+ systemProperty("whirr.test.credential"),
+ scanFeatures(String.format(WHIRR_FEATURE_URL,
+ MavenUtils.getArtifactVersion(WHIRR_KARAF_GROUP_ID, WHIRR_KARAF_ARTIFACT_ID)),
+ "jclouds-aws-ec2", "jclouds-cloudserver-us", "jclouds-cloudserver-uk", "whirr-zookeeper").start()
+ };
+ }
+}
Added: whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/integration/WhirrLiveTestSupport.java
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/integration/WhirrLiveTestSupport.java?rev=1295715&view=auto
==============================================================================
--- whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/integration/WhirrLiveTestSupport.java (added)
+++ whirr/trunk/platforms/karaf/itests/src/test/java/org/apache/whirr/karaf/itest/integration/WhirrLiveTestSupport.java Thu Mar 1 17:58:29 2012
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.whirr.karaf.itest.integration;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.whirr.karaf.itest.WhirrKarafTestSupport;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.Configuration;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+import java.io.IOException;
+import java.util.Dictionary;
+import java.util.Iterator;
+import java.util.Properties;
+
+public class WhirrLiveTestSupport extends WhirrKarafTestSupport {
+
+ public static final String ZOOKEEPER_RECIPE_PID = "org.apache.whirr.recipes.zookeeper";
+
+ String provider;
+ String identity;
+ String credential;
+
+ ConfigurationAdmin configurationAdmin;
+ ServiceReference configurationAdminReference;
+
+ public void lookupConfigurationAdmin() {
+ configurationAdminReference = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
+ configurationAdmin = (ConfigurationAdmin) bundleContext.getService(configurationAdminReference);
+ }
+
+ public void releaseConfigurationAdmin() {
+ if (configurationAdminReference != null) {
+ bundleContext.ungetService(configurationAdminReference);
+ }
+ }
+
+ /**
+ * Checks if Live Test parameters are properly configured.
+ *
+ * @return
+ */
+ public boolean isLiveConfigured() {
+ provider = System.getProperty("whirr.test.provider");
+ identity = System.getProperty("whirr.test.identity");
+ credential = System.getProperty("whirr.test.credential");
+
+ return provider != null & identity != null && credential != null
+ && !provider.isEmpty() && !identity.isEmpty() && !credential.isEmpty()
+ && (provider.equals("aws-ec2") || provider.equals("cloudservers-us"));
+ }
+
+
+ public void loadConfiguration(String name, String pid) throws ConfigurationException, IOException {
+ if (configurationAdmin == null) {
+ String message = "No configuration admin available. Make sure you have " +
+ "properly looked it up before invoking this method";
+ System.err.println(message);
+ throw new IllegalStateException(message);
+ }
+
+ PropertiesConfiguration properties = new PropertiesConfiguration(getClass().getClassLoader().getResource(name));
+ Configuration configuration = configurationAdmin.getConfiguration(pid);
+
+ Dictionary dictionary = configuration.getProperties();
+ if (dictionary == null) {
+ dictionary = new Properties();
+ }
+
+ Iterator iterator = properties.getKeys();
+ while (iterator.hasNext()) {
+ String key = (String) iterator.next();
+ String value = properties.getString(key);
+ dictionary.put(key, value);
+ }
+ configuration.update(dictionary);
+ }
+}
Added: whirr/trunk/platforms/karaf/itests/src/test/resources/whirr-zookeeper-test.properties
URL: http://svn.apache.org/viewvc/whirr/trunk/platforms/karaf/itests/src/test/resources/whirr-zookeeper-test.properties?rev=1295715&view=auto
==============================================================================
--- whirr/trunk/platforms/karaf/itests/src/test/resources/whirr-zookeeper-test.properties (added)
+++ whirr/trunk/platforms/karaf/itests/src/test/resources/whirr-zookeeper-test.properties Thu Mar 1 17:58:29 2012
@@ -0,0 +1,27 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+whirr.cluster-name=zookeeper-karaf-itest-${sys:whirr.test.provider}-${sys:user.name}
+whirr.instance-templates=1 zookeeper
+
+whirr.provider=${sys:whirr.test.provider}
+whirr.identity=${sys:whirr.test.identity}
+whirr.credential=${sys:whirr.test.credential}
+
+whirr.hardware-min-ram=512
+whirr.zookeeper.tarball.url=http://archive.apache.org/dist/zookeeper/zookeeper-3.3.3/zookeeper-3.3.3.tar.gz
+jclouds.compute.timeout.node-running=240000
Modified: whirr/trunk/pom.xml
URL: http://svn.apache.org/viewvc/whirr/trunk/pom.xml?rev=1295715&r1=1295714&r2=1295715&view=diff
==============================================================================
--- whirr/trunk/pom.xml (original)
+++ whirr/trunk/pom.xml Thu Mar 1 17:58:29 2012
@@ -15,21 +15,22 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<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/maven-v4_0_0.xsd">
+<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
-
+
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
<version>7</version>
- </parent>
+ </parent>
<groupId>org.apache.whirr</groupId>
<artifactId>whirr</artifactId>
<version>0.8.0-SNAPSHOT</version>
<packaging>pom</packaging>
-
+
<name>Whirr</name>
<description>Libraries for running cloud services</description>
<url>http://whirr.apache.org/</url>
@@ -192,7 +193,7 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
@@ -226,6 +227,14 @@
<artifactId>dnsjava</artifactId>
<version>${dnsjava.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.whirr.karaf</groupId>
+ <artifactId>apache-whirr</artifactId>
+ <version>${project.version}</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</dependencyManagement>
@@ -233,8 +242,8 @@
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-ssh-external</artifactId>
- <version>2.2</version>
+ <artifactId>wagon-ssh-external</artifactId>
+ <version>2.2</version>
</extension>
</extensions>
<plugins>
@@ -276,7 +285,9 @@
<failsOnError>true</failsOnError>
<!-- HBaseServiceController fails checkstyle since Thrift TException cannot be found.
Probably a classpath issue, so until that is fixed, we exclude the class. -->
- <excludes>**/org/apache/whirr/service/hbase/integration/HBaseServiceController.java</excludes>
+ <excludes>
+ **/org/apache/whirr/service/hbase/integration/HBaseServiceController.java
+ </excludes>
</configuration>
</plugin>
<plugin>
@@ -322,8 +333,10 @@
<configuration>
<archive>
<manifest>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+ <addDefaultImplementationEntries>true
+ </addDefaultImplementationEntries>
+ <addDefaultSpecificationEntries>true
+ </addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
@@ -358,9 +371,10 @@
</executions>
<configuration>
<resourceBundles>
- <resourceBundle>org.apache:apache-jar-resource-bundle:1.4</resourceBundle>
+ <resourceBundle>org.apache:apache-jar-resource-bundle:1.4
+ </resourceBundle>
</resourceBundles>
- </configuration>
+ </configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -416,7 +430,8 @@
<exclude>**/.classpath</exclude>
<exclude>**/.settings/**</exclude>
<exclude>**/target/**</exclude>
- <exclude>src/site/resources/images/whirr-logo.ai</exclude> <!-- binary -->
+ <exclude>src/site/resources/images/whirr-logo.ai</exclude>
+ <!-- binary -->
</excludes>
</configuration>
</plugin>
@@ -433,7 +448,8 @@
<Bundle-Activator>${osgi.bundle.activator}</Bundle-Activator>
<Export-Package>${osgi.export}</Export-Package>
<Import-Package>${osgi.import}</Import-Package>
- <DynamicImport-Package>${osgi.dynamic.import}</DynamicImport-Package>
+ <DynamicImport-Package>${osgi.dynamic.import}
+ </DynamicImport-Package>
<Private-Package>${osgi.private}</Private-Package>
<Require-Bundle>${osgi.bundles}</Require-Bundle>
<Export-Service>${osgi.export.service}</Export-Service>
@@ -469,31 +485,63 @@
<phase>initialize</phase>
<configuration>
<target>
- <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath"/>
- <property name="ant.regexp.regexpimpl" value="org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp"/>
+ <taskdef resource="net/sf/antcontrib/antcontrib.properties"
+ classpathref="maven.plugin.classpath"/>
+ <property name="ant.regexp.regexpimpl"
+ value="org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp"/>
<property name="whirr.mv" value="${project.version}"/>
<property name="jclouds.mv" value="${jclouds.version}"/>
<echo message="Whirr Maven version: ${whirr.mv}"/>
<echo message="Jclouds Maven version: ${jclouds.mv}"/>
- <propertyregex property="whirr.ov.p1" input="${whirr.mv}" regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?" replace="\1" defaultValue="0"/>
- <propertyregex property="whirr.ov.p2" input="${whirr.mv}" regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?" replace=".\2" defaultValue=".0"/>
- <propertyregex property="whirr.ov.p3" input="${whirr.mv}" regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?" replace=".\3" defaultValue=".0"/>
- <propertyregex property="whirr.ov.p4" input="${whirr.mv}" regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?" replace=".\4" defaultValue=""/>
- <propertyregex property="whirr.ov.p1a" input="${whirr.ov.p1}" regexp="(.+)" replace="\1" defaultValue="0"/>
- <propertyregex property="whirr.ov.p2a" input="${whirr.ov.p2}" regexp="(\..+)" replace="\1" defaultValue=".0"/>
- <propertyregex property="whirr.ov.p3a" input="${whirr.ov.p3}" regexp="(\..+)" replace="\1" defaultValue=".0"/>
- <propertyregex property="whirr.ov.p4a" input="${whirr.ov.p4}" regexp="(\..+)" replace="\1" defaultValue=""/>
- <property name="whirr.ov" value="${whirr.ov.p1a}${whirr.ov.p2a}${whirr.ov.p3a}${whirr.ov.p4a}"/>
+ <propertyregex property="whirr.ov.p1" input="${whirr.mv}"
+ regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
+ replace="\1" defaultValue="0"/>
+ <propertyregex property="whirr.ov.p2" input="${whirr.mv}"
+ regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
+ replace=".\2" defaultValue=".0"/>
+ <propertyregex property="whirr.ov.p3" input="${whirr.mv}"
+ regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
+ replace=".\3" defaultValue=".0"/>
+ <propertyregex property="whirr.ov.p4" input="${whirr.mv}"
+ regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
+ replace=".\4" defaultValue=""/>
+ <propertyregex property="whirr.ov.p1a" input="${whirr.ov.p1}"
+ regexp="(.+)" replace="\1" defaultValue="0"/>
+ <propertyregex property="whirr.ov.p2a" input="${whirr.ov.p2}"
+ regexp="(\..+)" replace="\1" defaultValue=".0"/>
+ <propertyregex property="whirr.ov.p3a" input="${whirr.ov.p3}"
+ regexp="(\..+)" replace="\1" defaultValue=".0"/>
+ <propertyregex property="whirr.ov.p4a" input="${whirr.ov.p4}"
+ regexp="(\..+)" replace="\1" defaultValue=""/>
+ <property name="whirr.ov"
+ value="${whirr.ov.p1a}${whirr.ov.p2a}${whirr.ov.p3a}${whirr.ov.p4a}"/>
- <propertyregex property="jclouds.ov.p1" input="${jclouds.mv}" regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?" replace="\1" defaultValue="0"/>
- <propertyregex property="jclouds.ov.p2" input="${jclouds.mv}" regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?" replace=".\2" defaultValue=".0"/>
- <propertyregex property="jclouds.ov.p3" input="${jclouds.mv}" regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?" replace=".\3" defaultValue=".0"/>
- <propertyregex property="jclouds.ov.p4" input="${jclouds.mv}" regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?" replace=".\4" defaultValue=""/>
- <propertyregex property="jclouds.ov.p1a" input="${jclouds.ov.p1}" regexp="(.+)" replace="\1" defaultValue="0"/>
- <propertyregex property="jclouds.ov.p2a" input="${jclouds.ov.p2}" regexp="(\..+)" replace="\1" defaultValue=".0"/>
- <propertyregex property="jclouds.ov.p3a" input="${jclouds.ov.p3}" regexp="(\..+)" replace="\1" defaultValue=".0"/>
- <propertyregex property="jclouds.ov.p4a" input="${jclouds.ov.p4}" regexp="(\..+)" replace="\1" defaultValue=""/>
- <property name="jclouds.ov" value="${jclouds.ov.p1a}${jclouds.ov.p2a}${jclouds.ov.p3a}${jclouds.ov.p4a}"/>
+ <propertyregex property="jclouds.ov.p1" input="${jclouds.mv}"
+ regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
+ replace="\1" defaultValue="0"/>
+ <propertyregex property="jclouds.ov.p2" input="${jclouds.mv}"
+ regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
+ replace=".\2" defaultValue=".0"/>
+ <propertyregex property="jclouds.ov.p3" input="${jclouds.mv}"
+ regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
+ replace=".\3" defaultValue=".0"/>
+ <propertyregex property="jclouds.ov.p4" input="${jclouds.mv}"
+ regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?"
+ replace=".\4" defaultValue=""/>
+ <propertyregex property="jclouds.ov.p1a"
+ input="${jclouds.ov.p1}" regexp="(.+)"
+ replace="\1" defaultValue="0"/>
+ <propertyregex property="jclouds.ov.p2a"
+ input="${jclouds.ov.p2}" regexp="(\..+)"
+ replace="\1" defaultValue=".0"/>
+ <propertyregex property="jclouds.ov.p3a"
+ input="${jclouds.ov.p3}" regexp="(\..+)"
+ replace="\1" defaultValue=".0"/>
+ <propertyregex property="jclouds.ov.p4a"
+ input="${jclouds.ov.p4}" regexp="(\..+)"
+ replace="\1" defaultValue=""/>
+ <property name="jclouds.ov"
+ value="${jclouds.ov.p1a}${jclouds.ov.p2a}${jclouds.ov.p3a}${jclouds.ov.p4a}"/>
<echo message="Whirr OSGi version: ${whirr.ov}"/>
<echo message="Jclouds OSGi version: ${jclouds.ov}"/>
<mkdir dir="target"/>
@@ -588,11 +636,14 @@
<repository>
<id>apache.staging.https</id>
<name>Nexus Staging Repo</name>
- <url>https://repository.apache.org/service/local/staging/deploy/maven2/</url>
+ <url>https://repository.apache.org/service/local/staging/deploy/maven2/
+ </url>
</repository>
<site>
<id>apache.website</id>
- <url>scpexe://people.apache.org/www/whirr.apache.org/docs/${project.version}</url>
+ <url>
+ scpexe://people.apache.org/www/whirr.apache.org/docs/${project.version}
+ </url>
</site>
</distributionManagement>
<profiles>
@@ -687,7 +738,7 @@
</goals>
</execution>
</executions>
- </plugin>
+ </plugin>
</plugins>
</build>
</profile>