Skip to content

Commit

Permalink
Update Compute client version to 23.0.0.
Browse files Browse the repository at this point in the history
Including shared gallery APIs, List VM by Location API, Diff disk support, and Ultra SSD support.
  • Loading branch information
hyonholee committed Sep 27, 2018
1 parent e836541 commit 21c5255
Show file tree
Hide file tree
Showing 198 changed files with 60,182 additions and 22,778 deletions.
2 changes: 1 addition & 1 deletion src/SDKs/Compute/AzSdk.RP.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--This file and it's contents are updated at build time moving or editing might result in build failure. Take due deligence while editing this file-->
<PropertyGroup>
<AzureApiTag>Compute_2018-06-01;Compute_2018-04-01;Compute_2017-09-01;ContainerService_2017-01-31;</AzureApiTag>
<AzureApiTag>Compute_2018-10-01;Compute_2018-06-01;Compute_2017-09-01;ContainerService_2017-01-31;</AzureApiTag>
<PackageTags>$(PackageTags);$(CommonTags);$(AzureApiTag);</PackageTags>
</PropertyGroup>
</Project>
16 changes: 14 additions & 2 deletions src/SDKs/Compute/Compute.Tests/DiskRPTests/DiskRPTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ private Disk GenerateImportDisk(string diskCreateOption, string rgName)
return disk;
}

