Skip to content

Commit 2fe955a

Browse files
authored
Merge pull request Azure#9936 from rileymckenna/preview
Peering Service Preview
2 parents 3f1cef7 + 121e47b commit 2fe955a

File tree

107 files changed

+8360
-3522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+8360
-3522
lines changed

src/Peering/Peering.Test/Peering.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.Azure.Management.Peering" Version="0.10.0-preview" />
14+
<PackageReference Include="Microsoft.Azure.Management.Peering" Version="1.0.0-preview" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

src/Peering/Peering.Test/ScenarioTests/ConvertLegacyTests.ps1

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,24 @@
1515
.SYNOPSIS
1616
GetLocationKindExchange
1717
#>
18-
function Test-ConvertLegacyKindExchangeAshburn
19-
{
20-
try{
21-
#must be hard coded asn because they have legacy items.
22-
$peerAsn = makePeerAsn 15224;
23-
$name = getPeeringVariable "Name" "AS15224_Ashburn_Exchange"
24-
$rg = getPeeringVariable "ResourceGroupName" "Building40"
25-
$legacy = Get-AzLegacyPeering -Kind Exchange -PeeringLocation Ashburn
26-
Assert-NotNull $legacy
27-
Assert-True {$legacy.Count -ge 1}
28-
$legacy | New-AzPeering -ResourceGroupName $rg -Name $name -PeerAsnResourceId $peerAsn.Id #-Tag @{ tfs_813289="Approved" })
29-
$peering = Get-AzPeering -ResourceGroupName $rg -Name $name
30-
Assert-NotNull $peering
31-
}finally {
32-
$isRemoved = Remove-AzPeerAsn -Name $peerAsn.Name -Force -PassThru
33-
Assert-True {$isRemoved}
34-
}
18+
function Test-ConvertLegacyKindExchangeAshburn {
19+
try {
20+
#must be hard coded asn because they have legacy items.
21+
$peerAsn = makePeerAsn 12129;
22+
$name = getPeeringVariable "Name" "AS12129_Ashburn_Exchange"
23+
$rg = getPeeringVariable "ResourceGroupName" "Building40"
24+
$legacy = Get-AzLegacyPeering -Kind Exchange -PeeringLocation Ashburn
25+
Assert-NotNull $peerAsn.Id
26+
Assert-NotNull $legacy
27+
Assert-True { $legacy.Count -ge 1 }
28+
$legacy | New-AzPeering -ResourceGroupName $rg -Name $name -PeerAsnResourceId $peerAsn.Id
29+
$peering = Get-AzPeering -ResourceGroupName $rg -Name $name
30+
Assert-NotNull $peering
31+
}
32+
finally {
33+
$isRemoved = Remove-AzPeerAsn -Name $peerAsn.Name -Force -PassThru
34+
Assert-True { $isRemoved }
35+
}
3536
}
3637

3738
<#
@@ -48,7 +49,7 @@ function Test-ConvertLegacyKindExchangeAmsterdamWithNewConnection {
4849
Assert-NotNull $legacy
4950
Assert-True { $legacy.Count -ge 1 }
5051
#has to be hard coded becuase this ip address isnt used.
51-
#testing trim
52+
#testing trim
5253
$ipaddress = getPeeringVariable "ipaddress" " 80.249.211.62 "
5354
$facilityId = 26
5455
$maxv4 = maxAdvertisedIpv4

src/Peering/Peering.Test/ScenarioTests/CreateNewExchangePeeringTests.ps1

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,6 @@
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
14-
<#
15-
.SYNOPSIS
16-
Helper Function NewExchangeConnectionV4V6
17-
#>
18-
function NewExchangeConnectionV4V6($facilityId, $v4, $v6)
19-
{
20-
#Create some data for the object
21-
Write-Debug "Creating Connection at $facilityId"
22-
$md5 = getHash
23-
$md5 = $md5.ToString()
24-
Write-Debug "Created Hash $md5"
25-
$offset = Get-Random -Maximum 20 -Minimum 3
26-
$sessionv4 = changeIp "$v4/32" $false $offset $false
27-
$sessionv6 = changeIp "$v6/128" $true $offset $false
28-
Write-Debug "Created IPs $sessionv4"
29-
$maxv4 = maxAdvertisedIpv4
30-
$maxv6 = maxAdvertisedIpv6
31-
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
32-
#create Connection
33-
$createdConnection = New-AzPeeringExchangeConnectionObject -PeeringDbFacilityId $facilityId -MaxPrefixesAdvertisedIPv4 $maxv4 -PeerSessionIPv4Address $sessionv4 -PeerSessionIPv6Address $sessionv6 -MaxPrefixesAdvertisedIPv6 $maxv6 -MD5AuthenticationKey $md5
34-
return $createdConnection
35-
}
36-
3714
<#
3815
.SYNOPSIS
3916
Tests new Exchange Peering
@@ -47,16 +24,16 @@ function Test-NewExchangePeering()
4724
$kind = IsDirect $false
4825
Write-Debug "Getting the Facility Information"
4926
try {
50-
$facility = Get-AzPeeringLocation -PeeringLocation $peeringLocation -Kind $kind
51-
$microsoftIpAddressV4 = $facility[0].MicrosoftIPv4Address.Split(',') | Select-Object -First 1
52-
$microsoftIpAddressV6 = $facility[0].MicrosoftIPv6Address.Split(',') | Select-Object -First 1
53-
$facilityId = $facility[0].PeeringDBFacilityId
54-
$peeringLocation = $facility[0].PeeringLocation
5527
Write-Debug "Getting the Asn Information"
5628
$randNum = getRandomNumber
5729
Write-Debug "Random Number $randNum";
5830
$peerAsn = makePeerAsn $randNum
5931
$asn = $peerAsn.Id
32+
$facility = Get-AzPeeringLocation -PeeringLocation $peeringLocation -Kind $kind
33+
$microsoftIpAddressV4 = $facility[0].MicrosoftIPv4Address.Split(',') | Select-Object -First 1
34+
$microsoftIpAddressV6 = $facility[0].MicrosoftIPv6Address.Split(',') | Select-Object -First 1
35+
$facilityId = $facility[0].PeeringDBFacilityId
36+
$peeringLocation = $facility[0].PeeringLocation
6037
Write-Debug "Creating Connections"
6138
$connection1 = NewExchangeConnectionV4V6 $facilityId $microsoftIpAddressV4 $microsoftIpAddressV6
6239
$connection2 = NewExchangeConnectionV4V6 $facilityId $microsoftIpAddressV4 $microsoftIpAddressV6

src/Peering/Peering.Test/ScenarioTests/GetLocationTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,25 @@ public void TestGetLocationKindDirectSeattle()
7979
{
8080
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindDirectSeattle");
8181
}
82+
83+
/// <summary>
84+
/// The test get location kind direct seattle facility 99999
85+
/// </summary>
86+
[Fact]
87+
[Trait(Category.AcceptanceType, Category.CheckIn)]
88+
public void TestGetLocationKindDirectSeattle99999WithLocation()
89+
{
90+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindDirectSeattle99999WithLocation");
91+
}
92+
93+
/// <summary>
94+
/// The test get location kind direct seattle
95+
/// </summary>
96+
[Fact]
97+
[Trait(Category.AcceptanceType, Category.CheckIn)]
98+
public void TestGetLocationKindDirectSeattle99999()
99+
{
100+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindDirectSeattle99999");
101+
}
82102
}
83103
}

src/Peering/Peering.Test/ScenarioTests/GetLocationTests.ps1

Lines changed: 78 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,97 @@
1515
.SYNOPSIS
1616
GetLocationKindDirect
1717
#>
18-
function Test-GetLocationKindDirect
19-
{
20-
$location = Get-AzPeeringLocation -Kind Direct
21-
Assert-NotNull $location
22-
Assert-True { $location.Count -gt 30}
18+
function Test-GetLocationKindDirect {
19+
try {
20+
$asn = 65000
21+
$asnPeerName = makePeerAsn $asn
22+
$location = Get-AzPeeringLocation -Kind Direct
23+
Assert-NotNull $location
24+
Assert-True { $location.Count -gt 30 }
25+
}
26+
finally {
27+
Remove-AzPeerAsn -Name $asnPeerName -Force
28+
}
2329
}
2430
<#
2531
.SYNOPSIS
2632
GetLocationKindDirect
2733
#>
28-
function Test-GetLocationKindExchange
29-
{
30-
$location = Get-AzPeeringLocation -Kind Exchange
31-
Assert-NotNull $location
32-
Assert-True {$location.Count -gt 60}
34+
function Test-GetLocationKindExchange {
35+
try {
36+
$asn = 65000
37+
$asnPeerName = makePeerAsn $asn
38+
$location = Get-AzPeeringLocation -Kind Exchange
39+
Assert-NotNull $location
40+
Assert-True { $location.Count -gt 60 }
41+
}
42+
finally {
43+
Remove-AzPeerAsn -Name $asnPeerName -Force
44+
}
3345
}
3446
<#
3547
.SYNOPSIS
3648
GetLocationKindExchangeSeattle
3749
#>
38-
function Test-GetLocationKindExchangeSeattle
39-
{
40-
$location = Get-AzPeeringLocation -Kind Exchange -PeeringLocation seattle
41-
Assert-NotNull $location
42-
Assert-AreEqual 5 $location.Count
50+
function Test-GetLocationKindExchangeSeattle {
51+
try {
52+
$asn = 65000
53+
$asnPeerName = makePeerAsn $asn
54+
$location = Get-AzPeeringLocation -Kind Exchange -PeeringLocation seattle
55+
Assert-NotNull $location
56+
Assert-AreEqual 5 $location.Count
57+
}
58+
finally {
59+
Remove-AzPeerAsn -Name $asnPeerName -Force
60+
}
4361
}
4462
<#
4563
.SYNOPSIS
4664
GetLocationKindDirectSeattle
4765
#>
48-
function Test-GetLocationKindDirectSeattle
49-
{
50-
$location = Get-AzPeeringLocation -Kind Direct -PeeringLocation seattle
51-
Assert-NotNull $location
52-
Assert-AreEqual 2 $location.Count
66+
function Test-GetLocationKindDirectSeattle {
67+
try {
68+
$asn = 65000
69+
$asnPeerName = makePeerAsn $asn
70+
$location = Get-AzPeeringLocation -Kind Direct -DirectPeeringType Edge -PeeringLocation sea
71+
Assert-NotNull $location
72+
Assert-True { $location.Count -ge 2 }
73+
}
74+
finally {
75+
Remove-AzPeerAsn -Name $asnPeerName -Force
76+
}
5377
}
78+
79+
<#
80+
.SYNOPSIS
81+
GetLocationKindDirectSeattle
82+
#>
83+
function Test-GetLocationKindDirectSeattle99999WithLocation {
84+
try {
85+
$asn = 65000
86+
$asnPeerName = makePeerAsn $asn
87+
$location = Get-AzPeeringLocation -Kind Direct -DirectPeeringType Edge -PeeringLocation sea -PeeringDbFacilityId 99999
88+
Assert-NotNull $location
89+
Assert-True { $location.Count -eq 1 }
90+
}
91+
finally {
92+
Remove-AzPeerAsn -Name $asnPeerName -Force
93+
}
94+
}
95+
96+
<#
97+
.SYNOPSIS
98+
GetLocationKindDirectSeattle
99+
#>
100+
function Test-GetLocationKindDirectSeattle99999 {
101+
try {
102+
$asn = 65000
103+
$asnPeerName = makePeerAsn $asn
104+
$location = Get-AzPeeringLocation -Kind Direct -DirectPeeringType Edge -PeeringDbFacilityId 99999
105+
Assert-NotNull $location
106+
Assert-True { $location.Count -eq 1 }
107+
}
108+
finally {
109+
Remove-AzPeerAsn -Name $asnPeerName -Force
110+
}
111+
}

src/Peering/Peering.Test/ScenarioTests/PeeringAsnTests.ps1

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,6 @@ function Test-ListPeerAsn
8686
Assert-Null $cleaner
8787
}
8888

89-
function makePeerAsn($asn)
90-
{
91-
$asnId = $asn
92-
$asnPeerName = getAssetName "Global"
93-
$asnPeer = getAssetName
94-
[string[]]$emails = "noc@$asnPeer.com","noc@$asnPeerName.com"
95-
$phone = getAssetName
96-
$created = New-AzPeerAsn -Name $asnPeerName -PeerName $asnPeer -PeerAsn $asnId -Email $emails -Phone $phone
97-
$created.ValidationState = "Approved";
98-
$created = $created | Set-AzPeerAsn
99-
return $created
100-
}
101-
10289
<#
10390
.SYNOPSIS
10491
Tests set email

src/Peering/Peering.Test/ScenarioTests/PeeringCommon.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,25 @@ function makePeerAsn($asn)
112112
return $created
113113
}
114114

115+
function NewExchangeConnectionV4V6($facilityId, $v4, $v6)
116+
{
117+
#Create some data for the object
118+
Write-Debug "Creating Connection at $facilityId"
119+
$md5 = getHash
120+
$md5 = $md5.ToString()
121+
Write-Debug "Created Hash $md5"
122+
$offset = Get-Random -Maximum 20 -Minimum 3
123+
$sessionv4 = changeIp "$v4/32" $false $offset $false
124+
$sessionv6 = changeIp "$v6/128" $true $offset $false
125+
Write-Debug "Created IPs $sessionv4"
126+
$maxv4 = maxAdvertisedIpv4
127+
$maxv6 = maxAdvertisedIpv6
128+
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
129+
#create Connection
130+
$createdConnection = New-AzPeeringExchangeConnectionObject -PeeringDbFacilityId $facilityId -MaxPrefixesAdvertisedIPv4 $maxv4 -PeerSessionIPv4Address $sessionv4 -PeerSessionIPv6Address $sessionv6 -MaxPrefixesAdvertisedIPv6 $maxv6 -MD5AuthenticationKey $md5
131+
return $createdConnection
132+
}
133+
115134
function getPeeringVariable
116135
{
117136
param([string]$variableName, $value)
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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+
namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
16+
{
17+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18+
19+
using Xunit;
20+
21+
/// <summary>
22+
/// The get legacy tests.
23+
/// </summary>
24+
public class PeeringServiceTests
25+
{
26+
/// <summary>
27+
/// The logger.
28+
/// </summary>
29+
private ServiceManagement.Common.Models.XunitTracingInterceptor logger;
30+
31+
/// <summary>
32+
/// Initializes a new instance of the <see cref="GetLegacyTests"/> class.
33+
/// </summary>
34+
/// <param name="output">
35+
/// The output.
36+
/// </param>
37+
public PeeringServiceTests(Xunit.Abstractions.ITestOutputHelper output)
38+
{
39+
this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
40+
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
41+
}
42+
43+
[Fact]
44+
[Trait(Category.AcceptanceType, Category.CheckIn)]
45+
public void TestGetPeeringServiceProviders()
46+
{
47+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetPeeringServiceProviders");
48+
}
49+
50+
[Fact]
51+
[Trait(Category.AcceptanceType, Category.CheckIn)]
52+
public void TestGetPeeringServiceLocations()
53+
{
54+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetPeeringServiceLocations");
55+
}
56+
57+
[Fact]
58+
[Trait(Category.AcceptanceType, Category.CheckIn)]
59+
public void TestGetPeeringServiceByResourceGroup()
60+
{
61+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetPeeringServiceByResourceGroup");
62+
}
63+
64+
[Fact]
65+
[Trait(Category.AcceptanceType, Category.CheckIn)]
66+
public void TestGetPeeringServiceByResourceId()
67+
{
68+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetPeeringServiceByResourceId");
69+
}
70+
71+
[Fact]
72+
[Trait(Category.AcceptanceType, Category.CheckIn)]
73+
public void TestListPeeringService()
74+
{
75+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-ListPeeringService");
76+
}
77+
78+
[Fact]
79+
[Trait(Category.AcceptanceType, Category.CheckIn)]
80+
public void TestNewPeeringService()
81+
{
82+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewPeeringService");
83+
}
84+
85+
[Fact]
86+
[Trait(Category.AcceptanceType, Category.CheckIn)]
87+
public void TestNewPeeringServicePrefix()
88+
{
89+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewPeeringServicePrefix");
90+
}
91+
}
92+
}

0 commit comments

Comments
 (0)