Search in sources :

Example 1 with ContainerProxy

use of io.fabric8.itests.paxexam.support.ContainerProxy in project fabric8 by jboss-fuse.

the class CamelProfileScriptTest method testFeatures.

@Test
public void testFeatures() throws Exception {
    System.out.println(executeCommand("fabric:create -n --wait-for-provisioning"));
    // System.out.println(executeCommand("shell:info"));
    // System.out.println(executeCommand("fabric:info"));
    // System.out.println(executeCommand("fabric:profile-list"));
    ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(bundleContext, FabricService.class);
    try {
        FabricService fabricService = fabricProxy.getService();
        Set<ContainerProxy> containers = ContainerBuilder.create(fabricProxy).withName("feature-camel").withProfiles("feature-camel").assertProvisioningResult().build();
        try {
            CuratorFramework curator = fabricService.adapt(CuratorFramework.class);
            assertProvisionedFeature(fabricService, curator, containers, "camel-script-javascript", "feature-camel", "scriptengines-javascript");
        } finally {
            ContainerBuilder.destroy(containers);
        }
    } finally {
        fabricProxy.close();
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) FabricService(io.fabric8.api.FabricService) ContainerProxy(io.fabric8.itests.paxexam.support.ContainerProxy) Test(org.junit.Test) FabricFeaturesTest(io.fabric8.itests.paxexam.support.FabricFeaturesTest)

Example 2 with ContainerProxy

use of io.fabric8.itests.paxexam.support.ContainerProxy in project fabric8 by jboss-fuse.

the class CamelProfileTest method testFeatures.

@Test
public void testFeatures() throws Exception {
    System.out.println(executeCommand("fabric:create -n --wait-for-provisioning"));
    // System.out.println(executeCommand("shell:info"));
    // System.out.println(executeCommand("fabric:info"));
    // System.out.println(executeCommand("fabric:profile-list"));
    ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(bundleContext, FabricService.class);
    try {
        FabricService fabricService = fabricProxy.getService();
        Set<ContainerProxy> containers = ContainerBuilder.create(fabricProxy).withName("feature-camel").withProfiles("feature-camel").assertProvisioningResult().build();
        try {
            CuratorFramework curator = fabricService.adapt(CuratorFramework.class);
            assertProvisionedFeature(fabricService, curator, containers, "camel-http", "feature-camel", "camel-http");
            assertProvisionedFeature(fabricService, curator, containers, "camel-jetty", "feature-camel", "camel-jetty");
            assertProvisionedFeature(fabricService, curator, containers, "camel-jms", "feature-camel", "camel-jms");
            assertProvisionedFeature(fabricService, curator, containers, "camel-ftp", "feature-camel", "camel-ftp");
            assertProvisionedFeature(fabricService, curator, containers, "camel-quartz", "feature-camel", "camel-quartz");
        } finally {
            ContainerBuilder.destroy(containers);
        }
    } finally {
        fabricProxy.close();
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) FabricService(io.fabric8.api.FabricService) ContainerProxy(io.fabric8.itests.paxexam.support.ContainerProxy) Test(org.junit.Test) FabricFeaturesTest(io.fabric8.itests.paxexam.support.FabricFeaturesTest)

Example 3 with ContainerProxy

use of io.fabric8.itests.paxexam.support.ContainerProxy in project fabric8 by jboss-fuse.

the class ExampleCamelClusterTest method testRegistryEntries.

@Test
public void testRegistryEntries() throws Exception {
    System.out.println(executeCommand("fabric:create -n --wait-for-provisioning root"));
    // System.out.println(executeCommand("shell:info"));
    // System.out.println(executeCommand("fabric:info"));
    // System.out.println(executeCommand("fabric:profile-list"));
    ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(bundleContext, FabricService.class);
    try {
        FabricService fabricService = fabricProxy.getService();
        CuratorFramework curator = fabricService.adapt(CuratorFramework.class);
        Set<ContainerProxy> containers = ContainerBuilder.create(fabricProxy, 3).withName("fabric-camel").assertProvisioningResult().build();
        try {
            // We will use the first container as a client and the rest as servers.
            LinkedList<Container> containerList = new LinkedList<Container>(containers);
            Container client = containerList.removeLast();
            LinkedList<Container> servers = new LinkedList<Container>(containerList);
            for (Container c : servers) {
                Profile p1 = c.getVersion().getRequiredProfile("feature-camel");
                Profile p2 = c.getVersion().getRequiredProfile("example-camel-cluster-cluster.server");
                c.setProfiles(new Profile[] { p1, p2 });
            }
            Provision.provisioningSuccess(servers, PROVISION_TIMEOUT);
            Profile p1 = client.getVersion().getRequiredProfile("feature-camel");
            Profile p2 = client.getVersion().getRequiredProfile("example-camel-cluster-cluster.client");
            client.setProfiles(new Profile[] { p1, p2 });
            Provision.provisioningSuccess(Arrays.asList(new Container[] { client }), PROVISION_TIMEOUT);
            System.out.println(executeCommand("fabric:container-list"));
            System.out.println(executeCommand("fabric:profile-display --overlay fabric-camel-server"));
            // Check that the entries have been properly propagated.
            Assert.assertNotNull(exists(curator, "/fabric/registry/camel/endpoints"));
            Assert.assertEquals(1, getChildren(curator, "/fabric/registry/camel/endpoints").size());
            Assert.assertTrue(Provision.waitForCondition(Arrays.asList(client), new ContainerCondition() {

                @Override
                public Boolean checkConditionOnContainer(final Container c) {
                    return getCompletedExchangesCount(c) > 0;
                }
            }, 60000L));
            // We want to kill all but one server, so we take out the first and keep it to the end.
            Container lastActiveServerContainer = servers.removeLast();
            for (Container c : servers) {
                try {
                    c.destroy(true);
                } catch (Exception ex) {
                // ignore.
                }
                // Get the number of exchanges completed before we kill the server.
                final int completed = getCompletedExchangesCount(client);
                // Ensure that we still have messages flowing
                Assert.assertTrue(Provision.waitForCondition(Arrays.asList(client), new ContainerCondition() {

                    @Override
                    public Boolean checkConditionOnContainer(final Container c) {
                        return getCompletedExchangesCount(c) > completed + 3;
                    }
                }, 60000L));
            }
            System.out.println(new AnsiString(executeCommand("fabric:container-connect -u admin -p admin " + client.getId() + " camel:route-info fabric-client")).getPlain().toString());
        } finally {
            ContainerBuilder.destroy(containers);
        }
    } finally {
        fabricProxy.close();
    }
}
Also used : AnsiString(org.fusesource.jansi.AnsiString) LinkedList(java.util.LinkedList) Profile(io.fabric8.api.Profile) ContainerCondition(io.fabric8.itests.paxexam.support.ContainerCondition) CuratorFramework(org.apache.curator.framework.CuratorFramework) Container(io.fabric8.api.Container) FabricService(io.fabric8.api.FabricService) ContainerProxy(io.fabric8.itests.paxexam.support.ContainerProxy) Test(org.junit.Test)

Example 4 with ContainerProxy

use of io.fabric8.itests.paxexam.support.ContainerProxy in project fabric8 by jboss-fuse.

the class ExampleCxfProfileLongTest method testExample.

@Test
public void testExample() throws Exception {
    System.out.println("creating the cxf-server container.");
    ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(bundleContext, FabricService.class);
    try {
        Set<ContainerProxy> containers = ContainerBuilder.create(fabricProxy).withName("child").withProfiles("example-cxf-cxf.server").assertProvisioningResult().build();
        try {
            assertTrue("We should create the cxf-server container.", containers.size() == 1);
            System.out.println("created the cxf-server container.");
            // install bundle of CXF
            Thread.sleep(2000);
            System.out.println(executeCommand("fabric:cluster-list"));
            // install bundle of CXF
            Thread.sleep(2000);
            // calling the client here
            System.out.println("install the cxf client demo in root container");
            // This test need to take sometime to download the cxf feature related bundles
            System.out.println(executeCommand("features:install fabric-cxf", 600000, false));
            String projectVersion = System.getProperty("fabricitest.version");
            // install bundle of CXF demo client
            System.out.println(executeCommand("osgi:install -s mvn:io.fabric8.examples/fabric-cxf-demo-common/" + projectVersion));
            System.out.println(executeCommand("osgi:install -s mvn:io.fabric8.examples/fabric-cxf-demo-client/" + projectVersion));
            System.out.println(executeCommand("osgi:list"));
            System.out.println("invoking the web service");
            Hello proxy = ServiceLocator.awaitService(bundleContext, Hello.class);
            assertNotNull(proxy);
            String result1 = proxy.sayHello();
            String result2 = proxy.sayHello();
            assertNotSame("We should get the two different result", result1, result2);
        } finally {
            ContainerBuilder.destroy(containers);
        }
    } finally {
        fabricProxy.close();
    }
}
Also used : Hello(io.fabric8.demo.cxf.Hello) FabricService(io.fabric8.api.FabricService) ContainerProxy(io.fabric8.itests.paxexam.support.ContainerProxy) Test(org.junit.Test)

Example 5 with ContainerProxy

use of io.fabric8.itests.paxexam.support.ContainerProxy in project fabric8 by jboss-fuse.

the class ExampleMQProfileTest method testExample.

@Test
public void testExample() throws Exception {
    System.out.println(executeCommand("fabric:create -n --wait-for-provisioning"));
    // System.out.println(executeCommand("shell:info"));
    // System.out.println(executeCommand("fabric:info"));
    // System.out.println(executeCommand("fabric:profile-list"));
    ServiceProxy<FabricService> fabricProxy = ServiceProxy.createServiceProxy(bundleContext, FabricService.class);
    try {
        FabricService fabricService = fabricProxy.getService();
        CuratorFramework curator = fabricService.adapt(CuratorFramework.class);
        Set<ContainerProxy> containers = ContainerBuilder.create(fabricProxy, 2).withName("cnt").withProfiles("default").assertProvisioningResult().build();
        try {
            LinkedList<Container> containerList = new LinkedList<Container>(containers);
            Container broker = containerList.removeLast();
            setData(curator, ZkPath.CONTAINER_PROVISION_RESULT.getPath(broker.getId()), "changing");
            System.out.println(executeCommand("fabric:container-change-profile " + broker.getId() + " mq-default"));
            Provision.provisioningSuccess(Arrays.asList(new Container[] { broker }), PROVISION_TIMEOUT);
            System.out.println(executeCommand("fabric:cluster-list"));
            for (Container c : containerList) {
                setData(curator, ZkPath.CONTAINER_PROVISION_RESULT.getPath(c.getId()), "changing");
                System.out.println(executeCommand("fabric:container-change-profile " + c.getId() + " example-mq"));
            }
            Provision.provisioningSuccess(containerList, PROVISION_TIMEOUT);
            System.out.println(executeCommand("fabric:cluster-list"));
            Assert.assertTrue(Provision.waitForCondition(Arrays.asList(new Container[] { broker }), new ContainerCondition() {

                @Override
                public Boolean checkConditionOnContainer(final Container c) {
                    System.out.println(executeCommand("fabric:container-connect -u admin -p admin " + c.getId() + " activemq:bstat"));
                    String output = executeCommand("fabric:container-connect -u admin -p admin " + c.getId() + " activemq:query -QQueue=FABRIC.DEMO");
                    return output.contains("DequeueCount = ") && !output.contains("DequeueCount = 0");
                }
            }, 10000L));
        } finally {
            ContainerBuilder.destroy(containers);
        }
    } finally {
        fabricProxy.close();
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) Container(io.fabric8.api.Container) FabricService(io.fabric8.api.FabricService) ContainerProxy(io.fabric8.itests.paxexam.support.ContainerProxy) LinkedList(java.util.LinkedList) ContainerCondition(io.fabric8.itests.paxexam.support.ContainerCondition) Test(org.junit.Test)

Aggregations

FabricService (io.fabric8.api.FabricService)14 ContainerProxy (io.fabric8.itests.paxexam.support.ContainerProxy)11 Test (org.junit.Test)11 Container (io.fabric8.api.Container)7 CuratorFramework (org.apache.curator.framework.CuratorFramework)7 Profile (io.fabric8.api.Profile)4 ContainerCondition (io.fabric8.itests.paxexam.support.ContainerCondition)4 LinkedList (java.util.LinkedList)4 FabricFeaturesTest (io.fabric8.itests.paxexam.support.FabricFeaturesTest)3 ArrayList (java.util.ArrayList)3 FabricException (io.fabric8.api.FabricException)2 HashSet (java.util.HashSet)2 ObjectName (javax.management.ObjectName)2 BrokerViewMBean (org.apache.activemq.broker.jmx.BrokerViewMBean)2 AnsiString (org.fusesource.jansi.AnsiString)2 BundleContext (org.osgi.framework.BundleContext)2 CreateContainerBasicOptions (io.fabric8.api.CreateContainerBasicOptions)1 CreateContainerMetadata (io.fabric8.api.CreateContainerMetadata)1 Hello (io.fabric8.demo.cxf.Hello)1 CreateSshContainerOptions (io.fabric8.service.ssh.CreateSshContainerOptions)1