use of com.vmware.photon.controller.model.adapters.util.instance.BaseComputeInstanceContext.ImageSource 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.util.instance.BaseComputeInstanceContext.ImageSource 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