private Disk GenerateBaseDisk(string diskCreateOption)
protected Disk GenerateBaseDisk(string diskCreateOption)
{
var disk = new Disk
{
Expand Down Expand Up @@ -476,7 +476,7 @@ private void Validate(Snapshot snapshotExpected, Snapshot snapshotActual, bool d
}
}

protected void Validate(Disk diskExpected, Disk diskActual, string location, bool diskHydrated = false)
protected void Validate(Disk diskExpected, Disk diskActual, string location, bool diskHydrated = false, bool update = false)
{
// disk resource
Assert.Equal(string.Format("{0}/{1}", ApiConstants.ResourceProviderNamespace, "disks"), diskActual.Type);
Expand All @@ -494,6 +494,18 @@ protected void Validate(Disk diskExpected, Disk diskActual, string location, boo
Assert.Equal(diskExpected.DiskSizeGB, diskActual.DiskSizeGB);
}

if (!update)
{
if (diskExpected.DiskIOPSReadWrite != null)
{
Assert.Equal(diskExpected.DiskIOPSReadWrite, diskActual.DiskIOPSReadWrite);
}

if (diskExpected.DiskMBpsReadWrite != null)
{
Assert.Equal(diskExpected.DiskMBpsReadWrite, diskActual.DiskMBpsReadWrite);
}
}

// Creation data
CreationData creationDataExp = diskExpected.CreationData;
Expand Down
89 changes: 89 additions & 0 deletions src/SDKs/Compute/Compute.Tests/DiskRPTests/DiskRPUltraSSDTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using System.Net;
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Azure.Management.ResourceManager;
using Microsoft.Azure.Management.ResourceManager.Models;
using Microsoft.Rest.Azure;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using Xunit;
using System.Collections.Generic;

namespace Compute.Tests.DiskRPTests
{
public class DiskRPUltraSSDTests : DiskRPTestsBase
{
//direct drive is only enabled in eastus2euap
private static string DiskRPLocation = "eastus2euap";

[Fact]
public void UltraSSD_CRUD_EmptyDisk()
{
using (MockContext context = MockContext.Start(this.GetType().FullName))
{
EnsureClientsInitialized(context);

// Data
var rgName = TestUtilities.GenerateName(TestPrefix);
var diskName = TestUtilities.GenerateName(DiskNamePrefix);
Disk disk = GenerateBaseDisk("Empty");
disk.Sku = new DiskSku
{
Name = DiskStorageAccountTypes.UltraSSDLRS
};
disk.DiskSizeGB = 256;
disk.Zones = new List<string> { "3" };
disk.DiskMBpsReadWrite = 8;
disk.DiskIOPSReadWrite = 500;

try
{
m_ResourcesClient.ResourceGroups.CreateOrUpdate(rgName, new ResourceGroup { Location = DiskRPLocation });

// Put
Disk diskOut = m_CrpClient.Disks.CreateOrUpdate(rgName, diskName, disk);
Validate(disk, diskOut, DiskRPLocation);

// Get
diskOut = m_CrpClient.Disks.Get(rgName, diskName);
Validate(disk, diskOut, DiskRPLocation);

// Patch
const string tagKey = "tagKey";
var updatedisk = new DiskUpdate();
updatedisk.Tags = new Dictionary<string, string>() { { tagKey, "tagValue" } };
updatedisk.DiskMBpsReadWrite = 9;
updatedisk.DiskIOPSReadWrite = 600;
diskOut = m_CrpClient.Disks.Update(rgName, diskName, updatedisk);
Validate(disk, diskOut, DiskRPLocation, update : true);
Assert.Equal(updatedisk.DiskIOPSReadWrite, diskOut.DiskIOPSReadWrite);
Assert.Equal(updatedisk.DiskMBpsReadWrite, diskOut.DiskMBpsReadWrite);

// Get
diskOut = m_CrpClient.Disks.Get(rgName, diskName);
Validate(disk, diskOut, DiskRPLocation, update: true);
Assert.Equal(updatedisk.DiskIOPSReadWrite, diskOut.DiskIOPSReadWrite);
Assert.Equal(updatedisk.DiskMBpsReadWrite, diskOut.DiskMBpsReadWrite);

// Delete
m_CrpClient.Disks.Delete(rgName, diskName);

try
{
// Ensure it was really deleted
m_CrpClient.Disks.Get(rgName, diskName);
Assert.False(true);
}
catch (CloudException ex)
{
Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode);
}
}
finally
{
// Delete resource group
m_ResourcesClient.ResourceGroups.Delete(rgName);
}
}
}
}
}
28 changes: 25 additions & 3 deletions src/SDKs/Compute/Compute.Tests/Helpers/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public static void DeleteIfExists(this IResourceGroupsOperations rgOps, string r
}

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

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

private static List<VirtualMachineSize> GetExpectedVirtualMachineSize(bool hasAZ, bool? writeAcceleratorEnabled = null)
private static List<VirtualMachineSize> GetExpectedVirtualMachineSize(bool hasAZ, bool? writeAcceleratorEnabled = null, bool hasDiffDisks = false)
{
var expectedVMSizePropertiesList = new List<VirtualMachineSize>();
if (writeAcceleratorEnabled.HasValue && writeAcceleratorEnabled.Value)
Expand Down Expand Up @@ -110,6 +110,28 @@ private static List<VirtualMachineSize> GetExpectedVirtualMachineSize(bool hasAZ
MaxDataDiskCount = 8
});
}
else if (hasDiffDisks)
{
expectedVMSizePropertiesList.Add(new VirtualMachineSize()
{
Name = VirtualMachineSizeTypes.StandardDS1V2,
MemoryInMB = 3584,
NumberOfCores = 1,
OsDiskSizeInMB = 1047552,
ResourceDiskSizeInMB = 7168,
MaxDataDiskCount = 4
});

expectedVMSizePropertiesList.Add(new VirtualMachineSize()
{
Name = VirtualMachineSizeTypes.StandardDS2V2,
MemoryInMB = 7168,
NumberOfCores = 2,
OsDiskSizeInMB = 1047552,
ResourceDiskSizeInMB = 14336,
MaxDataDiskCount = 8
});
}
else
{
expectedVMSizePropertiesList.Add(new VirtualMachineSize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ public class AvailabilitySetTests : VMTestBase
[Fact]
public void TestOperations()
{
string originalTestLocation = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION");
using (MockContext context = MockContext.Start(this.GetType().FullName))
{
try
{
Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", "westcentralus");
EnsureClientsInitialized(context);
Initialize(context);

Expand All @@ -71,6 +73,7 @@ public void TestOperations()
}
finally
{
Environment.SetEnvironmentVariable("AZURE_VM_TEST_LOCATION", originalTestLocation);
resourcesClient.ResourceGroups.Delete(resourceGroup1Name);
}
}
Expand Down
Loading

0 comments on commit 21c5255

Please sign in to comment.