Skip to content

Commit

Permalink
Add Azure Route Server CRUD cmdlets to deprecate Virtual Router cmdle…
Browse files Browse the repository at this point in the history
…ts (#14036)

* change name from virtual router to route server

* add test records

* fix warning

* delete unused import
  • Loading branch information
litchiyangMSFT authored Jan 28, 2021
1 parent cea4e1c commit 9c72a1d
Show file tree
Hide file tree
Showing 39 changed files with 12,485 additions and 4 deletions.
17 changes: 17 additions & 0 deletions src/Network/Network.Test/ScenarioTests/VirtualRouterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ public void TestVirtualRouterCRUDMinimalParameters()
TestRunner.RunTestScript(string.Format("Test-VirtualRouterCRUD"));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.pgtm)]
public void TestRouteServerCRUD()
{
TestRunner.RunTestScript(string.Format("Test-RouteServerCRUD"));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.pgtm)]
Expand All @@ -41,6 +49,15 @@ public void TestVirtualRouterPeerCRUD()
TestRunner.RunTestScript(string.Format("Test-VirtualRouterPeerCRUD"));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.pgtm)]
public void TestRouteServerPeerCRUD()
{
TestRunner.RunTestScript(string.Format("Test-RouteServerPeerCRUD"));
}


[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.pgtm)]
Expand Down
117 changes: 117 additions & 0 deletions src/Network/Network.Test/ScenarioTests/VirtualRouterTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,123 @@ function Test-VirtualRouterPeerCRUD
}
}

<#
.SYNOPSIS
Test route server CRUD
#>
function Test-RouteServerCRUD
{
# Setup
$rgname = Get-ResourceGroupName
$vnetName = Get-ResourceName
$rglocation = Get-ProviderLocation ResourceManagement "centraluseuap"
$routeServerName = Get-ResourceName
$subnetName = Get-ResourceName

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

# Create the Virtual Network
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $rglocation -AddressPrefix 10.0.0.0/16 -Subnet $subnet
$vnet = Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname
$hostedSubnet = Get-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $vnet

# Create Virtual Router
$actualvr = New-AzRouteServer -ResourceGroupName $rgname -location $rglocation -RouteServerName $routeServerName -HostedSubnet $hostedsubnet.Id
$expectedvr = Get-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerName
Assert-AreEqual $expectedvr.ResourceGroupName $actualvr.ResourceGroupName
Assert-AreEqual $expectedvr.Name $actualvr.Name
Assert-AreEqual $expectedvr.Location $actualvr.Location

# Update virtual route with branch to branch traffic
$actualvr = Update-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerName -AllowBranchToBranchTraffic
$expectedvr = Get-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerName
Assert-True { $expectedvr.AllowBranchToBranchTraffic }

# Block branch to branch traffic
$actualvr = Update-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerName
$expectedvr = Get-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerName
Assert-False { $expectedvr.AllowBranchToBranchTraffic }

# List Virtual Routers
$list = Get-AzRouteServer -ResourceGroupName $rgname
Assert-AreEqual 1 @($list).Count
Assert-AreEqual $list[0].ResourceGroupName $actualvr.ResourceGroupName
Assert-AreEqual $list[0].Name $actualvr.Name
Assert-AreEqual $list[0].Location $actualvr.Location

# Delete VR
$deletevr = Remove-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerName -PassThru -Force
Assert-AreEqual true $deletevr

$list = Get-AzRouteServer -ResourceGroupName $rgname
Assert-AreEqual 0 @($list).Count
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Test route server peer CRUD
#>
function Test-RouteServerPeerCRUD
{
# Setup
$rgname = Get-ResourceGroupName
$vnetName = Get-ResourceName
$rglocation = Get-ProviderLocation ResourceManagement "centraluseuap"
$routeServerName = Get-ResourceName
$virtualWanName = Get-ResourceName
$subnetName = Get-ResourceName
$peerName = Get-ResourceName

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

# Create virtual network and subnet
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $rglocation -AddressPrefix 10.0.0.0/16 -Subnet $subnet
$vnet = Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname
$hostedSubnet = Get-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $vnet

# Create virtual router
$routeServer = New-AzRouteServer -ResourceGroupName $rgname -location $rglocation -RouteServerName $routeServerName -HostedSubnet $hostedsubnet.Id
$routeServer = Get-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerName

# Create hub bgp connection
$actualBgpConnection = Add-AzRouteServerPeer -ResourceGroupName $rgname -RouteServerName $routeServerName -PeerName $peerName -PeerIp "192.168.1.5" -PeerAsn "20000"
$expectedBgpConnection = Get-AzRouteServerPeer -ResourceGroupName $rgname -RouteServerName $routeServerName -PeerName $peerName
Assert-AreEqual $expectedBgpConnection.Peerings.PeerName $actualBgpConnection.PeerName
Assert-AreEqual $expectedBgpConnection.PeerIp "192.168.1.5"
Assert-AreEqual $expectedBgpConnection.PeerAsn "20000"

#delete hub bgp connection
$deleteBgpConnection = Remove-AzRouteServerPeer -ResourceGroupName $rgname -RouteServerName $routeServerName -PeerName $peerName -Force
Assert-AreEqual 0 @($deleteBgpConnection.Peerings).Count

# Delete virtual router
$deleteRouteServer = Remove-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerName -PassThru -Force
Assert-AreEqual true $deleteRouteServer

$list = Get-AzRouteServer -ResourceGroupName $rgname
Assert-AreEqual 0 @($list).Count
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Test virtual router peer learned and advertiesd routes (bgp routes)
Expand Down
Loading

0 comments on commit 9c72a1d

Please sign in to comment.