Skip to content

Commit b8e6d05

Browse files
committed
Fixed bug in peering location
added additional tests for direct connection
1 parent dc50283 commit b8e6d05

28 files changed

+4834
-369
lines changed

src/Peering/Peering.Test/ScenarioTests/CreateNewDirectConnectionTests.cs

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
1616
{
1717
using Microsoft.Azure.ServiceManagement.Common.Models;
18-
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
1918
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2019

2120
using Xunit;
@@ -123,6 +122,66 @@ public void TestNewDirectConnectionWrongV6()
123122
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWrongV6");
124123
}
125124

125+
/// <summary>
126+
/// The test new direct connection with microsoft ip address
127+
/// </summary>
128+
[Fact]
129+
[Trait(Category.AcceptanceType, Category.CheckIn)]
130+
public void TestNewDirectConnectionWithMicrosoftSession()
131+
{
132+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSession");
133+
}
134+
135+
/// <summary>
136+
/// The test new direct connection with microsoft ip address
137+
/// </summary>
138+
[Fact]
139+
[Trait(Category.AcceptanceType, Category.CheckIn)]
140+
public void TestNewDirectConnectionWithMicrosoftSessionWithPeeringService()
141+
{
142+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSessionWithPeeringService");
143+
}
144+
145+
/// <summary>
146+
/// The test new direct connection with microsoft ip address
147+
/// </summary>
148+
[Fact]
149+
[Trait(Category.AcceptanceType, Category.CheckIn)]
150+
public void TestNewDirectConnectionWithMicrosoftSessionInvalidV4()
151+
{
152+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSessionInvalidV4");
153+
}
154+
155+
/// <summary>
156+
/// The test new direct connection with microsoft ip address
157+
/// </summary>
158+
[Fact]
159+
[Trait(Category.AcceptanceType, Category.CheckIn)]
160+
public void TestNewDirectConnectionWithMicrosoftSessionInvalidV6()
161+
{
162+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithMicrosoftSessionInvalidV6");
163+
}
164+
165+
/// <summary>
166+
/// The test new direct connection with microsoft ip address
167+
/// </summary>
168+
[Fact]
169+
[Trait(Category.AcceptanceType, Category.CheckIn)]
170+
public void TestNewDirectConnectionWithNoPeeringFacility()
171+
{
172+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithNoPeeringFacility");
173+
}
174+
175+
/// <summary>
176+
/// The test new direct connection with microsoft ip address
177+
/// </summary>
178+
[Fact]
179+
[Trait(Category.AcceptanceType, Category.CheckIn)]
180+
public void TestNewDirectConnectionWithNoBgpSession()
181+
{
182+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-NewDirectConnectionWithNoBgpSession");
183+
}
184+
126185
/// <summary>
127186
/// The test new direct connection with microsoft ip address
128187
/// </summary>

src/Peering/Peering.Test/ScenarioTests/CreateNewDirectConnectionTests.ps1

