mirror of https://github.com/apache/jclouds.git
Merge branch 'vapp-live-tests' of https://github.com/grkvlt/jclouds
* 'vapp-live-tests' of https://github.com/grkvlt/jclouds: Fix VApp instantiation failure Refactor clients to be more consistent Comments for media types
This commit is contained in:
commit
ff00374d4d
|
@ -32,12 +32,17 @@ import com.google.common.collect.ImmutableList;
|
||||||
*/
|
*/
|
||||||
public class VCloudDirectorMediaType {
|
public class VCloudDirectorMediaType {
|
||||||
|
|
||||||
|
// Wildcarded media types
|
||||||
|
|
||||||
public static final String ANY = "*/*";
|
public static final String ANY = "*/*";
|
||||||
|
|
||||||
public static final String ANY_IMAGE = "image/*";
|
public static final String ANY_IMAGE = "image/*";
|
||||||
|
|
||||||
|
/** The default {@literal Accept} header for the vCloud API. */
|
||||||
public static final String APPLICATION_XML_1_5 = "application/*+xml;version=1.5";
|
public static final String APPLICATION_XML_1_5 = "application/*+xml;version=1.5";
|
||||||
|
|
||||||
|
// Specific media types
|
||||||
|
|
||||||
public static final String SESSION = "application/vnd.vmware.vcloud.session+xml";
|
public static final String SESSION = "application/vnd.vmware.vcloud.session+xml";
|
||||||
|
|
||||||
public static final String ERROR = "application/vnd.vmware.vcloud.error+xml";
|
public static final String ERROR = "application/vnd.vmware.vcloud.error+xml";
|
||||||
|
@ -188,14 +193,15 @@ public class VCloudDirectorMediaType {
|
||||||
|
|
||||||
public static final String OVF_TEXT_XML = "text/xml";
|
public static final String OVF_TEXT_XML = "text/xml";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All acceptable OVF-specific media types.
|
||||||
|
*/
|
||||||
public static final List<String> ALL_OVF = ImmutableList.of(
|
public static final List<String> ALL_OVF = ImmutableList.of(
|
||||||
OVF_TEXT_XML
|
OVF_TEXT_XML
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All acceptable vcloud-specific media types.
|
* All acceptable vCloud-specific media types.
|
||||||
*
|
|
||||||
* This list must be updated whenever a new media type constant is added.
|
|
||||||
*/
|
*/
|
||||||
public static final List<String> ALL = ImmutableList.of(
|
public static final List<String> ALL = ImmutableList.of(
|
||||||
SESSION, ERROR, ORG_LIST, METADATA, METADATA_ENTRY, METADATA_VALUE,
|
SESSION, ERROR, ORG_LIST, METADATA, METADATA_ENTRY, METADATA_VALUE,
|
||||||
|
@ -215,7 +221,10 @@ public class VCloudDirectorMediaType {
|
||||||
ORG_LEASE_SETTINGS, ORG_PASSWORD_POLICY_SETTINGS, ORG_LDAP_SETTINGS,
|
ORG_LEASE_SETTINGS, ORG_PASSWORD_POLICY_SETTINGS, ORG_LDAP_SETTINGS,
|
||||||
ORG_GENERAL_SETTINGS, ORG_EMAIL_SETTINGS, ORG_SETTINGS, ADMIN_NETWORK,
|
ORG_GENERAL_SETTINGS, ORG_EMAIL_SETTINGS, ORG_SETTINGS, ADMIN_NETWORK,
|
||||||
ADMIN_ORG_NETWORK, USER, ROLE, DEPLOY_VAPP_PARAMS, RECOMPOSE_VAPP_PARAMS,
|
ADMIN_ORG_NETWORK, USER, ROLE, DEPLOY_VAPP_PARAMS, RECOMPOSE_VAPP_PARAMS,
|
||||||
RELOCATE_VM_PARAMS, UNDEPLOY_VAPP_PARAMS, ADMIN_VDC, MEDIA_PARAMS, RUNTIME_INFO_SECTION,
|
RELOCATE_VM_PARAMS, UNDEPLOY_VAPP_PARAMS, ADMIN_VDC, MEDIA_PARAMS,
|
||||||
SCREEN_TICKET, VAPP_NETWORK
|
RUNTIME_INFO_SECTION, SCREEN_TICKET, VAPP_NETWORK
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// NOTE These lists must be updated whenever a new media type constant is added.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ public abstract class AbstractVAppType extends ResourceEntityType {
|
||||||
return new ConcreteBuilder();
|
return new ConcreteBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Builder<?> toBuilder() {
|
public Builder<?> toBuilder() {
|
||||||
return builder().fromResourceEntityType(this);
|
return builder().fromResourceEntityType(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class CustomizationSection extends SectionType {
|
||||||
// For JAXB
|
// For JAXB
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement(name = "CustomizeOnInstantiate")
|
@XmlElement(name = "CustomizeOnInstantiate", required = true)
|
||||||
protected boolean customizeOnInstantiate;
|
protected boolean customizeOnInstantiate;
|
||||||
@XmlElement(name = "Link")
|
@XmlElement(name = "Link")
|
||||||
protected Set<Link> links = Sets.newLinkedHashSet();
|
protected Set<Link> links = Sets.newLinkedHashSet();
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ import com.google.common.base.Objects.ToStringHelper;
|
||||||
@XmlSeeAlso({
|
@XmlSeeAlso({
|
||||||
CatalogReference.class
|
CatalogReference.class
|
||||||
})
|
})
|
||||||
//@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlType(name = "ReferenceType")
|
||||||
public class Reference {
|
public class Reference {
|
||||||
|
|
||||||
@javax.annotation.Resource
|
@javax.annotation.Resource
|
||||||
|
|
|
@ -53,6 +53,7 @@ public interface AdminOrgClient extends OrgClient {
|
||||||
* @param orgRef the reference for the admin org
|
* @param orgRef the reference for the admin org
|
||||||
* @return the admin org
|
* @return the admin org
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
AdminOrg getOrg(URI orgRef);
|
AdminOrg getOrg(URI orgRef);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -47,5 +47,6 @@ public interface AdminVdcAsyncClient extends VdcAsyncClient {
|
||||||
@Consumes
|
@Consumes
|
||||||
@JAXBResponseParser
|
@JAXBResponseParser
|
||||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
|
@Override
|
||||||
ListenableFuture<AdminVdc> getVdc(@EndpointParam URI vdcRef);
|
ListenableFuture<AdminVdc> getVdc(@EndpointParam URI vdcRef);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,5 +44,6 @@ public interface AdminVdcClient extends VdcClient {
|
||||||
*
|
*
|
||||||
* @return the admin vDC or null if not found
|
* @return the admin vDC or null if not found
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
AdminVdc getVdc(URI vdcRef);
|
AdminVdc getVdc(URI vdcRef);
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,7 +361,7 @@ public interface VAppAsyncClient {
|
||||||
@BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams);
|
@BinderParam(BindToXMLPayload.class) MediaInsertOrEjectParams mediaParams);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return asynchronous access to {@link Writable} features
|
* @return asynchronous access to {@link Metadata} features
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
MetadataAsyncClient.Writable getMetadataClient();
|
MetadataAsyncClient.Writable getMetadataClient();
|
||||||
|
|
|
@ -434,7 +434,7 @@ public interface VAppClient {
|
||||||
Task insertMedia(URI vAppURI, MediaInsertOrEjectParams mediaParams);
|
Task insertMedia(URI vAppURI, MediaInsertOrEjectParams mediaParams);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return synchronous access to {@link Metadata.Writeable} features
|
* @return synchronous access to {@link Metadata} features
|
||||||
*/
|
*/
|
||||||
@Delegate
|
@Delegate
|
||||||
MetadataClient.Writeable getMetadataClient();
|
MetadataClient.Writeable getMetadataClient();
|
||||||
|
|
|
@ -160,16 +160,32 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
assertNotNull(vAppTemplate, String.format(ENTITY_NON_NULL, VAPP_TEMPLATE));
|
assertNotNull(vAppTemplate, String.format(ENTITY_NON_NULL, VAPP_TEMPLATE));
|
||||||
|
|
||||||
// Delete the test-vapp VApp if present
|
// Delete the test-vapp VApp if present
|
||||||
Optional<Reference> testVApp = Iterables.tryFind(
|
Iterable<Reference> vApps = Iterables.filter(
|
||||||
vdc.getResourceEntities().getResourceEntities(),
|
vdc.getResourceEntities().getResourceEntities(),
|
||||||
Predicates.and(
|
Predicates.and(
|
||||||
ReferenceTypePredicates.<Reference>typeEquals(VCloudDirectorMediaType.VAPP),
|
ReferenceTypePredicates.<Reference>typeEquals(VCloudDirectorMediaType.VAPP),
|
||||||
ReferenceTypePredicates.<Reference>nameEquals("test-vapp")
|
Predicates.or(
|
||||||
|
ReferenceTypePredicates.<Reference>nameEquals("test-vapp"),
|
||||||
|
ReferenceTypePredicates.<Reference>nameEquals("new-name")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (testVApp.isPresent()) {
|
if (vApps != null && !Iterables.isEmpty(vApps)) {
|
||||||
Task deleteTestVApp = vAppClient.deleteVApp(testVApp.get().getHref());
|
for (Reference each : vApps) {
|
||||||
retryTaskSuccess.apply(deleteTestVApp);
|
VApp found = vAppClient.getVApp(each.getHref());
|
||||||
|
// debug(found);
|
||||||
|
if (found.getStatus().equals(Status.POWERED_ON.getValue())) {
|
||||||
|
Task shutdownTask = vAppClient.shutdown(found.getHref());
|
||||||
|
retryTaskSuccess.apply(shutdownTask);
|
||||||
|
}
|
||||||
|
if (found.isDeployed()) {
|
||||||
|
UndeployVAppParams params = UndeployVAppParams.builder().build();
|
||||||
|
Task undeployTask = vAppClient.undeploy(vApp.getHref(), params);
|
||||||
|
retryTaskSuccess.apply(undeployTask);
|
||||||
|
}
|
||||||
|
Task deleteTask = vAppClient.deleteVApp(found.getHref());
|
||||||
|
retryTaskSuccess.apply(deleteTask);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,21 +196,23 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
public void testGetVApp() {
|
public void testGetVApp() {
|
||||||
VApp vAppInstantiated = instantiateVApp();
|
VApp vAppInstantiated = instantiateVApp();
|
||||||
|
|
||||||
|
// Wait for the task to complete
|
||||||
|
Task instantiateTask = Iterables.getOnlyElement(vAppInstantiated.getTasks());
|
||||||
|
assertTrue(retryTaskSuccessLong.apply(instantiateTask), String.format(TASK_COMPLETE_TIMELY, "instantiateTask"));
|
||||||
|
|
||||||
// The method under test
|
// The method under test
|
||||||
vApp = vAppClient.getVApp(vAppInstantiated.getHref());
|
vApp = vAppClient.getVApp(vAppInstantiated.getHref());
|
||||||
|
|
||||||
// Check the retrieved object is well formed
|
// Check the retrieved object is well formed
|
||||||
checkVApp(vApp);
|
checkVApp(vApp);
|
||||||
|
|
||||||
// Check that task progress is increasing
|
// Check the required fields are set
|
||||||
Integer vAppProgress = Iterables.getOnlyElement(vApp.getTasks()).getProgress();
|
assertEquals(vApp.isDeployed(), Boolean.FALSE, String.format(OBJ_FIELD_EQ, VAPP, "deployed", "FALSE", vApp.isDeployed().toString()));
|
||||||
Integer vAppInstantiatedProgress = Iterables.getOnlyElement(vAppInstantiated.getTasks()).getProgress();
|
// TODO others
|
||||||
assertTrue(vAppProgress >= vAppInstantiatedProgress,
|
|
||||||
String.format(ENTITY_CONDITION, VAPP, "have an increasing value in the Progress field", String.format("%d < %d", vAppProgress, vAppInstantiatedProgress)));
|
|
||||||
|
|
||||||
// Cheat and copy the VApp with the progress of the instantiate task modified for equality testing
|
// Check status
|
||||||
VApp vAppCopy = vApp.toBuilder().tasks(ImmutableSet.of(Iterables.getOnlyElement(vApp.getTasks()).toBuilder().progress(vAppInstantiatedProgress).build())).build();
|
Status poweredOffStatus = Status.POWERED_OFF;
|
||||||
assertEquals(vAppCopy, vAppInstantiated, String.format(ENTITY_EQUAL, VAPP));
|
assertEquals(vApp.getStatus(), poweredOffStatus.getValue(), String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOffStatus.toString(), Status.fromValue(vApp.getStatus()).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -211,7 +229,10 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
Task modifyVApp = vAppClient.modifyVApp(vApp.getHref(), newVApp);
|
Task modifyVApp = vAppClient.modifyVApp(vApp.getHref(), newVApp);
|
||||||
assertTrue(retryTaskSuccess.apply(modifyVApp), String.format(TASK_COMPLETE_TIMELY, "modifyVApp"));
|
assertTrue(retryTaskSuccess.apply(modifyVApp), String.format(TASK_COMPLETE_TIMELY, "modifyVApp"));
|
||||||
|
|
||||||
|
// Get the updated VApp
|
||||||
vApp = vAppClient.getVApp(vApp.getHref());
|
vApp = vAppClient.getVApp(vApp.getHref());
|
||||||
|
|
||||||
|
// Check the required fields are set
|
||||||
assertEquals(vApp.getName(), newVApp.getName(), String.format(OBJ_FIELD_EQ, VAPP, "Name", newVApp.getName(), vApp.getName()));
|
assertEquals(vApp.getName(), newVApp.getName(), String.format(OBJ_FIELD_EQ, VAPP, "Name", newVApp.getName(), vApp.getName()));
|
||||||
assertEquals(vApp.getDescription(), newVApp.getDescription(), String.format(OBJ_FIELD_EQ, VAPP, "Description", newVApp.getDescription(), vApp.getDescription()));
|
assertEquals(vApp.getDescription(), newVApp.getDescription(), String.format(OBJ_FIELD_EQ, VAPP, "Description", newVApp.getDescription(), vApp.getDescription()));
|
||||||
}
|
}
|
||||||
|
@ -220,17 +241,23 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
public void testDeployVApp() {
|
public void testDeployVApp() {
|
||||||
DeployVAppParams params = DeployVAppParams.builder()
|
DeployVAppParams params = DeployVAppParams.builder()
|
||||||
.deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS))
|
.deploymentLeaseSeconds((int) TimeUnit.SECONDS.convert(1L, TimeUnit.HOURS))
|
||||||
.forceCustomization()
|
.notForceCustomization()
|
||||||
.notPowerOn()
|
.notPowerOn()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// The method under test
|
// The method under test
|
||||||
Task deployVApp = vAppClient.deploy(vApp.getHref(), params);
|
Task deployVApp = vAppClient.deploy(vApp.getHref(), params);
|
||||||
assertTrue(retryTaskSuccess.apply(deployVApp), String.format(TASK_COMPLETE_TIMELY, "deployVApp"));
|
assertTrue(retryTaskSuccessLong.apply(deployVApp), String.format(TASK_COMPLETE_TIMELY, "deployVApp"));
|
||||||
|
|
||||||
|
// Get the updated VApp
|
||||||
vApp = vAppClient.getVApp(vApp.getHref());
|
vApp = vAppClient.getVApp(vApp.getHref());
|
||||||
Integer deployedStatus = Status.DEPLOYED.getValue();
|
|
||||||
assertEquals(vApp.getStatus(), deployedStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", deployedStatus, vApp.getStatus()));
|
// Check the required fields are set
|
||||||
|
assertEquals(vApp.isDeployed(), Boolean.TRUE, String.format(OBJ_FIELD_EQ, VAPP, "deployed", "TRUE", vApp.isDeployed().toString()));
|
||||||
|
|
||||||
|
// Check status
|
||||||
|
Status deployedStatus = Status.POWERED_OFF;
|
||||||
|
assertEquals(vApp.getStatus(), deployedStatus.getValue(), String.format(OBJ_FIELD_EQ, VAPP, "status", deployedStatus.toString(), Status.fromValue(vApp.getStatus()).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(testName = "POST /vApp/{id}/power/action/powerOn", dependsOnMethods = { "testDeployVApp" })
|
@Test(testName = "POST /vApp/{id}/power/action/powerOn", dependsOnMethods = { "testDeployVApp" })
|
||||||
|
@ -239,9 +266,84 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
Task powerOnVApp = vAppClient.powerOn(vApp.getHref());
|
Task powerOnVApp = vAppClient.powerOn(vApp.getHref());
|
||||||
assertTrue(retryTaskSuccess.apply(powerOnVApp), String.format(TASK_COMPLETE_TIMELY, "powerOnVApp"));
|
assertTrue(retryTaskSuccess.apply(powerOnVApp), String.format(TASK_COMPLETE_TIMELY, "powerOnVApp"));
|
||||||
|
|
||||||
|
// Get the updated VApp
|
||||||
vApp = vAppClient.getVApp(vApp.getHref());
|
vApp = vAppClient.getVApp(vApp.getHref());
|
||||||
Integer poweredOnStatus = Status.POWERED_ON.getValue();
|
|
||||||
assertEquals(vApp.getStatus(), poweredOnStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOnStatus, vApp.getStatus()));
|
// Check status
|
||||||
|
Status poweredOnStatus = Status.POWERED_ON;
|
||||||
|
assertEquals(vApp.getStatus(), poweredOnStatus.getValue(), String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOnStatus.toString(), Status.fromValue(vApp.getStatus()).toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(testName = "POST /vApp/{id}/power/action/reboot", dependsOnMethods = { "testPowerOnVApp" })
|
||||||
|
public void testReboot() {
|
||||||
|
// The method under test
|
||||||
|
Task reboot = vAppClient.reboot(vApp.getHref());
|
||||||
|
assertTrue(retryTaskSuccess.apply(reboot), String.format(TASK_COMPLETE_TIMELY, "reboot"));
|
||||||
|
|
||||||
|
// Get the updated VApp
|
||||||
|
vApp = vAppClient.getVApp(vApp.getHref());
|
||||||
|
|
||||||
|
// Check status
|
||||||
|
Status poweredOnStatus = Status.POWERED_ON;
|
||||||
|
assertEquals(vApp.getStatus(), poweredOnStatus.getValue(), String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOnStatus.toString(), Status.fromValue(vApp.getStatus()).toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(testName = "POST /vApp/{id}/power/action/shutdown", dependsOnMethods = { "testReboot" })
|
||||||
|
public void testShutdown() {
|
||||||
|
// The method under test
|
||||||
|
Task shutdown = vAppClient.shutdown(vApp.getHref());
|
||||||
|
assertTrue(retryTaskSuccess.apply(shutdown), String.format(TASK_COMPLETE_TIMELY, "shutdown"));
|
||||||
|
|
||||||
|
// Get the updated VApp
|
||||||
|
vApp = vAppClient.getVApp(vApp.getHref());
|
||||||
|
|
||||||
|
// Check status
|
||||||
|
Status poweredOnStatus = Status.POWERED_ON;
|
||||||
|
assertEquals(vApp.getStatus(), poweredOnStatus.getValue(), String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOnStatus.toString(), Status.fromValue(vApp.getStatus()).toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(testName = "POST /vApp/{id}/power/action/suspend", dependsOnMethods = { "testShutdown" })
|
||||||
|
public void testSuspend() {
|
||||||
|
// The method under test
|
||||||
|
Task suspend = vAppClient.suspend(vApp.getHref());
|
||||||
|
assertTrue(retryTaskSuccess.apply(suspend), String.format(TASK_COMPLETE_TIMELY, "suspend"));
|
||||||
|
|
||||||
|
// Get the updated VApp
|
||||||
|
vApp = vAppClient.getVApp(vApp.getHref());
|
||||||
|
|
||||||
|
// Check status
|
||||||
|
Status poweredOnStatus = Status.POWERED_ON;
|
||||||
|
assertEquals(vApp.getStatus(), poweredOnStatus.getValue(), String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOnStatus.toString(), Status.fromValue(vApp.getStatus()).toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(testName = "POST /vApp/{id}/power/action/reset", dependsOnMethods = { "testSuspend" })
|
||||||
|
public void testReset() {
|
||||||
|
// The method under test
|
||||||
|
Task reset = vAppClient.reset(vApp.getHref());
|
||||||
|
assertTrue(retryTaskSuccess.apply(reset), String.format(TASK_COMPLETE_TIMELY, "reset"));
|
||||||
|
|
||||||
|
// Get the updated VApp
|
||||||
|
vApp = vAppClient.getVApp(vApp.getHref());
|
||||||
|
|
||||||
|
// Check status
|
||||||
|
Status poweredOnStatus = Status.POWERED_ON;
|
||||||
|
assertEquals(vApp.getStatus(), poweredOnStatus.getValue(), String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOnStatus.toString(), Status.fromValue(vApp.getStatus()).toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(testName = "POST /vApp/{id}/action/undeploy", dependsOnMethods = { "testReset" })
|
||||||
|
public void testUndeployVApp() {
|
||||||
|
UndeployVAppParams params = UndeployVAppParams.builder().build();
|
||||||
|
|
||||||
|
// The method under test
|
||||||
|
Task undeploy = vAppClient.undeploy(vApp.getHref(), params);
|
||||||
|
assertTrue(retryTaskSuccess.apply(undeploy), String.format(TASK_COMPLETE_TIMELY, "undeploy"));
|
||||||
|
|
||||||
|
// Get the updated VApp
|
||||||
|
vApp = vAppClient.getVApp(vApp.getHref());
|
||||||
|
|
||||||
|
// Check status
|
||||||
|
Status poweredOnStatus = Status.POWERED_ON;
|
||||||
|
assertEquals(vApp.getStatus(), poweredOnStatus.getValue(), String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOnStatus.toString(), Status.fromValue(vApp.getStatus()).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(testName = "POST /vApp/{id}/power/action/powerOff", dependsOnMethods = { "testUndeployVApp" })
|
@Test(testName = "POST /vApp/{id}/power/action/powerOff", dependsOnMethods = { "testUndeployVApp" })
|
||||||
|
@ -250,12 +352,15 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
Task powerOffVApp = vAppClient.powerOff(vApp.getHref());
|
Task powerOffVApp = vAppClient.powerOff(vApp.getHref());
|
||||||
assertTrue(retryTaskSuccess.apply(powerOffVApp), String.format(TASK_COMPLETE_TIMELY, "powerOffVApp"));
|
assertTrue(retryTaskSuccess.apply(powerOffVApp), String.format(TASK_COMPLETE_TIMELY, "powerOffVApp"));
|
||||||
|
|
||||||
|
// Get the updated VApp
|
||||||
vApp = vAppClient.getVApp(vApp.getHref());
|
vApp = vAppClient.getVApp(vApp.getHref());
|
||||||
Integer poweredOffStatus = Status.POWERED_OFF.getValue();
|
|
||||||
assertEquals(vApp.getStatus(), poweredOffStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOffStatus, vApp.getStatus()));
|
// Check status
|
||||||
|
Status poweredOffStatus = Status.POWERED_OFF;
|
||||||
|
assertEquals(vApp.getStatus(), poweredOffStatus.getValue(), String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOffStatus.toString(), Status.fromValue(vApp.getStatus()).toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(testName = "POST /vApp/{id}/action/consolidate", dependsOnMethods = { "testGetVApp" })
|
@Test(testName = "POST /vApp/{id}/action/consolidate", dependsOnMethods = { "testPowerOnVApp" })
|
||||||
public void testConsolidateVApp() {
|
public void testConsolidateVApp() {
|
||||||
// The method under test
|
// The method under test
|
||||||
Task consolidateVApp = vAppClient.consolidateVApp(vApp.getHref());
|
Task consolidateVApp = vAppClient.consolidateVApp(vApp.getHref());
|
||||||
|
@ -293,7 +398,7 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
assertEquals(modified, params, String.format(ENTITY_EQUAL, "ControlAccessParams"));
|
assertEquals(modified, params, String.format(ENTITY_EQUAL, "ControlAccessParams"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(testName = "POST /vApp/{id}/action/discardSuspendedState", dependsOnMethods = { "testGetVApp" })
|
@Test(testName = "POST /vApp/{id}/action/discardSuspendedState", dependsOnMethods = { "testSuspend" })
|
||||||
public void testDiscardSuspendedState() {
|
public void testDiscardSuspendedState() {
|
||||||
// The method under test
|
// The method under test
|
||||||
Task discardSuspendedState = vAppClient.discardSuspendedState(vApp.getHref());
|
Task discardSuspendedState = vAppClient.discardSuspendedState(vApp.getHref());
|
||||||
|
@ -348,20 +453,6 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
assertTrue(retryTaskSuccess.apply(relocate), String.format(TASK_COMPLETE_TIMELY, "relocate"));
|
assertTrue(retryTaskSuccess.apply(relocate), String.format(TASK_COMPLETE_TIMELY, "relocate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(testName = "POST /vApp/{id}/action/undeploy", dependsOnMethods = { "testDeployVApp" })
|
|
||||||
public void testUndeployVApp() {
|
|
||||||
UndeployVAppParams params = UndeployVAppParams.builder()
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// The method under test
|
|
||||||
Task undeploy = vAppClient.undeploy(vApp.getHref(), params);
|
|
||||||
assertTrue(retryTaskSuccess.apply(undeploy), String.format(TASK_COMPLETE_TIMELY, "undeploy"));
|
|
||||||
|
|
||||||
vApp = vAppClient.getVApp(vApp.getHref());
|
|
||||||
Integer resolvedStatus = Status.RESOLVED.getValue();
|
|
||||||
assertEquals(vApp.getStatus(), resolvedStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", resolvedStatus, vApp.getStatus()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(testName = "POST /vApp/{id}/action/upgradeHardwareVersion", dependsOnMethods = { "testGetVApp" })
|
@Test(testName = "POST /vApp/{id}/action/upgradeHardwareVersion", dependsOnMethods = { "testGetVApp" })
|
||||||
public void testUpgradeHardwareVersion() {
|
public void testUpgradeHardwareVersion() {
|
||||||
// The method under test
|
// The method under test
|
||||||
|
@ -369,50 +460,6 @@ public class VAppClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
assertTrue(retryTaskSuccess.apply(upgradeHardwareVersion), String.format(TASK_COMPLETE_TIMELY, "upgradeHardwareVersion"));
|
assertTrue(retryTaskSuccess.apply(upgradeHardwareVersion), String.format(TASK_COMPLETE_TIMELY, "upgradeHardwareVersion"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(testName = "POST /vApp/{id}/power/action/reboot", dependsOnMethods = { "testGetVApp" })
|
|
||||||
public void testReboot() {
|
|
||||||
// The method under test
|
|
||||||
Task reboot = vAppClient.reboot(vApp.getHref());
|
|
||||||
assertTrue(retryTaskSuccess.apply(reboot), String.format(TASK_COMPLETE_TIMELY, "reboot"));
|
|
||||||
|
|
||||||
vApp = vAppClient.getVApp(vApp.getHref());
|
|
||||||
Integer poweredOnStatus = Status.POWERED_ON.getValue();
|
|
||||||
assertEquals(vApp.getStatus(), poweredOnStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOnStatus, "powered off"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(testName = "POST /vApp/{id}/power/action/reset", dependsOnMethods = { "testGetVApp" })
|
|
||||||
public void testReset() {
|
|
||||||
// The method under test
|
|
||||||
Task reset = vAppClient.reset(vApp.getHref());
|
|
||||||
assertTrue(retryTaskSuccess.apply(reset), String.format(TASK_COMPLETE_TIMELY, "reset"));
|
|
||||||
|
|
||||||
vApp = vAppClient.getVApp(vApp.getHref());
|
|
||||||
Integer poweredOffStatus = Status.POWERED_ON.getValue();
|
|
||||||
assertEquals(vApp.getStatus(), poweredOffStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOffStatus, "powered off"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(testName = "POST /vApp/{id}/power/action/shutdown", dependsOnMethods = { "testGetVApp" })
|
|
||||||
public void testShutdown() {
|
|
||||||
// The method under test
|
|
||||||
Task shutdown = vAppClient.shutdown(vApp.getHref());
|
|
||||||
assertTrue(retryTaskSuccess.apply(shutdown), String.format(TASK_COMPLETE_TIMELY, "shutdown"));
|
|
||||||
|
|
||||||
vApp = vAppClient.getVApp(vApp.getHref());
|
|
||||||
Integer poweredOffStatus = Status.POWERED_OFF.getValue();
|
|
||||||
assertEquals(vApp.getStatus(), poweredOffStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOffStatus, "powered off"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(testName = "POST /vApp/{id}/power/action/suspend", dependsOnMethods = { "testGetVApp" })
|
|
||||||
public void testSuspend() {
|
|
||||||
// The method under test
|
|
||||||
Task suspend = vAppClient.suspend(vApp.getHref());
|
|
||||||
assertTrue(retryTaskSuccess.apply(suspend), String.format(TASK_COMPLETE_TIMELY, "suspend"));
|
|
||||||
|
|
||||||
vApp = vAppClient.getVApp(vApp.getHref());
|
|
||||||
Integer poweredOffStatus = Status.POWERED_OFF.getValue();
|
|
||||||
assertEquals(vApp.getStatus(), poweredOffStatus, String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOffStatus, "powered off"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(testName = "GET /vApp/{id}/controlAccess", dependsOnMethods = { "testGetVApp" })
|
@Test(testName = "GET /vApp/{id}/controlAccess", dependsOnMethods = { "testGetVApp" })
|
||||||
public void testGetControlAccess() {
|
public void testGetControlAccess() {
|
||||||
// The method under test
|
// The method under test
|
||||||
|
|
|
@ -62,6 +62,9 @@ import com.google.inject.Module;
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServiceLiveTest {
|
public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
|
|
||||||
|
protected static final long TASK_TIMEOUT_SECONDS = 10L;
|
||||||
|
protected static final long LONG_TASK_TIMEOUT_SECONDS = 300L;
|
||||||
|
|
||||||
protected BaseVCloudDirectorClientLiveTest() {
|
protected BaseVCloudDirectorClientLiveTest() {
|
||||||
provider = "vcloud-director";
|
provider = "vcloud-director";
|
||||||
}
|
}
|
||||||
|
@ -70,10 +73,16 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
public abstract void setupRequiredClients();
|
public abstract void setupRequiredClients();
|
||||||
|
|
||||||
public Predicate<Task> retryTaskSuccess;
|
public Predicate<Task> retryTaskSuccess;
|
||||||
|
public Predicate<Task> retryTaskSuccessLong;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected void initTaskSuccess(TaskSuccess taskSuccess) {
|
protected void initTaskSuccess(TaskSuccess taskSuccess) {
|
||||||
retryTaskSuccess = new RetryablePredicate<Task>(taskSuccess, 1000L);
|
retryTaskSuccess = new RetryablePredicate<Task>(taskSuccess, TASK_TIMEOUT_SECONDS * 1000L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
protected void initTaskSuccessLong(TaskSuccess taskSuccess) {
|
||||||
|
retryTaskSuccessLong = new RetryablePredicate<Task>(taskSuccess, LONG_TASK_TIMEOUT_SECONDS * 1000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RestContext<VCloudDirectorClient, VCloudDirectorAsyncClient> context;
|
protected RestContext<VCloudDirectorClient, VCloudDirectorAsyncClient> context;
|
||||||
|
|
Loading…
Reference in New Issue