fixed tests for savvis

This commit is contained in:
Kedar Dave 2011-06-02 13:36:23 -05:00
parent 3fea56253e
commit 85fad8e3f7
6 changed files with 83 additions and 121 deletions

View File

@ -126,6 +126,7 @@
<goal>test</goal>
</goals>
<configuration>
<threadCount>1</threadCount>
<systemProperties>
<property>
<name>test.savvis-symphonyvpdc.endpoint</name>

View File

@ -55,7 +55,7 @@ public interface FirewallAsyncClient {
*/
@PUT
@XMLResponseParser(TaskHandler.class)
@Path("v{jclouds.api-version}/org/{billingSiteId}/vdc/{vpdcId}/FirewallService/")
@Path("v{jclouds.api-version}/org/{billingSiteId}/vdc/{vpdcId}/FirewallService")
@MapBinder(BindFirewallRuleToXmlPayload.class)
ListenableFuture<Task> addFirewallRule(
@PathParam("billingSiteId") @Nullable @ParamParser(DefaultOrgIfNull.class) String billingSiteId,
@ -66,7 +66,7 @@ public interface FirewallAsyncClient {
*/
@DELETE
@XMLResponseParser(TaskHandler.class)
@Path("v{jclouds.api-version}/org/{billingSiteId}/vdc/{vpdcId}/FirewallService/")
@Path("v{jclouds.api-version}/org/{billingSiteId}/vdc/{vpdcId}/FirewallService")
@MapBinder(BindFirewallRuleToXmlPayload.class)
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<Task> deleteFirewallRule(

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.jclouds.Constants;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
@ -79,6 +80,9 @@ public class BaseVPDCClientLiveTest {
overrides.setProperty(provider + ".endpoint", endpoint);
if (apiversion != null)
overrides.setProperty(provider + ".apiversion", apiversion);
// TODO savvis uses untrusted certificates, remove these once savvis fixes the issue
overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
return overrides;
}

View File

@ -151,9 +151,13 @@ public class BrowsingClientLiveTest extends BaseVPDCClientLiveTest {
String ip = Iterables.get(response.getNetworkConnectionSections(), 0).getIpAddress();
assert HostSpecifier.isValid(ip) : response;
if (InetAddresses2.isPrivateIPAddress(ip)) {
// get public ip
ip = Iterables.get(response.getNetworkConfigSections(), 0).getInternalToExternalNATRules().get(ip);
// could be null
if(ip != null){
assert HostSpecifier.isValid(ip) : response;
}
}
assert HostSpecifier.isValid(ip) : response;
}
}

View File

@ -52,9 +52,14 @@ public class FirewallClientLiveTest extends BaseVPDCClientLiveTest {
// the jclouds-wire.log
@Override
public boolean apply(Resource arg0) {
String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId,
if(restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId,
arg0.getId()).getName().equals("Oracle")){
return true;
}
return false;
/*String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId,
arg0.getId()).getDescription();
return description.indexOf(email) != -1;
return description.indexOf(email) != -1;*/
}
}).getId();
@ -66,7 +71,7 @@ public class FirewallClientLiveTest extends BaseVPDCClientLiveTest {
FirewallRule firewallRule = FirewallRule.builder().firewallType("SERVER_TIER_FIREWALL").isEnabled(true).source("internet")
.destination(networkTierName).port("10000").protocol("Tcp").policy("allow").description("Server Tier Firewall Rule").isLogged(false).build();
System.out.printf("adding firewall rule:%s %n", firewallRule.toString());
System.out.printf("adding firewall rule:%s in vpdc %s %n", firewallRule.toString(), vpdcId);
Task task = client.addFirewallRule(billingSiteId, vpdcId, firewallRule);
@ -87,9 +92,14 @@ public class FirewallClientLiveTest extends BaseVPDCClientLiveTest {
// the jclouds-wire.log
@Override
public boolean apply(Resource arg0) {
String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId,
if(restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId,
arg0.getId()).getName().equals("Oracle")){
return true;
}
return false;
/*String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId,
arg0.getId()).getDescription();
return description.indexOf(email) != -1;
return description.indexOf(email) != -1;*/
}
}).getId();
@ -101,7 +111,7 @@ public class FirewallClientLiveTest extends BaseVPDCClientLiveTest {
FirewallRule firewallRule = FirewallRule.builder().firewallType("SERVER_TIER_FIREWALL").isEnabled(true).source("internet")
.destination(networkTierName).port("10000").protocol("Tcp").policy("allow").description("Server Tier Firewall Rule").isLogged(false).build();
System.out.printf("deleting firewall rule:%s %n", firewallRule.toString());
System.out.printf("deleting firewall rule:%s in vpdc %s %n", firewallRule.toString(), vpdcId);
Task task = client.deleteFirewallRule(billingSiteId, vpdcId, firewallRule);

View File

@ -21,10 +21,11 @@ package org.jclouds.savvis.vpdc.features;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.testng.Assert.assertEquals;
import java.net.URI;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.jclouds.Constants;
import org.jclouds.cim.OSType;
import org.jclouds.compute.domain.CIMOperatingSystem;
import org.jclouds.compute.domain.ExecResponse;
@ -38,7 +39,6 @@ import org.jclouds.savvis.vpdc.domain.Task;
import org.jclouds.savvis.vpdc.domain.VDC;
import org.jclouds.savvis.vpdc.domain.VM;
import org.jclouds.savvis.vpdc.domain.VMSpec;
import org.jclouds.savvis.vpdc.domain.VM.Status;
import org.jclouds.savvis.vpdc.options.GetVMOptions;
import org.jclouds.savvis.vpdc.reference.VCloudMediaType;
import org.jclouds.ssh.SshClient;
@ -49,8 +49,8 @@ import org.testng.annotations.Test;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.ImmutableSet.Builder;
import com.google.common.collect.Iterables;
import com.google.common.net.HostSpecifier;
@Test(groups = "live")
@ -98,13 +98,8 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
.getName();
String name = prefix;
// delete any old VM
VDC vpdc = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId);
for (Resource resource : vpdc.getResourceEntities()) {
if (resource.getName().equals(prefix)) {
taskTester.apply(client.removeVMFromVDC(billingSiteId, vpdcId, resource.getId()).getId());
}
}
CIMOperatingSystem os = Iterables.find(restContext.getApi().listPredefinedOperatingSystems(),
new Predicate<CIMOperatingSystem>() {
@ -114,22 +109,30 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
}
});
System.out.printf("vpdcId %s, networkName %s, name %s, os %s%n", vpdcId, networkTierName, name, os);
System.out.printf("Creating vm - vpdcId %s, vpdcName %s, networkName %s, name %s, os %s%n", vpdcId, vpdc.getName(), networkTierName, name, os);
// TODO: determine the sizes available in the VDC, for example there's
// a minimum size of boot disk, and also a preset combination of cpu count vs ram
Task task = client.addVMIntoVDC(billingSiteId, vpdcId, VMSpec.builder().name(name).networkTierName(
networkTierName).operatingSystem(os).memoryInGig(2).addDataDrive("/data01", 25).build());
// make sure there's no error
assert task.getId() != null && task.getError() == null : task;
assert this.taskTester.apply(task.getId());
vm = restContext.getApi().getBrowsingClient().getVMInVDC(billingSiteId, vpdcId, task.getOwner().getId());
conditionallyCheckSSH();
// fetch the task again, in savvis, task.getOwner is populated with vApp after task has finished
task = restContext.getApi().getBrowsingClient().getTask(task.getId());
vm = restContext.getApi().getBrowsingClient().getVM(task.getOwner().getHref(), GetVMOptions.NONE);
assert vm.getHref() != null : vm;
// cannot ssh in savvis, as no public ip is assigned by default
// conditionallyCheckSSH();
}
public void testCreateMultipleVMs() throws Exception {
@Test
public void testZCreateMultipleVMs() throws Exception {
billingSiteId = restContext.getApi().getBrowsingClient().getOrg(null).getId();// default
vpdcId = Iterables.find(restContext.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(),
new Predicate<Resource>() {
@ -168,7 +171,7 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
// TODO: Savvis returns network names with a - instead of space on getNetworkInVDC call,
// fix this once savvis api starts returning correctly
System.out.printf("vpdcId %s, vpdcName %s, networkName %s, name %s, os %s%n", vpdcId, vpdc.getName(), networkTier
System.out.printf("Creating vm's - vpdcId %s, vpdcName %s, networkName %s, name %s, os %s%n", vpdcId, vpdc.getName(), networkTier
.getName().replace("-", " "), name, os);
Builder<VMSpec> vmSpecs = ImmutableSet.<VMSpec> builder();
@ -186,11 +189,21 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
for (Task task : tasks) {
// make sure there's no error
assert task.getId() != null && task.getError() == null : task;
assert this.taskTester.apply(task.getId());
// fetch the task again, in savvis, task.getOwner is populated with vApp after task has finished
task = restContext.getApi().getBrowsingClient().getTask(task.getId());
vm = restContext.getApi().getBrowsingClient().getVM(task.getOwner().getHref(), GetVMOptions.NONE);
assert vm.getHref() != null : vm;
}
}
/**
* disabled because it not currently supported by savvis. Planned for august release by savvis.
* @throws Exception
*/
@Test(enabled=false)
public void testCaptureVAppTemplate() throws Exception {
billingSiteId = restContext.getApi().getBrowsingClient().getOrg(null).getId();// default
vpdcId = Iterables.find(restContext.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(),
@ -229,9 +242,10 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
}
}
@Test(dependsOnMethods="testPowerOnVM")
public void testCloneVApp() throws Exception {
billingSiteId = restContext.getApi().getBrowsingClient().getOrg(null).getId();// default
vpdcId = Iterables.find(restContext.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(),
billingSiteId = restContext.getApi().getBrowsingClient().getOrg(null).getId();// default
vpdcId = Iterables.find(restContext.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(),
new Predicate<Resource>() {
// try to find the first VDC owned by the current user
@ -245,29 +259,22 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
}
}).getId();
VDC vpdc = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId);
String networkTierName = Iterables.get(vpdc.getAvailableNetworks(), 0).getId();
for (Resource vApp : Iterables.filter(vpdc.getResourceEntities(), new Predicate<Resource>() {
@Override
public boolean apply(Resource arg0) {
return VCloudMediaType.VAPP_XML.equals(arg0.getType());
}
})) {
System.out.printf("Cloning VApp - %s%n", vApp.getName());
Task task = client.cloneVApp(vApp.getHref(), "clonedvm", networkTierName);
// make sure there's no error
assert task.getId() != null && task.getError() == null : task;
assert this.taskTester.apply(task.getId());
}
String networkTierName = Iterables.get(
restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId).getAvailableNetworks(), 0)
.getId();
Task task = client.cloneVApp(vm.getHref(), "clonedvm", networkTierName);
// make sure there's no error
assert task.getId() != null && task.getError() == null : task;
assert this.taskTester.apply(task.getId());
// fetch the task again, in savvis, task.getOwner is populated with vApp after task has finished
task = restContext.getApi().getBrowsingClient().getTask(task.getId());
vm = restContext.getApi().getBrowsingClient().getVM(task.getOwner().getHref(), GetVMOptions.NONE);
assert vm.getHref() != null : vm;
}
private void conditionallyCheckSSH() {
@ -297,84 +304,20 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest {
}
}
@Test(enabled = false)
@Test(dependsOnMethods="testCreateVirtualMachine")
public void testPowerOffVM() throws Exception {
billingSiteId = restContext.getApi().getBrowsingClient().getOrg(null).getId();// default
vpdcId = Iterables.find(restContext.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(),
new Predicate<Resource>() {
// try to find the first VDC owned by the current user
// check here for what the email property might be, or in
// the jclouds-wire.log
@Override
public boolean apply(Resource arg0) {
String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId,
arg0.getId()).getDescription();
return description.indexOf(email) != -1;
}
}).getId();
VDC vpdc = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId);
URI vmURI = Iterables.find(vpdc.getResourceEntities(), new Predicate<Resource>() {
@Override
public boolean apply(Resource arg0) {
if (VCloudMediaType.VAPP_XML.equals(arg0.getType())) {
VM response1 = restContext.getApi().getBrowsingClient().getVM(arg0.getHref(), (GetVMOptions[]) null);
System.out.printf("powering off vm - %s%n", response1.getName());
if (response1.getStatus().equals(Status.ON)) {
return true;
}
}
return false;
}
}).getHref();
Task task = client.powerOffVM(vmURI);
Task task = client.powerOffVM(vm.getHref());
// make sure there's no error
assert task.getId() != null && task.getError() == null : task;
assert this.taskTester.apply(task.getId());
}
@Test(enabled = false)
@Test(dependsOnMethods="testPowerOffVM")
public void testPowerOnVM() throws Exception {
billingSiteId = restContext.getApi().getBrowsingClient().getOrg(null).getId();// default
vpdcId = Iterables.find(restContext.getApi().getBrowsingClient().getOrg(billingSiteId).getVDCs(),
new Predicate<Resource>() {
// try to find the first VDC owned by the current user
// check here for what the email property might be, or in
// the jclouds-wire.log
@Override
public boolean apply(Resource arg0) {
String description = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId,
arg0.getId()).getDescription();
return description.indexOf(email) != -1;
}
}).getId();
VDC vpdc = restContext.getApi().getBrowsingClient().getVDCInOrg(billingSiteId, vpdcId);
URI vmURI = Iterables.find(vpdc.getResourceEntities(), new Predicate<Resource>() {
@Override
public boolean apply(Resource arg0) {
if (VCloudMediaType.VAPP_XML.equals(arg0.getType())) {
VM response1 = restContext.getApi().getBrowsingClient().getVM(arg0.getHref(), (GetVMOptions[]) null);
System.out.printf("powering on vm - %s%n", response1.getName());
if (response1.getStatus().equals(Status.OFF)) {
return true;
}
}
return false;
}
}).getHref();
Task task = client.powerOnVM(vmURI);
Task task = client.powerOnVM(vm.getHref());
// make sure there's no error
assert task.getId() != null && task.getError() == null : task;