Skip to content

Commit 38b4f27

Browse files
jjcv-msftjjaviercv-msftVeryEarly
authored
Add customer control knobs for different ExpressRoute gateway types (#22990)
* Add control knobs * Fixes * all changes * fix expected value type * Fix UT * Update ChangeLog.md * fix UT * Add test recording * add cortex tests * . * recording for ER gateways * Fix static analysis --------- Co-authored-by: Javier Colomer <[email protected]> Co-authored-by: Yabo Hu <[email protected]>
1 parent b2abd61 commit 38b4f27

14 files changed

+24016
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using Microsoft.Azure.Commands.Network.Test.ScenarioTests;
17+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18+
using Xunit;
19+
20+
namespace Commands.Network.Test.ScenarioTests
21+
{
22+
public class ExpressRouteGatewayTests : NetworkTestRunner
23+
{
24+
public ExpressRouteGatewayTests(Xunit.Abstractions.ITestOutputHelper output)
25+
: base(output)
26+
{
27+
}
28+
29+
[Fact]
30+
[Trait(Category.AcceptanceType, Category.CheckIn)]
31+
[Trait(Category.Owner, NrpTeamAlias.exrdev)]
32+
public void TestExpressRouteGatewayUpdatesForDifferentCustomerBlockTrafficPreferences()
33+
{
34+
TestRunner.RunTestScript("Test-ExpressRouteGatewayForDifferentCustomerBlockTrafficPreferences");
35+
}
36+
}
37+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
<#
16+
.SYNOPSIS
17+
ExpressRoute gateway traffic block preferences that may be configured by customers
18+
#>
19+
function Test-ExpressRouteGatewayForDifferentCustomerBlockTrafficPreferences
20+
{
21+
# Setup
22+
$rgname = Get-ResourceGroupName
23+
$vWanName = Get-ResourceName
24+
$vHubName = Get-ResourceName
25+
$gatewayName = Get-ResourceName
26+
27+
# return
28+
$rname = Get-ResourceName
29+
$vnetName = Get-ResourceName
30+
$publicIpName = Get-ResourceName
31+
$vnetGatewayConfigName = Get-ResourceName
32+
$rglocation = "centraluseuap"
33+
$resourceTypeParent = "Microsoft.Network/virtualNetworkGateways"
34+
$location = "centraluseuap"
35+
36+
try
37+
{
38+
# Create the resource group
39+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
40+
41+
# Create the virtual WAN
42+
$vwan = New-AzVirtualWan -ResourceGroupName $rgname -Name $vWanName -Location $rglocation
43+
44+
# Create the virtual hub
45+
$hub = New-AzVirtualHub -ResourceGroupName $rgname -Name $vHubName -VirtualWan $vwan -AddressPrefix '10.0.0.0/16' -Location $rglocation
46+
47+
# Create the ExpressRoute gateway
48+
$gateway = New-AzExpressRouteGateway -ResourceGroupName $rgname -Name $gatewayName -MinScaleUnits 1 -VirtualHub $hub
49+
50+
# Update vnet-to-vWAN via property and pass it as input object
51+
$gateway.AllowNonVirtualWanTraffic = $true
52+
Set-AzExpressRouteGateway -InputObject $gateway
53+
$gateway = Get-AzExpressRouteGateway -ResourceGroupName $rgname -Name $gatewayName
54+
Assert-AreEqual $true $gateway.AllowNonVirtualWanTraffic
55+
56+
$gateway.AllowNonVirtualWanTraffic = $false
57+
Set-AzExpressRouteGateway -InputObject $gateway
58+
$gateway = Get-AzExpressRouteGateway -ResourceGroupName $rgname -Name $gatewayName
59+
Assert-AreEqual $false $gateway.AllowNonVirtualWanTraffic
60+
61+
# Update vnet-to-vWAN via cmdlet switch
62+
Set-AzExpressRouteGateway -ResourceGroupName $rgname -Name $gatewayName -AllowNonVirtualWanTraffic $true
63+
$gateway = Get-AzExpressRouteGateway -ResourceGroupName $rgname -Name $gatewayName
64+
Assert-AreEqual $true $gateway.AllowNonVirtualWanTraffic
65+
66+
Set-AzExpressRouteGateway -ResourceGroupName $rgname -Name $gatewayName -AllowNonVirtualWanTraffic $false
67+
$gateway = Get-AzExpressRouteGateway -ResourceGroupName $rgname -Name $gatewayName
68+
Assert-AreEqual $false $gateway.AllowNonVirtualWanTraffic
69+
}
70+
finally
71+
{
72+
# Cleanup
73+
Clean-ResourceGroup $rgname
74+
}
75+
}

src/Network/Network.Test/ScenarioTests/VirtualNetworkGatewayTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,12 @@ public void TestVirtualNetworkExpressRouteGatewayCRUDwithAdminState()
188188
TestRunner.RunTestScript("Test-VirtualNetworkExpressRouteGatewayCRUDwithAdminState");
189189
}
190190

191+
[Fact]
192+
[Trait(Category.AcceptanceType, Category.CheckIn)]
193+
[Trait(Category.Owner, NrpTeamAlias.exrdev)]
194+
public void TestVirtualNetworkExpressRouteGatewayUpdatesForDifferentCustomerBlockTrafficPreferences()
195+
{
196+
TestRunner.RunTestScript("Test-VirtualNetworkExpressRouteGatewayForDifferentCustomerBlockTrafficPreferences");
197+
}
191198
}
192199
}

