Merge pull request #497 from grkvlt/vapp-reorder

Issue 830: Fix VApp power and virtual hardware section tests
This commit is contained in:
Adrian Cole 2012-03-20 18:25:50 -07:00
commit b782fce5bf
27 changed files with 175 additions and 286 deletions

View File

@ -1,30 +0,0 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain.cim;
import javax.xml.bind.annotation.XmlType;
/**
* Java class for anonymous complex type.
*/
@XmlType(name = "")
public class AutomaticRecoveryAction extends CimAnySimpleType {
}

View File

@ -1,30 +0,0 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain.cim;
import javax.xml.bind.annotation.XmlType;
/**
* Java class for anonymous complex type.
*/
@XmlType(name = "")
public class AutomaticShutdownAction extends CimAnySimpleType {
}

View File

@ -1,32 +0,0 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain.cim;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* Java class for anonymous complex type.
*/
@XmlType(name = "")
public class AutomaticStartupAction extends CimAnySimpleType {
}

View File

@ -1,30 +0,0 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain.cim;
import javax.xml.bind.annotation.XmlType;
/**
* Java class for anonymous complex type.
*/
@XmlType(name = "")
public class ConsumerVisibility extends CimAnySimpleType {
}

View File

@ -1,30 +0,0 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain.cim;
import javax.xml.bind.annotation.XmlType;
/**
* Java class for anonymous complex type.
*/
@XmlType(name = "")
public class MappingBehavior extends CimAnySimpleType {
}

View File

@ -1,30 +0,0 @@
/*
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.director.v1_5.domain.cim;
import javax.xml.bind.annotation.XmlType;
/**
* Java class for anonymous complex type.
*/
@XmlType(name = "")
public class ResourceType extends CimAnySimpleType {
}

View File