Lines changed: 143 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ NewDirectConnectionWithV4V6
1717
#>
1818
function Test-NewDirectConnectionWithV4V6
1919
{
20+
$asn = makePeerAsn 65000
2021
#Hard Coded locations becuase of limitations in locations
2122
$kind = isDirect $true;
2223
$loc = "Los Angeles"
@@ -43,13 +44,18 @@ function Test-NewDirectConnectionWithV4V6
4344
Assert-AreEqual $sessionv6 $createdConnection.BgpSession.SessionPrefixV6
4445
Assert-AreEqual $false $createdConnection.UseForPeeringService
4546
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider
47+
48+
removePeerAsn $asn
49+
50+
4651
}
4752
<#
4853
.SYNOPSIS
4954
NewDirectConnectionWithV6 v6 should be null
5055
#>
5156
function Test-NewDirectConnectionWithV4
5257
{
58+
$asn = makePeerAsn 65000
5359
#Hard Coded locations becuase of limitations in locations
5460
$kind = isDirect $true;
5561
$loc = "Amsterdam"
@@ -75,13 +81,17 @@ function Test-NewDirectConnectionWithV4
7581
Assert-Null $createdConnection.BgpSession.SessionPrefixV6
7682
Assert-AreEqual $false $createdConnection.UseForPeeringService
7783
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider
84+
85+
removePeerAsn $asn
86+
7887
}
7988
<#
8089
.SYNOPSIS
8190
NewDirectConnectionWithV6 v4 should be Null
8291
#>
8392
function Test-NewDirectConnectionWithV6
8493
{
94+
$asn = makePeerAsn 65000
8595
#Hard Coded locations becuase of limitations in locations
8696
$kind = isDirect $true;
8797
$loc = "Los Angeles"
@@ -106,13 +116,17 @@ function Test-NewDirectConnectionWithV6
106116
Assert-AreEqual $sessionv6 $createdConnection.BgpSession.SessionPrefixV6
107117
Assert-AreEqual $false $createdConnection.UseForPeeringService
108118
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider
119+
120+
removePeerAsn $asn
121+
109122
}
110123
<#
111124
.SYNOPSIS
112125
NewDirectConnectionNoSession should pass with null value
113126
#>
114127
function Test-NewDirectConnectionNoSession
115128
{
129+
$asn = makePeerAsn 65000
116130
#Hard Coded locations becuase of limitations in locations
117131
$kind = isDirect $true;
118132
$loc = "Ashburn"
@@ -136,13 +150,17 @@ function Test-NewDirectConnectionNoSession
136150
Assert-AreEqual $facilityId $createdConnection.PeeringDBFacilityId
137151
Assert-Null $createdConnection.BgpSession
138152
Assert-AreEqual $true $createdConnection.UseForPeeringService
139-
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider}
153+
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider
154+
155+
removePeerAsn $asn
156+
}
140157
<#
141158
.SYNOPSIS
142159
NewDirectConnectionWithV6 should fail with high BandwidthInMbps message
143160
#>
144161
function Test-NewDirectConnectionHighBandwidth
145162
{
163+
$asn = makePeerAsn 65000
146164
#Hard Coded locations becuase of limitations in locations
147165
$kind = isDirect $true;
148166
$loc = "Los Angeles"
@@ -165,13 +183,17 @@ function Test-NewDirectConnectionHighBandwidth
165183
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
166184
#create Connection
167185
Assert-ThrowsContains { New-AzPeeringDirectConnectionObject -PeeringDbFacilityId $facilityId -SessionPrefixV6 $sessionv6 -MaxPrefixesAdvertisedIPv6 $maxv6 -BandwidthInMbps $bandwidth -MD5AuthenticationKey $md5 } "The $bandwidth argument is greater than the maximum allowed range of 100000"
186+
187+
removePeerAsn $asn
188+
168189
}
169190
<#
170191
.SYNOPSIS
171192
NewDirectConnectionWithV6 should fail with low BandwidthInMbps message
172193
#>
173194
function Test-NewDirectConnectionLowBandwidth
174195
{
196+
$asn = makePeerAsn 65000
175197
#Hard Coded locations becuase of limitations in locations
176198
$kind = isDirect $true;
177199
$loc = "Ashburn"
@@ -192,14 +214,18 @@ function Test-NewDirectConnectionLowBandwidth
192214
$maxv6 = maxAdvertisedIpv6
193215
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
194216
#create Connection
195-
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDbFacilityId $facilityId -SessionPrefixV6 $sessionv6 -MaxPrefixesAdvertisedIPv6 $maxv6 -BandwidthInMbps $wrongBandwidth -MD5AuthenticationKey $md5} "The $wrongBandwidth argument is less than the minimum allowed range of 10000"
217+
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDbFacilityId $facilityId -SessionPrefixV6 $sessionv6 -MaxPrefixesAdvertisedIPv6 $maxv6 -BandwidthInMbps $wrongBandwidth -MD5AuthenticationKey $md5} "The $wrongBandwidth argument is less than the minimum allowed range of 10000"
218+
219+
removePeerAsn $asn
220+
196221
}
197222
<#
198223
.SYNOPSIS
199224
NewDirectConnectionWithV6 should fail with wrong IP
200225
#>
201226
function Test-NewDirectConnectionWrongV6
202227
{
228+
$asn = makePeerAsn 65000
203229
#Hard Coded locations becuase of limitations in locations
204230
$kind = isDirect $true;
205231
$loc = "Ashburn"
@@ -220,13 +246,17 @@ function Test-NewDirectConnectionWrongV6
220246
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
221247
#create Connection
222248
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDbFacilityId $facilityId -SessionPrefixV6 $wrongv6 -MaxPrefixesAdvertisedIPv6 $maxv6 -BandwidthInMbps $bandwidth -MD5AuthenticationKey $md5} "Invalid Prefix: $wrongv6, must be"
249+
250+
removePeerAsn $asn
251+
223252
}
224253
<#
225254
.SYNOPSIS
226255
NewDirectConnectionWithV4 with fail on wrong IP
227256
#>
228257
function Test-NewDirectConnectionWrongV4
229258
{
259+
$asn = makePeerAsn 65000
230260
#Hard Coded locations becuase of limitations in locations
231261
$kind = isDirect $true;
232262
$loc = "Ashburn"
@@ -247,6 +277,9 @@ function Test-NewDirectConnectionWrongV4
247277
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
248278
#create Connection
249279
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDbFacilityId $facilityId -SessionPrefixV4 $wrongv4 -MaxPrefixesAdvertisedIPv4 $maxv4 -BandwidthInMbps $bandwidth -MD5AuthenticationKey $md5.ToString} "Invalid Prefix: $wrongv4, must be "
280+
281+
removePeerAsn $asn
282+
250283
}
251284

