Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Compute] WriteAcceleratorEnabled, VM instance view update, and vmss force recovery API #4029

Merged
merged 2 commits into from
Feb 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void DiskManagedByTest()
var storageAccountOutput = CreateStorageAccount(rgName, storageAccountName);

// Create the VM, whose OS disk will be used in creating the image
var createdVM = CreateVM_NoAsyncTracking(rgName, avSet, storageAccountOutput, imageRef, out inputVM, hasManagedDisks: true);
var createdVM = CreateVM(rgName, avSet, storageAccountOutput, imageRef, out inputVM, hasManagedDisks: true);
var listResponse = m_CrpClient.VirtualMachines.ListAll();
Assert.True(listResponse.Count() >= 1);
var vmName = createdVM.Name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ private Disk GenerateImportDisk(DiskCreateOption diskCreateOption, string rgName
var storageAccountOutput = CreateStorageAccount(rgName, storageAccountName);

// Create the VM, whose OS disk will be used in creating the image
var createdVM = CreateVM_NoAsyncTracking(rgName, asName, storageAccountOutput, imageRef, out inputVM);
var createdVM = CreateVM(rgName, asName, storageAccountOutput, imageRef, out inputVM);
var listResponse = m_CrpClient.VirtualMachines.ListAll();
Assert.True(listResponse.Count() >= 1);
string[] id = createdVM.Id.Split('/');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Net;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Network;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.Storage;
using Microsoft.Azure.Test.HttpRecorder;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using System;
using System.Net;

namespace Compute.Tests
{
Expand Down Expand Up @@ -57,6 +57,11 @@ public static void WaitSeconds(double seconds)
}
}

public static void WaitMinutes(double minutes)
{
WaitSeconds(minutes * 60);
}

public static string GenerateName(string prefix = null,
[System.Runtime.CompilerServices.CallerMemberName]
string methodName="GenerateName_failed")
Expand Down
38 changes: 30 additions & 8 deletions src/SDKs/Compute/Compute.Tests/Helpers/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ public static void DeleteIfExists(this IResourceGroupsOperations rgOps, string r
}
}