@ -60,7 +60,31 @@ import com.google.common.collect.Maps;
* @author grkvlt@apache.org
* @see http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_VirtualSystemSettingData.xsd
*/
@XmlType(name = "CIM_VirtualSystemSettingData_Type", namespace = VCLOUD_OVF_NS)
@XmlType(name = "CIM_VirtualSystemSettingData_Type", namespace = VCLOUD_OVF_NS,
propOrder = {
"automaticRecoveryAction",
"automaticShutdownAction",
"automaticStartupAction",
"automaticStartupActionDelay",
"automaticStartupActionSequenceNumber",
"caption",
"configurationDataRoot",
"configurationFile",
"configurationID",
"creationTime",
"description",
"elementName",
"instanceID",
"logDataRoot",
"notes",
"recoveryFile",
"snapshotDataRoot",
"suspendDataRoot",
"swapFileDataRoot",
"virtualSystemIdentifier",
"virtualSystemType"
}
)
public class VirtualSystemSettingData {
public static Builder builder() {
@ -615,7 +639,7 @@ public class VirtualSystemSettingData {
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
@ -624,6 +648,20 @@ public class VirtualSystemSettingData {
equal(this.instanceID, that.instanceID) &&
equal(this.caption, that.caption) &&
equal(this.description, that.description) &&
equal(this.automaticRecoveryAction, that.automaticRecoveryAction) &&
equal(this.automaticShutdownAction, that.automaticShutdownAction) &&
equal(this.automaticStartupAction, that.automaticStartupAction) &&
equal(this.automaticStartupActionDelay, that.automaticStartupActionDelay) &&
equal(this.automaticStartupActionSequenceNumber, that.automaticStartupActionSequenceNumber) &&
equal(this.configurationDataRoot, that.configurationDataRoot) &&
equal(this.configurationFile, that.configurationFile) &&
equal(this.configurationID, that.configurationID) &&
equal(this.creationTime, that.creationTime) &&
equal(this.logDataRoot, that.logDataRoot) &&
equal(this.recoveryFile, that.recoveryFile) &&
equal(this.snapshotDataRoot, that.snapshotDataRoot) &&
equal(this.suspendDataRoot, that.suspendDataRoot) &&
equal(this.swapFileDataRoot, that.swapFileDataRoot) &&
equal(this.virtualSystemIdentifier, that.virtualSystemIdentifier) &&
equal(this.virtualSystemType, that.virtualSystemType);
}
@ -631,8 +669,24 @@ public class VirtualSystemSettingData {
@Override
public String toString() {
return Objects.toStringHelper("")
.add("elementName", elementName)
.add("instanceID", instanceID)
.add("caption", caption)
.add("description", description)
.add("automaticRecoveryAction", automaticRecoveryAction)
.add("automaticShutdownAction", automaticShutdownAction)
.add("automaticStartupAction", automaticStartupAction)
.add("automaticStartupActionDelay", automaticStartupActionDelay)
.add("automaticStartupActionSequenceNumber", automaticStartupActionSequenceNumber)
.add("configurationDataRoot", configurationDataRoot)
.add("configurationFile", configurationFile)
.add("configurationID", configurationID)
.add("creationTime", creationTime)
.add("logDataRoot", logDataRoot)
.add("recoveryFile", recoveryFile)
.add("snapshotDataRoot", snapshotDataRoot)
.add("suspendDataRoot", suspendDataRoot)
.add("swapFileDataRoot", swapFileDataRoot)
.add("virtualSystemIdentifier", virtualSystemIdentifier)
.add("virtualSystemType", virtualSystemType)
.toString();

View File

@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
import java.net.URI;
import java.util.Collections;
import java.util.Set;
import javax.xml.bind.annotation.XmlAttribute;

View File

@ -757,7 +757,26 @@ public class Checks {
}
public static void checkVirtualSystemSettingData(VirtualSystemSettingData virtualSystem) {
// TODO
assertNotNull(virtualSystem.getElementName(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "elementName"));
assertNotNull(virtualSystem.getInstanceID(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "instanceID"));
// assertNotNull(virtualSystem.getCaption(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "caption"));
// assertNotNull(virtualSystem.getDescription(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "description"));
// assertNotNull(virtualSystem.getAutomaticRecoveryAction(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "automaticRecoveryAction"));
// assertNotNull(virtualSystem.getAutomaticShutdownAction(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "automaticShutdownAction"));
// assertNotNull(virtualSystem.getAutomaticStartupAction(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "automaticStartupAction"));
// assertNotNull(virtualSystem.getAutomaticStartupActionDelay(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "automaticStartupActionDelay"));
// assertNotNull(virtualSystem.getAutomaticStartupActionSequenceNumber(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "automaticStartupActionSequenceNumber"));
// assertNotNull(virtualSystem.getConfigurationDataRoot(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "configurationDataRoot"));
// assertNotNull(virtualSystem.getConfigurationFile(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "configurationFile"));
// assertNotNull(virtualSystem.getConfigurationID(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "configurationID"));
// assertNotNull(virtualSystem.getCreationTime(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "creationTime"));
// assertNotNull(virtualSystem.getLogDataRoot(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "logDataRoot"));
// assertNotNull(virtualSystem.getRecoveryFile(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "recoveryFile"));
// assertNotNull(virtualSystem.getSnapshotDataRoot(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "snapshotDataRoot"));
// assertNotNull(virtualSystem.getSuspendDataRoot(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "suspendDataRoot"));
// assertNotNull(virtualSystem.getSwapFileDataRoot(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "swapFileDataRoot"));
// assertNotNull(virtualSystem.getVirtualSystemIdentifier(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "virtualSystemIdentifier"));
// assertNotNull(virtualSystem.getVirtualSystemType(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "virtualSystemType"));
}
public static void checkResourceAllocationSettingData(ResourceAllocationSettingData item) {

View File

@ -41,7 +41,7 @@ import com.google.common.collect.ImmutableSet;
*
* @author grkvlt@apache.org
*/
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "CatalogClientExpectTest")
@Test(groups = { "unit", "admin", "catalog" }, singleThreaded = true, testName = "CatalogClientExpectTest")
public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
private Reference orgRef = Reference.builder()

View File

@ -29,7 +29,6 @@ import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.util.Collections;
import java.util.Random;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog;
@ -67,7 +66,6 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
* Shared state between dependant tests.
*/
private final Random random = new Random();
private Reference orgRef;
private AdminCatalog catalog;
private Owner owner;
@ -82,7 +80,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
@Test(testName = "POST /admin/org/{id}/catalogs")
public void testCreateCatalog() {
AdminCatalog newCatalog = AdminCatalog.builder()
.name("Test Catalog " + random.nextInt())
.name(name("Test Catalog "))
.description("created by testCreateCatalog()")
.build();
catalog = catalogClient.createCatalog(orgRef.getHref(), newCatalog);
@ -196,7 +194,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
// String.format(OBJ_FIELD_EMPTY_TO_DELETE, "Catalog", "CatalogItems",
// catalog.getCatalogItems().getCatalogItems().toString()));
AdminCatalog deleteCatalog = AdminCatalog.builder()
.name("Test Catalog " + random.nextInt())
.name(name("Test Catalog "))
.description("created by testCreateCatalog()")
.build();
deleteCatalog = catalogClient.createCatalog(orgRef.getHref(), deleteCatalog);

View File

@ -38,7 +38,7 @@ import com.google.common.collect.ImmutableSet;
*
* @author danikov
*/
@Test(groups = { "unit", "admin", "adminNetwork"}, singleThreaded = true, testName = "AdminNetworkClientExpectTest")
@Test(groups = { "unit", "admin", "network"}, singleThreaded = true, testName = "AdminNetworkClientExpectTest")
public class AdminNetworkClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
Reference networkRef = Reference.builder()

View File

@ -64,6 +64,7 @@ public class AdminNetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest
Reference networkRef;
Network network;
@Override
@BeforeClass(inheritGroups = true)
protected void setupRequiredClients() {
networkClient = context.getApi().getAdminNetworkClient();

View File

@ -40,7 +40,7 @@ import com.google.common.collect.ImmutableMultimap;
*
* @author Aled Sage
*/
@Test(groups = { "unit", "user", "query" }, singleThreaded = true, testName = "AdminQueryClientExpectTest")
@Test(groups = { "unit", "admin", "query" }, singleThreaded = true, testName = "AdminQueryClientExpectTest")
public class AdminQueryClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
// TODO Write expect tests for all other admin-query operations

View File

@ -39,7 +39,7 @@ import org.testng.annotations.Test;
*
* @author Aled Sage
*/
@Test(groups = { "live", "user", "query" }, singleThreaded = true, testName = "AdminQueryClientLiveTest")
@Test(groups = { "live", "admin", "query" }, singleThreaded = true, testName = "AdminQueryClientLiveTest")
public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
/*

View File

@ -68,7 +68,7 @@ public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
adminVdcUri = toAdminUri(vdcURI);
}
@AfterClass(groups = { "live" })
@AfterClass(alwaysRun = true)
public void cleanUp() throws Exception {
if (metadataKey != null) {
try {
@ -93,7 +93,7 @@ public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "PUT /admin/vdc/{id}", enabled=false)
public void testEditVdc() throws Exception {
String origName = vdcClient.getVdc(adminVdcUri).getName();
String newName = "a"+random.nextInt(Integer.MAX_VALUE);
String newName = name("a");
Exception exception = null;
AdminVdc vdc = AdminVdc.builder()
@ -175,8 +175,8 @@ public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// TODO insufficient permissions to test
@Test(testName = "PUT /admin/vdc/{id}/metadata", enabled=false)
public void testSetMetadata() throws Exception {
metadataKey = ""+random.nextInt(Integer.MAX_VALUE);
metadataValue = ""+random.nextInt(Integer.MAX_VALUE);
metadataKey = name("key-");
metadataValue = name("value-");
Metadata metadata = Metadata.builder()
.entry(MetadataEntry.builder().entry(metadataKey, metadataValue).build())
.build();
@ -200,7 +200,7 @@ public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// TODO insufficient permissions to test
@Test(testName = "PUT /admin/vdc/{id}/metadata", dependsOnMethods = { "testGetMetadataValue" }, enabled=false )
public void testSetMetadataValue() throws Exception {
metadataValue = ""+random.nextInt(Integer.MAX_VALUE);
metadataValue = name("value-");
MetadataValue newV = MetadataValue.builder().value(metadataValue).build();
Task task = metadataClient.setMetadata(adminVdcUri, metadataKey, newV);

View File

@ -73,7 +73,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
Reference orgRef = Iterables.getFirst(context.getApi().getOrgClient().getOrgList().getOrgs(), null).toAdminReference(endpoint);
AdminCatalog newCatalog = AdminCatalog.builder()
.name("Test Catalog " + random.nextInt())
.name(name("Test Catalog "))
.description("created by CatalogClientLiveTest")
.build();

View File

@ -34,7 +34,7 @@ import org.testng.annotations.Test;
*
* @author danikov
*/
@Test(groups = { "unit", "user", "group"}, singleThreaded = true, testName = "GroupClientExpectTest")
@Test(groups = { "unit", "admin", "group"}, singleThreaded = true, testName = "GroupClientExpectTest")
public class GroupClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
private Reference groupRef = Reference.builder()

View File

@ -47,7 +47,7 @@ import com.google.common.collect.ImmutableSet;
*
* @author danikov
*/
@Test(groups = { "unit", "media" }, singleThreaded = true, testName = "MediaClientExpectTest")
@Test(groups = { "unit", "user", "media" }, singleThreaded = true, testName = "MediaClientExpectTest")
public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
@Test

View File

@ -65,41 +65,15 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
*/
private QueryClient queryClient;
private VAppTemplateClient vappTemplateClient;
private VAppClient vappClient;
private VAppTemplateClient vAppTemplateClient;
private VAppClient vAppClient;
private VApp vApp;
@AfterClass(groups = { "live" })
@AfterClass(alwaysRun = true)
public void cleanUp() throws Exception {
if (vApp != null) {
vApp = vappClient.getVApp(vApp.getHref()); // update
// Shutdown and power off the VApp if necessary
if (vApp.getStatus().equals(Status.POWERED_ON.getValue())) {
try {
Task shutdownTask = vappClient.shutdown(vApp.getHref());
retryTaskSuccess.apply(shutdownTask);
} catch (Exception e) {
// keep going; cleanup as much as possible
logger.warn(e, "Continuing cleanup after error shutting down VApp %s", vApp);
}
}
// Undeploy the VApp if necessary
if (vApp.isDeployed()) {
try {
UndeployVAppParams params = UndeployVAppParams.builder().build();
Task undeployTask = vappClient.undeploy(vApp.getHref(), params);
retryTaskSuccess.apply(undeployTask);
} catch (Exception e) {
// keep going; cleanup as much as possible
logger.warn(e, "Continuing cleanup after error undeploying VApp %s", vApp);
}
}
Task task = vappClient.deleteVApp(vApp.getHref());
assertTaskSucceeds(task);
cleanUpVApp(vApp);
}
}
@ -107,8 +81,8 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@BeforeClass(inheritGroups = true)
public void setupRequiredClients() {
queryClient = context.getApi().getQueryClient();
vappTemplateClient = context.getApi().getVAppTemplateClient();
vappClient = context.getApi().getVAppClient();
vAppTemplateClient = context.getApi().getVAppTemplateClient();
vAppClient = context.getApi().getVAppClient();
}
@Test(testName = "GET /query")
@ -144,7 +118,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "GET /vAppTemplates/query?filter)")
public void testQueryVAppTemplatesWithFilter() {
VAppTemplate vAppTemplate = vappTemplateClient.getVAppTemplate(vAppTemplateURI);
VAppTemplate vAppTemplate = vAppTemplateClient.getVAppTemplate(vAppTemplateURI);
QueryResultRecords queryResult = queryClient.vAppTemplatesQuery(String.format("name==%s", vAppTemplate.getName()));
Set<URI> hrefs = toHrefs(queryResult);
@ -181,10 +155,10 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
}
// Start the vApp so that it has VMs
Task task = vappClient.powerOn(vApp.getHref());
Task task = vAppClient.powerOn(vApp.getHref());
assertTaskSucceedsLong(task);
vApp = vappClient.getVApp(vApp.getHref()); // reload, so it has the VMs
vApp = vAppClient.getVApp(vApp.getHref()); // reload, so it has the VMs
List<Vm> vms = vApp.getChildren().getVms();
Set<URI> vmHrefs = toHrefs(vms);
@ -208,7 +182,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
assertEquals(hrefs, vmHrefs, "VMs query result should equal vms of vApp "+vApp.getName()+" ("+vmHrefs+"); but only has "+hrefs);
}
private static void assertRecordTypes(QueryResultRecords queryResult, Collection<String> validTypes, Class validClazz) {
private static void assertRecordTypes(QueryResultRecords queryResult, Collection<String> validTypes, Class<?> validClazz) {
for (QueryResultRecordType record : queryResult.getRecords()) {
assertTrue(validTypes.contains(record.getType()), "invalid type for query result record, "+record.getType()+"; valid types are "+validTypes);
assertEquals(record.getClass(), validClazz, "invalid type for query result record, "+record.getClass()+"; expected "+validClazz);

View File

@ -72,7 +72,7 @@ public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest {
taskClient = context.getApi().getTaskClient();
}
@AfterClass(groups = { "live" })
@AfterClass(alwaysRun = true)
public void cleanUp() throws Exception {
if (vApp != null) cleanUpVApp(vApp);
}

View File

@ -81,7 +81,7 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest {
orgRef = Iterables.getFirst(context.getApi().getOrgClient().getOrgList().getOrgs(), null).toAdminReference(endpoint);
}
@AfterClass(groups = { "live" })
@AfterClass(alwaysRun = true)
public void cleanUp() throws Exception {
if (user != null) {
try {
@ -127,7 +127,7 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public static User randomTestUser(String prefix, Reference role) {
return User.builder()
.name(prefix+random.nextInt())
.name(name(prefix))
.fullName("testFullName")
.emailAddress("test@test.com")
.telephone("555-1234")
@ -267,7 +267,7 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest {
dependsOnMethods = { "testCreateUser" } )
public void testDeleteUser() {
// Create a user to be deleted (so we remove dependencies on test ordering)
String name = "a"+random.nextInt();
String name = name("a");
User newUser = User.builder()
.name(name)
.role(Reference.builder() // FIXME: auto-fetch a role? or inject

View File

@ -142,7 +142,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
@Test(testName = "PUT /vApp/{id}", dependsOnMethods = { "testGetVApp" })
public void testModifyVApp() {
VApp newVApp = VApp.builder()
.name("new-name-" + Integer.toString(random.nextInt(Integer.MAX_VALUE)))
.name(name("new-name-"))
.description("New Description")
.build();
vAppNames.add(newVApp.getName());
@ -175,7 +175,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
vApp = vAppClient.getVApp(vApp.getHref());
// Check the required fields are set
assertEquals(vApp.isDeployed(), Boolean.TRUE, String.format(OBJ_FIELD_EQ, VAPP, "deployed", "TRUE", vApp.isDeployed().toString()));
assertTrue(vApp.isDeployed(), String.format(OBJ_FIELD_EQ, VAPP, "deployed", "TRUE", vApp.isDeployed().toString()));
// Check status
Status deployedStatus = Status.POWERED_OFF;
@ -186,7 +186,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
public void testPowerOnVApp() {
// The method under test
Task powerOnVApp = vAppClient.powerOn(vApp.getHref());
assertTrue(retryTaskSuccess.apply(powerOnVApp), String.format(TASK_COMPLETE_TIMELY, "powerOnVApp"));
assertTaskSucceedsLong(powerOnVApp);
// Get the updated VApp
vApp = vAppClient.getVApp(vApp.getHref());
@ -200,7 +200,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
public void testReboot() {
// The method under test
Task reboot = vAppClient.reboot(vApp.getHref());
assertTrue(retryTaskSuccess.apply(reboot), String.format(TASK_COMPLETE_TIMELY, "reboot"));
assertTaskSucceedsLong(reboot);
// Get the updated VApp
vApp = vAppClient.getVApp(vApp.getHref());
@ -210,39 +210,54 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
assertEquals(vApp.getStatus(), poweredOffStatus.getValue(), String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOffStatus.toString(), Status.fromValue(vApp.getStatus()).toString()));
}
@Test(testName = "POST /vApp/{id}/power/action/shutdown", dependsOnMethods = { "testReboot" })
@Test(testName = "POST /vApp/{id}/power/action/shutdown", dependsOnMethods = { "testPowerOnVApp" })
public void testShutdown() {
// Power on VApp
powerOn();
// The method under test
Task shutdown = vAppClient.shutdown(vApp.getHref());
assertTrue(retryTaskSuccess.apply(shutdown), String.format(TASK_COMPLETE_TIMELY, "shutdown"));
Task shutdown = vAppClient.shutdown(vAppURI);
assertTaskSucceedsLong(shutdown);
// Get the updated VApp
vApp = vAppClient.getVApp(vApp.getHref());
vApp = vAppClient.getVApp(vAppURI);
// 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()));
Status poweredOffStatus = Status.POWERED_OFF;
assertEquals(vApp.getStatus(), poweredOffStatus.getValue(), String.format(OBJ_FIELD_EQ, VAPP, "status", poweredOffStatus.toString(), Status.fromValue(vApp.getStatus()).toString()));
// Power on the VApp again
powerOn();
}
@Test(testName = "POST /vApp/{id}/power/action/suspend", dependsOnMethods = { "testShutdown" })
@Test(testName = "POST /vApp/{id}/power/action/suspend", dependsOnMethods = { "testPowerOnVApp" })
public void testSuspend() {
// Power on VApp
powerOn();
// The method under test
Task suspend = vAppClient.suspend(vApp.getHref());
assertTrue(retryTaskSuccess.apply(suspend), String.format(TASK_COMPLETE_TIMELY, "suspend"));
Task suspend = vAppClient.suspend(vAppURI);
assertTaskSucceedsLong(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()));
Status suspendedStatus = Status.SUSPENDED;
assertEquals(vApp.getStatus(), suspendedStatus.getValue(), String.format(OBJ_FIELD_EQ, VAPP, "status", suspendedStatus.toString(), Status.fromValue(vApp.getStatus()).toString()));
// Power on the VApp again
powerOn();
}
@Test(testName = "POST /vApp/{id}/power/action/reset", dependsOnMethods = { "testSuspend" })
@Test(testName = "POST /vApp/{id}/power/action/reset", dependsOnMethods = { "testPowerOnVApp" })
public void testReset() {
// Power on VApp
powerOn();
// The method under test
Task reset = vAppClient.reset(vApp.getHref());
assertTrue(retryTaskSuccess.apply(reset), String.format(TASK_COMPLETE_TIMELY, "reset"));
assertTaskSucceedsLong(reset);
// Get the updated VApp
vApp = vAppClient.getVApp(vApp.getHref());
@ -264,8 +279,10 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
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()));
assertFalse(vApp.isDeployed(), String.format(OBJ_FIELD_EQ, VAPP, "deployed", "FALSE", vApp.isDeployed().toString()));
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}/power/action/powerOff", dependsOnMethods = { "testUndeployVApp" })
@ -861,8 +878,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
checkVirtualHardwareSection(modifiedSection);
// Check the modified section fields are set correctly
Set<ResourceAllocationSettingData> modifiedItems = modifiedSection.getItems();
ResourceAllocationSettingData modifiedMemory = Iterables.find(modifiedItems, new Predicate<ResourceAllocationSettingData>() {
ResourceAllocationSettingData modifiedMemory = Iterables.find(modifiedSection.getItems(), new Predicate<ResourceAllocationSettingData>() {
@Override
public boolean apply(ResourceAllocationSettingData rasd) {
return rasd.getResourceType() == ResourceAllocationSettingData.ResourceType.MEMORY;
@ -1095,8 +1111,8 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
@Test(testName = "PUT & GET /vApp/{id}/metadata", dependsOnMethods = { "testGetMetadata" })
public void testSetAndGetMetadataValue() {
// Store a value
String key = Integer.toString(random.nextInt(Integer.MAX_VALUE));
String value = Integer.toString(random.nextInt(Integer.MAX_VALUE));
String key = name("key-");
String value = name("value-");
MetadataValue metadataValue = MetadataValue.builder().value(value).build();
vAppClient.getMetadataClient().setMetadata(vApp.getHref(), key, metadataValue);
@ -1110,7 +1126,7 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
@Test(testName = "DELETE /vApp/{id}/metadata/{key}", dependsOnMethods = { "testSetAndGetMetadataValue" })
public void testDeleteMetadataEntry() {
// Store a value, to be deleted
String key = Integer.toString(random.nextInt(Integer.MAX_VALUE));
String key = name("key-");
MetadataValue metadataValue = MetadataValue.builder().value("myval").build();
vAppClient.getMetadataClient().setMetadata(vApp.getHref(), key, metadataValue);
@ -1131,8 +1147,8 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
Map<String, String> oldMetadataMap = Checks.metadataToMap(oldMetadata);
// Store a value, to be deleted
String key = Integer.toString(random.nextInt(Integer.MAX_VALUE));
String value = Integer.toString(random.nextInt(Integer.MAX_VALUE));
String key = name("key-");
String value = name("value-");
Metadata addedMetadata = Metadata.builder()
.entry(MetadataEntry.builder().key(key).value(value).build())
.build();
@ -1176,4 +1192,13 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
assertEquals(vcde.getError().getMajorErrorCode(), Integer.valueOf(403), "The error code should have been 'Forbidden' (403)");
}
}
private void powerOn() {
vApp = vAppClient.getVApp(vAppURI); // Refresh
Status status = Status.fromValue(vApp.getStatus());
if (status != Status.POWERED_ON) {
Task powerOn = vAppClient.powerOn(vAppURI);
assertTaskSucceedsLong(powerOn);
}
}
}

View File

@ -74,7 +74,7 @@ import com.google.common.collect.ImmutableSet;
*
* @author Adam Lowe
*/
@Test(groups = {"unit", "user"}, testName = "VAppTemplateClientExpectTest")
@Test(groups = { "unit", "user", "vapptemplate" }, testName = "VAppTemplateClientExpectTest")
public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
public VAppTemplateClientExpectTest() {

View File

@ -205,9 +205,8 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
@Test
public void testEditVAppTemplate() {
String uid = ""+random.nextInt();
String name = "myname-"+uid;
String description = "mydescr-"+uid;
String name = name("myname-");
String description = name("Description ");
VAppTemplate template = VAppTemplate.builder()
.name(name)
.description(description)
@ -228,9 +227,8 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
Metadata oldMetadata = vAppTemplateClient.getMetadataClient().getMetadata(vAppTemplateURI);
Map<String,String> oldMetadataMap = metadataToMap(oldMetadata);
String uid = ""+random.nextInt();
String key = "mykey-"+uid;
String val = "myval-"+uid;
String key = name("key-");
String val = name("value-");
MetadataEntry metadataEntry = MetadataEntry.builder().entry(key, val).build();
Metadata metadata = Metadata.builder().fromMetadata(oldMetadata).entry(metadataEntry).build();
@ -249,9 +247,8 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
public void testEditMetadataValue() {
// TODO Cleanup after ourselves..
String uid = ""+random.nextInt();
String key = "mykey-"+uid;
String val = "myval-"+uid;
String key = name("key-");
String val = name("value-");
MetadataValue metadataValue = MetadataValue.builder().value(val).build();
final Task task = vAppTemplateClient.getMetadataClient().setMetadata(vAppTemplateURI, key, metadataValue);
@ -264,7 +261,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
@Test
public void testDeleteVAppTemplateMetadataValue() {
// First store a value
String key = "mykey-"+random.nextInt();
String key = name("key-");
MetadataValue metadataValue = MetadataValue.builder().value("myval").build();
final Task task = vAppTemplateClient.getMetadataClient().setMetadata(vAppTemplateURI, key, metadataValue);
retryTaskSuccess.apply(task);
@ -280,7 +277,7 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
@Test
public void testEditGuestCustomizationSection() {
String computerName = "a"+random.nextInt(Integer.MAX_VALUE);
String computerName = name("server-");
GuestCustomizationSection newSection = GuestCustomizationSection.builder()
.info("my info")
.computerName(computerName)

View File

@ -84,7 +84,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
private VAppTemplate capturedVAppTemplate;
private VAppTemplate uploadedVAppTemplate;
@AfterClass(groups = { "live" })
@AfterClass(alwaysRun = true)
public void cleanUp() throws Exception {
if (clonedVAppTemplate != null) {
cleanUpVAppTemplate(clonedVAppTemplate);
@ -127,7 +127,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "POST /vdc/{id}/action/captureVApp", dependsOnMethods = { "testInstantiateVAppTemplate" } )
public void testCaptureVApp() {
String name = "captured-"+random.nextInt(Integer.MAX_VALUE);
String name = name("captured-");
CaptureVAppParams captureVappParams = CaptureVAppParams.builder()
.name(name)
@ -191,7 +191,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
@Test(testName = "POST /vdc/{id}/action/composeVApp")
public void testComposeVApp() {
String name = "composed-"+random.nextInt(Integer.MAX_VALUE);
String name = name("composed-");
composedVApp = vdcClient.composeVApp(vdcURI, ComposeVAppParams.builder()
.name(name)
@ -257,7 +257,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
.build();
InstantiateVAppTemplateParams instantiate = InstantiateVAppTemplateParams.builder()
.name("test-vapp-"+random.nextInt(Integer.MAX_VALUE))
.name(name("test-vapp-"))
.notDeploy()
.notPowerOn()
.description("Test VApp")
@ -280,7 +280,7 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
// 3. uploading disks described from the OVF
// 4. finishing task for uploading
String name = "uploaded-"+random.nextInt(Integer.MAX_VALUE);
String name = name("uploaded-");
UploadVAppTemplateParams uploadVAppTemplateParams = UploadVAppTemplateParams.builder()
.name(name)

View File

@ -253,7 +253,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
* @return the VApp that is being instantiated
*/
protected VApp instantiateVApp() {
return instantiateVApp("test-vapp-" + random.nextInt(Integer.MAX_VALUE));
return instantiateVApp(name("test-vapp-"));
}
protected VApp instantiateVApp(String name) {
@ -396,4 +396,8 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
logger.warn(e, "Deleting vApp failed: vApp="+vApp);
}
}
public static String name(String prefix) {
return prefix + Integer.toString(random.nextInt(Integer.MAX_VALUE));
}
}