252285
<#
@@ -255,6 +288,7 @@ Microsoft Provided IP address
255288
#>
256289
function Test-NewDirectConnectionWithMicrosoftIpProvidedAddress
257290
{
291+
$asn = makePeerAsn 65000
258292
#Hard Coded locations becuase of limitations in locations
259293
$kind = isDirect $true;
260294
$loc = "Los Angeles"
@@ -270,4 +304,111 @@ function Test-NewDirectConnectionWithMicrosoftIpProvidedAddress
270304
Assert-AreEqual $null $createdConnection.BgpSession
271305
Assert-AreEqual $true $createdConnection.UseForPeeringService
272306
Assert-AreEqual "Microsoft" $createdConnection.SessionAddressProvider
307+
308+
removePeerAsn $asn
309+
310+
}
311+
312+
<#
313+
.SYNOPSIS
314+
Microsoft Provided IP address
315+
#>
316+
function Test-NewDirectConnectionWithNoPeeringFacility
317+
{
318+
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDbFacilityId} "Missing an argument for parameter 'PeeringDBFacilityId'"
319+
}
320+
321+
<#
322+
.SYNOPSIS
323+
NoBgpSession
324+
#>
325+
function Test-NewDirectConnectionWithNoBgpSession
326+
{
327+
$asn = makePeerAsn 65000
328+
$peeringLocation = Get-AzPeeringLocation -Kind Direct
329+
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
330+
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
331+
$bandwidth = getBandwidth
332+
$connection = New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth
333+
Assert-AreEqual $facilityId $connection.PeeringDBFacilityId
334+
Assert-AreEqual $bandwidth $connection.BandwidthInMbps
335+
Assert-AreEqual "Peer" $connection.SessionAddressProvider
336+
337+
removePeerAsn $asn
338+
339+
}
340+
341+
<#
342+
.SYNOPSIS
343+
NoBgpSession
344+
#>
345+
function Test-NewDirectConnectionWithMicrosoftSession
346+
{
347+
$asn = makePeerAsn 65000
348+
$peeringLocation = Get-AzPeeringLocation -Kind Direct
349+
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
350+
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
351+
$bandwidth = getBandwidth
352+
$connection = New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth -MicrosoftProvidedIPAddress
353+
Assert-AreEqual $facilityId $connection.PeeringDBFacilityId
354+
Assert-AreEqual $bandwidth $connection.BandwidthInMbps
355+
Assert-AreEqual "Microsoft" $connection.SessionAddressProvider
356+
Assert-False {$connection.UseForPeeringService}
357+
358+
removePeerAsn $asn
359+
360+
}
361+
<#
362+
.SYNOPSIS
363+
NoBgpSession
364+
#>
365+
function Test-NewDirectConnectionWithMicrosoftSessionWithPeeringService
366+
{
367+
$asn = makePeerAsn 65000
368+
$peeringLocation = Get-AzPeeringLocation -Kind Direct
369+
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
370+
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
371+
$bandwidth = getBandwidth
372+
$connection = New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth -MicrosoftProvidedIPAddress -UseForPeeringService
373+
Assert-AreEqual $facilityId $connection.PeeringDBFacilityId
374+
Assert-AreEqual $bandwidth $connection.BandwidthInMbps
375+
Assert-AreEqual "Microsoft" $connection.SessionAddressProvider
376+
Assert-True {$connection.UseForPeeringService}
377+
378+
removePeerAsn $asn
379+
380+
}
381+
382+
<#
383+
.SYNOPSIS
384+
NoBgpSession
385+
#>
386+
function Test-NewDirectConnectionWithMicrosoftSessionInvalidV4
387+
{
388+
$asn = makePeerAsn 65000
389+
$peeringLocation = Get-AzPeeringLocation -Kind Direct
390+
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
391+
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
392+
$bandwidth = getBandwidth
393+
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth -SessionPrefixV4 4.4.4.4 -MicrosoftProvidedIPAddress} "Parameter set cannot be resolved using the specified named parameters"
394+
395+
removePeerAsn $asn
396+
397+
}
398+
399+
<#
400+
.SYNOPSIS
401+
NoBgpSession
402+
#>
403+
function Test-NewDirectConnectionWithMicrosoftSessionInvalidV6
404+
{
405+
$asn = makePeerAsn 65000
406+
$peeringLocation = Get-AzPeeringLocation -Kind Direct
407+
$index = Get-Random -Maximum ($peeringLocation.Count -1) -Minimum 1
408+
$facilityId = $peeringLocation[$index].PeeringDBFacilityId
409+
$bandwidth = getBandwidth
410+
Assert-ThrowsContains {New-AzPeeringDirectConnectionObject -PeeringDBFacilityId $facilityId -BandwidthInMbps $bandwidth -SessionPrefixV6 "fe01::40ef" -MicrosoftProvidedIPAddress} "Parameter set cannot be resolved using the specified named parameters"
411+
412+
removePeerAsn $asn
413+
273414
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,15 @@ public void TestGetLocationKindDirectSeattle99999()
9999
{
100100
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindDirectSeattle99999");
101101
}
102+
103+
/// <summary>
104+
/// The test get location kind direct ams
105+
/// </summary>
106+
[Fact]
107+
[Trait(Category.AcceptanceType, Category.CheckIn)]
108+
public void TestGetLocationKindDirectAmsterdam()
109+
{
110+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetLocationKindDirectAmsterdam");
111+
}
102112
}
103113
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,21 @@ function Test-GetLocationKindDirectSeattle99999 {
108108
finally {
109109
Remove-AzPeerAsn -Name $asnPeerName -Force
110110
}
111+
}
112+
113+
<#
114+
.SYNOPSIS
115+
GetLocationKindDirectSeattle
116+
#>
117+
function Test-GetLocationKindDirectAmsterdam {
118+
try {
119+
$asn = 65000
120+
$asnPeerName = makePeerAsn $asn
121+
$location = Get-AzPeeringLocation -Kind Direct -DirectPeeringType Cdn -PeeringLocation Amsterdam
122+
Assert-NotNull $location
123+
Assert-True { $location.Count -ge 1 }
124+
}
125+
finally {
126+
Remove-AzPeerAsn -Name $asnPeerName -Force
127+
}
111128
}

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

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

115+
function removePeerAsn($asn){
116+
$asn | Remove-AzPeerAsn -Force
117+
}
118+
115119
function NewExchangeConnectionV4V6($facilityId, $v4, $v6)
116120
{
117121
#Create some data for the object

0 commit comments

Comments
 (0)