mirror of https://github.com/apache/jclouds.git
stabilizing vcloud tests
This commit is contained in:
parent
232b58203f
commit
0dfecb0a47
|
@ -99,10 +99,12 @@ import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
import static com.google.common.base.Predicates.*;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.base.Suppliers;
|
import static com.google.common.base.Suppliers.*;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableMap.Builder;
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
|
import static com.google.common.collect.Iterables.*;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
@ -197,7 +199,7 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
@Singleton
|
@Singleton
|
||||||
@org.jclouds.vcloud.endpoints.VDC
|
@org.jclouds.vcloud.endpoints.VDC
|
||||||
protected Supplier<Map<String, String>> provideVDCtoORG(Supplier<Map<String, ? extends Org>> orgNameToOrgSuppier) {
|
protected Supplier<Map<String, String>> provideVDCtoORG(Supplier<Map<String, ? extends Org>> orgNameToOrgSuppier) {
|
||||||
return Suppliers.compose(new Function<Map<String, ? extends Org>, Map<String, String>>() {
|
return compose(new Function<Map<String, ? extends Org>, Map<String, String>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> apply(Map<String, ? extends Org> arg0) {
|
public Map<String, String> apply(Map<String, ? extends Org> arg0) {
|
||||||
|
@ -471,7 +473,7 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ? extends CatalogItem> apply(org.jclouds.vcloud.domain.Catalog from) {
|
public Map<String, ? extends CatalogItem> apply(org.jclouds.vcloud.domain.Catalog from) {
|
||||||
return uniqueIndex(allCatalogItemsInCatalog.apply(from), name);
|
return uniqueIndex(filter(allCatalogItemsInCatalog.apply(from), notNull()), name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.vcloud.features;
|
||||||
|
|
||||||
import static com.google.common.collect.Iterables.get;
|
import static com.google.common.collect.Iterables.get;
|
||||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||||
|
import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript;
|
||||||
import static org.jclouds.crypto.CryptoStreams.base64;
|
import static org.jclouds.crypto.CryptoStreams.base64;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
@ -28,7 +29,6 @@ import org.jclouds.compute.domain.ExecResponse;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.options.TemplateOptions;
|
import org.jclouds.compute.options.TemplateOptions;
|
||||||
import org.jclouds.net.IPSocket;
|
import org.jclouds.net.IPSocket;
|
||||||
import org.jclouds.ssh.SshClient;
|
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.jclouds.vcloud.VCloudMediaType;
|
import org.jclouds.vcloud.VCloudMediaType;
|
||||||
import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
|
import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
|
||||||
|
@ -104,6 +104,7 @@ public class VmClientLiveTest extends BaseVCloudClientLiveTest {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
TemplateOptions options = client.templateOptions();
|
TemplateOptions options = client.templateOptions();
|
||||||
|
options.blockOnPort(22, 180);
|
||||||
options.as(VCloudTemplateOptions.class).customizationScript(script);
|
options.as(VCloudTemplateOptions.class).customizationScript(script);
|
||||||
options.as(VCloudTemplateOptions.class).description(group);
|
options.as(VCloudTemplateOptions.class).description(group);
|
||||||
node = getOnlyElement(client.createNodesInGroup(group, 1, options));
|
node = getOnlyElement(client.createNodesInGroup(group, 1, options));
|
||||||
|
@ -116,21 +117,14 @@ public class VmClientLiveTest extends BaseVCloudClientLiveTest {
|
||||||
String apiOutput = vm.getGuestCustomizationSection().getCustomizationScript();
|
String apiOutput = vm.getGuestCustomizationSection().getCustomizationScript();
|
||||||
checkApiOutput(apiOutput);
|
checkApiOutput(apiOutput);
|
||||||
|
|
||||||
IPSocket socket = getSocket(node);
|
ExecResponse vmTools = client.runScriptOnNode(node.getId(), PARSE_VMTOOLSD,
|
||||||
|
wrapInInitScript(false).runAsRoot(false));
|
||||||
|
checkApiOutput(new String(base64(vmTools.getOutput().trim())));
|
||||||
|
|
||||||
System.out.printf("%s:%s@%s", node.getCredentials().identity, node.getCredentials().credential, socket);
|
ExecResponse foo = client.runScriptOnNode(node.getId(), "cat /root/foo.txt", wrapInInitScript(false)
|
||||||
assert socketTester.apply(socket) : socket;
|
.runAsRoot(false));
|
||||||
|
checkCustomizationOccurred(foo);
|
||||||
|
|
||||||
SshClient ssh = sshFactory.create(socket, node.getCredentials());
|
|
||||||
try {
|
|
||||||
ssh.connect();
|
|
||||||
ExecResponse vmTools = ssh.exec(PARSE_VMTOOLSD);
|
|
||||||
checkApiOutput(new String(base64(vmTools.getOutput().trim())));
|
|
||||||
checkCustomizationOccurred(ssh.exec("cat /root/foo.txt"));
|
|
||||||
} finally {
|
|
||||||
if (ssh != null)
|
|
||||||
ssh.disconnect();
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
if (node != null)
|
if (node != null)
|
||||||
client.destroyNode(node.getId());
|
client.destroyNode(node.getId());
|
||||||
|
|
|
@ -22,18 +22,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.compute.ComputeService;
|
import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
import org.jclouds.net.IPSocket;
|
|
||||||
import org.jclouds.predicates.InetSocketAddressConnect;
|
|
||||||
import org.jclouds.predicates.RetryablePredicate;
|
|
||||||
import org.jclouds.rest.RestContextFactory;
|
import org.jclouds.rest.RestContextFactory;
|
||||||
import org.jclouds.ssh.SshClient.Factory;
|
|
||||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||||
import org.jclouds.vcloud.VCloudClient;
|
import org.jclouds.vcloud.VCloudClient;
|
||||||
import org.testng.annotations.AfterGroups;
|
import org.testng.annotations.AfterGroups;
|
||||||
|
@ -42,7 +37,6 @@ import org.testng.annotations.BeforeGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Guice;
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,9 +55,6 @@ public abstract class BaseVCloudClientLiveTest {
|
||||||
protected String endpoint;
|
protected String endpoint;
|
||||||
protected String apiversion;
|
protected String apiversion;
|
||||||
|
|
||||||
protected RetryablePredicate<IPSocket> socketTester;
|
|
||||||
protected Factory sshFactory;
|
|
||||||
|
|
||||||
protected VCloudClient getVCloudApi() {
|
protected VCloudClient getVCloudApi() {
|
||||||
return VCloudClient.class.cast(client.getContext().getProviderSpecificContext().getApi());
|
return VCloudClient.class.cast(client.getContext().getProviderSpecificContext().getApi());
|
||||||
}
|
}
|
||||||
|
@ -95,9 +86,7 @@ public abstract class BaseVCloudClientLiveTest {
|
||||||
setupCredentials();
|
setupCredentials();
|
||||||
Properties overrides = setupProperties();
|
Properties overrides = setupProperties();
|
||||||
client = new ComputeServiceContextFactory().createContext(provider,
|
client = new ComputeServiceContextFactory().createContext(provider,
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getComputeService();
|
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides).getComputeService();
|
||||||
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 300, 1, TimeUnit.SECONDS);
|
|
||||||
sshFactory = Guice.createInjector(getSshModule()).getInstance(Factory.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Properties setupRestProperties() {
|
protected Properties setupRestProperties() {
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.stratogen.vcloud.mycloud.features;
|
package org.jclouds.stratogen.vcloud.mycloud.features;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.ExecResponse;
|
|
||||||
import org.jclouds.vcloud.features.VmClientLiveTest;
|
import org.jclouds.vcloud.features.VmClientLiveTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -34,14 +33,4 @@ public class StratoGenVCloudMyCloudVmClientLiveTest extends VmClientLiveTest {
|
||||||
provider = "stratogen-vcloud-mycloud";
|
provider = "stratogen-vcloud-mycloud";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void checkApiOutput(String apiOutput) {
|
|
||||||
checkApiOutput1_0_0(apiOutput);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void checkCustomizationOccurred(ExecResponse exec) {
|
|
||||||
// for some reason
|
|
||||||
assert exec.getOutput().equals("") : exec;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue