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.Predicate;
|
||||
import static com.google.common.base.Predicates.*;
|
||||
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.Builder;
|
||||
import static com.google.common.collect.Iterables.*;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
@ -197,7 +199,7 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
|||
@Singleton
|
||||
@org.jclouds.vcloud.endpoints.VDC
|
||||
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
|
||||
public Map<String, String> apply(Map<String, ? extends Org> arg0) {
|
||||
|
@ -471,7 +473,7 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
|
|||
|
||||
@Override
|
||||
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.getOnlyElement;
|
||||
import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript;
|
||||
import static org.jclouds.crypto.CryptoStreams.base64;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
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.options.TemplateOptions;
|
||||
import org.jclouds.net.IPSocket;
|
||||
import org.jclouds.ssh.SshClient;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.jclouds.vcloud.VCloudMediaType;
|
||||
import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
|
||||
|
@ -104,6 +104,7 @@ public class VmClientLiveTest extends BaseVCloudClientLiveTest {
|
|||
try {
|
||||
|
||||
TemplateOptions options = client.templateOptions();
|
||||
options.blockOnPort(22, 180);
|
||||
options.as(VCloudTemplateOptions.class).customizationScript(script);
|
||||
options.as(VCloudTemplateOptions.class).description(group);
|
||||
node = getOnlyElement(client.createNodesInGroup(group, 1, options));
|
||||
|
@ -116,21 +117,14 @@ public class VmClientLiveTest extends BaseVCloudClientLiveTest {
|
|||
String apiOutput = vm.getGuestCustomizationSection().getCustomizationScript();
|
||||
checkApiOutput(apiOutput);
|
||||
|
||||
IPSocket socket = getSocket(node);
|
||||
|
||||
System.out.printf("%s:%s@%s", node.getCredentials().identity, node.getCredentials().credential, socket);
|
||||
assert socketTester.apply(socket) : socket;
|
||||
|
||||
SshClient ssh = sshFactory.create(socket, node.getCredentials());
|
||||
try {
|
||||
ssh.connect();
|
||||
ExecResponse vmTools = ssh.exec(PARSE_VMTOOLSD);
|
||||
ExecResponse vmTools = client.runScriptOnNode(node.getId(), PARSE_VMTOOLSD,
|
||||
wrapInInitScript(false).runAsRoot(false));
|
||||
checkApiOutput(new String(base64(vmTools.getOutput().trim())));
|
||||
checkCustomizationOccurred(ssh.exec("cat /root/foo.txt"));
|
||||
} finally {
|
||||
if (ssh != null)
|
||||
ssh.disconnect();
|
||||
}
|
||||
|
||||
ExecResponse foo = client.runScriptOnNode(node.getId(), "cat /root/foo.txt", wrapInInitScript(false)
|
||||
.runAsRoot(false));
|
||||
checkCustomizationOccurred(foo);
|
||||
|
||||
} finally {
|
||||
if (node != null)
|
||||
client.destroyNode(node.getId());
|
||||
|
|
|
@ -22,18 +22,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.compute.ComputeService;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
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.ssh.SshClient.Factory;
|
||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||
import org.jclouds.vcloud.VCloudClient;
|
||||
import org.testng.annotations.AfterGroups;
|
||||
|
@ -42,7 +37,6 @@ import org.testng.annotations.BeforeGroups;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
|
@ -61,9 +55,6 @@ public abstract class BaseVCloudClientLiveTest {
|
|||
protected String endpoint;
|
||||
protected String apiversion;
|
||||
|
||||
protected RetryablePredicate<IPSocket> socketTester;
|
||||
protected Factory sshFactory;
|
||||
|
||||
protected VCloudClient getVCloudApi() {
|
||||
return VCloudClient.class.cast(client.getContext().getProviderSpecificContext().getApi());
|
||||
}
|
||||
|
@ -95,9 +86,7 @@ public abstract class BaseVCloudClientLiveTest {
|
|||
setupCredentials();
|
||||
Properties overrides = setupProperties();
|
||||
client = new ComputeServiceContextFactory().createContext(provider,
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule()), overrides).getComputeService();
|
||||
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 300, 1, TimeUnit.SECONDS);
|
||||
sshFactory = Guice.createInjector(getSshModule()).getInstance(Factory.class);
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides).getComputeService();
|
||||
}
|
||||
|
||||
protected Properties setupRestProperties() {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.stratogen.vcloud.mycloud.features;
|
||||
|
||||
import org.jclouds.compute.domain.ExecResponse;
|
||||
import org.jclouds.vcloud.features.VmClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -34,14 +33,4 @@ public class StratoGenVCloudMyCloudVmClientLiveTest extends VmClientLiveTest {
|
|||
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