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();
}
}
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);
}
}
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;
}
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"));
}
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;
}
Aggregations