public static void ValidateVirtualMachineSizeListResponse(IEnumerable<VirtualMachineSize> vmSizeListResponse, bool hasAZ = false)
public static void ValidateVirtualMachineSizeListResponse(IEnumerable<VirtualMachineSize> vmSizeListResponse, bool hasAZ = false,
bool? writeAcceleratorEnabled = null)
{
var expectedVMSizePropertiesList = GetExpectedVirtualMachineSize(hasAZ);
var expectedVMSizePropertiesList = GetExpectedVirtualMachineSize(hasAZ, writeAcceleratorEnabled);

IEnumerable<VirtualMachineSize> vmSizesPropertyList = vmSizeListResponse;
Assert.NotNull(vmSizesPropertyList);
Expand All @@ -63,14 +64,35 @@ public static void ValidateVirtualMachineSizeListResponse(IEnumerable<VirtualMac
CompareVMSizes(expectedVMSizeProperties, vmSizeProperties);
}

private static List<VirtualMachineSize> GetExpectedVirtualMachineSize(bool hasAZ)
private static List<VirtualMachineSize> GetExpectedVirtualMachineSize(bool hasAZ, bool? writeAcceleratorEnabled = null)
{
var expectedVMSizePropertiesList = new List<VirtualMachineSize>();
if (hasAZ)
if (writeAcceleratorEnabled.HasValue && writeAcceleratorEnabled.Value)
{
expectedVMSizePropertiesList.Add(new VirtualMachineSize()
{
Name = "Standard_D1_v2",
Name = "Standard_M64s",
MemoryInMB = 1024000,
NumberOfCores = 64,
OsDiskSizeInMB = 1047552,
ResourceDiskSizeInMB = 2048000,
MaxDataDiskCount = 64
});
expectedVMSizePropertiesList.Add(new VirtualMachineSize()
{
Name = "Standard_M64-16ms",
MemoryInMB = 1792000,
NumberOfCores = 64,
OsDiskSizeInMB = 1047552,
ResourceDiskSizeInMB = 2048000,
MaxDataDiskCount = 64
});
}
else if (hasAZ)
{
expectedVMSizePropertiesList.Add(new VirtualMachineSize()
{
Name = VirtualMachineSizeTypes.StandardD1V2,
MemoryInMB = 3584,
NumberOfCores = 1,
OsDiskSizeInMB = 1047552,
Expand All @@ -80,7 +102,7 @@ private static List<VirtualMachineSize> GetExpectedVirtualMachineSize(bool hasAZ

expectedVMSizePropertiesList.Add(new VirtualMachineSize()
{
Name = "Standard_D2_v2",
Name = VirtualMachineSizeTypes.StandardD2V2,
MemoryInMB = 7168,
NumberOfCores = 2,
OsDiskSizeInMB = 102400,
Expand All @@ -92,7 +114,7 @@ private static List<VirtualMachineSize> GetExpectedVirtualMachineSize(bool hasAZ
{
expectedVMSizePropertiesList.Add(new VirtualMachineSize()
{
Name = "Standard_A0",
Name = VirtualMachineSizeTypes.StandardA0,
MemoryInMB = 768,
NumberOfCores = 1,
OsDiskSizeInMB = 130048,
Expand All @@ -101,7 +123,7 @@ private static List<VirtualMachineSize> GetExpectedVirtualMachineSize(bool hasAZ
});
expectedVMSizePropertiesList.Add(new VirtualMachineSize()
{
Name = "Standard_A1",
Name = VirtualMachineSizeTypes.StandardA1,
MemoryInMB = 1792,
NumberOfCores = 1,
OsDiskSizeInMB = 130048,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void TestVMExtensionOperations()
// Create Storage Account, so that both the VMs can share it
var storageAccountOutput = CreateStorageAccount(rgName, storageAccountName);

var vm = CreateVM_NoAsyncTracking(rgName, asName, storageAccountOutput, imageRef, out inputVM);
var vm = CreateVM(rgName, asName, storageAccountOutput, imageRef, out inputVM);

// Delete an extension that does not exist in the VM. A http status code of NoContent should be returned which translates to operation success.
m_CrpClient.VirtualMachineExtensions.Delete(rgName, vm.Name, "VMExtensionDoesNotExist");
Expand Down
2 changes: 1 addition & 1 deletion src/SDKs/Compute/Compute.Tests/ScenarioTests/ImageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void TestImageOperations()
};

// Create the VM, whose OS disk will be used in creating the image
var createdVM = CreateVM_NoAsyncTracking(rgName, asName, storageAccountOutput, imageRef, out inputVM, addDataDiskToVM);
var createdVM = CreateVM(rgName, asName, storageAccountOutput, imageRef, out inputVM, addDataDiskToVM);

// Create the Image
var imageInput = new Image()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public void TestListSkus()
Assert.True(skus.Any(sku => sku.LocationInfo != null), "Assert that the sku list has non null location info in it.");
Assert.True(skus.All(sku => sku.LocationInfo.Count == 1), "There should be exactly one location info per entry.");
Assert.True(skus.Any(sku => sku.LocationInfo[0].Location.Equals("westus", StringComparison.Ordinal)), "Assert that it has entry for one of the CRP regions (randomly picked).");
Assert.True(skus.Any(sku => sku.Restrictions != null && sku.Restrictions[0].RestrictionInfo != null), "Assert that it has entry for some restriction and restriction info.");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/SDKs/Compute/Compute.Tests/ScenarioTests/ListVMTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public void TestListVMInSubscription()
// Create Storage Account, so that both the VMs can share it
var storageAccountOutput = CreateStorageAccount(rg1Name, storageAccountName);

var vm1 = CreateVM_NoAsyncTracking(rg1Name, asName, storageAccountOutput, imageRef, out inputVM1);
var vm2 = CreateVM_NoAsyncTracking(rg2Name, asName, storageAccountOutput, imageRef, out inputVM2);
var vm1 = CreateVM(rg1Name, asName, storageAccountOutput, imageRef, out inputVM1);
var vm2 = CreateVM(rg2Name, asName, storageAccountOutput, imageRef, out inputVM2);

var listResponse = m_CrpClient.VirtualMachines.ListAll();
Assert.True(listResponse.Count() >= 2);
Expand Down
21 changes: 2 additions & 19 deletions src/SDKs/Compute/Compute.Tests/ScenarioTests/OSProfileTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private void TestVMWithOSProfile(
{
StorageAccount storageAccountOutput = CreateStorageAccount(rgName, storageAccountName);

VirtualMachine vm = CreateVM_NoAsyncTracking(rgName, asName, storageAccountOutput, imageRef, out inputVM, vmCustomizer);
VirtualMachine vm = CreateVM(rgName, asName, storageAccountOutput, imageRef, out inputVM, vmCustomizer);

var getVMWithInstanceViewResponse = m_CrpClient.VirtualMachines.Get(rgName, inputVM.Name, InstanceViewTypes.InstanceView);
ValidateVMInstanceView(inputVM, getVMWithInstanceViewResponse);
Expand All @@ -279,19 +279,12 @@ private void TestVMWithOSProfile(
vmValidator(vm);
}

m_CrpClient.VirtualMachines.Delete(rgName, vm.Name);

// TODO: VM delete operation takes too long, disable it for now
// lroResponse = m_CrpClient.VirtualMachines.Delete(rgName, vm.Name);
// Assert.True(lroResponse.Status == ComputeOperationStatus.Succeeded);
m_CrpClient.VirtualMachines.BeginDelete(rgName, vm.Name);
}
finally
{
if (m_ResourcesClient != null)
{
// TODO: RG delete operation takes too long, disable it for now
// var deleteResourceGroupResponse = m_ResourcesClient.ResourceGroups.Delete(rgName);
// Assert.True(deleteResourceGroupResponse.StatusCode == HttpStatusCode.OK);
m_ResourcesClient.ResourceGroups.Delete(rgName);
}
}
Expand All @@ -302,16 +295,6 @@ private void TestVMWithOSProfile(
public static string ReadFromEmbeddedResource(Type type, string resourceName)
{
throw new NotSupportedException("\'type.Assembly\' is not supported for cross platform");
//string result;
//using (Stream manifestResourceStream = type.Assembly.GetManifestResourceStream(type, resourceName) ?? type.Assembly.GetManifestResourceStream(resourceName))
//{
// using (StreamReader streamReader = new StreamReader(manifestResourceStream))
// {
// result = streamReader.ReadToEnd();
// }
//}

//return result;
}

private static string GetAutoLogonContent(uint logonCount, string userName, string password)
Expand Down
2 changes: 1 addition & 1 deletion src/SDKs/Compute/Compute.Tests/ScenarioTests/UsageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void TestListUsages()
// Create Storage Account, so that both the VMs can share it
var storageAccountOutput = CreateStorageAccount(rgName, storageAccountName);

var vm1 = CreateVM_NoAsyncTracking(rgName, asName, storageAccountOutput, imageRef, out inputVM);
var vm1 = CreateVM(rgName, asName, storageAccountOutput, imageRef, out inputVM);

// List Usages, and do weak validation to assure that some usages were returned.
var luResponse = m_CrpClient.Usage.List(vm1.Location);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void TestVMCertificatesOperations()
// Create Storage Account, so that both the VMs can share it
var storageAccountOutput = CreateStorageAccount(rgName, storageAccountName);

var vm1 = CreateVM_NoAsyncTracking(rgName, asName, storageAccountOutput, imageRef, out inputVM, AddCertificateInfo);
var vm1 = CreateVM(rgName, asName, storageAccountOutput, imageRef, out inputVM, AddCertificateInfo);

m_CrpClient.VirtualMachines.Delete(rgName, inputVM.Name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void TestVMDataDiskScenario()
}; */
};

var vm1 = CreateVM_NoAsyncTracking(rgName, asName, storageAccountOutput, imgageRef, out inputVM, addDataDiskToVM);
var vm1 = CreateVM(rgName, asName, storageAccountOutput, imgageRef, out inputVM, addDataDiskToVM);

var getVMWithInstanceViewResponse = m_CrpClient.VirtualMachines.Get(rgName, inputVM.Name, InstanceViewTypes.InstanceView);
Assert.True(getVMWithInstanceViewResponse != null, "VM in Get");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void TestVMBootDiagnostics()
var storageAccountOutput = CreateStorageAccount(rgName, storageAccountName);

VirtualMachine inputVM;
CreateVM_NoAsyncTracking(rgName, asName, storageAccountOutput, imageRef, out inputVM,
CreateVM(rgName, asName, storageAccountOutput, imageRef, out inputVM,
(vm) =>
{
vm.DiagnosticsProfile = GetDiagnosticsProfile(storageAccountOutput.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ public void TestVMDiskEncryption()
var storageAccountOutput = CreateStorageAccount(rgName, storageAccountName);
//Create VM with encryptionKey
VirtualMachine inputVM1;
CreateVM_NoAsyncTracking(rgName, asName, storageAccountOutput, imageRef, out inputVM1,
CreateVM(rgName, asName, storageAccountOutput, imageRef, out inputVM1,
(vm) =>
{
vm.StorageProfile.OsDisk.EncryptionSettings = GetEncryptionSettings();
vm.HardwareProfile.VmSize = "Standard_D1";
}, waitOperation: false);
vm.HardwareProfile.VmSize = VirtualMachineSizeTypes.StandardD1;
}, waitForCompletion: false);
//Create VM with encryptionKey and KEK
VirtualMachine inputVM2;
CreateVM_NoAsyncTracking(rgName, asName, storageAccountOutput, imageRef, out inputVM2,
CreateVM(rgName, asName, storageAccountOutput, imageRef, out inputVM2,
(vm) =>
{
vm.StorageProfile.OsDisk.EncryptionSettings = GetEncryptionSettings(addKek:true);
vm.HardwareProfile.VmSize = "Standard_D1";
}, waitOperation: false);
vm.HardwareProfile.VmSize = VirtualMachineSizeTypes.StandardD1;
}, waitForCompletion: false);

m_CrpClient.VirtualMachines.Delete(rgName, inputVM1.Name);
m_CrpClient.VirtualMachines.Delete(rgName, inputVM2.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void TestVMDiskSizeScenario()
{
var storageAccountOutput = CreateStorageAccount(rgName, storageAccountName);

var vm1 = CreateVM_NoAsyncTracking(rgName, asName, storageAccountOutput, imageRef, out inputVM, (vm) =>
var vm1 = CreateVM(rgName, asName, storageAccountOutput, imageRef, out inputVM, (vm) =>
{
vm.StorageProfile.OsDisk.DiskSizeGB = 150;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void TestVMMarketplace()
inputVM = null;
try
{
vm1 = CreateVM_NoAsyncTracking(rgName, asName, storageAccountOutput, dummyImageRef, out inputVM, useVMMImage);
vm1 = CreateVM(rgName, asName, storageAccountOutput, dummyImageRef, out inputVM, useVMMImage);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -122,7 +122,7 @@ public void TestVMBYOL()
VirtualMachine vm1 = null;
try
{
vm1 = CreateVM_NoAsyncTracking(rgName, asName, storageAccountOutput, dummyImageRef, out inputVM, useVMMImage);
vm1 = CreateVM(rgName, asName, storageAccountOutput, dummyImageRef, out inputVM, useVMMImage);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void TestVMOperations()
// Create Storage Account, so that both the VMs can share it
var storageAccountOutput = CreateStorageAccount(rg1Name, storageAccountName);

VirtualMachine vm1 = CreateVM_NoAsyncTracking(rg1Name, as1Name, storageAccountOutput, imageRef, out inputVM1);
VirtualMachine vm1 = CreateVM(rg1Name, as1Name, storageAccountOutput, imageRef, out inputVM1);

m_CrpClient.VirtualMachines.Start(rg1Name, vm1.Name);
m_CrpClient.VirtualMachines.Redeploy(rg1Name, vm1.Name);
Expand Down Expand Up @@ -137,7 +137,7 @@ public void TestVMOperations()
// TODO : Provisioning Time-out Issues
VirtualMachine inputVM2;
string as2Name = as1Name + "b";
VirtualMachine vm2 = CreateVM_NoAsyncTracking(rg1Name, as2Name, storageAccountOutput, imageRef, out inputVM2,
VirtualMachine vm2 = CreateVM(rg1Name, as2Name, storageAccountOutput, imageRef, out inputVM2,
vm =>
{
vm.StorageProfile.ImageReference = null;
Expand Down Expand Up @@ -187,7 +187,7 @@ public void TestVMOperations_Redeploy()
// Create Storage Account, so that both the VMs can share it
var storageAccountOutput = CreateStorageAccount(rg1Name, storageAccountName);

VirtualMachine vm1 = CreateVM_NoAsyncTracking(rg1Name, asName, storageAccountOutput, imageRef,
VirtualMachine vm1 = CreateVM(rg1Name, asName, storageAccountOutput, imageRef,
out inputVM1);

var redeployOperationResponse = m_CrpClient.VirtualMachines.BeginRedeployWithHttpMessagesAsync(rg1Name, vm1.Name);
Expand Down Expand Up @@ -242,7 +242,7 @@ public void TestVMOperations_PerformMaintenance()
// Create Storage Account, so that both the VMs can share it
var storageAccountOutput = CreateStorageAccount(rg1Name, storageAccountName);

VirtualMachine vm1 = CreateVM_NoAsyncTracking(rg1Name, asName, storageAccountOutput, imageRef,
VirtualMachine vm1 = CreateVM(rg1Name, asName, storageAccountOutput, imageRef,
out inputVM1);

m_CrpClient.VirtualMachines.PerformMaintenance(rg1Name, vm1.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void TestListVMRunCommands()
var computeClient = ComputeManagementTestUtilities.GetComputeManagementClient(context,
new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
string location = ComputeManagementTestUtilities.DefaultLocation.Replace(" ", "");
string documentId = "PowerShellScript";
string documentId = "RunPowerShellScript";

// Verify the List of commands
IEnumerable<RunCommandDocumentBase> runCommandListResponse = computeClient.VirtualMachineRunCommands.List(location);
Expand Down
Loading