Search in sources :

Example 1 with AdminService

use of org.apache.karaf.admin.AdminService in project fabric8 by jboss-fuse.

the class ExtendedJoinTest method testJoinAndAddToEnsemble.

/**
 * This is a test for FABRIC-353.
 */
@Test
@Ignore
public void testJoinAndAddToEnsemble() throws Exception {
    System.err.println(CommandSupport.executeCommand("fabric:create --force --clean -n --wait-for-provisioning"));
    // System.out.println(executeCommand("shell:info"));
    // System.out.println(executeCommand("fabric:info"));
    // System.out.println(executeCommand("fabric:profile-list"));
    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.out.println(CommandSupport.executeCommand("admin:create --featureURL mvn:io.fabric8/fabric8-karaf/" + version + "/xml/features --feature fabric-git --feature fabric-agent --feature fabric-boot-commands basic_cnt_f"));
        System.out.println(CommandSupport.executeCommand("admin:create --featureURL mvn:io.fabric8/fabric8-karaf/" + version + "/xml/features --feature fabric-git --feature fabric-agent --feature fabric-boot-commands basic_cnt_g"));
        try {
            System.out.println(CommandSupport.executeCommand("admin:start basic_cnt_f"));
            System.out.println(CommandSupport.executeCommand("admin:start basic_cnt_g"));
            ProvisionSupport.instanceStarted(Arrays.asList("basic_cnt_f", "basic_cnt_g"), ProvisionSupport.PROVISION_TIMEOUT);
            System.out.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("basic_cnt_f").getSshPort() + " localhost " + WAIT_FOR_JOIN_SERVICE);
                Thread.sleep(1000);
            }
            response = "";
            for (int i = 0; i < 10 && !response.contains("true"); i++) {
                response = CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("basic_cnt_g").getSshPort() + " localhost " + WAIT_FOR_JOIN_SERVICE);
                Thread.sleep(1000);
            }
            System.err.println(CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("basic_cnt_f").getSshPort() + " localhost " + joinCommand));
            System.err.println(CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("basic_cnt_g").getSshPort() + " localhost " + joinCommand));
            ProvisionSupport.containersExist(Arrays.asList("basic_cnt_f", "basic_cnt_g"), ProvisionSupport.PROVISION_TIMEOUT);
            Container cntF = fabricService.getContainer("basic_cnt_f");
            Container cntG = fabricService.getContainer("basic_cnt_g");
            ProvisionSupport.containerStatus(Arrays.asList(cntF, cntG), "success", ProvisionSupport.PROVISION_TIMEOUT);
            EnsembleSupport.addToEnsemble(fabricService, cntF, cntG);
            System.out.println(CommandSupport.executeCommand("fabric:container-list"));
            EnsembleSupport.removeFromEnsemble(fabricService, cntF, cntG);
            System.out.println(CommandSupport.executeCommand("fabric:container-list"));
        } finally {
            System.out.println(CommandSupport.executeCommand("admin:stop basic_cnt_f"));
            System.out.println(CommandSupport.executeCommand("admin:stop basic_cnt_g"));
        }
    } 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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with AdminService

use of org.apache.karaf.admin.AdminService in project fabric8 by jboss-fuse.

the class ExtendedJoinTest method testContainerHostnameSupport.

/**
 * Verify that containers can use dot symbol in their name
 *
 * @throws Exception
 */
@Test
public void testContainerHostnameSupport() throws Exception {
    System.out.println(CommandSupport.executeCommand("fabric:create --force --clean -n"));
    // System.out.println(executeCommand("shell:info"));
    // System.out.println(executeCommand("fabric:info"));
    // System.out.println(executeCommand("fabric:profile-list"));
    BundleContext moduleContext = ServiceLocator.getSystemContext();
    ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(moduleContext, FabricService.class);
    try {
        FabricService fabricService = fabricProxy.getService();
        AdminService adminService = ServiceLocator.awaitService(AdminService.class);
        Container root = fabricService.getContainer("root");
        Set<Container> set = new HashSet<>();
        set.add(root);
        String version = System.getProperty("fabric.version");
        try {
            System.out.println(CommandSupport.executeCommand("fabric:profile-edit --features admin default"));
            ProvisionSupport.provisioningSuccess(set, 60_000L);
            System.out.println(CommandSupport.executeCommand("admin:create --java-opts ' -Dpatching.disabled=true ' --featureURL mvn:io.fabric8/fabric8-karaf/" + version + "/xml/features --feature fabric joiner "));
            System.out.println(CommandSupport.executeCommand("admin:start joiner"));
            ProvisionSupport.instanceStarted(Arrays.asList("joiner"), ProvisionSupport.PROVISION_TIMEOUT);
            System.out.println(CommandSupport.executeCommand("admin:list"));
            String joinCommand = "fabric:join -f --zookeeper-password " + fabricService.getZookeeperPassword() + " " + fabricService.getZookeeperUrl() + " joiner.complex.name";
            String response = "";
            for (int i = 0; i < 10 && !response.contains("true"); i++) {
                response = CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("joiner").getSshPort() + " localhost " + WAIT_FOR_JOIN_SERVICE);
                Thread.sleep(1000);
            }
            response = CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("joiner").getSshPort() + " localhost " + joinCommand);
            ProvisionSupport.containersExist(Arrays.asList("joiner.complex.name"), ProvisionSupport.PROVISION_TIMEOUT);
            Container joiner = fabricService.getContainer("joiner.complex.name");
            ProvisionSupport.containerStatus(Arrays.asList(joiner), "success", ProvisionSupport.PROVISION_TIMEOUT);
        // System.err.println(CommandSupport.executeCommand("ssh:ssh -l karaf -P karaf -p " + adminService.getInstance("basic_cnt_f").getSshPort() + " localhost " + joinCommand));
        } finally {
            System.out.println(CommandSupport.executeCommand("fabric:container-info joiner"));
            System.out.println(CommandSupport.executeCommand("admin:stop joiner"));
        }
    } 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) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with AdminService

use of org.apache.karaf.admin.AdminService 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

Container (io.fabric8.api.Container)3 FabricService (io.fabric8.api.FabricService)3 AdminService (org.apache.karaf.admin.AdminService)3 Test (org.junit.Test)3 BundleContext (org.osgi.framework.BundleContext)3 HashSet (java.util.HashSet)1 Ignore (org.junit.Ignore)1