Skip to content

Commit 0880b51

Browse files
author
Maddie Clayton
authored
Merge branch 'preview' into network-september-release
2 parents a33197e + c1eb249 commit 0880b51

File tree

36 files changed

+9236
-32
lines changed

36 files changed

+9236
-32
lines changed

src/ResourceManager/Network/Commands.Network.Test/Commands.Network.Test.csproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<Reference Include="Microsoft.Azure.Management.ContainerInstance">
6666
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ContainerInstance.1.1.0\lib\net452\Microsoft.Azure.Management.ContainerInstance.dll</HintPath>
6767
</Reference>
68+
<Reference Include="System.Runtime" />
6869
</ItemGroup>
6970
<ItemGroup>
7071
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -93,6 +94,7 @@
9394
<Compile Include="ScenarioTests\Generated\RouteTableTestsGenerated.cs" />
9495
<Compile Include="ScenarioTests\TestDnsAvailabilityTest.cs" />
9596
<Compile Include="ScenarioTests\UsageTests.cs" />
97+
<Compile Include="ScenarioTests\VirtualNetworkTapTests.cs" />
9698
<Compile Include="ScenarioTests\VirtualNetworkTests.cs" />
9799
<Compile Include="ScenarioTests\PublicIpAddressTests.cs" />
98100
<Compile Include="ScenarioTests\VirtualNetworkGatewayTests.cs" />
@@ -193,6 +195,9 @@
193195
<None Include="ScenarioTests\UsageTests.ps1">
194196
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
195197
</None>
198+
<None Include="ScenarioTests\VirtualNetworkTapTests.ps1">
199+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
200+
</None>
196201
<None Include="ScenarioTests\VirtualNetworkTests.ps1">
197202
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
198203
</None>
@@ -371,6 +376,9 @@
371376
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.NetworkProfileTests\TestNetworkProfileCRUDMinimalParameters.json">
372377
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
373378
</None>
379+
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.NetworkInterfaceTests\TestNetworkInterfaceTapConfigurationCRUD.json">
380+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
381+
</None>
374382
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.NetworkSecurityGroupTests\TestNetworkSecurityGroupMultiValuedRules.json">
375383
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
376384
</None>
@@ -665,6 +673,9 @@
665673
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.VirtualNetworkGatewayTests\VirtualNetworkGatewayVpnCustomIpsecPolicySetTest.json">
666674
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
667675
</None>
676+
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.VirtualNetworkTapTests\TestVirtualNetworkTapCRUDUsingIpConfig.json">
677+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
678+
</None>
668679
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.VirtualNetworkTests\TestResourceNavigationLinksOnSubnetCRUD.json">
669680
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
670681
</None>

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/NetworkInterfaceTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,13 @@ public void TestNetworkInterfaceWithAcceleratedNetworking()
116116
{
117117
NetworkResourcesController.NewInstance.RunPsTest(_logger, "Test-NetworkInterfaceWithAcceleratedNetworking");
118118
}
119+
120+
[Fact]
121+
[Trait(Category.AcceptanceType, Category.CheckIn)]
122+
[Trait(Category.Owner, Category.sdnnrp)]
123+
public void TestNetworkInterfaceTapConfigurationCRUD()
124+
{
125+
NetworkResourcesController.NewInstance.RunPsTest(_logger, string.Format("Test-NetworkInterfaceTapConfigurationCRUD"));
126+
}
119127
}
120128
}

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/NetworkInterfaceTests.ps1

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,3 +887,98 @@ function Test-NetworkInterfaceWithAcceleratedNetworking
887887
Clean-ResourceGroup $rgname
888888
}
889889
}
890+
891+
<#
892+
.SYNOPSIS
893+
Test creating new NetworkInterfaceTapConfiguration using minimal set of parameters
894+
#>
895+
function Test-NetworkInterfaceTapConfigurationCRUD
896+
{
897+
# Setup
898+
# Setup
899+
$rgname = Get-ResourceGroupName
900+
$vnetName = Get-ResourceName
901+
$subnetName = Get-ResourceName
902+
$publicIpName = Get-ResourceName
903+
$nicName = Get-ResourceName
904+
$domainNameLabel = Get-ResourceName
905+
$rglocation = Get-ProviderLocation ResourceManagement
906+
$resourceTypeParent = "Microsoft.Network/networkInterfaces"
907+
$location = Get-ProviderLocation $resourceTypeParent
908+
$rname = Get-ResourceName
909+
$vtapName = Get-ResourceName
910+
$vtapName2 = Get-ResourceName
911+
$sourceIpConfigName = Get-ResourceName
912+
$sourceNicName = Get-ResourceName
913+
914+
try
915+
{
916+
# Create the resource group
917+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
918+
919+
# Create the Virtual Network
920+
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.1.0/24
921+
$vnet = New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
922+
923+
# Create the publicip
924+
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel
925+
926+
# Create NetworkInterface
927+
$job = New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $rgname -Location $location -Subnet $vnet.Subnets[0] -PublicIpAddress $publicip -AsJob
928+
$job | Wait-Job
929+
$expectedNic = Get-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $rgname
930+
931+
# Create required dependencies (Vtap)
932+
$DestinationEndpoint = $expectedNic.IpConfigurations[0]
933+
$actualVtap = New-AzureRmVirtualNetworkTap -ResourceGroupName $rgname -Name $vtapName -Location $location -DestinationNetworkInterfaceIPConfiguration $DestinationEndpoint -Force
934+
$vVirtualNetworkTap = Get-AzureRmVirtualNetworkTap -ResourceGroupName $rgname -Name $vtapName;
935+
936+
# Create source Nic which is getting tapped
937+
$sourceIpConfig = New-AzureRmNetworkInterfaceIpConfig -Name $sourceIpConfigName -Subnet $vnet.Subnets[0]
938+
$sourceNic = New-AzureRmNetworkInterface -Name $sourceNicName -ResourceGroupName $rgname -Location $location -IpConfiguration $sourceIpConfig -Tag @{ testtag = "testval" }
939+
940+
# Add tap configuration
941+
Add-AzureRmNetworkInterfaceTapConfig -NetworkInterface $sourceNic -VirtualNetworkTap $vVirtualNetworkTap -Name $rname
942+
943+
#get tap configuration
944+
$tapConfig = Get-AzureRmNetworkInterfaceTapConfig -ResourceGroupName $rgname -NetworkInterfaceName $sourceNicName -Name $rname
945+
Assert-NotNull $tapConfig
946+
Assert-AreEqual $tapConfig.ResourceGroupName $rgname
947+
Assert-AreEqual $tapConfig.NetworkInterfaceName $sourceNicName
948+
Assert-AreEqual $tapConfig.Name $rname
949+
950+
# get nic and check back reference
951+
$sourceNic = Get-AzureRmNetworkInterface -Name $sourceNicName -ResourceGroupName $rgname
952+
Assert-NotNull $sourceNic.TapConfigurations
953+
Assert-NotNull $sourceNic.TapConfigurations[0]
954+
Assert-AreEqual $sourceNic.TapConfigurations[0].Id $tapConfig.Id
955+
956+
# get vtap and check back reference
957+
$vVirtualNetworkTap = Get-AzureRmVirtualNetworkTap -ResourceGroupName $rgname -Name $vtapName;
958+
Assert-NotNull $vVirtualNetworkTap.NetworkInterfaceTapConfigurations
959+
Assert-NotNull $vVirtualNetworkTap.NetworkInterfaceTapConfigurations[0]
960+
Assert-AreEqual $vVirtualNetworkTap.NetworkInterfaceTapConfigurations[0].Id $tapConfig.Id
961+
962+
963+
# Remove NetworkInterfaceTapConfiguration
964+
$removeNetworkInterfaceTapConfiguration = Remove-AzureRmNetworkInterfaceTapConfig -ResourceGroupName $rgname -NetworkInterfaceName $sourceNicName -Name $rname -PassThru -Force;
965+
Assert-AreEqual $true $removeNetworkInterfaceTapConfiguration;
966+
967+
$sourceNic = Get-AzureRmNetworkInterface -Name $sourceNicName -ResourceGroupName $rgname
968+
Assert-NotNull $sourceNic.TapConfigurations
969+
Assert-Null $sourceNic.TapConfigurations[0]
970+
971+
# get vtap and check back reference
972+
$vVirtualNetworkTap = Get-AzureRmVirtualNetworkTap -ResourceGroupName $rgname -Name $vtapName;
973+
Assert-NotNull $vVirtualNetworkTap.NetworkInterfaceTapConfigurations
974+
Assert-Null $vVirtualNetworkTap.NetworkInterfaceTapConfigurations[0]
975+
976+
# Get NetworkInterfaceTapConfiguration should fail
977+
Assert-ThrowsContains { Get-AzureRmNetworkInterfaceTapConfig -ResourceGroupName $rgname -NetworkInterfaceName $sourceNicName -Name $rname } "not found";
978+
}
979+
finally
980+
{
981+
# Cleanup
982+
Clean-ResourceGroup $rgname;
983+
}
984+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// <auto-generated>
2+
// Copyright (c) Microsoft and contributors. All rights reserved.
3+
//
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+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
//
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
//
17+
// Warning: This code was generated by a tool.
18+
//
19+
// Changes to this file may cause incorrect behavior and will be lost if the
20+
// code is regenerated.
21+
//
22+
// For documentation on code generator please visit
23+
// https://aka.ms/nrp-code-generation
24+
// Please contact [email protected] if you need to make changes to this file.
25+
// </auto-generated>
26+
27+
using System;
28+
using Microsoft.Azure.ServiceManagemenet.Common.Models;
29+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
30+
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
31+
using Xunit;
32+
using Xunit.Abstractions;
33+
34+
namespace Commands.Network.Test.ScenarioTests
35+
{
36+
public class VirtualNetworkTapTests : RMTestBase
37+
{
38+
public XunitTracingInterceptor _logger;
39+
40+
public VirtualNetworkTapTests(Xunit.Abstractions.ITestOutputHelper output)
41+
{
42+
_logger = new XunitTracingInterceptor(output);
43+
XunitTracingInterceptor.AddToContext(_logger);
44+
}
45+
46+
[Fact]
47+
[Trait(Category.AcceptanceType, Category.CheckIn)]
48+
[Trait(Category.Owner, Category.wanrpdev)]
49+
public void TestVirtualNetworkTapCRUDUsingIpConfig()
50+
{
51+
NetworkResourcesController.NewInstance.RunPsTest(_logger, string.Format("Test-VirtualNetworkTapCRUDUsingIpConfig"));
52+
}
53+
}
54+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+
Tests VirtualNetworkTap using ipendpoints
18+
#>
19+
function Test-VirtualNetworkTapCRUDUsingIpConfig
20+
{
21+
#added temporarily
22+
# Register-AzureRmResourceProvider -ProviderNamespace "Microsoft.Network"
23+
24+
# Setup
25+
$rgname = Get-ResourceGroupName
26+
$vnetName = Get-ResourceName
27+
$subnetName = Get-ResourceName
28+
$publicIpName = Get-ResourceName
29+
$nicName = Get-ResourceName
30+
$domainNameLabel = Get-ResourceName
31+
$rglocation = Get-ProviderLocation ResourceManagement
32+
$resourceTypeParent = "Microsoft.Network/networkInterfaces"
33+
$location = Get-ProviderLocation $resourceTypeParent
34+
$rname = Get-ResourceName
35+
36+
try
37+
{
38+
# Create the resource group
39+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
40+
41+
# Create the Virtual Network
42+
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.1.0/24
43+
$vnet = New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
44+
45+
# Create the publicip
46+
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel
47+
48+
# Create NetworkInterface
49+
$job = New-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $rgname -Location $location -Subnet $vnet.Subnets[0] -PublicIpAddress $publicip -AsJob
50+
$job | Wait-Job
51+
$expectedNic = Get-AzureRmNetworkInterface -Name $nicName -ResourceGroupName $rgname
52+
53+
# Create required dependencies
54+
$DestinationEndpoint = $expectedNic.IpConfigurations[0]
55+
$actualVtap = New-AzureRmVirtualNetworkTap -ResourceGroupName $rgname -Name $rname -Location $location -DestinationNetworkInterfaceIPConfiguration $DestinationEndpoint
56+
57+
$vVirtualNetworkTap = Get-AzureRmVirtualNetworkTap -ResourceGroupName $rgname -Name $rname;
58+
Assert-NotNull $vVirtualNetworkTap;
59+
Assert-AreEqual $vVirtualNetworkTap.ResourceGroupName $actualVtap.ResourceGroupName;
60+
Assert-AreEqual $vVirtualNetworkTap.Name $rname;
61+
Assert-AreEqual $vVirtualNetworkTap.DestinationNetworkInterfaceIPConfiguration.Id $DestinationEndpoint.Id
62+
63+
#update the Vtap resource
64+
$vVirtualNetworkTap.DestinationPort = 8888;
65+
Set-AzureRmVirtualNetworkTap -VirtualNetworkTap $vVirtualNetworkTap
66+
67+
$vVirtualNetworkTap = Get-AzureRmVirtualNetworkTap -ResourceGroupName $rgname -Name $rname;
68+
Assert-NotNull $vVirtualNetworkTap;
69+
Assert-AreEqual $vVirtualNetworkTap.ResourceGroupName $actualVtap.ResourceGroupName;
70+
Assert-AreEqual $vVirtualNetworkTap.Name $rname;
71+
Assert-AreEqual $vVirtualNetworkTap.DestinationNetworkInterfaceIPConfiguration.Id $DestinationEndpoint.Id
72+
Assert-AreEqual $vVirtualNetworkTap.DestinationPort 8888
73+
74+
# Remove VirtualNetworkTap
75+
$removeVirtualNetworkTap = Remove-AzureRmVirtualNetworkTap -ResourceGroupName $rgname -Name $rname -PassThru -Force;
76+
Assert-AreEqual $true $removeVirtualNetworkTap;
77+
78+
# Get VirtualNetworkTap should fail
79+
Assert-ThrowsLike { Get-AzureRmVirtualNetworkTap -ResourceGroupName $rgname -Name $rname } "*${rname}*not found*";
80+
}
81+
finally
82+
{
83+
# Cleanup
84+
Clean-ResourceGroup $rgname
85+
}
86+
}
87+

0 commit comments

Comments
 (0)