Fix VApp instantiation failure

This commit is contained in:
Andrew Donald Kennedy 2012-03-15 18:16:51 +00:00
parent 5bb34f4599
commit 3420a1794c
6 changed files with 154 additions and 96 deletions

View File

@ -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);
} }

View File

@ -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

View File

@ -60,21 +60,21 @@ public interface QueryAsyncClient {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> queryAll(@QueryParam("type") String type); ListenableFuture<QueryResultRecords> queryAll(@QueryParam("type") String type);
@GET @GET
@Path("/query") @Path("/query")
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> query(@QueryParam("type") String type, @QueryParam("filter") String filter); ListenableFuture<QueryResultRecords> query(@QueryParam("type") String type, @QueryParam("filter") String filter);
@GET @GET
@Path("/query") @Path("/query")
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> query(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize, ListenableFuture<QueryResultRecords> query(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize,
@QueryParam("format") String format, @QueryParam("type") String type, @QueryParam("filter") String filter); @QueryParam("format") String format, @QueryParam("type") String type, @QueryParam("filter") String filter);
/** /**
@ -85,21 +85,21 @@ public interface QueryAsyncClient {
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> catalogsQueryAll(); ListenableFuture<QueryResultRecords> catalogsQueryAll();
@GET @GET
@Path("/catalogs/query") @Path("/catalogs/query")
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> catalogsQuery(@QueryParam("filter") String filter); ListenableFuture<QueryResultRecords> catalogsQuery(@QueryParam("filter") String filter);
@GET @GET
@Path("/catalogs/query") @Path("/catalogs/query")
@Consumes @Consumes
@JAXBResponseParser @JAXBResponseParser
@ExceptionParser(ThrowVCloudErrorOn4xx.class) @ExceptionParser(ThrowVCloudErrorOn4xx.class)
ListenableFuture<QueryResultRecords<?>> catalogsQuery(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize, ListenableFuture<QueryResultRecords> catalogsQuery(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize,
@QueryParam("filter") String filter); @QueryParam("filter") String filter);
@GET @GET

View File

@ -43,11 +43,11 @@ public interface QueryClient {
*/ */
QueryList queryList(); QueryList queryList();
QueryResultRecords<?> queryAll(String type); QueryResultRecords queryAll(String type);
QueryResultRecords<?> query(String type, String filter); QueryResultRecords query(String type, String filter);
QueryResultRecords<?> query(Integer page, Integer pageSize, String format, String type, String filter); QueryResultRecords query(Integer page, Integer pageSize, String format, String type, String filter);
/** /**
* Retrieves a list of Catalogs by using REST API general QueryHandler. * Retrieves a list of Catalogs by using REST API general QueryHandler.
@ -60,11 +60,11 @@ public interface QueryClient {
* GET /catalogs/query * GET /catalogs/query
* </pre> * </pre>
*/ */
QueryResultRecords<?> catalogsQueryAll(); QueryResultRecords catalogsQueryAll();
QueryResultRecords<?> catalogsQuery(String filter); QueryResultRecords catalogsQuery(String filter);
QueryResultRecords<?> catalogsQuery(Integer page, Integer pageSize, String filter); QueryResultRecords catalogsQuery(Integer page, Integer pageSize, String filter);
CatalogReferences catalogReferencesQueryAll(); CatalogReferences catalogReferencesQueryAll();

View File

@ -149,16 +149,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);
}
} }
} }
@ -169,21 +185,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()));
} }
/** /**
@ -200,7 +218,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()));
} }
@ -209,17 +230,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" })
@ -228,9 +255,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" })
@ -239,12 +341,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());
@ -282,7 +387,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());
@ -337,20 +442,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
@ -358,50 +449,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

View File

@ -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;