Skip to content

Commit

Permalink
Add HubIpConfiguration and HubBgpConnections (#12565)
Browse files Browse the repository at this point in the history
* Add HubIpConfiguration and HubBgpConnections

* Fix bug in test record and static analysis

* Modify info in breaking changes

* Change format of csv file

* Change output type of AzVirtualRouterPeer cmdlets

* Add back AllowActivaFTP

* Add back RemoteBgpCommunitiesText

* Update Network.format.ps1xml

* Update Network.format.ps1xml

* Update HubBgpConnectionTests.ps1

* Update VirtualRouterTests.ps1

* Modify output types

* Update BreakingChangeIssues.csv

* Update ChangeLog.md

* Update New-AzVirtualWan.md

* Update New-AzVirtualRouter.md

* Update New-AzVirtualRouter.md

* Update New-AzVirtualRouter.md

Co-authored-by: Yabo Hu <[email protected]>
  • Loading branch information
litchiyangMSFT and VeryEarly authored Aug 6, 2020
1 parent 3aa7d78 commit 13eab56
Show file tree
Hide file tree
Showing 32 changed files with 5,879 additions and 17,295 deletions.
22 changes: 22 additions & 0 deletions src/Network/Network.Test/ScenarioTests/HubBgpConnectionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.Azure.Commands.Network.Test.ScenarioTests;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Commands.Network.Test.ScenarioTests
{
public class HubBgpConnectionTests : NetworkTestRunner
{
public HubBgpConnectionTests(Xunit.Abstractions.ITestOutputHelper output)
: base(output)
{
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.pgtm)]
public void TestHubBgpConnectionCRUDMinimalParameters()
{
TestRunner.RunTestScript(string.Format("Test-HubBgpConnectionCRUD"));
}
}
}
80 changes: 80 additions & 0 deletions src/Network/Network.Test/ScenarioTests/HubBgpConnectionTests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

function Check-CmdletReturnType
{
param($cmdletName, $cmdletReturn)

$cmdletData = Get-Command $cmdletName
Assert-NotNull $cmdletData
[array]$cmdletReturnTypes = $cmdletData.OutputType.Name | Foreach-Object { return ($_ -replace "Microsoft.Azure.Commands.Network.Models.","") }
[array]$cmdletReturnTypes = $cmdletReturnTypes | Foreach-Object { return ($_ -replace "System.","") }
$realReturnType = $cmdletReturn.GetType().Name -replace "Microsoft.Azure.Commands.Network.Models.",""
return $cmdletReturnTypes -contains $realReturnType
}

