Search in sources :

Example 71 with io.fabric8.kubernetes.api.model

use of io.fabric8.kubernetes.api.model in project fabric8 by jboss-fuse.

the class ResolverTest method testResolverInheritanceOnChild.

@Test
public void testResolverInheritanceOnChild() throws Exception {
    System.out.println(CommandSupport.executeCommand("fabric:create --force --clean -n --wait-for-provisioning -g localip -r manualip --manual-ip localhost -b localhost"));
    // 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();
        CuratorFramework curator = fabricService.adapt(CuratorFramework.class);
        Set<Container> containers = ContainerBuilder.create(1, 1).withName("basic.cntG").withProfiles("default").assertProvisioningResult().build(fabricService);
        try {
            Container cntG = containers.iterator().next();
            Assert.assertEquals("manualip", getSubstitutedPath(curator, ZkPath.CONTAINER_RESOLVER.getPath(cntG.getId())));
            Assert.assertEquals("manualip", fabricService.getCurrentContainer().getResolver());
            // We stop the config admin bridge, since the next step is going to hung the container if we do propagate the change to config admin.
            // new BundleUtils(bundleContext).findAndStopBundle("io.fabric8.fabric-configadmin");
            // We want to make sure that the child points to the parent, so we change the parent resolvers and assert.
            System.out.println(CommandSupport.executeCommand("fabric:container-resolver-set --container root localip"));
            Assert.assertEquals("localip", getSubstitutedPath(curator, ZkPath.CONTAINER_RESOLVER.getPath(cntG.getId())));
        } finally {
            ContainerBuilder.destroy(fabricService, containers);
        }
    } finally {
        fabricProxy.close();
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) Container(io.fabric8.api.Container) FabricService(io.fabric8.api.FabricService) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Example 72 with io.fabric8.kubernetes.api.model

use of io.fabric8.kubernetes.api.model in project fabric8 by jboss-fuse.

the class ExceptionMavenCoordsTest method testQueryOfLogMessages.

@Test
public void testQueryOfLogMessages() throws Exception {
    Logger testLog = LoggerFactory.getLogger("io.fabric8.insight.log.log4j.TestLogger");
    // now lets force an exception with a stack trace from camel...
    try {
        CamelContextHelper.getMandatoryEndpoint(null, null);
    } catch (Throwable e) {
        testLog.error("Expected exception for testing: " + e, e);
    }
    // now lets find the error
    LogResults results = logQuery.allLogResults();
    List<LogEvent> logEvents = Log4jTest.assertNotEmpty(results);
    LogEvent log = logEvents.get(0);
    assertNotNull("Should have a log event", log);
    List<String> list = Arrays.asList(log.getException());
    assertTrue("Should have more than 1 items in the stack trace but got: " + list, list.size() > 1);
    String first = list.get(1);
    LOG.info("First line: " + first);
    String expects = "[org.apache.camel:camel-core:";
    assertTrue("Should have camel coordinate '" + expects + "' but got " + first, first.indexOf(expects) > 0);
    for (String line : list) {
        LOG.info(line);
    }
}
Also used : LogResults(io.fabric8.insight.log.LogResults) LogEvent(io.fabric8.insight.log.LogEvent) Logger(org.slf4j.Logger) Test(org.junit.Test)

Example 73 with io.fabric8.kubernetes.api.model

use of io.fabric8.kubernetes.api.model in project fabric8 by jboss-fuse.

the class ContainerStartupTest method deployment.

@Deployment
@StartLevelAware(autostart = true)
public static Archive<?> deployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "container-startup-test.jar");
    archive.addClasses(PasswordEncoder.class, Base64Encoder.class);
    archive.addPackage(CommandSupport.class.getPackage());
    archive.setManifest(new Asset() {

        @Override
        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleManifestVersion(2);
            builder.addBundleSymbolicName(archive.getName());
            builder.addBundleVersion("1.0.0");
            builder.addImportPackages(ServiceLocator.class, FabricService.class);
            builder.addImportPackages("io.fabric8.git");
            builder.addImportPackages(ConfigurationAdmin.class, ServiceTracker.class, Logger.class);
            return builder.openStream();
        }
    });
    return archive;
}
Also used : ServiceLocator(io.fabric8.api.gravia.ServiceLocator) ServiceTracker(org.osgi.util.tracker.ServiceTracker) InputStream(java.io.InputStream) FabricService(io.fabric8.api.FabricService) OSGiManifestBuilder(org.jboss.osgi.metadata.OSGiManifestBuilder) Asset(org.jboss.shrinkwrap.api.asset.Asset) Logger(org.slf4j.Logger) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) CommandSupport(io.fabric8.itests.support.CommandSupport) StartLevelAware(org.jboss.arquillian.osgi.StartLevelAware) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 74 with io.fabric8.kubernetes.api.model

