Skip to content

Commit bdbc75b

Browse files
authored
Merge pull request #4292 from EvgenyAgafonchikov/vmss-tests
Adding vmss networking tests
2 parents 97006a2 + 6a03758 commit bdbc75b

File tree

4 files changed

+236725
-0
lines changed

4 files changed

+236725
-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
@@ -350,6 +350,9 @@
350350
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineScaleSetTests\TestVirtualMachineScaleSetBootDiagnostics.json">
351351
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
352352
</None>
353+
<None Include="SessionRecords\Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineScaleSetTests\TestVirtualMachineScaleSetNetworking.json">
354+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
355+
</None>
353356
<None Include="Templates\azuredeploy.json">
354357
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
355358
</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: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,3 +856,70 @@ 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+
$namespace = "Microsoft.Compute";
871+
$type = "virtualMachineScaleSets/publicIPAddresses";
872+
$location = Get-AzureRmResourceProvider -ProviderNamespace $namespace | where {$_.ResourceTypes[0].ResourceTypeName -eq $type};
873+
$loc = "";
874+
if($location) { $loc = $location.Locations[0] } else { $loc = "southeastasia" };
875+
876+
try
877+
{
878+
# Common
879+
New-AzureRMResourceGroup -Name $rgname -Location $loc -Force;
880+
881+
# SRP
882+
$stoname = 'sto' + $rgname;
883+
$stotype = 'Standard_GRS';
884+
New-AzureRMStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
885+
$stoaccount = Get-AzureRMStorageAccount -ResourceGroupName $rgname -Name $stoname;
886+
887+
# NRP
888+
$subnet = New-AzureRMVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
889+
$vnet = New-AzureRMVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
890+
$vnet = Get-AzureRMVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
891+
$subnetId = $vnet.Subnets[0].Id;
892+
893+
# New VMSS Parameters
894+
$vmssName = 'vmss' + $rgname;
895+
$adminUsername = 'Foo12';
896+
$adminPassword = $PLACEHOLDER;
897+
$imgRef = Get-DefaultCRPImage -loc $loc;
898+
$vmss_number = 2;
899+
900+
$nsg = New-AzureRmNetworkSecurityGroup -ResourceGroupName $rgname -Name $nsgName -Location $loc;
901+
$nsgId = $nsg.Id;
902+
$dns = '10.11.12.13';
903+
904+
$ipCfg = New-AzureRmVmssIPConfig -Name 'test' -SubnetId $subnetId -PublicIPAddressConfigurationName $ipName -PublicIPAddressConfigurationIdleTimeoutInMinutes 10 -DnsSetting "testvmssdnscom";
905+
$vmss = New-AzureRmVmssConfig -Location $loc -SkuCapacity $vmss_number -SkuName 'Standard_A0' -UpgradePolicyMode 'Automatic' -NetworkInterfaceConfiguration $netCfg -Overprovision $false -SinglePlacementGroup $false `
906+
| Add-AzureRmVmssNetworkInterfaceConfiguration -Name 'test' -Primary $true -IPConfiguration $ipCfg -DnsSettingsDnsServer $dns -NetworkSecurityGroupId $nsg.Id `
907+
| Set-AzureRmVmssOSProfile -ComputerNamePrefix 'test' -AdminUsername $adminUsername -AdminPassword $adminPassword `
908+
| Set-AzureRmVmssStorageProfile -OsDiskCreateOption 'FromImage' -OsDiskCaching 'None' `
909+
-ImageReferenceOffer $imgRef.Offer -ImageReferenceSku $imgRef.Skus -ImageReferenceVersion $imgRef.Version -ImageReferencePublisher $imgRef.PublisherName;
910+
911+
$result = New-AzureRmVmss -ResourceGroupName $rgname -Name $vmssName -VirtualMachineScaleSet $vmss;
912+
913+
Assert-NotNull $result.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations;
914+
Assert-AreEqual $result.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].DnsSettings.DnsServers $dns;
915+
Assert-AreEqual $result.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].NetworkSecurityGroup.Id $nsgId;
916+
Assert-NotNull $result.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations;
917+
Assert-AreEqual $result.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations[0].PublicIPAddressConfiguration.Name $ipName;
918+
919+
}
920+
finally
921+
{
922+
# Cleanup
923+
Clean-ResourceGroup $rgname
924+
}
925+
}

0 commit comments

Comments
 (0)