Skip to content

Commit 53fc708

Browse files
authored
Merge pull request #9801 from rileymckenna/feature/updateApiVersion
Bug fixes added tests.
2 parents 0a967f9 + 0a13830 commit 53fc708

22 files changed

+1808
-11014
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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 ConvertLegacyTests
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 ConvertLegacyTests(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+
/// <summary>
44+
/// The test get legacy kind exchange amsterdam.
45+
/// </summary>
46+
[Fact]
47+
[Trait(Category.AcceptanceType, Category.CheckIn)]
48+
public void TestConvertLegacyKindExchangeAshburn()
49+
{
50+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-ConvertLegacyKindExchangeAshburn");
51+
}
52+
53+
/// <summary>
54+
/// The test get legacy kind direct amsterdam.
55+
/// </summary>
56+
[Fact]
57+
[Trait(Category.AcceptanceType, Category.CheckIn)]
58+
public void TestConvertLegacyKindExchangeAmsterdamWithNewConnection()
59+
{
60+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-ConvertLegacyKindExchangeAmsterdamWithNewConnection");
61+
}
62+
}
63+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
.SYNOPSIS
16+
GetLocationKindExchange
17+
#>
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+
}
35+
}
36+
37+
<#
38+
.SYNOPSIS
39+
Convert Legacy Kind Exchange Amsterdam With New Connection
40+
#>
41+
function Test-ConvertLegacyKindExchangeAmsterdamWithNewConnection {
42+
try {
43+
#must be hard coded asn because they have legacy items.
44+
$peerAsn = makePeerAsn 15224
45+
$name = getPeeringVariable "Name" "AS15224_Amsterdam_Exchange"
46+
$rg = getPeeringVariable "ResourceGroupName" "Building40"
47+
$legacy = Get-AzLegacyPeering -Kind Exchange -PeeringLocation Amsterdam
48+
Assert-NotNull $legacy
49+
Assert-True { $legacy.Count -ge 1 }
50+
#has to be hard coded becuase this ip address isnt used.
51+
#testing trim
52+
$ipaddress = getPeeringVariable "ipaddress" " 80.249.211.62 "
53+
$facilityId = 26
54+
$maxv4 = maxAdvertisedIpv4
55+
$connection = New-AzPeeringExchangeConnectionObject -PeeringDbFacilityId $facilityId -MaxPrefixesAdvertisedIPv4 $maxv4 -PeerSessionIPv4Address $ipaddress
56+
$peering = $legacy | New-AzPeering -ResourceGroupName $rg -Name $name -PeerAsnResourceId $peerAsn.Id -ExchangeConnection $connection -Tag @{ "tfs_813288" = "Approved" }
57+
}
58+
finally {
59+
$isRemoved = Remove-AzPeerAsn -Name $peerAsn.Name -Force -PassThru
60+
Assert-True { $isRemoved }
61+
}
62+
}
63+

src/Peering/Peering.Test/ScenarioTests/SetPeeringTests.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,35 @@ public void TestSetNewBandwidth()
6060
{
6161
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-SetNewBandwidth");
6262
}
63+
64+
/// <summary>
65+
/// The test set new bandwidth.
66+
/// </summary>
67+
[Fact]
68+
[Trait(Category.AcceptanceType, Category.CheckIn)]
69+
public void TestSetNewIP()
70+
{
71+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-SetNewIP");
72+
}
73+
74+
/// <summary>
75+
/// The test set new bandwidth.
76+
/// </summary>
77+
[Fact]
78+
[Trait(Category.AcceptanceType, Category.CheckIn)]
79+
public void TestSetNewIPv6()
80+
{
81+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-SetNewIPv6");
82+
}
83+
84+
/// <summary>
85+
/// The test set new bandwidth.
86+
/// </summary>
87+
[Fact]
88+
[Trait(Category.AcceptanceType, Category.CheckIn)]
89+
public void TestSetNewMd5Hash()
90+
{
91+
TestController.NewInstance.RunPowerShellTest(this.logger, "Test-SetNewMd5Hash");
92+
}
6393
}
6494
}

