Skip to content

Commit 89f0833

Browse files
Adding of VMSS networking part tests
1 parent 27d946a commit 89f0833

File tree

4 files changed

+188304
-0
lines changed

4 files changed

+188304
-0
lines changed

src/ResourceManager/Compute/Commands.Compute.Test/Commands.Compute.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@
349349
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineScaleSetTests\TestVirtualMachineScaleSetBootDiagnostics.json">
350350
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
351351
</None>
352+
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineScaleSetTests\TestVirtualMachineScaleSetNetworking.json">
353+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
354+
</None>
352355
<None Include="Templates\azuredeploy.json">
353356
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
354357
</None>

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,12 @@ public void TestVirtualMachineScaleSetIdentity()
7171
{
7272
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineScaleSetIdentity");
7373
}
74+
75+
[Fact]
76+
[Trait(Category.AcceptanceType, Category.CheckIn)]
77+
public void TestVirtualMachineScaleSetNetworking()
78+
{
79+
ComputeTestController.NewInstance.RunPsTest("Test-VirtualMachineScaleSetNetworking");
80+
}
7481
}
7582
}

src/ResourceManager/Compute/Commands.Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,3 +856,66 @@ function Test-VirtualMachineScaleSetIdentity
856856
Clean-ResourceGroup $rgname
857857
}
858858
}
859+
860+
<#
861+
.SYNOPSIS
862+
Test Virtual Machine Scale Set Networking part
863+
#>
864+
function Test-VirtualMachineScaleSetNetworking
865+
{
866+
# Setup
867+
$rgname = Get-ComputeTestResourceName
868+
$ipName = Get-ComputeTestResourceName
869+
$nsgName = Get-ComputeTestResourceName
870+
871+
try
872+
{
873+
# Common
874+
$loc = 'southeastasia';
875+
New-AzureRMResourceGroup -Name $rgname -Location $loc -Force;
876+
877+
# SRP
878+
$stoname = 'sto' + $rgname;
879+
$stotype = 'Standard_GRS';
880+
New-AzureRMStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
881+
$stoaccount = Get-AzureRMStorageAccount -ResourceGroupName $rgname -Name $stoname;
882+
883+
# NRP
884+
$subnet = New-AzureRMVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
885+
$vnet = New-AzureRMVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
886+
$vnet = Get-AzureRMVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
887+
$subnetId = $vnet.Subnets[0].Id;
888+
889+
# New VMSS Parameters
890+
$vmssName = 'vmss' + $rgname;
891+
$adminUsername = 'Foo12';
892+
$adminPassword = $PLACEHOLDER;
893+
$imgRef = Get-DefaultCRPImage -loc $loc;
894+
$vmss_number = 2;
895+
896+
$nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName $rgname -Name $nsgName -Location $loc;
897+
$nsgId = $nsg.Id;
898+
$dns = '10.11.12.13';
899+
900+
$ipCfg = New-AzureRmVmssIPConfig -Name 'test' -SubnetId $subnetId -PublicIPAddressConfigurationName $ipName -PublicIPAddressConfigurationIdleTimeoutInMinutes 10 -DnsSetting "testvmssdnscom";
901+
$vmss = New-AzureRmVmssConfig -Location $loc -SkuCapacity $vmss_number -SkuName 'Standard_A0' -UpgradePolicyMode 'Automatic' -NetworkInterfaceConfiguration $netCfg -Overprovision $false -SinglePlacementGroup $false `
902+
| Add-AzureRmVmssNetworkInterfaceConfiguration -Name 'test' -Primary $true -IPConfiguration $ipCfg -DnsSettingsDnsServer $dns -NetworkSecurityGroupId $nsg.Id `
903+
| Set-AzureRmVmssOSProfile -ComputerNamePrefix 'test' -AdminUsername $adminUsername -AdminPassword $adminPassword `
904+
| Set-AzureRmVmssStorageProfile -OsDiskCreateOption 'FromImage' -OsDiskCaching 'None' `
905+
-ImageReferenceOffer $imgRef.Offer -ImageReferenceSku $imgRef.Skus -ImageReferenceVersion $imgRef.Version -ImageReferencePublisher $imgRef.PublisherName;
906+
907+
$result = New-AzureRmVmss -ResourceGroupName $rgname -Name $vmssName -VirtualMachineScaleSet $vmss;
908+
909+
Assert-NotNull $result.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations;
910+
Assert-AreEqual $result.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].DnsSettings.DnsServers $dns;
911+
Assert-AreEqual $result.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].NetworkSecurityGroup.Id $nsgId;
912+
Assert-NotNull $result.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations;
913+
Assert-AreEqual $result.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations[0].PublicIPAddressConfiguration.Name $ipName;
914+
915+
}
916+
finally
917+
{
918+
# Cleanup
919+
Clean-ResourceGroup $rgname
920+
}
921+
}

0 commit comments

Comments
 (0)