public async Task TestListVMSizes() { string location = DefaultLocation.Replace(" ", ""); var virtualMachineSizeListResponse = await(VirtualMachineSizesOperations.ListAsync(location)).ToEnumerableAsync(); Helpers.ValidateVirtualMachineSizeListResponse(virtualMachineSizeListResponse); }
private async Task ValidateResults(AvailabilitySet outputAvailabilitySet, AvailabilitySet inputAvailabilitySet, string resourceGroupName, string inputAvailabilitySetName, int expectedFD, int expectedUD) { string expectedAvailabilitySetId = Helpers.GetAvailabilitySetRef(subId, resourceGroupName, inputAvailabilitySetName); Assert.True(outputAvailabilitySet.Name == inputAvailabilitySetName); Assert.True(outputAvailabilitySet.Location.ToLower() == this.TestEnvironment.Location.ToLower() || outputAvailabilitySet.Location.ToLower() == inputAvailabilitySet.Location.ToLower()); ValidateAvailabilitySet(inputAvailabilitySet, outputAvailabilitySet, inputAvailabilitySetName, expectedAvailabilitySetId, expectedFD, expectedUD); // GET AvailabilitySet var getResponse = await AvailabilitySetsOperations.GetAsync(resourceGroupName, inputAvailabilitySetName); ValidateAvailabilitySet(inputAvailabilitySet, getResponse, inputAvailabilitySetName, expectedAvailabilitySetId, expectedFD, expectedUD); // List VM Sizes var listVMSizesResponse = AvailabilitySetsOperations.ListAvailableSizesAsync(resourceGroupName, inputAvailabilitySetName); var listVMSizesResp = await listVMSizesResponse.ToEnumerableAsync(); Helpers.ValidateVirtualMachineSizeListResponse(listVMSizesResp); // Delete AvailabilitySet await AvailabilitySetsOperations.DeleteAsync(resourceGroupName, inputAvailabilitySetName); }
private async Task TestVMScenarioOperationsInternal(string methodName, bool hasManagedDisks = false, IList <string> zones = null, string vmSize = "Standard_A0", string osDiskStorageAccountType = "Standard_LRS", string dataDiskStorageAccountType = "Standard_LRS", bool?writeAcceleratorEnabled = null, bool hasDiffDisks = false, bool callUpdateVM = false, bool isPpgScenario = false, string diskEncryptionSetId = null) { var imageRef = await GetPlatformVMImage(useWindowsImage : true); const string expectedOSName = "Windows Server 2012 R2 Datacenter", expectedOSVersion = "Microsoft Windows NT 6.3.9600.0", expectedComputerName = ComputerName; // Create resource group var rgName = Recording.GenerateAssetName(TestPrefix); string storageAccountName = Recording.GenerateAssetName(TestPrefix); string asName = Recording.GenerateAssetName("as"); string ppgName = null; string expectedPpgReferenceId = null; if (isPpgScenario) { ppgName = Recording.GenerateAssetName("ppgtest"); expectedPpgReferenceId = Helpers.GetProximityPlacementGroupRef(m_subId, rgName, ppgName); } VirtualMachine inputVM; if (!hasManagedDisks) { await CreateStorageAccount(rgName, storageAccountName); } var returnTwoVM = await CreateVM(rgName, asName, storageAccountName, imageRef, hasManagedDisks : hasManagedDisks, hasDiffDisks : hasDiffDisks, vmSize : vmSize, osDiskStorageAccountType : osDiskStorageAccountType, dataDiskStorageAccountType : dataDiskStorageAccountType, writeAcceleratorEnabled : writeAcceleratorEnabled, zones : zones, ppgName : ppgName, diskEncryptionSetId : diskEncryptionSetId); //VirtualMachine outVM = returnTwoVM.Item1; inputVM = returnTwoVM.Input; string inputVMName = returnTwoVM.Name; // Instance view is not completely populated just after VM is provisioned. So we wait here for a few minutes to // allow GA blob to populate. WaitMinutes(5); var getVMWithInstanceViewResponse = (await VirtualMachinesOperations.GetAsync(rgName, inputVMName)).Value; Assert.True(getVMWithInstanceViewResponse != null, "VM in Get"); if (diskEncryptionSetId != null) { Assert.True(getVMWithInstanceViewResponse.StorageProfile.OsDisk.ManagedDisk.DiskEncryptionSet != null, "OsDisk.ManagedDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getVMWithInstanceViewResponse.StorageProfile.OsDisk.ManagedDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "OsDisk.ManagedDisk.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); Assert.AreEqual(1, getVMWithInstanceViewResponse.StorageProfile.DataDisks.Count); Assert.True(getVMWithInstanceViewResponse.StorageProfile.DataDisks[0].ManagedDisk.DiskEncryptionSet != null, ".DataDisks.ManagedDisk.DiskEncryptionSet is null"); Assert.True(string.Equals(diskEncryptionSetId, getVMWithInstanceViewResponse.StorageProfile.DataDisks[0].ManagedDisk.DiskEncryptionSet.Id, StringComparison.OrdinalIgnoreCase), "DataDisks.ManagedDisk.DiskEncryptionSet.Id is not matching with expected DiskEncryptionSet resource"); } ValidateVMInstanceView(inputVM, getVMWithInstanceViewResponse, hasManagedDisks, expectedComputerName, expectedOSName, expectedOSVersion); var getVMInstanceViewResponse = await VirtualMachinesOperations.InstanceViewAsync(rgName, inputVMName); Assert.True(getVMInstanceViewResponse != null, "VM in InstanceView"); ValidateVMInstanceView(inputVM, getVMInstanceViewResponse, hasManagedDisks, expectedComputerName, expectedOSName, expectedOSVersion); bool hasUserDefinedAS = zones == null; string expectedVMReferenceId = Helpers.GetVMReferenceId(m_subId, rgName, inputVMName); var listResponse = await(VirtualMachinesOperations.ListAsync(rgName)).ToEnumerableAsync(); ValidateVM(inputVM, listResponse.FirstOrDefault(x => x.Name == inputVMName), expectedVMReferenceId, hasManagedDisks, hasUserDefinedAS, writeAcceleratorEnabled, hasDiffDisks, expectedPpgReferenceId: expectedPpgReferenceId); var listVMSizesResponse = await(VirtualMachinesOperations.ListAvailableSizesAsync(rgName, inputVMName)).ToEnumerableAsync(); Helpers.ValidateVirtualMachineSizeListResponse(listVMSizesResponse, hasAZ: zones != null, writeAcceleratorEnabled: writeAcceleratorEnabled, hasDiffDisks: hasDiffDisks); listVMSizesResponse = await(AvailabilitySetsOperations.ListAvailableSizesAsync(rgName, asName)).ToEnumerableAsync(); Helpers.ValidateVirtualMachineSizeListResponse(listVMSizesResponse, hasAZ: zones != null, writeAcceleratorEnabled: writeAcceleratorEnabled, hasDiffDisks: hasDiffDisks); if (isPpgScenario) { ProximityPlacementGroup outProximityPlacementGroup = await ProximityPlacementGroupsOperations.GetAsync(rgName, ppgName); string expectedAvSetReferenceId = Helpers.GetAvailabilitySetRef(m_subId, rgName, asName); Assert.AreEqual(1, outProximityPlacementGroup.VirtualMachines.Count); Assert.AreEqual(1, outProximityPlacementGroup.AvailabilitySets.Count); Assert.AreEqual(expectedVMReferenceId, outProximityPlacementGroup.VirtualMachines.First().Id); Assert.AreEqual(expectedAvSetReferenceId, outProximityPlacementGroup.AvailabilitySets.First().Id); //Assert.Equal(expectedVMReferenceId, outProximityPlacementGroup.VirtualMachines.First().Id, StringComparer.OrdinalIgnoreCase); //Assert.Equal(expectedAvSetReferenceId, outProximityPlacementGroup.AvailabilitySets.First().Id, StringComparer.OrdinalIgnoreCase); } if (callUpdateVM) { VirtualMachineUpdate updateParams = new VirtualMachineUpdate(); updateParams.Tags.InitializeFrom(inputVM.Tags); string updateKey = "UpdateTag"; updateParams.Tags.Add(updateKey, "UpdateTagValue"); VirtualMachine updateResponse = await WaitForCompletionAsync(await VirtualMachinesOperations.StartUpdateAsync(rgName, inputVMName, updateParams)); Assert.True(updateResponse.Tags.ContainsKey(updateKey)); } }