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

Accelerated networking changes #2943

Merged
merged 1 commit into from
Sep 15, 2016
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 @@ -67,9 +67,9 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.13.0.4-prerelease\lib\net45\Microsoft.Azure.Management.Compute.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.6.1.1-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>

<Reference Include="Microsoft.Azure.Management.Network, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.7.1.0-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -398,6 +398,7 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineNetworkInterfaceTests\TestVirtualMachineSingleNetworkInterface.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineNetworkInterfaceTests\TestVirtualMachineSingleNetworkInterfaceWithAcceleratedNetworking.json" />
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineProfileTests\TestVirtualMachineProfileWithoutAUC.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,19 @@ public void TestEffectiveRoutesAndNsg()
{
ComputeTestController.NewInstance.RunPsTest("Test-EffectiveRoutesAndNsg");
}

[Fact(Skip = "NRP not deployed")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVirtualMachineSingleNetworkInterfaceWithAcceleratedNetworking()
{
ComputeTestController.NewInstance.RunPsTest("Test-SingleNetworkInterfaceWithAcceleratedNetworking");
}

[Fact(Skip ="NRP not deployed")]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVMNicWithAcceleratedNetworkingValidations()
{
ComputeTestController.NewInstance.RunPsTest("Test-VMNicWithAcceleratedNetworkingValidations");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -591,3 +591,247 @@ function Test-EffectiveRoutesAndNsg
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Test Virtual Machines with single NetworkInterface
#>
function Test-SingleNetworkInterfaceWithAcceleratedNetworking
{
# Setup
$rgname = Get-ComputeTestResourceName

try
{
# Common
$loc = "WestCentralUS";
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;

# VM Profile & Hardware
$vmsize = 'Standard_DS15_v2';
$vmname = 'vm' + $rgname;
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;

# NRP
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzureRmVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzureRmPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$pubipId = $pubip.Id;
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -EnableAcceleratedNetworking -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;
Assert-AreEqual $nic.EnableAcceleratedNetworking $true

$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;
Assert-Null $p.NetworkProfile.NetworkInterfaces[0].Primary;

# Storage Account (SA)
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname;

$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
$dataDiskVhdUri2 = "https://$stoname.blob.core.windows.net/test/data2.vhd";
$dataDiskVhdUri3 = "https://$stoname.blob.core.windows.net/test/data3.vhd";

$p = Set-AzureRmVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;

$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 2 -VhdUri $dataDiskVhdUri2 -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3' -Caching 'ReadOnly' -DiskSizeInGB 12 -Lun 3 -VhdUri $dataDiskVhdUri3 -CreateOption Empty;
$p = Remove-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3';

Assert-AreEqual $p.StorageProfile.OSDisk.Caching $osDiskCaching;
Assert-AreEqual $p.StorageProfile.OSDisk.Name $osDiskName;
Assert-AreEqual $p.StorageProfile.OSDisk.Vhd.Uri $osDiskVhdUri;
Assert-AreEqual $p.StorageProfile.DataDisks.Count 2;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Caching 'ReadOnly';
Assert-AreEqual $p.StorageProfile.DataDisks[0].DiskSizeGB 10;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Lun 1;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Vhd.Uri $dataDiskVhdUri1;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Caching 'ReadOnly';
Assert-AreEqual $p.StorageProfile.DataDisks[1].DiskSizeGB 11;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Lun 2;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Vhd.Uri $dataDiskVhdUri2;

# OS & Image
$user = "Foo12";
$password = $PLACEHOLDER;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
$img = 'a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-Datacenter-201503.01-en.us-127GB.vhd';

# $p.StorageProfile.OSDisk = $null;
$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;

Assert-AreEqual $p.OSProfile.AdminUsername $user;
Assert-AreEqual $p.OSProfile.ComputerName $computerName;
Assert-AreEqual $p.OSProfile.AdminPassword $password;

# Image Reference
$imgRef = Get-DefaultCRPImage "westcentralus" "MicrosoftWindowsServer";
$p = ($imgRef | Set-AzureRmVMSourceImage -VM $p);
Assert-NotNull $p.StorageProfile.ImageReference;
Assert-Null $p.StorageProfile.SourceImageId;

# TODO: Remove Data Disks for now
$p.StorageProfile.DataDisks = $null;

# Virtual Machine
# TODO: Still need to do retry for New-AzureRmVM for SA, even it's returned in Get-.
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;

# Get VM
$vm1 = Get-AzureRmVM -Name $vmname -ResourceGroupName $rgname;
Assert-AreEqual $vm1.Name $vmname;
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces[0].Id $nicId;

# Get NetworkInterface
$getnic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces[0].Id $getnic.Id;
Assert-AreEqual $getnic.EnableAcceleratedNetworking $true

# Remove
Remove-AzureRmVM -Name $vmname -ResourceGroupName $rgname -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Test Virtual Machines with single NetworkInterface
#>
function Test-VMNicWithAcceleratedNetworkingValidations
{
# Setup
$rgname = Get-ComputeTestResourceName

try
{
# Common
$loc = "WestCentralUS";
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;

# VM Profile & Hardware
$vmsize = 'Standard_DS15_v2';
$vmname = 'vm' + $rgname;
$p = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;

# NRP
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzureRmVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzureRmVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzureRmPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzureRmPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$pubipId = $pubip.Id;
$nic = New-AzureRmNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -EnableAcceleratedNetworking -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
$nic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
$nicId = $nic.Id;
Assert-AreEqual $nic.EnableAcceleratedNetworking $true

$p = Add-AzureRmVMNetworkInterface -VM $p -Id $nicId;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;
Assert-Null $p.NetworkProfile.NetworkInterfaces[0].Primary;

# Storage Account (SA)
$stoname = 'sto' + $rgname;
$stotype = 'Standard_GRS';
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$stoaccount = Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname;

$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
$dataDiskVhdUri2 = "https://$stoname.blob.core.windows.net/test/data2.vhd";
$dataDiskVhdUri3 = "https://$stoname.blob.core.windows.net/test/data3.vhd";

$p = Set-AzureRmVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;

$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 2 -VhdUri $dataDiskVhdUri2 -CreateOption Empty;
$p = Add-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3' -Caching 'ReadOnly' -DiskSizeInGB 12 -Lun 3 -VhdUri $dataDiskVhdUri3 -CreateOption Empty;
$p = Remove-AzureRmVMDataDisk -VM $p -Name 'testDataDisk3';

Assert-AreEqual $p.StorageProfile.OSDisk.Caching $osDiskCaching;
Assert-AreEqual $p.StorageProfile.OSDisk.Name $osDiskName;
Assert-AreEqual $p.StorageProfile.OSDisk.Vhd.Uri $osDiskVhdUri;
Assert-AreEqual $p.StorageProfile.DataDisks.Count 2;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Caching 'ReadOnly';
Assert-AreEqual $p.StorageProfile.DataDisks[0].DiskSizeGB 10;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Lun 1;
Assert-AreEqual $p.StorageProfile.DataDisks[0].Vhd.Uri $dataDiskVhdUri1;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Caching 'ReadOnly';
Assert-AreEqual $p.StorageProfile.DataDisks[1].DiskSizeGB 11;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Lun 2;
Assert-AreEqual $p.StorageProfile.DataDisks[1].Vhd.Uri $dataDiskVhdUri2;

# OS & Image
$user = "Foo12";
$password = $PLACEHOLDER;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
$img = 'a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-Datacenter-201503.01-en.us-127GB.vhd';

# $p.StorageProfile.OSDisk = $null;
$p = Set-AzureRmVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;

Assert-AreEqual $p.OSProfile.AdminUsername $user;
Assert-AreEqual $p.OSProfile.ComputerName $computerName;
Assert-AreEqual $p.OSProfile.AdminPassword $password;

# Image Reference
$imgRef = Get-DefaultCRPImage "westcentralus" "MicrosoftWindowsServer";
$p = ($imgRef | Set-AzureRmVMSourceImage -VM $p);
Assert-NotNull $p.StorageProfile.ImageReference;
Assert-Null $p.StorageProfile.SourceImageId;

# TODO: Remove Data Disks for now
$p.StorageProfile.DataDisks = $null;

# Virtual Machine
# TODO: Still need to do retry for New-AzureRmVM for SA, even it's returned in Get-.
New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $p;

# Get VM
$vm1 = Get-AzureRmVM -Name $vmname -ResourceGroupName $rgname;
Assert-AreEqual $vm1.Name $vmname;
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces.Count 1;
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces[0].Id $nicId;

# Get NetworkInterface
$getnic = Get-AzureRmNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces[0].Id $getnic.Id;
Assert-AreEqual $getnic.EnableAcceleratedNetworking $true

# Remove
Remove-AzureRmVM -Name $vmname -ResourceGroupName $rgname -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
Loading