<#
.SYNOPSIS
Test creating new HubBgpConnection
#>
function Test-HubBgpConnectionCRUD
{
# Setup
$rgname = Get-ResourceGroupName
$vnetName = Get-ResourceName
$rglocation = Get-ProviderLocation ResourceManagement "centraluseuap"
$virtualRouterName = 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
$virtualRouter = New-AzVirtualRouter -ResourceGroupName $rgname -location $rglocation -Name $virtualRouterName -HostedSubnet $hostedsubnet.Id
$virtualRouter = Get-AzVirtualRouter -ResourceGroupName $rgname -RouterName $virtualRouterName

# Create hub bgp connection
$actualBgpConnection = Add-AzVirtualRouterPeer -ResourceGroupName $rgname -VirtualRouterName $virtualRouterName -PeerName $peerName -PeerIp "192.168.1.5" -PeerAsn "20000"
$expectedBgpConnection = Get-AzVirtualRouterPeer -ResourceGroupName $rgname -VirtualRouterName $virtualRouterName -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-AzVirtualRouterPeer -ResourceGroupName $rgname -VirtualRouterName $virtualRouterName -PeerName $peerName -Force
Assert-AreEqual 0 @($deleteBgpConnection.Peerings).Count

# Delete virtual router
$deleteVirtualRouter = Remove-AzVirtualRouter -ResourceGroupName $rgname -RouterName $virtualRouterName -PassThru -Force
Assert-AreEqual true $deleteVirtualRouter

$list = Get-AzVirtualRouter -ResourceGroupName $rgname
Assert-AreEqual 0 @($list).Count
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public VirtualRouterTests(Xunit.Abstractions.ITestOutputHelper output)
{
}

[Fact(Skip = "Fails with Internal Server Error")]
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.pgtm)]
public void TestVirtualRouterCRUDMinimalParameters()
Expand Down
69 changes: 23 additions & 46 deletions src/Network/Network.Test/ScenarioTests/VirtualRouterTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,69 +32,46 @@ function Test-VirtualRouterCRUD
{
# Setup
$rgname = Get-ResourceGroupName
$rname = Get-ResourceName
$domainNameLabel = Get-ResourceName
$vnetName = Get-ResourceName
$publicIpName = Get-ResourceName
$vnetGatewayConfigName = Get-ResourceName
$rglocation = Get-ProviderLocation ResourceManagement "southcentralus"
$resourceTypeParent = "Microsoft.Network/virtualNetworkGateways"
$location = Get-ProviderLocation $resourceTypeParent "southcentralus"
$virtualRouterName = Get-ResourceName
$rglocation = Get-ProviderLocation ResourceManagement "centraluseuap"
$virtualRouterName = 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 "GatewaySubnet" -AddressPrefix 10.0.0.0/24
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $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
$subnet = Get-AzVirtualNetworkSubnetConfig -Name "GatewaySubnet" -VirtualNetwork $vnet

# Create the publicip
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel

# Create & Get virtualnetworkgateway
$vnetIpConfig = New-AzVirtualNetworkGatewayIpConfig -Name $vnetGatewayConfigName -PublicIpAddress $publicip -Subnet $subnet

$actual = New-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -IpConfigurations $vnetIpConfig -GatewayType ExpressRoute -GatewaySku HighPerformance -VpnType RouteBased -VpnGatewayGeneration None -Force
$expected = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName
Assert-AreEqual $expected.Name $actual.Name
Assert-AreEqual "ExpressRoute" $expected.GatewayType
Assert-AreEqual "None" $expected.VpnGatewayGeneration

# Create Virtual Router
$actualvr = New-AzVirtualRouter -ResourceGroupName $rgname -location $location -Name $virtualRouterName -HostedGateway $expected
$expectedvr = Get-AzVirtualRouter -ResourceGroupName $rgname -RouterName $virtualRouterName
Assert-AreEqual $expectedvr.ResourceGroupName $actualvr.ResourceGroupName
$hostedSubnet = Get-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $vnet

# Create Virtual Router
$actualvr = New-AzVirtualRouter -ResourceGroupName $rgname -location $rglocation -Name $virtualRouterName -HostedSubnet $hostedsubnet.Id
$expectedvr = Get-AzVirtualRouter -ResourceGroupName $rgname -RouterName $virtualRouterName
Assert-AreEqual $expectedvr.ResourceGroupName $actualvr.ResourceGroupName
Assert-AreEqual $expectedvr.Name $actualvr.Name

# List Virtual Routers
$list = Get-AzVirtualRouter -ResourceGroupName $rgname
Assert-AreEqual $expectedvr.Location $actualvr.Location

# List Virtual Routers
$list = Get-AzVirtualRouter -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-AzVirtualRouter -ResourceGroupName $rgname -RouterName $virtualRouterName -PassThru -Force
Assert-AreEqual true $deletevR

# Delete virtualNetworkGateway
$delete = Remove-AzVirtualNetworkGateway -ResourceGroupName $actual.ResourceGroupName -name $rname -PassThru -Force
Assert-AreEqual true $delete

$list = Get-AzVirtualRouter -ResourceGroupName $rgname
Assert-AreEqual 0 @($list).Count

# Delete VR
$deletevr = Remove-AzVirtualRouter -ResourceGroupName $rgname -RouterName $virtualRouterName -PassThru -Force
Assert-AreEqual true $deletevr

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

Loading

0 comments on commit 13eab56

Please sign in to comment.