use of com.vmware.photon.controller.model.tasks.ProvisioningUtils in project photon-model by vmware.
the class TestAzureProvisionTask method assertStorageDescription.
/**
* Ensure that after provisioning, there is one (but only one) StorageDescription created for
* the shared storage account. This test does not use shared SA, thus provisioning should create
* a StorageDescription.
*/
private void assertStorageDescription() {
if (this.isMock) {
// return. Nothing provisioned on Azure so nothing to check
return;
}
try {
ComputeState vm = getHost().getServiceState(null, ComputeState.class, UriUtils.buildUri(getHost(), this.vmState.documentSelfLink));
String sharedSAName = vm.customProperties.get(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME);
if (sharedSAName != null && !sharedSAName.isEmpty()) {
Map<String, StorageDescription> storageDescriptionsMap = ProvisioningUtils.<StorageDescription>getResourceStates(getHost(), StorageDescriptionService.FACTORY_LINK, StorageDescription.class);
assertTrue(!storageDescriptionsMap.isEmpty());
List<StorageDescription> storageDescriptions = storageDescriptionsMap.values().stream().filter(name -> name.equals(sharedSAName)).collect(Collectors.toList());
assertEquals("More than one storage description was created for the provisinoed storage account.", storageDescriptions.size(), 1);
}
} catch (Throwable t) {
fail("Unable to verify Storage Description documents");
t.printStackTrace();
}
}
Aggregations