use of io.fabric8.kubernetes.api.model in project fabric8 by jboss-fuse.

the class ContainerStartupTest method testLocalFabricCluster.

@Test
public void testLocalFabricCluster() throws Exception {
    Builder<?> builder = CreateEnsembleOptions.builder().agentEnabled(false).clean(true).zookeeperPassword(ADMIN_PASSWORD).waitForProvision(false);
    CreateEnsembleOptions options = builder.build();
    ZooKeeperClusterBootstrap bootstrap = ServiceLocator.getRequiredService(ZooKeeperClusterBootstrap.class);
    bootstrap.create(options);
    FabricService fabricService = ServiceLocator.getRequiredService(FabricService.class);
    Container[] containers = fabricService.getContainers();
    Assert.assertNotNull("Containers not null", containers);
    // Test that a provided default password exists
    ConfigurationAdmin configurationAdmin = ServiceLocator.getRequiredService(ConfigurationAdmin.class);
    org.osgi.service.cm.Configuration configuration = configurationAdmin.getConfiguration(io.fabric8.api.Constants.ZOOKEEPER_CLIENT_PID);
    Dictionary<String, Object> dictionary = configuration.getProperties();
    Assert.assertEquals("Expected provided zookeeper password", PasswordEncoder.encode(ADMIN_PASSWORD), dictionary.get("zookeeper.password"));
}
Also used : ZooKeeperClusterBootstrap(io.fabric8.api.ZooKeeperClusterBootstrap) CreateEnsembleOptions(io.fabric8.api.CreateEnsembleOptions) Container(io.fabric8.api.Container) FabricService(io.fabric8.api.FabricService) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) Test(org.junit.Test)

Example 75 with io.fabric8.kubernetes.api.model

use of io.fabric8.kubernetes.api.model in project fabric8 by jboss-fuse.

the class FabricCreateCommandTest method deployment.

@Deployment
@StartLevelAware(autostart = true)
public static Archive<?> deployment() {
    final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "create-command-test.jar");
    archive.addClasses(PasswordEncoder.class, Base64Encoder.class);
    archive.addPackage(CommandSupport.class.getPackage());
    archive.setManifest(new Asset() {

        @Override
        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleManifestVersion(2);
            builder.addBundleSymbolicName(archive.getName());
            builder.addBundleVersion("1.0.0");
            builder.addImportPackages(ServiceLocator.class, FabricService.class);
            builder.addImportPackages("io.fabric8.git");
            builder.addImportPackages(AbstractCommand.class, Action.class);
            builder.addImportPackage("org.apache.felix.service.command;status=provisional");
            builder.addImportPackages(ConfigurationAdmin.class, ServiceTracker.class, Logger.class);
            return builder.openStream();
        }
    });
    return archive;
}
Also used : Action(org.apache.felix.gogo.commands.Action) ServiceTracker(org.osgi.util.tracker.ServiceTracker) InputStream(java.io.InputStream) AbstractCommand(org.apache.felix.gogo.commands.basic.AbstractCommand) Logger(org.slf4j.Logger) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) ServiceLocator(io.fabric8.api.gravia.ServiceLocator) FabricService(io.fabric8.api.FabricService) OSGiManifestBuilder(org.jboss.osgi.metadata.OSGiManifestBuilder) Asset(org.jboss.shrinkwrap.api.asset.Asset) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) CommandSupport(io.fabric8.itests.support.CommandSupport) StartLevelAware(org.jboss.arquillian.osgi.StartLevelAware) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Aggregations

Test (org.junit.Test)29 FabricService (io.fabric8.api.FabricService)26 File (java.io.File)22 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)18 InputStream (java.io.InputStream)16 Logger (org.slf4j.Logger)16 ServiceLocator (io.fabric8.api.gravia.ServiceLocator)15 CommandSupport (io.fabric8.itests.support.CommandSupport)15 Deployment (org.jboss.arquillian.container.test.api.Deployment)15 StartLevelAware (org.jboss.arquillian.osgi.StartLevelAware)15 OSGiManifestBuilder (org.jboss.osgi.metadata.OSGiManifestBuilder)15 Asset (org.jboss.shrinkwrap.api.asset.Asset)15 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)15 ServiceTracker (org.osgi.util.tracker.ServiceTracker)15 IOException (java.io.IOException)14 Action (org.apache.felix.gogo.commands.Action)14 AbstractCommand (org.apache.felix.gogo.commands.basic.AbstractCommand)14 MavenResolver (io.fabric8.maven.MavenResolver)11 Container (io.fabric8.api.Container)10 BundleContext (org.osgi.framework.BundleContext)9