use of io.fabric8.itests.paxexam.support.ContainerProxy in project fabric8 by jboss-fuse.
the class ContainerBuilder method buildInternal.
private Set<ContainerProxy> buildInternal(Collection<B> buildersList) {
Set<ContainerProxy> containers = new HashSet<ContainerProxy>();
BundleContext bundleContext = getBundleContext();
ServiceLocator.awaitService(getBundleContext(), FabricComplete.class);
synchronizeGitRepositories();
FabricService fabricService = fabricServiceServiceProxy.getService();
CompletionService<Set<ContainerProxy>> completionService = new ExecutorCompletionService<Set<ContainerProxy>>(executorService);
int tasks = 0;
for (B builder : buildersList) {
builder.profiles(profileNames);
if (!builder.isEnsembleServer()) {
builder.zookeeperUrl(fabricService.getZookeeperUrl());
CreateContainerBasicOptions options = builder.build();
ServiceLocator.awaitService(bundleContext, ContainerProvider.class, "(fabric.container.protocol=" + options.getProviderType() + ")", CREATE_TIMEOUT, TimeUnit.MILLISECONDS);
completionService.submit(new CreateContainerTask(fabricServiceServiceProxy, options));
tasks++;
}
}
try {
for (int i = 0; i < tasks; i++) {
Future<Set<ContainerProxy>> futureContainerSet = completionService.poll(CREATE_TIMEOUT, TimeUnit.MILLISECONDS);
Set<ContainerProxy> containerSet = futureContainerSet.get();
containers.addAll(containerSet);
}
try {
if (waitForProvisioning) {
Provision.containerStatus(containers, provisionTimeOut);
}
if (assertProvisioningResult) {
Provision.provisioningSuccess(containers, provisionTimeOut, ContainerCallback.DISPLAY_ALL);
}
} catch (Exception e) {
throw FabricException.launderThrowable(e);
}
} catch (Exception e) {
throw FabricException.launderThrowable(e);
}
return Collections.unmodifiableSet(containers);
}
use of io.fabric8.itests.paxexam.support.ContainerProxy in project fabric8 by jboss-fuse.
the class FabricMavenProxyTest method testUpload.
@Test
public void testUpload() throws Exception {
String featureLocation = System.getProperty("feature.location");
System.out.println("Testing with feature from:" + featureLocation);
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 {
Set<ContainerProxy> containers = ContainerBuilder.create(fabricProxy, 2).withName("maven").withProfiles("fabric").waitForProvisioning(10 * 60 * 1000L).assertProvisioningResult().build();
try {
List<String> uploadUrls = new ArrayList<String>();
ServiceProxy<CuratorFramework> curatorProxy = ServiceProxy.createServiceProxy(bundleContext, CuratorFramework.class);
try {
CuratorFramework curator = curatorProxy.getService();
List<String> children = ZooKeeperUtils.getChildren(curator, ZkPath.MAVEN_PROXY.getPath("upload"));
for (String child : children) {
String uploadeUrl = ZooKeeperUtils.getSubstitutedPath(curator, ZkPath.MAVEN_PROXY.getPath("upload") + "/" + child);
uploadUrls.add(uploadeUrl);
}
} finally {
curatorProxy.close();
}
// Pick a random maven proxy from the list.
Random random = new Random();
int index = random.nextInt(uploadUrls.size());
String targetUrl = uploadUrls.get(index);
String uploadUrl = targetUrl + "itest/itest/1.0/itest-1.0-features.xml";
System.out.println("Using URI: " + uploadUrl);
BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("admin", "admin"));
CloseableHttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(credentialsProvider).build();
HttpPut put = new HttpPut(uploadUrl);
NFileEntity entity = new NFileEntity(new File(featureLocation), ContentType.TEXT_XML);
put.setEntity(entity);
HttpResponse response = client.execute(put);
System.out.println("Response:" + response.getStatusLine());
Assert.assertTrue(response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 202);
System.out.println(executeCommand("fabric:profile-edit --repository mvn:itest/itest/1.0/xml/features default"));
System.out.println(executeCommand("fabric:profile-edit --feature example-cbr default"));
Provision.containerStatus(containers, PROVISION_TIMEOUT);
} finally {
ContainerBuilder.destroy(containers);
}
} finally {
fabricProxy.close();
}
}
use of io.fabric8.itests.paxexam.support.ContainerProxy in project fabric8 by jboss-fuse.
the class SshContainerBuilder method build.
/**
* Create the containers.
*/
@Override
public Set<ContainerProxy> build() {
BundleContext bundleContext = ContainerBuilder.getBundleContext();
if (getOptionsBuilder().getHost() == null || getOptionsBuilder().getHost().isEmpty()) {
FabricService fabricService = ServiceLocator.awaitService(bundleContext, FabricService.class);
getOptionsBuilder().zookeeperUrl(fabricService.getZookeeperUrl()).zookeeperPassword("admin").proxyUri(fabricService.getMavenRepoURI());
String hostProperty = System.getProperty(SSH_HOSTS_PROPERTY);
String userProperty = System.getProperty(SSH_USERS_PROPERTY);
String passwordProperty = System.getProperty(SSH_PASSWORD_PROPERTY);
String resolverProperty = System.getProperty(SSH_RESOLVER_PROPERTY, ZkDefs.DEFAULT_RESOLVER);
if (resolverProperty.isEmpty()) {
resolverProperty = ZkDefs.DEFAULT_RESOLVER;
}
String numberOfContainersProperty = System.getProperty(CONTAINER_NUMBER_PROPERTY, "1");
int numberOfContainers = Integer.parseInt(numberOfContainersProperty);
String[] hosts = null;
String[] usernames = null;
String[] passwords = null;
if (hostProperty != null && !hostProperty.isEmpty()) {
hosts = hostProperty.replaceAll(" ", "").split(",");
}
if (userProperty != null && !userProperty.isEmpty()) {
usernames = userProperty.replaceAll(" ", "").split(",");
}
if (passwordProperty != null && !passwordProperty.isEmpty()) {
passwords = passwordProperty.replaceAll(" ", "").split(",");
}
int numberOfHosts = hosts.length;
int containersPerHost = numberOfContainers > 1 ? numberOfContainers / numberOfHosts : 1;
List<CreateSshContainerOptions.Builder> optionsList = new ArrayList<CreateSshContainerOptions.Builder>();
for (int i = 0; i < hosts.length; i++) {
try {
CreateSshContainerOptions.Builder hostOpts = getOptionsBuilder().clone();
hostOpts.number(containersPerHost).host(hosts[i]);
if (hostOpts.getNumber() > 1) {
hostOpts.name(hostOpts.getName() + "-" + i + "-");
} else {
hostOpts.name(hostOpts.getName() + i);
}
hostOpts.resolver(resolverProperty);
if (usernames.length > i) {
hostOpts.setUsername(usernames[i]);
}
if (passwords.length > i) {
hostOpts.setPassword(passwords[i]);
}
optionsList.add(hostOpts);
} catch (CloneNotSupportedException e) {
throw FabricException.launderThrowable(e);
}
}
return super.build(optionsList);
} else {
return super.build();
}
}
use of io.fabric8.itests.paxexam.support.ContainerProxy in project fabric8 by jboss-fuse.
the class FabricDosgiCamelTest method testFeatureProvisioning.
@Test
public void testFeatureProvisioning() 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);
waitForFabricCommands();
Set<ContainerProxy> containers = ContainerBuilder.create(fabricProxy, 2).withName("dosgi").withProfiles("karaf").assertProvisioningResult().build();
try {
List<Container> containerList = new ArrayList<Container>(containers);
List<Container> dosgiProviderContainers = containerList.subList(0, containerList.size() / 2);
List<Container> dosgiCamelContainers = containerList.subList(containerList.size() / 2, containerList.size());
for (Container c : dosgiProviderContainers) {
setData(curator, ZkPath.CONTAINER_PROVISION_RESULT.getPath(c.getId()), "changing profile");
Profile p = c.getVersion().getRequiredProfile("example-dosgi-camel.provider");
c.setProfiles(new Profile[] { p });
}
for (Container c : dosgiCamelContainers) {
setData(curator, ZkPath.CONTAINER_PROVISION_RESULT.getPath(c.getId()), "changing profile");
Profile p = c.getVersion().getRequiredProfile("example-dosgi-camel.consumer");
c.setProfiles(new Profile[] { p });
}
Provision.provisioningSuccess(dosgiProviderContainers, PROVISION_TIMEOUT);
Provision.provisioningSuccess(dosgiCamelContainers, PROVISION_TIMEOUT);
Assert.assertTrue(Provision.waitForCondition(dosgiCamelContainers, new ContainerCondition() {
@Override
public Boolean checkConditionOnContainer(final Container c) {
String response = executeCommand("fabric:container-connect -u admin -p admin " + c.getId() + " log:display | grep \"Message from distributed service to\"");
System.out.println(executeCommand("fabric:container-connect -u admin -p admin " + c.getId() + " camel:route-info fabric-client"));
Assert.assertNotNull(response);
System.out.println(response);
String[] lines = response.split("\n");
// TODO: This assertion is very relaxed and guarantees nothing.
return lines.length >= 1;
}
}, 20000L));
} finally {
ContainerBuilder.destroy(containers);
}
} finally {
fabricProxy.close();
}
}
use of io.fabric8.itests.paxexam.support.ContainerProxy in project fabric8 by jboss-fuse.
the class CamelProfileLongTest 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();
CuratorFramework curator = fabricService.adapt(CuratorFramework.class);
Set<ContainerProxy> containers = ContainerBuilder.create(fabricProxy).withName("feautre-camel").withProfiles("default").assertProvisioningResult().build();
try {
prepareFeaturesForTesting(containers, "camel-blueprint", "feautre-camel", "camel-blueprint");
prepareFeaturesForTesting(containers, "camel-jms", "feautre-camel", "camel-jms");
prepareFeaturesForTesting(containers, "camel-http", "feautre-camel", "camel-http");
prepareFeaturesForTesting(containers, "camel-cxf", "feautre-camel", "camel-cxf");
prepareFeaturesForTesting(containers, "camel-cache", "feautre-camel", "camel-cache");
prepareFeaturesForTesting(containers, "camel-castor", "feautre-camel", "camel-castor");
prepareFeaturesForTesting(containers, "camel-http", "feautre-camel", "camel-http");
prepareFeaturesForTesting(containers, "camel-http4", "feautre-camel", "camel-http4");
prepareFeaturesForTesting(containers, "camel-mina", "feautre-camel", "camel-mina");
prepareFeaturesForTesting(containers, "camel-jetty", "feautre-camel", "camel-jetty");
prepareFeaturesForTesting(containers, "camel-servlet", "feautre-camel", "camel-servlet");
prepareFeaturesForTesting(containers, "camel-jms", "feautre-camel", "camel-jms");
prepareFeaturesForTesting(containers, "camel-jmx", "feautre-camel", "camel-jmx");
prepareFeaturesForTesting(containers, "camel-ahc", "feautre-camel", "camel-ahc");
prepareFeaturesForTesting(containers, "camel-amqp", "feautre-camel", "camel-amqp");
prepareFeaturesForTesting(containers, "camel-atom", "feautre-camel", "camel-atom");
prepareFeaturesForTesting(containers, "camel-aws", "feautre-camel", "camel-aws");
prepareFeaturesForTesting(containers, "camel-bam", "feautre-camel", "camel-bam");
prepareFeaturesForTesting(containers, "camel-bean-validator", "feautre-camel", "camel-bean-validator");
prepareFeaturesForTesting(containers, "camel-bindy", "feautre-camel", "camel-bindy");
prepareFeaturesForTesting(containers, "camel-cometd", "feautre-camel", "camel-cometd");
prepareFeaturesForTesting(containers, "camel-csv", "feautre-camel", "camel-csv");
prepareFeaturesForTesting(containers, "camel-dozer", "feautre-camel", "camel-dozer");
prepareFeaturesForTesting(containers, "camel-eventadmin", "feautre-camel", "camel-eventadmin");
prepareFeaturesForTesting(containers, "camel-exec", "feautre-camel", "camel-exec");
prepareFeaturesForTesting(containers, "camel-flatpack", "feautre-camel", "camel-flatpack");
prepareFeaturesForTesting(containers, "camel-freemarker", "feautre-camel", "camel-freemarker");
prepareFeaturesForTesting(containers, "camel-ftp", "feautre-camel", "camel-ftp");
prepareFeaturesForTesting(containers, "camel-guice", "feautre-camel", "camel-guice");
prepareFeaturesForTesting(containers, "camel-groovy", "feautre-camel", "camel-groovy");
prepareFeaturesForTesting(containers, "camel-hazelcast", "feautre-camel", "camel-hazelcast");
prepareFeaturesForTesting(containers, "camel-hawtdb", "feautre-camel", "camel-hawtdb");
prepareFeaturesForTesting(containers, "camel-hdfs", "feautre-camel", "camel-hdfs");
prepareFeaturesForTesting(containers, "camel-hl7", "feautre-camel", "camel-hl7");
prepareFeaturesForTesting(containers, "camel-ibatis", "feautre-camel", "camel-ibatis");
prepareFeaturesForTesting(containers, "camel-irc", "feautre-camel", "camel-irc");
prepareFeaturesForTesting(containers, "camel-jackson", "feautre-camel", "camel-jackson");
prepareFeaturesForTesting(containers, "camel-jasypt", "feautre-camel", "camel-jasypt");
prepareFeaturesForTesting(containers, "camel-jaxb", "feautre-camel", "camel-jaxb");
prepareFeaturesForTesting(containers, "camel-jclouds", "feautre-camel", "camel-jclouds");
prepareFeaturesForTesting(containers, "camel-jcr", "feautre-camel", "camel-jcr");
prepareFeaturesForTesting(containers, "camel-jing", "feautre-camel", "camel-jing");
prepareFeaturesForTesting(containers, "camel-jibx", "feautre-camel", "camel-jibx");
prepareFeaturesForTesting(containers, "camel-jdbc", "feautre-camel", "camel-jdbc");
prepareFeaturesForTesting(containers, "camel-josql", "feautre-camel", "camel-josql");
prepareFeaturesForTesting(containers, "camel-josql", "feautre-camel", "camel-josql");
prepareFeaturesForTesting(containers, "camel-jpa", "feautre-camel", "camel-jpa");
prepareFeaturesForTesting(containers, "camel-jxpath", "feautre-camel", "camel-jxpath");
prepareFeaturesForTesting(containers, "camel-juel", "feautre-camel", "camel-juel");
prepareFeaturesForTesting(containers, "camel-kestrel", "feautre-camel", "camel-kestrel");
prepareFeaturesForTesting(containers, "camel-krati", "feautre-camel", "camel-krati");
prepareFeaturesForTesting(containers, "camel-ldap", "feautre-camel", "camel-ldap");
prepareFeaturesForTesting(containers, "camel-lucene", "feautre-camel", "camel-lucene");
prepareFeaturesForTesting(containers, "camel-mail", "feautre-camel", "camel-mail");
prepareFeaturesForTesting(containers, "camel-msv", "feautre-camel", "camel-msv");
prepareFeaturesForTesting(containers, "camel-mvel", "feautre-camel", "camel-mvel");
prepareFeaturesForTesting(containers, "camel-mybatis", "feautre-camel", "camel-mybatis");
prepareFeaturesForTesting(containers, "camel-nagios", "feautre-camel", "camel-nagios");
prepareFeaturesForTesting(containers, "camel-netty", "feautre-camel", "camel-netty");
prepareFeaturesForTesting(containers, "camel-ognl", "feautre-camel", "camel-ognl");
prepareFeaturesForTesting(containers, "camel-paxlogging", "feautre-camel", "camel-paxlogging");
prepareFeaturesForTesting(containers, "camel-printer", "feautre-camel", "camel-printer");
prepareFeaturesForTesting(containers, "camel-protobuf", "feautre-camel", "camel-protobuf");
prepareFeaturesForTesting(containers, "camel-quartz", "feautre-camel", "camel-quartz");
prepareFeaturesForTesting(containers, "camel-quickfix", "feautre-camel", "camel-quickfix");
prepareFeaturesForTesting(containers, "camel-restlet", "feautre-camel", "camel-restlet");
prepareFeaturesForTesting(containers, "camel-rmi", "feautre-camel", "camel-rmi");
prepareFeaturesForTesting(containers, "camel-routebox", "feautre-camel", "camel-routebox");
prepareFeaturesForTesting(containers, "camel-ruby", "feautre-camel", "org.jruby.jruby");
prepareFeaturesForTesting(containers, "camel-rss", "feautre-camel", "camel-rss");
prepareFeaturesForTesting(containers, "camel-saxon", "feautre-camel", "camel-saxon");
prepareFeaturesForTesting(containers, "camel-scala", "feautre-camel", "camel-scala");
prepareFeaturesForTesting(containers, "camel-script", "feautre-camel", "camel-script");
prepareFeaturesForTesting(containers, "camel-sip", "feautre-camel", "camel-sip");
prepareFeaturesForTesting(containers, "camel-shiro", "feautre-camel", "camel-shiro");
prepareFeaturesForTesting(containers, "camel-smpp", "feautre-camel", "camel-smpp");
prepareFeaturesForTesting(containers, "camel-snmp", "feautre-camel", "camel-snmp");
prepareFeaturesForTesting(containers, "camel-soap", "feautre-camel", "camel-soap");
prepareFeaturesForTesting(containers, "camel-solr", "feautre-camel", "camel-solr");
prepareFeaturesForTesting(containers, "camel-spring-integration", "feautre-camel", "camel-spring-integration");
prepareFeaturesForTesting(containers, "camel-spring-javaconfig", "feautre-camel", "camel-spring-javaconfig");
prepareFeaturesForTesting(containers, "camel-spring-security", "feautre-camel", "camel-spring-security");
prepareFeaturesForTesting(containers, "camel-spring-ws", "feautre-camel", "camel-spring-ws");
prepareFeaturesForTesting(containers, "camel-sql", "feautre-camel", "camel-sql");
prepareFeaturesForTesting(containers, "camel-stax", "feautre-camel", "camel-stax");
prepareFeaturesForTesting(containers, "camel-stream", "feautre-camel", "camel-stream");
prepareFeaturesForTesting(containers, "camel-string-template", "feautre-camel", "org.apache.servicemix.bundles.stringtemplate");
prepareFeaturesForTesting(containers, "camel-syslog", "feautre-camel", "camel-syslog");
prepareFeaturesForTesting(containers, "camel-tagsoup", "feautre-camel", "camel-tagsoup");
prepareFeaturesForTesting(containers, "camel-velocity", "feautre-camel", "camel-velocity");
prepareFeaturesForTesting(containers, "camel-xmlbeans", "feautre-camel", "camel-xmlbeans");
prepareFeaturesForTesting(containers, "camel-xmlsecurity", "feautre-camel", "camel-xmlsecurity");
prepareFeaturesForTesting(containers, "camel-xmpp", "feautre-camel", "camel-xmpp");
prepareFeaturesForTesting(containers, "camel-xstream", "feautre-camel", "camel-xstream");
prepareFeaturesForTesting(containers, "camel-zookeeper", "feautre-camel", "camel-zookeeper");
// prepareFeaturesForTesting(containers, "camel-crypto", "feautre-camel", "camel-crypto");
// prepareFeaturesForTesting(containers, "camel-script camel-script-jruby", "feautre-camel", "camel-script-jruby");
// prepareFeaturesForTesting(containers, "camel-script camel-script-javascript", "feautre-camel", "camel-script-javascript");
// prepareFeaturesForTesting(containers, "camel-script camel-script-groovy", "feautre-camel", "camel-script-groovy");
assertFeatures(fabricService, curator);
} finally {
ContainerBuilder.destroy(containers);
}
} finally {
fabricProxy.close();
}
}
Aggregations