Search in sources :

Example 26 with Agent

use of io.fabric8.agent.service.Agent in project fabric8 by jboss-fuse.

the class JoinTest method testJoin.

@Test
public void testJoin() throws Exception {
    System.err.println(CommandSupport.executeCommand("fabric:create --force --clean -n --wait-for-provisioning"));
    BundleContext moduleContext = ServiceLocator.getSystemContext();
    ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class);
    try {
        FabricService fabricService = fabricProxy.getService();
        AdminService adminService = ServiceLocator.awaitService(AdminService.class);
        String version = System.getProperty("fabric.version");
        System.err.println(CommandSupport.executeCommand("admin:create -o '-server -Xmx1536M -Dcom.sun.management.jmxremote -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -Dpatching.disabled=true -Djava.security.egd=file:/dev/./urandom' --featureURL mvn:io.fabric8/fabric8-karaf/" + version + "/xml/features --feature fabric-git --feature fabric-agent --feature fabric-boot-commands smoke_child_d"));
        try {
            System.err.println(CommandSupport.executeCommand("admin:start smoke_child_d"));
            ProvisionSupport.instanceStarted(Arrays.asList("smoke_child_d"), ProvisionSupport.PROVISION_TIMEOUT);
            System.err.println(CommandSupport.executeCommand("admin:list"));
            String joinCommand = "fabric:join -f --zookeeper-password " + fabricService.getZookeeperPassword() + " " + fabricService.getZookeeperUrl();
            String response = "";
            for (int i = 0; i < 10 && !response.contains("true"); i++) {
                response = CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("smoke_child_d").getSshPort() + " localhost " + WAIT_FOR_JOIN_SERVICE);
                Thread.sleep(1000);
            }
            System.err.println(CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("smoke_child_d").getSshPort() + " localhost " + joinCommand));
            ProvisionSupport.containersExist(Arrays.asList("smoke_child_d"), ProvisionSupport.PROVISION_TIMEOUT);
            Container childD = fabricService.getContainer("smoke_child_d");
            System.err.println(CommandSupport.executeCommand("fabric:container-list"));
            ProvisionSupport.containerStatus(Arrays.asList(childD), "success", ProvisionSupport.PROVISION_TIMEOUT);
            System.err.println(CommandSupport.executeCommand("fabric:container-list"));
        } finally {
            System.err.println(CommandSupport.executeCommand("admin:stop smoke_child_d"));
        }
    } finally {
        fabricProxy.close();
    }
}
Also used : Container(io.fabric8.api.Container) AdminService(org.apache.karaf.admin.AdminService) FabricService(io.fabric8.api.FabricService) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)8 FabricService (io.fabric8.api.FabricService)7 Container (io.fabric8.api.Container)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Test (org.junit.Test)6 Bundle (org.osgi.framework.Bundle)5 BundleContext (org.osgi.framework.BundleContext)5 Profile (io.fabric8.api.Profile)4 File (java.io.File)4 BundleException (org.osgi.framework.BundleException)4 MultiException (io.fabric8.common.util.MultiException)3 FileInputStream (java.io.FileInputStream)3 List (java.util.List)3 Set (java.util.Set)3 ConfigurationException (org.osgi.service.cm.ConfigurationException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 DownloadManager (io.fabric8.agent.download.DownloadManager)2 Downloader (io.fabric8.agent.download.Downloader)2