Skip to content

Commit

Permalink
Add new properties a new commandlet to support the address space upda…
Browse files Browse the repository at this point in the history
…te in peered vNets (#14730)

* Changes for adding new commandlet for sync operation

* Reverting the unintended change related to flow timeout

* Updating with the SDK that has the newer fields

Updating with the SDK that has the newer fields

* Updating the networking SDK for all references

Updating the networking SDK for all references

* Added Parameter Set & Updated Changelog.md & Recorded PS Test

* Minor update to changelog.md file and removed comment from VirtualNetworkTests.cs

* Added default parameter set and ShouldSupportProcess=false

* Added default parameter set and ShouldSupportProcess=false

* Sync-AzVirtualNetworkPeering.md Help file

* Updated links in help files

* Minor spacing issue in help files hyperlink

* Changed synopsis and description from comment to actual string

* Added Sync-AzVirtualNetworkPeering to StaticAnalysis exception to ignore the shouldProcess error

* Updating build steps

* Setting supportsshouldprocess = true in sync-azvnetpeering

* Reverting the Signature Issues

Co-authored-by: Hari Prasad Perabattula <haperaba@microsoft.com>
Co-authored-by: Satya-anshu <70507845+Satya-anshu@users.noreply.github.com>
  • Loading branch information
3 people authored May 18, 2021
1 parent b996748 commit 5f81ef0
Show file tree
Hide file tree
Showing 38 changed files with 4,241 additions and 23 deletions.
6 changes: 6 additions & 0 deletions .azure-pipelines/util/analyze-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ steps:
parameters:
osName: ${{ parameters.osName }}

- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 2.1.x

- pwsh: 'Install-Module platyPS -Force -Confirm:$false -Scope CurrentUser'
displayName: 'Install platyPS'

Expand Down
6 changes: 6 additions & 0 deletions .azure-pipelines/util/build-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ steps:
inputs:
filePath: tools/CheckIgnoredFile.ps1

- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 2.1.x

- task: DotNetCoreCLI@2
displayName: Build
inputs:
Expand Down
2 changes: 1 addition & 1 deletion src/Batch/Batch.Test/Batch.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="Microsoft.Azure.Batch" Version="13.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Batch" Version="11.0.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="330.2247.36274" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="413.1856.57282" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.CognitiveServices" Version="7.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="330.2247.36274" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="413.1856.57282" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Compute/Compute.Test/Compute.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="44.0.0" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="3.1.0-preview.2" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="330.2247.36274" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="413.1856.57282" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.ContainerRegistry" Version="4.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="330.2247.36274" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="413.1856.57282" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.6.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="5.6.0">
<NoWarn>NU1608</NoWarn>
Expand Down
2 changes: 1 addition & 1 deletion src/CosmosDB/CosmosDB.Test/CosmosDB.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.Test.props" />
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Network" Version="330.2247.36274" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="413.1856.57282" />
<PackageReference Include="Microsoft.Azure.Management.CosmosDB" Version="2.0.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.DataLake.Store" Version="2.4.2-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="330.2247.36274" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="413.1856.57282" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Dns/Dns.Test/Dns.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Dns" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="330.2247.36274" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="413.1856.57282" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/HDInsight/HDInsight.Test/HDInsight.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="Microsoft.Azure.Management.HDInsight.Job" Version="2.0.7" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="3.1.0-preview.2" />
<PackageReference Include="Microsoft.Azure.Management.ManagedServiceIdentity" Version="0.11.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="330.2247.36274" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="413.1856.57282" />
<PackageReference Include="Microsoft.Azure.Management.OperationalInsights" Version="0.21.0-preview" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/HPCCache/HPCCache.Test/HPCCache.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Authorization" Version="2.11.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="14.5.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="330.2247.36274" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="413.1856.57282" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/KeyVault/KeyVault.Test/KeyVault.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.KeyVault.WebKey" Version="3.0.1" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="3.1.0-preview.2" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="330.2247.36274" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="413.1856.57282" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Monitor/Monitor.Test/Monitor.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Monitor" Version="0.25.3-preview" />
<PackageReference Include="Microsoft.Azure.Management.ApplicationInsights" Version="0.3.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="330.2247.36274" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="413.1856.57282" />
<PackageReference Include="Microsoft.Azure.Management.OperationalInsights" Version="0.21.0-preview" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/NetAppFiles/NetAppFiles.Test/NetAppFiles.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.NetApp" Version="1.10.0" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="330.2247.36274" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="413.1856.57282" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Network/Network.Test/Network.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="330.2247.36274" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="413.1856.57282" />
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.5" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="3.1.0-preview.2" />
<PackageReference Include="Microsoft.Azure.Insights" Version="0.16.0-preview" />
Expand Down
8 changes: 8 additions & 0 deletions src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,13 @@ public void TestVirtualNetworkCRUDFlowTimeout()
{
TestRunner.RunTestScript("Test-VirtualNetworkCRUD-FlowTimeout");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]
public void TestVirtualNetworkPeeringSyncCRUD()
{
TestRunner.RunTestScript("Test-SyncVirtualNetworkPeeringCRUD");
}
}
}
124 changes: 123 additions & 1 deletion src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1342,4 +1342,126 @@ function Test-VirtualNetworkCRUD-FlowTimeout
# Cleanup
Clean-ResourceGroup $rgname
}
}
}