src/Network/Network.Test/ScenarioTests/VirtualNetworkGatewayTests.ps1

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,3 +1651,100 @@ function Test-VirtualNetworkExpressRouteGatewayCRUDwithAdminState
16511651
Clean-ResourceGroup $rgname
16521652
}
16531653
}
1654+
1655+
<#
1656+
.SYNOPSIS
1657+
Virtual network gateway traffic block preferences that may be configured by customers
1658+
#>
1659+
function Test-VirtualNetworkExpressRouteGatewayForDifferentCustomerBlockTrafficPreferences
1660+
{
1661+
# Setup
1662+
$rgname = Get-ResourceGroupName
1663+
# return
1664+
1665+
$rname = Get-ResourceName
1666+
$vnetName = Get-ResourceName
1667+
$publicIpName = Get-ResourceName
1668+
$vnetGatewayConfigName = Get-ResourceName
1669+
$rglocation = "centraluseuap"
1670+
$resourceTypeParent = "Microsoft.Network/virtualNetworkGateways"
1671+
$location = "centraluseuap"
1672+
1673+
try
1674+
{
1675+
# Create the resource group
1676+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
1677+
1678+
# Create the virtual network
1679+
$subnet = New-AzVirtualNetworkSubnetConfig -Name "GatewaySubnet" -AddressPrefix 10.0.0.0/24
1680+
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
1681+
$vnet = Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname
1682+
$subnet = Get-AzVirtualNetworkSubnetConfig -Name "GatewaySubnet" -VirtualNetwork $vnet
1683+
1684+
# Create the public IP
1685+
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Static
1686+
1687+
# Create & Get virtual network gateway
1688+
$vnetIpConfig = New-AzVirtualNetworkGatewayIpConfig -Name $vnetGatewayConfigName -PublicIpAddress $publicip -Subnet $subnet
1689+
1690+
$createdGateway = New-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -IpConfigurations $vnetIpConfig -GatewayType ExpressRoute -GatewaySku UltraPerformance
1691+
1692+
# Brand-new gateway validations
1693+
$retrievedGateway = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
1694+
Assert-AreEqual $retrievedGateway.ResourceGroupName $createdGateway.ResourceGroupName
1695+
Assert-AreEqual $retrievedGateway.Name $createdGateway.Name
1696+
Assert-AreEqual "ExpressRoute" $retrievedGateway.GatewayType
1697+
Assert-AreEqual $false $retrievedGateway.AllowRemoteVnetTraffic
1698+
Assert-AreEqual $false $retrievedGateway.AllowVirtualWanTraffic
1699+
1700+
# Update vnet-to-vWAN via property
1701+
$retrievedGateway.AllowVirtualWanTraffic = $true
1702+
Set-AzVirtualNetworkGateway -VirtualNetworkGateway $retrievedGateway
1703+
$retrievedGateway = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
1704+
Assert-AreEqual $false $retrievedGateway.AllowRemoteVnetTraffic
1705+
Assert-AreEqual $true $retrievedGateway.AllowVirtualWanTraffic
1706+
$retrievedGateway.AllowVirtualWanTraffic = $false
1707+
Set-AzVirtualNetworkGateway -VirtualNetworkGateway $retrievedGateway
1708+
Assert-AreEqual $false $retrievedGateway.AllowRemoteVnetTraffic
1709+
Assert-AreEqual $false $retrievedGateway.AllowVirtualWanTraffic
1710+
1711+
# Update vnet-to-vWAN via switch
1712+
$retrievedGateway = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
1713+
Set-AzVirtualNetworkGateway -VirtualNetworkGateway $retrievedGateway -AllowVirtualWanTraffic $true
1714+
$retrievedGateway = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
1715+
Assert-AreEqual $false $retrievedGateway.AllowRemoteVnetTraffic
1716+
Assert-AreEqual $true $retrievedGateway.AllowVirtualWanTraffic
1717+
Set-AzVirtualNetworkGateway -VirtualNetworkGateway $retrievedGateway -AllowVirtualWanTraffic $false
1718+
$retrievedGateway = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
1719+
Assert-AreEqual $false $retrievedGateway.AllowRemoteVnetTraffic
1720+
Assert-AreEqual $false $retrievedGateway.AllowVirtualWanTraffic
1721+
1722+
# Update vnet-to-vnet via property
1723+
$retrievedGateway.AllowRemoteVnetTraffic = $true
1724+
Set-AzVirtualNetworkGateway -VirtualNetworkGateway $retrievedGateway
1725+
$retrievedGateway = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
1726+
Assert-AreEqual $true $retrievedGateway.AllowRemoteVnetTraffic
1727+
Assert-AreEqual $false $retrievedGateway.AllowVirtualWanTraffic
1728+
$retrievedGateway.AllowRemoteVnetTraffic = $false
1729+
Set-AzVirtualNetworkGateway -VirtualNetworkGateway $retrievedGateway
1730+
$retrievedGateway = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
1731+
Assert-AreEqual $false $retrievedGateway.AllowRemoteVnetTraffic
1732+
Assert-AreEqual $false $retrievedGateway.AllowVirtualWanTraffic
1733+
1734+
# Update vnet-to-vnet via switch
1735+
$retrievedGateway = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
1736+
Set-AzVirtualNetworkGateway -VirtualNetworkGateway $retrievedGateway -AllowRemoteVnetTraffic $true
1737+
$retrievedGateway = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
1738+
Assert-AreEqual $true $retrievedGateway.AllowRemoteVnetTraffic
1739+
Assert-AreEqual $false $retrievedGateway.AllowVirtualWanTraffic
1740+
Set-AzVirtualNetworkGateway -VirtualNetworkGateway $retrievedGateway -AllowRemoteVnetTraffic $false
1741+
$retrievedGateway = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
1742+
Assert-AreEqual $false $retrievedGateway.AllowRemoteVnetTraffic
1743+
Assert-AreEqual $false $retrievedGateway.AllowVirtualWanTraffic
1744+
}
1745+
finally
1746+
{
1747+
# Cleanup
1748+
Clean-ResourceGroup $rgname
1749+
}
1750+
}

0 commit comments

Comments
 (0)