src/Peering/Peering.Test/ScenarioTests/SetPeeringTests.ps1

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ SetNewIP
3030
#>
3131
function Test-SetNewIP
3232
{
33-
$peers = Get-AzPeering -Kind Direct
34-
$peer = $peers | Select -First 1
35-
$peerIpAddress = $peer.Connections[0].BgpSession.SessionPrefixV4
33+
$name = getPeeringVariable "Name" "AS8088_Seattle_Exchange"
34+
$rg = getPeeringVariable "ResourceGroupName" "Building40"
35+
$peer = Get-AzPeering -ResourceGroupName $rg -Name $name
36+
$peerIpAddress = $peer.Connections[1].BgpSession.PeerSessionIPv4Address
3637
$offset = getPeeringVariable "offSet" (Get-Random -Maximum 100 -Minimum 1 | % { $_ * 2 } )
37-
$newIpAddress = getPeeringVariable "newIpAddress" (changeIp "$peerIpAddress" $false $offset $true )
38-
$msip = getPeeringVariable "MicrosoftSessionIPv4Address" $peer.Connections[0].BgpSession.MicrosoftSessionIPv4Address
39-
$peer.Connections[0] = $peer.Connections[0] | Set-AzPeeringDirectConnectionObject -SessionPrefixV4 $newIpAddress
40-
Assert-ThrowsContains {$peer | Update-AzPeering} "ErrorCode: OperationFailed ErrorMessage: Input prefix $newIpAddress"
38+
$newIpAddress = getPeeringVariable "newIpAddress" (changeIp "$peerIpAddress/32" $false $offset $false )
39+
$msip = getPeeringVariable "MicrosoftSessionIPv4Address" $peer.Connections[1].BgpSession.MicrosoftSessionIPv4Address
40+
$peer.Connections[1] = $peer.Connections[1] | Set-AzPeeringExchangeConnectionObject -PeerSessionIPv4Address $newIpAddress
41+
$peering = $peer | Update-AzPeering
42+
Assert-True {$newIpAddress -eq $peering.Connections[1].BgpSession.PeerSessionIPv4Address}
4143

4244
}
4345
<#
@@ -46,14 +48,13 @@ SetNewIPv6
4648
#>
4749
function Test-SetNewIPv6
4850
{
49-
$peers = Get-AzPeering -Kind Direct
50-
$peer = $peers | Select -First 1
51-
$peerIpAddress = $peer.Connections[0].BgpSession.SessionPrefixV6
52-
$offset = getPeeringVariable "offSet" (Get-Random -Maximum 100 -Minimum 1 | % { $_ * 2 } )
53-
$newIpAddress = getPeeringVariable "newIpAddress" (changeIp "$peerIpAddress" $true $offset $true )
54-
$msip = getPeeringVariable "MicrosoftSessionIPv6Address" $peer.Connections[0].BgpSession.MicrosoftSessionIPv6Address
55-
$peer.Connections[0] = $peer.Connections[0] | Set-AzPeeringDirectConnectionObject -SessionPrefixV6 $newIpAddress
56-
Assert-ThrowsContains {$peer | Update-AzPeering} "ErrorCode: OperationFailed ErrorMessage: Input prefix $newIpAddress"
51+
$name = getPeeringVariable "Name" "AS8088_Seattle_Exchange"
52+
$rg = getPeeringVariable "ResourceGroupName" "Building40"
53+
$peer = Get-AzPeering -ResourceGroupName $rg -Name $name
54+
$peerIpAddress = getPeeringVariable "IpAddress" (newIpV6Address $false $false 0 0)
55+
$peer.Connections[1] = $peer.Connections[1] | Set-AzPeeringExchangeConnectionObject -PeerSessionIPv6Address $peerIpAddress
56+
$peering = $peer | Update-AzPeering
57+
Assert-True {$peerIpAddress -eq $peering.Connections[1].BgpSession.PeerSessionIPv6Address}
5758
}
5859
<#
5960
.SYNOPSIS
@@ -76,11 +77,12 @@ SetNewMd5Hash
7677
#>
7778
function Test-SetNewMd5Hash
7879
{
79-
$peers = Get-AzPeering -Kind Direct
80-
$peer = $peers | Select -First 1
80+
$name = getPeeringVariable "Name" "AS8088_Seattle_Exchange"
81+
$rg = getPeeringVariable "ResourceGroupName" "Building40"
82+
$peer = Get-AzPeering -ResourceGroupName $rg -Name $name
8183
$hash = getHash
82-
$peer.Connections[0] = $peer.Connections[0] | Set-AzPeeringDirectConnectionObject -MD5AuthenticationKey $hash
83-
$setPeer = $peer | Update-AzPeering
84+
$connection = $peer.Connections[0] | Set-AzPeeringExchangeConnectionObject -MD5AuthenticationKey $hash
85+
$setPeer = Update-AzPeering -ResourceId $peer.Id -ExchangeConnection $connection
8486
Assert-NotNull $setPeer
8587
Assert-AreEqual $hash $setPeer.Connections[0].BgpSession.Md5AuthenticationKey
8688
}

0 commit comments

Comments
 (0)