<#
.SYNOPSIS
Tests on CRUD for Sync on VirtualNetworkpeering.
#>
function Test-SyncVirtualNetworkPeeringCRUD
{
# Setup
$rgname = Get-ResourceGroupName
$peerName = Get-ResourceName
$peerName2 = Get-ResourceName
$vnet1Name = Get-ResourceName
$vnet2Name = Get-ResourceName
$subnet1Name = Get-ResourceName
$subnet2Name = Get-ResourceName
$rglocation = "eastus2euap"
$resourceTypeParent = "Microsoft.Network/virtualNetworks"
$location = "eastus2euap"

try
{
# Create the resource group
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }

# Create the Virtual Network1
$subnet1 = New-AzVirtualNetworkSubnetConfig -Name $subnet1Name -AddressPrefix 10.1.1.0/24
$vnet1 = New-AzVirtualNetwork -Name $vnet1Name -ResourceGroupName $rgname -Location $location -AddressPrefix 10.1.0.0/16 -Subnet $subnet1


Assert-AreEqual $vnet1.ResourceGroupName $rgname
Assert-AreEqual $vnet1.Name $vnet1Name
Assert-AreEqual $vnet1.Location $rglocation
Assert-AreEqual "Succeeded" $vnet1.ProvisioningState
Assert-AreEqual $vnet1.Subnets[0].Name $subnet1.Name

# Create the Virtual Network2
$subnet2 = New-AzVirtualNetworkSubnetConfig -Name $subnet2Name -AddressPrefix 10.2.1.0/24
$vnet2 = New-AzVirtualNetwork -Name $vnet2Name -ResourceGroupName $rgname -Location $location -AddressPrefix 10.2.0.0/16 -Subnet $subnet2

Assert-AreEqual $vnet2.ResourceGroupName $rgname
Assert-AreEqual $vnet2.Name $vnet2Name
Assert-AreEqual $vnet2.Location $rglocation
Assert-AreEqual "Succeeded" $vnet2.ProvisioningState

# Add Peering to vnet1
$job = $vnet1 | Add-AzVirtualNetworkPeering -name $peerName -RemoteVirtualNetworkId $vnet2.Id -AllowForwardedTraffic -AsJob
$job | Wait-Job
$peer1 = $job | Receive-Job

# Add Peering to VNet2
$job = $vnet2 | Add-AzVirtualNetworkPeering -name $peerName2 -RemoteVirtualNetworkId $vnet1.Id -AllowForwardedTraffic -AsJob
$job | Wait-Job
$peer2 = $job | Receive-Job

Assert-AreEqual $peer1.ResourceGroupName $rgname
Assert-AreEqual $peer1.Name $peerName
Assert-AreEqual $peer1.VirtualNetworkName $vnet1Name
Assert-AreEqual "Succeeded" $peer1.ProvisioningState
Assert-AreEqual $peer1.RemoteVirtualNetwork.Id $vnet2.Id
Assert-AreEqual $peer1.AllowVirtualNetworkAccess True
Assert-AreEqual $peer1.AllowForwardedTraffic True

Assert-AreEqual $peer2.ResourceGroupName $rgname
Assert-AreEqual $peer2.Name $peerName2
Assert-AreEqual $peer2.VirtualNetworkName $vnet2Name
Assert-AreEqual "Succeeded" $peer2.ProvisioningState
Assert-AreEqual $peer2.RemoteVirtualNetwork.Id $vnet1.Id
Assert-AreEqual $peer2.AllowVirtualNetworkAccess True
Assert-AreEqual $peer2.AllowForwardedTraffic True

# Check if Address Spaces are same
Assert-AreEqual $peer1.RemoteVirtualNetworkAddressSpace.AddressPrefixesText $vnet2.AddressSpace.AddressPrefixesText

# Update Address Space of vnet1
$vnet1.AddressSpace.AddressPrefixes.Add("10.99.0.0/16")
$vnet1 | Set-AzVirtualNetwork

# Get and Check Peering Sync Levels of Vnet1 and Vnet2
$peer1 = Get-AzVirtualNetworkPeering -VirtualNetworkName $vnet1Name -Name $peerName -ResourceGroupName $rgname
$peer2 = Get-AzVirtualNetworkPeering -VirtualNetworkName $vnet2Name -Name $peerName2 -ResourceGroupName $rgname

Assert-AreEqual $peer1.PeeringSyncLevel "RemoteNotInSync"
Assert-AreEqual $peer2.PeeringSyncLevel "LocalNotInSync"

# Call Sync on VNet2
$syncVnet2 = Sync-AzVirtualNetworkPeering -Name $peerName2 -VirtualNetworkName $vnet2Name -ResourceGroupName $rgname

# Get and Check Peering Sync Levels of Vnet1 and Vnet2 after updating address space of Vnet1 and syncing them
$peer1 = Get-AzVirtualNetworkPeering -VirtualNetworkName $vnet1Name -Name $peerName -ResourceGroupName $rgname
$peer2 = Get-AzVirtualNetworkPeering -VirtualNetworkName $vnet2Name -Name $peerName2 -ResourceGroupName $rgname

Assert-AreEqual $peer1.PeeringSyncLevel "FullyInSync"
Assert-AreEqual $peer2.PeeringSyncLevel "FullyInSync"

$vnet1 = Get-AzVirtualNetwork -Name $vnet1Name -ResourceGroupName $rgname

Assert-AreEqual $peer2.RemoteVirtualNetworkAddressSpace.AddressPrefixesText $vnet1.AddressSpace.AddressPrefixesText

# Delete Peer1 and Peer2
$job = Remove-AzVirtualNetworkPeering -name $peerName -VirtualNetworkName $vnet1Name -ResourceGroupName $rgname -Force -PassThru -AsJob
$job | Wait-Job
$delete = $job | Receive-Job
Assert-AreEqual true $delete

$job = Remove-AzVirtualNetworkPeering -name $peerName2 -VirtualNetworkName $vnet2Name -ResourceGroupName $rgname -Force -PassThru -AsJob
$job | Wait-Job
$delete = $job | Receive-Job
Assert-AreEqual true $delete

# Delete VirtualNetwork
$delete = Remove-AzVirtualNetwork -ResourceGroupName $rgname -name $vnet1Name -PassThru -Force
Assert-AreEqual true $delete

$delete = Remove-AzVirtualNetwork -ResourceGroupName $rgname -name $vnet2Name -PassThru -Force
Assert-AreEqual true $delete
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
Loading

0 comments on commit 5f81ef0

Please sign in to comment.