Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Peering] Add API version 2020-10-01 #14714

Merged
merged 16 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Peering/Peering.Test/Peering.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Peering" Version="2.1.0" />
<PackageReference Include="Microsoft.Azure.Management.Peering" Version="2.1.1" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>

Expand Down
10 changes: 5 additions & 5 deletions src/Peering/Peering.Test/ScenarioTests/ConvertLegacyTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ GetLocationKindExchange
function Test-ConvertLegacyKindExchangeAshburn {
try {
#must be hard coded asn because they have legacy items.
$peerAsn = makePeerAsn 42;
$name = getPeeringVariable "Name" "AS42_Ashburn_Exchange"
$peerAsn = makePeerAsn 1828;
$name = getPeeringVariable "Name" "AS1828_Ashburn_Exchange"
$rg = getPeeringVariable "ResourceGroupName" "Building40"
$legacy = Get-AzLegacyPeering -Kind Exchange -PeeringLocation Ashburn
Assert-NotNull $peerAsn.Id
Expand All @@ -42,15 +42,15 @@ Convert Legacy Kind Exchange Amsterdam With New Connection
function Test-ConvertLegacyKindExchangeAmsterdamWithNewConnection {
try {
#must be hard coded asn because they have legacy items.
$peerAsn = makePeerAsn 42
$name = getPeeringVariable "Name" "AS42_Amsterdam_Exchange"
$peerAsn = makePeerAsn 559
$name = getPeeringVariable "Name" "AS559_Amsterdam_Exchange"
$rg = getPeeringVariable "ResourceGroupName" "Building40"
$legacy = Get-AzLegacyPeering -Kind Exchange -PeeringLocation Amsterdam
Assert-NotNull $legacy
Assert-True { $legacy.Count -ge 1 }
#has to be hard coded becuase this ip address isnt used.
#testing trim
$ipaddress = getPeeringVariable "ipaddress" " 80.249.211.62 "
$ipaddress = getPeeringVariable "ipaddress" " 80.249.208.37 "
$facilityId = 26
$maxv4 = maxAdvertisedIpv4
$connection = New-AzPeeringExchangeConnectionObject -PeeringDbFacilityId $facilityId -MaxPrefixesAdvertisedIPv4 $maxv4 -PeerSessionIPv4Address $ipaddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function Test-NewDirectConnectionWithV4V6 {
$createdConnection = New-AzPeeringDirectConnectionObject -PeeringDbFacilityId $facilityId -SessionPrefixV4 $sessionv4 -SessionPrefixV6 $sessionv6 -MaxPrefixesAdvertisedIPv4 $maxv4 -MaxPrefixesAdvertisedIPv6 $maxv6 -BandwidthInMbps $bandwidth -MD5AuthenticationKey $md5
Assert-AreEqual $md5 $createdConnection.BgpSession.Md5AuthenticationKey
Assert-AreEqual $bandwidth $createdConnection.BandwidthInMbps
Assert-AreEqual $facilityId $createdConnection.PeeringDBFacilityId
Assert-AreEqual $facilityId $createdConnection.PeeringDBFacilityId
Assert-AreEqual $sessionv4 $createdConnection.BgpSession.SessionPrefixV4
Assert-AreEqual $sessionv6 $createdConnection.BgpSession.SessionPrefixV6
Assert-AreEqual $false $createdConnection.UseForPeeringService
Expand Down Expand Up @@ -152,7 +152,7 @@ function Test-NewDirectConnectionNoSession {
}
<#
.SYNOPSIS
NewDirectConnectionWithV6 should fail with high BandwidthInMbps message
NewDirectConnectionWithV6 should allow high BandwidthInMbps and pass
#>
function Test-NewDirectConnectionHighBandwidth {
$asn = makePeerAsn (getRandomNumber)
Expand All @@ -162,23 +162,26 @@ function Test-NewDirectConnectionHighBandwidth {
$peeringLocation = getPeeringLocation $kind $loc;
$facilityId = $peeringLocation[0].PeeringDBFacilityId
#Create some data for the object
#Set up the wrong BandwidthInMbps
#Set up the BandwidthInMbps in multiples of 100G
$bandwidth = getBandwidth
#Anything over 100000 will fail.
#Multiples of 100000 should pass.
$bandwidth = [int]$bandwidth * 10
Write-Debug "Creating Connection at $facilityId"
$md5 = getHash
$md5 = $md5.ToString()
Write-Debug "Created Hash $md5"
$sessionv4 = newIpV4Address $true $true 0 0
$sessionv6 = newIpV6Address $true $true 0 0
Write-Debug "Created IPs $sessionv4 $SessionPrefixV6"
Write-Debug "Created IPs $sessionv4"
$maxv4 = maxAdvertisedIpv4
$maxv6 = maxAdvertisedIpv6
Write-Debug "Created maxAdvertised $maxv4 $maxv6"
Write-Debug "Created maxAdvertised $maxv4"
#create Connection
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"

$createdConnection = New-AzPeeringDirectConnectionObject -PeeringDbFacilityId $facilityId -SessionPrefixV4 $sessionv4 -MaxPrefixesAdvertisedIPv4 $maxv4 -BandwidthInMbps $bandwidth -MD5AuthenticationKey $md5
Assert-AreEqual $md5 $createdConnection.BgpSession.Md5AuthenticationKey
Assert-AreEqual $bandwidth $createdConnection.BandwidthInMbps
Assert-AreEqual $facilityId $createdConnection.PeeringDBFacilityId
Assert-AreEqual $sessionv4 $createdConnection.BgpSession.SessionPrefixV4
Assert-AreEqual $false $createdConnection.UseForPeeringService
Assert-AreEqual "Peer" $createdConnection.SessionAddressProvider
removePeerAsn $asn

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Test-NewDirectPeering
Write-Debug "Random Number $randNum";
$peerAsn = makePeerAsn $randNum
$asn = Get-AzPeerAsn -Name $peerAsn.Name
$facilityId = $peeringLocation[0].PeeringDBFacilityId
$facilityId = 104
#create Connection
$bandwidth = getBandwidth
$directConnection = NewDirectConnectionV4V6 $facilityId $bandwidth
Expand Down Expand Up @@ -203,7 +203,7 @@ function Test-NewDirectPeeringPremiumDirectUnlimited
$resourceName = getAssetName "DirectOneConnection";
Write-Debug "Setting $resourceName"
$peeringLocation = getPeeringLocation $kind $loc;
$facilityId = $peeringLocation[0].PeeringDBFacilityId
$facilityId = 1236
#create Connection
$bandwidth = getBandwidth
$bandwidth2 = getBandwidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Test-NewExchangePeering()
#Hard Coded locations becuase of limitations in locations
$resourceName = getAssetName "NewExchangePeeringCVS"
$resourceGroup = "testCarrier"
$peeringLocation = "Seattle"
$peeringLocation = "Ashburn"
$kind = IsDirect $false
Write-Debug "Getting the Facility Information"
try {
Expand Down
63 changes: 63 additions & 0 deletions src/Peering/Peering.Test/ScenarioTests/GetCdnPeeringPrefixTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

namespace Microsoft.Azure.Commands.Peering.Test.ScenarioTests
{
using Microsoft.WindowsAzure.Commands.ScenarioTest;

using Xunit;

/// <summary>
/// The get cdn peering prefixes tests.
/// </summary>
public class GetCdnPeeringPrefixTests
{
/// <summary>
/// The logger.
/// </summary>
private ServiceManagement.Common.Models.XunitTracingInterceptor logger;

/// <summary>
/// Initializes a new instance of the <see cref="GetCdnPeeringPrefixTests"/> class.
/// </summary>
/// <param name="output">
/// The output.
/// </param>
public GetCdnPeeringPrefixTests(Xunit.Abstractions.ITestOutputHelper output)
{
this.logger = new ServiceManagement.Common.Models.XunitTracingInterceptor(output);
ServiceManagement.Common.Models.XunitTracingInterceptor.AddToContext(this.logger);
}

/// <summary>
/// The test Get Cdn Peering Prefix For Location.
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetCdnPeeringPrefixForLocation()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetCdnPeeringPrefixForLocation");
}

/// <summary>
/// The test Get Cdn Peering Prefix NonExistent Location.
/// </summary>
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGetCdnPeeringPrefixNonExistentLocation()
{
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-GetCdnPeeringPrefixNonExistentLocation");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------
<#
.SYNOPSIS
GetCdnPeeringPrefixForLocation
#>
function Test-GetCdnPeeringPrefixForLocation {
$cdnPeeringPrefix = Get-AzPeeringCdnPeeringPrefix -PeeringLocation "Seattle"
Assert-NotNull $cdnPeeringPrefix
Assert-True { $cdnPeeringPrefix.Count -eq 4 }
}
<#
.SYNOPSIS
GetCdnPeeringPrefixNonExistentLocation
#>
function Test-GetCdnPeeringPrefixNonExistentLocation {
$cdnPeeringPrefix = Get-AzPeeringCdnPeeringPrefix -PeeringLocation 'abcde'
Assert-Null $cdnPeeringPrefix
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Test-GetLocationKindExchangeSeattle {
$asnPeerName = makePeerAsn $asn
$location = Get-AzPeeringLocation -Kind Exchange -PeeringLocation seattle
Assert-NotNull $location
Assert-AreEqual 5 $location.Count
Assert-AreEqual 4 $location.Count
}
finally {
Remove-AzPeerAsn -Name $asnPeerName -Force
Expand Down
16 changes: 8 additions & 8 deletions src/Peering/Peering.Test/ScenarioTests/PeeringServiceTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ GetPeeringServiceProviders
function Test-GetPeeringServiceByResourceGroup {
#Hard Coded locations becuase of limitations in locations
$name = getAssetName "myPeeringService";
$loc = "Washington"
$provider = "Verizon Communications Inc."
$loc = "Ile-de-France"
$provider = "InterCloud"
$resourceGroup = "Building40"
$peeringService = New-AzPeeringService -ResourceGroupName $resourceGroup -Name $name -PeeringLocation $loc -PeeringServiceProvider $provider
Assert-NotNull $peeringService
Expand All @@ -72,8 +72,8 @@ GetPeeringServiceLocations
function Test-GetPeeringServiceByResourceId {
#Hard Coded locations becuase of limitations in locations
$name = getAssetName "myPeeringService";
$loc = "Washington"
$provider = "Verizon Communications Inc."
$loc = "Ile-de-France"
$provider = "InterCloud"
$resourceGroup = "Building40"
$peeringService = New-AzPeeringService -ResourceGroupName $resourceGroup -Name $name -PeeringLocation $loc -PeeringServiceProvider $provider
Assert-NotNull $peeringService
Expand Down Expand Up @@ -103,8 +103,8 @@ GetPeeringServiceLocations
function Test-NewPeeringService {
#Hard Coded locations becuase of limitations in locations
$name = getAssetName "myPeeringService";
$loc = "Washington"
$provider = "Verizon Communications Inc."
$loc = "Ile-de-France"
$provider = "InterCloud"
$resourceGroup = "Building40"
$peeringService = New-AzPeeringService -ResourceGroupName $resourceGroup -Name $name -PeeringLocation $loc -PeeringServiceProvider $provider
Assert-NotNull $peeringService
Expand All @@ -121,8 +121,8 @@ function Test-NewPeeringServicePrefix {
#Hard Coded locations becuase of limitations in locations
$name = getAssetName "myPeeringService";
$prefixName = getAssetName "myPrefix";
$loc = "Washington"
$provider = "Verizon Communications Inc."
$loc = "Ile-de-France"
$provider = "InterCloud"
$resourceGroup = "Building40"
$prefix = newIpV4Address $true $true 0 4
$peeringService = New-AzPeeringService -ResourceGroupName $resourceGroup -Name $name -PeeringLocation $loc -PeeringServiceProvider $provider
Expand Down
2 changes: 1 addition & 1 deletion src/Peering/Peering.Test/ScenarioTests/SetPeeringTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function Test-SetNewIP {
$peering = CreateExchangePeering $resourceGroup $peerAsn.Name
$peer = Get-AzPeering -ResourceId $peering.Id
$peerIpAddress = $peer.Connections[0].BgpSession.PeerSessionIPv4Address
$offset = getPeeringVariable "offSet" (Get-Random -Maximum 100 -Minimum 1 | % { $_ * 2 } )
$offset = getPeeringVariable "offSet" (Get-Random -Maximum 10 -Minimum 1 | % { $_ * 2 } )
$newIpAddress = getPeeringVariable "newIpAddress" (changeIp "$peerIpAddress/32" $false $offset $false )
$peer.Connections[0] = $peer.Connections[0] | Set-AzPeeringExchangeConnectionObject -PeerSessionIPv4Address $newIpAddress
Assert-ThrowsContains { $peer | Update-AzPeering } "OperationNotSupported"
Expand Down
Loading