use of io.fabric8.agent.model.Feature 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();
}
}
use of io.fabric8.agent.model.Feature in project fabric8 by jboss-fuse.
the class ContainerUpgradeAndRollbackTest method testContainerUpgradeAndRollback.
/**
* This tests the simple scenario of
* 1. create a child container
* 2. create a new version
* 3. modify the profile of the new version
* 4. upgrade all containers
* 5. verify that child is provisioned according to the new version
* 6. rollback containers.
* 7. verify that the child is provisioned according to the old version.
*/
@Test
@SuppressWarnings("unchecked")
public void testContainerUpgradeAndRollback() throws Exception {
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();
Set<Container> containers = null;
try {
CommandSupport.executeCommand("fabric:version-create --parent 1.0 1.1");
// Make sure that the profile change has been applied before changing the version
CountDownLatch latch = WaitForConfigurationChange.on(fabricService);
CommandSupport.executeCommand("fabric:profile-edit --feature camel-script --feature camel-hazelcast feature-camel 1.1");
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
CommandSupport.executeCommand("fabric:profile-display --version 1.1 feature-camel");
containers = ContainerBuilder.create().withName("smoke_camel").withProfiles("feature-camel").assertProvisioningResult().build(fabricService);
CommandSupport.executeCommand("fabric:container-upgrade --all 1.1");
ProvisionSupport.provisioningSuccess(containers, ProvisionSupport.PROVISION_TIMEOUT);
CommandSupport.executeCommand("fabric:container-list");
for (Container container : containers) {
Assert.assertEquals("Container should have version 1.1", "1.1", container.getVersion().getId());
String bundles = CommandSupport.executeCommand("fabric:container-connect -u admin -p admin " + container.getId() + " osgi:list -t 0 -s | grep camel-hazelcast");
Assert.assertNotNull(bundles);
System.out.println(bundles);
Assert.assertFalse("Expected camel-hazelcast installed on container: " + container.getId(), bundles.isEmpty());
}
CommandSupport.executeCommand("fabric:container-rollback --all 1.0");
ProvisionSupport.provisioningSuccess(containers, ProvisionSupport.PROVISION_TIMEOUT);
CommandSupport.executeCommand("fabric:container-list");
for (Container container : containers) {
Assert.assertEquals("Container should have version 1.0", "1.0", container.getVersion().getId());
String bundles = CommandSupport.executeCommand("fabric:container-connect -u admin -p admin " + container.getId() + " osgi:list -t 0 -s | grep camel-hazelcast");
Assert.assertNotNull(bundles);
System.out.println(bundles);
Assert.assertTrue("Expected no camel-hazelcast installed on container: " + container.getId(), bundles.isEmpty());
}
} finally {
ContainerBuilder.stop(fabricService, containers);
}
} finally {
fabricProxy.close();
}
}
use of io.fabric8.agent.model.Feature in project fabric8-maven-plugin by fabric8io.
the class KarafHealthCheckEnricher method discoverKarafProbe.
//
// Karaf has a readiness/health URL exposed if the fabric8-karaf-check feature is installed.
//
private Probe discoverKarafProbe(String path, int initialDelay) {
for (Plugin plugin : this.getProject().getBuildPlugins()) {
if ("karaf-maven-plugin".equals(plugin.getArtifactId())) {
Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
if (configuration == null)
return null;
Xpp3Dom startupFeatures = configuration.getChild("startupFeatures");
if (startupFeatures == null)
return null;
for (Xpp3Dom feature : startupFeatures.getChildren("feature")) {
if ("fabric8-karaf-checks".equals(feature.getValue())) {
// TODO: handle the case where the user changes the default port
return new ProbeBuilder().withNewHttpGet().withNewPort(DEFAULT_HEALTH_CHECK_PORT).withPath(path).endHttpGet().withInitialDelaySeconds(initialDelay).build();
}
}
}
}
return null;
}
use of io.fabric8.agent.model.Feature in project fabric8 by fabric8io.
the class Java2SwaggerJsonMojo method execute.
public void execute() throws MojoExecutionException {
List<Class<?>> resourceClasses = loadResourceClasses();
List<Object> resourceObjects = new ArrayList<Object>();
for (Class<?> resourceClass : resourceClasses) {
try {
resourceObjects.add(resourceClass.newInstance());
} catch (InstantiationException e) {
throw new MojoExecutionException(e.getMessage(), e);
} catch (IllegalAccessException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
Thread.currentThread().setContextClassLoader(getClassLoader());
List<Feature> features = new ArrayList<Feature>();
features.add(new SwaggerFeature());
JAXRSServerFactoryBean serverFacBean = new JAXRSServerFactoryBean();
serverFacBean.setAddress(address);
serverFacBean.setServiceBeans(resourceObjects);
serverFacBean.setFeatures(features);
Server server = serverFacBean.create();
InputStream in = null;
try {
String serverAddress = server.getEndpoint().getEndpointInfo().getAddress();
String apiDocs = serverAddress + "/swagger.json";
URL url = new URL(apiDocs);
in = url.openStream();
String res = getStringFromInputStream(in);
generateJson(resourceClasses, res);
} catch (Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
} finally {
server.stop();
}
}
Aggregations