use of com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.VMResourceSpec in project photon-model by vmware.
the class TestAzureProvisionTask method testProvisionWithPersistentDisks.
/**
* Creates a Azure instance with persistent disk via a provision task.
*/
@Test
@Ignore("This test does VM provisioning with persistent disks. Ignored for timeouts of " + "preflights")
public void testProvisionWithPersistentDisks() throws Throwable {
ImageSource imageSource = createImageSource(getHost(), this.endpointState, IMAGE_REFERENCE);
// Create a Azure VM compute resource with 2 additional disks.
int numberOfAdditionalDisks = 2;
VMResourceSpec vmResourceSpec = new VMResourceSpec(getHost(), this.computeHost, this.endpointState, azureVMName).withImageSource(imageSource).withNicSpecs(DEFAULT_NIC_SPEC).withNumberOfAdditionalDisks(numberOfAdditionalDisks).withPersistentDisks(VMResourceSpec.PersistentDisks.SOME).withManagedDisk(true);
// create Azure VM compute resource.
this.vmState = createVMResourceFromSpec(vmResourceSpec);
kickOffProvisionTask();
// Assert if 2 additional disks were created
assertConfigurationOfDisks(numberOfAdditionalDisks, 0);
}
use of com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.VMResourceSpec in project photon-model by vmware.
the class TestAzureProvisionTask method testProvision.
/**
* Creates a Azure instance via a provision task.
*/
@Test
public void testProvision() throws Throwable {
ImageSource imageSource = createImageSource(getHost(), this.endpointState, IMAGE_REFERENCE);
VMResourceSpec vmResourceSpec = new VMResourceSpec(getHost(), this.computeHost, this.endpointState, azureVMName).withNicSpecs(DEFAULT_NIC_SPEC).withImageSource(imageSource).withManagedDisk(false);
// create Azure VM compute resource.
this.vmState = createVMResourceFromSpec(vmResourceSpec);
kickOffProvisionTask();
assertVmNetworksConfiguration(DEFAULT_NIC_SPEC, vmResourceSpec.azureVmName);
assertConfigurationOfDisks(0, 0);
assertStorageDescription();
// Stats on individual VM is currently broken.
if (!this.skipStats) {
getHost().setTimeoutSeconds(60);
getHost().waitFor("Error waiting for stats", () -> {
try {
issueStatsRequest(this.vmState);
} catch (Throwable t) {
return false;
}
return true;
});
}
}
use of com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.VMResourceSpec in project photon-model by vmware.
the class TestAzureProvisionTask method testProvisionFromPrivateImage.
/**
* Creates a Azure instance via a provision task.
*/
@Test
@Ignore("This test does an additional VM provisioning that will cause the total preflight " + "time to exceed the limit and timeout the preflight. Only for manual execution.")
public void testProvisionFromPrivateImage() throws Throwable {
ImageSource privateImageSource = createPrivateImageSource(getHost(), this.endpointState);
int numberOfAdditionalDisks = 1;
VMResourceSpec vmResourceSpec = new VMResourceSpec(getHost(), this.computeHost, this.endpointState, azureVMName).withImageSource(privateImageSource).withNicSpecs(NO_PUBLIC_IP_NIC_SPEC).withNumberOfAdditionalDisks(numberOfAdditionalDisks).withManagedDisk(true);
// create Azure VM compute resource.
this.vmState = createVMResourceFromSpec(vmResourceSpec);
kickOffProvisionTask();
assertConfigurationOfDisks(numberOfAdditionalDisks, 2);
assertStorageDescription();
}
use of com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.VMResourceSpec in project photon-model by vmware.
the class TestAzureProvisionTask method testProvisionDataDisksAndEnumeration.
/**
* Creates Azure instance with 2 data disks via provision task and enumerate the disks
* and verify disk duplication in local store.
*/
@Test
public void testProvisionDataDisksAndEnumeration() throws Throwable {
ImageSource imageSource = createImageSource(getHost(), this.endpointState, IMAGE_REFERENCE);
// Create a Azure VM compute resource with 2 additional disks.
int numberOfAdditionalDisks = 2;
VMResourceSpec vmResourceSpec = new VMResourceSpec(getHost(), this.computeHost, this.endpointState, azureVMName).withImageSource(imageSource).withNicSpecs(DEFAULT_NIC_SPEC).withNumberOfAdditionalDisks(numberOfAdditionalDisks).withManagedDisk(false);
// create Azure VM compute resource.
this.vmState = createVMResourceFromSpec(vmResourceSpec);
kickOffProvisionTask();
runEnumeration();
// Assert if 2 additional disks were created
List<DiskState> diskStates = this.vmState.diskLinks.stream().map(diskLink -> getHost().getServiceState(null, DiskState.class, UriUtils.buildUri(getHost(), diskLink))).collect(Collectors.toList());
for (DiskState diskState : diskStates) {
if (diskState.bootOrder == 1) {
assertEquals("OS Disk size does not match", AzureTestUtil.AZURE_CUSTOM_OSDISK_SIZE, diskState.capacityMBytes);
} else {
assertEquals("Data Disk size does not match", AzureTestUtil.AZURE_CUSTOM_DATA_DISK_SIZE, diskState.capacityMBytes);
if (!this.isMock) {
assertNotNull(diskState.customProperties);
assertNotNull(diskState.customProperties.get(DISK_CONTROLLER_NUMBER));
}
}
}
// Run enumeration second time to verify disk states are not duplicated
runEnumeration();
ServiceDocumentQueryResult result = ProvisioningUtils.queryAllFactoryResources(this.host, DiskService.FACTORY_LINK);
List<DiskState> diskList = result.documents.keySet().stream().map(diskLink -> getHost().getServiceState(null, DiskState.class, UriUtils.buildUri(getHost(), diskLink))).collect(Collectors.toList());
for (DiskState diskState : diskStates) {
long nameCount = diskList.stream().filter(ds -> ds.name.equalsIgnoreCase(diskState.name)).count();
String msg = String.format("Duplicate of DiskState %s must not be present. ", diskState.name);
assertEquals(msg, 1, nameCount);
long idCount = diskList.stream().filter(ds -> ds.id.equalsIgnoreCase(diskState.id)).count();
String idMsg = String.format("Duplicate of DiskState ID %s must not be present. ", diskState.id);
assertEquals(idMsg, 1, idCount);
}
}
use of com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.VMResourceSpec in project photon-model by vmware.
the class TestAzureProvisionTask method testProvisionWithDataDisks.
/**
* Creates a Azure instance with additional disk via a provision task.
*/
@Test
@Ignore("This test does VM provisioning with additional disks. Ignored for timeouts of " + "preflights")
public void testProvisionWithDataDisks() throws Throwable {
ImageSource imageSource = createImageSource(getHost(), this.endpointState, IMAGE_REFERENCE);
// Create a Azure VM compute resource with 2 additional disks.
int numberOfAdditionalDisks = 2;
VMResourceSpec vmResourceSpec = new VMResourceSpec(getHost(), this.computeHost, this.endpointState, azureVMName).withImageSource(imageSource).withNicSpecs(DEFAULT_NIC_SPEC).withNumberOfAdditionalDisks(numberOfAdditionalDisks).withManagedDisk(true);
// create Azure VM compute resource.
this.vmState = createVMResourceFromSpec(vmResourceSpec);
kickOffProvisionTask();
// Assert if 2 additional disks were created
assertConfigurationOfDisks(numberOfAdditionalDisks, 0);
}
Aggregations