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

Add Azure Route Server CRUD cmdlets to deprecate Virtual Router cmdlets #14061

Merged
merged 2 commits into from
Jan 31, 2021
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
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