You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by io...@apache.org on 2011/11/22 22:47:47 UTC

svn commit: r1205187 - in /karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests: CellarFeaturesTest.java CellarTestSupport.java

Author: iocanel
Date: Tue Nov 22 21:47:46 2011
New Revision: 1205187

URL: http://svn.apache.org/viewvc?rev=1205187&view=rev
Log:
[KARAF-1026] Added integration test for cellar features synchronization and commands.

Added:
    karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java
Modified:
    karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java

Added: karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java?rev=1205187&view=auto
==============================================================================
--- karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java (added)
+++ karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarFeaturesTest.java Tue Nov 22 21:47:46 2011
@@ -0,0 +1,95 @@
+package org.apache.karaf.cellar.itests;
+
+import java.util.Set;
+import org.apache.karaf.cellar.core.ClusterManager;
+import org.apache.karaf.cellar.core.Node;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+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 static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
+
+@RunWith(JUnit4TestRunner.class)
+@ExamReactorStrategy(AllConfinedStagedReactorFactory.class)
+public class CellarFeaturesTest extends CellarTestSupport {
+
+    private static final String UNINSTALLED="[uninstalled]";
+    private static final String INSTALLED="[installed  ]";
+
+    @Test
+    public void testCellarFeaturesModule() throws InterruptedException {
+        installCellar();
+        configureLocalDiscovery(2);
+        createCellarChild("child1");
+        Thread.sleep(DEFAULT_TIMEOUT);
+        ClusterManager clusterManager = getOsgiService(ClusterManager.class);
+        assertNotNull(clusterManager);
+
+        System.err.println(executeCommand("admin:list"));
+
+        String httpFeatureStatus = executeCommand("admin:connect child1 features:list | grep eventadmin");
+        System.err.println(httpFeatureStatus);
+        assertTrue(httpFeatureStatus.startsWith(UNINSTALLED));
+
+        //Test feature sync - install
+        System.err.println(executeCommand("features:install eventadmin"));
+        Thread.sleep(5000);
+        httpFeatureStatus = executeCommand("admin:connect child1 features:list | grep eventadmin");
+        System.err.println(httpFeatureStatus);
+        assertTrue(httpFeatureStatus.startsWith(INSTALLED));
+
+        //Test feature sync - uninstall
+        System.err.println(executeCommand("features:uninstall eventadmin"));
+        Thread.sleep(5000);
+        httpFeatureStatus = executeCommand("admin:connect child1 features:list | grep eventadmin");
+        System.err.println(httpFeatureStatus);
+        assertTrue(httpFeatureStatus.startsWith(UNINSTALLED));
+
+        //Test feature command - install
+        System.err.println(executeCommand("cluster:features-install default eventadmin"));
+        Thread.sleep(5000);
+        httpFeatureStatus = executeCommand("admin:connect child1 features:list | grep eventadmin");
+        System.err.println(httpFeatureStatus);
+        assertTrue(httpFeatureStatus.startsWith(INSTALLED));
+
+        //Test feature command - uninstall
+        System.err.println(executeCommand("cluster:features-uninstall default eventadmin"));
+        Thread.sleep(5000);
+        httpFeatureStatus = executeCommand("admin:connect child1 features:list | grep eventadmin");
+        System.err.println(httpFeatureStatus);
+        assertTrue(httpFeatureStatus.startsWith(UNINSTALLED));
+
+
+        Node localNode = clusterManager.getNode();
+        Set<Node> nodes =clusterManager.listNodes();
+        System.err.println(executeCommand("cluster:nodes-list"));
+        assertTrue("There should be at least 2 cellar nodes running", 2 <= nodes.size());
+
+
+    }
+
+    @After
+    public void tearDown() {
+        try {
+            unInstallCellar();
+            destroyCellarChild("child1");
+        } catch (Exception ex) {
+            //Ignore
+        }
+    }
+
+
+    @Configuration
+    public Option[] config() {
+        return new Option[]{
+                cellarDistributionConfiguration(), keepRuntimeFolder()};
+    }
+}

Modified: karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java?rev=1205187&r1=1205186&r2=1205187&view=diff
==============================================================================
--- karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java (original)
+++ karaf/cellar/trunk/itests/src/test/java/org/apache/karaf/cellar/itests/CellarTestSupport.java Tue Nov 22 21:47:46 2011
@@ -48,6 +48,7 @@ import static org.ops4j.pax.exam.CoreOpt
 public class CellarTestSupport {
 
     static final Long DEFAULT_TIMEOUT = 20000L;
+    static final Long SERVICE_TIMEOUT = 30000L;
     static final String GROUP_ID = "org.apache.karaf";
     static final String ARTIFACT_ID = "apache-karaf";
 
@@ -203,7 +204,7 @@ public class CellarTestSupport {
     }
 
     protected <T> T getOsgiService(Class<T> type) {
-        return getOsgiService(type, null, DEFAULT_TIMEOUT);
+        return getOsgiService(type, null, SERVICE_TIMEOUT);
     }
 
     protected <T> T getOsgiService(Class<T> type, String filter, long timeout) {