Skip to content

Commit 57521bf

Browse files
author
Hovsep
committed
Merge pull request #1506 from vladca/trafficmanagerNovGA
Update TrafficManager .NET SDK package, support Nested endpoints
2 parents 1e4d68e + 2b86fdf commit 57521bf

File tree

39 files changed

+3321
-4049
lines changed

39 files changed

+3321
-4049
lines changed

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/Commands.TrafficManager.Test.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
</ItemGroup>
118118
<ItemGroup>
119119
<Compile Include="Properties\AssemblyInfo.cs" />
120+
<Compile Include="ScenarioTests\NestedEndpointsTests.cs" />
120121
<Compile Include="ScenarioTests\ProfileTests.cs" />
121122
<Compile Include="ScenarioTests\EndpointTests.cs" />
122123
<Compile Include="ScenarioTests\TestController.cs" />
@@ -132,12 +133,18 @@
132133
<None Include="ScenarioTests\EndpointTests.ps1">
133134
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
134135
</None>
136+
<None Include="ScenarioTests\NestedEndpointsTests.ps1">
137+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
138+
</None>
135139
<None Include="ScenarioTests\ProfileTests.ps1">
136140
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
137141
</None>
138142
<None Include="SessionRecords\**\*.json">
139143
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
140144
</None>
145+
<None Include="SessionRecords\Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.NestedEndpointsTests\TestProfileWithNestedEndpointsGetPut.json">
146+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
147+
</None>
141148
</ItemGroup>
142149
<ItemGroup>
143150
<ProjectReference Include="..\..\..\Common\Commands.Common\Commands.Common.csproj">

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/ScenarioTests/EndpointTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,28 @@ public void TestRemoveNonExistingEndpointFromProfile()
8282
TestController.NewInstance.RunPowerShellTest("Test-RemoveNonExistingEndpointFromProfile");
8383
}
8484

85-
[Fact(Skip = "Bug")]
85+
[Fact(Skip = "TFS#5185296")]
8686
[Trait(Category.AcceptanceType, Category.CheckIn)]
8787
public void TestEnableEndpoint()
8888
{
8989
TestController.NewInstance.RunPowerShellTest("Test-EnableEndpoint");
9090
}
9191

92-
[Fact(Skip = "Bug")]
92+
[Fact(Skip = "TFS#5185296")]
9393
[Trait(Category.AcceptanceType, Category.CheckIn)]
9494
public void TestDisableEndpoint()
9595
{
9696
TestController.NewInstance.RunPowerShellTest("Test-DisableEndpoint");
9797
}
9898

99-
[Fact(Skip = "Bug")]
99+
[Fact(Skip = "TFS#5185296")]
100100
[Trait(Category.AcceptanceType, Category.CheckIn)]
101101
public void TestEnableEndpointUsingPiping()
102102
{
103103
TestController.NewInstance.RunPowerShellTest("Test-EnableEndpointUsingPiping");
104104
}
105105

106-
[Fact(Skip = "Bug")]
106+
[Fact(Skip = "TFS#5185296")]
107107
[Trait(Category.AcceptanceType, Category.CheckIn)]
108108
public void TestDisableEndpointUsingPiping()
109109
{

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/ScenarioTests/EndpointTests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ function Test-EnableEndpointUsingPiping
283283

284284
<#
285285
.SYNOPSIS
286-
Disable Endpoint
286+
Disable Endpoint using piping
287287
#>
288-
function Test-DisableEndpoint
288+
function Test-DisableEndpointUsingPiping
289289
{
290290
$endpointName = getAssetname
291291
$profileName = getAssetname
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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.TrafficManager.Test.ScenarioTests
16+
{
17+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
18+
using Xunit;
19+
20+
public class NestedEndpointsTests
21+
{
22+
[Fact]
23+
[Trait(Category.AcceptanceType, Category.CheckIn)]
24+
public void TestNestedEndpointsCreateUpdate()
25+
{
26+
TestController.NewInstance.RunPowerShellTest("Test-NestedEndpointsCreateUpdate");
27+
}
28+
29+
[Fact]
30+
[Trait(Category.AcceptanceType, Category.CheckIn)]
31+
public void TestProfileWithNestedEndpointsGetPut()
32+
{
33+
TestController.NewInstance.RunPowerShellTest("Test-ProfileWithNestedEndpointsGetPut");
34+
}
35+
}
36+
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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+
Profile with Nested Endpoint
18+
#>
19+
function Test-NestedEndpointsCreateUpdate
20+
{
21+
$resourceGroup = TestSetup-CreateResourceGroup
22+
$childProfileName = getAssetName
23+
$childProfileRelativeName = getAssetName
24+
$anotherChildProfileName = getAssetName
25+
$anotherChildProfileRelativeName = getAssetName
26+
$parentProfileName = getAssetName
27+
$parentProfileRelativeName = getAssetName
28+
29+
$createdChildProfile = New-AzureRmTrafficManagerProfile -Name $childProfileName -ResourceGroupName $resourceGroup.ResourceGroupName -RelativeDnsName $childProfileRelativeName -Ttl 50 -TrafficRoutingMethod "Performance" -MonitorProtocol "HTTP" -MonitorPort 80 -MonitorPath "/testpath.asp"
30+
Assert-NotNull $createdChildProfile.Id
31+
32+
$createdParentProfile = New-AzureRmTrafficManagerProfile -Name $parentProfileName -ResourceGroupName $resourceGroup.ResourceGroupName -RelativeDnsName $parentProfileRelativeName -Ttl 50 -TrafficRoutingMethod "Performance" -MonitorProtocol "HTTP" -MonitorPort 80 -MonitorPath "/testpath.asp"
33+
$createdParentProfile = Add-AzureRmTrafficManagerEndpointConfig -EndpointName "MyNestedEndpoint" -TrafficManagerProfile $createdParentProfile -Type "NestedEndpoints" -TargetResourceId $createdChildProfile.Id -EndpointStatus "Enabled" -EndpointLocation "North Europe" -MinChildEndpoints 2
34+
$updatedParentProfile = Set-AzureRmTrafficManagerProfile -TrafficManagerProfile $createdParentProfile
35+
36+
Assert-NotNull $updatedParentProfile
37+
Assert-AreEqual 1 $updatedParentProfile.Endpoints.Count
38+
Assert-AreEqual 2 $updatedParentProfile.Endpoints[0].MinChildEndpoints
39+
Assert-AreEqual "North Europe" $updatedParentProfile.Endpoints[0].Location
40+
41+
$retrievedParentProfile = Get-AzureRmTrafficManagerProfile -Name $parentProfileName -ResourceGroupName $resourceGroup.ResourceGroupName
42+
43+
Assert-NotNull $retrievedParentProfile
44+
Assert-AreEqual 1 $retrievedParentProfile.Endpoints.Count
45+
Assert-AreEqual 2 $retrievedParentProfile.Endpoints[0].MinChildEndpoints
46+
Assert-AreEqual "North Europe" $retrievedParentProfile.Endpoints[0].Location
47+
48+
$anotherCreatedChildProfile = New-AzureRmTrafficManagerProfile -Name $anotherChildProfileName -ResourceGroupName $resourceGroup.ResourceGroupName -RelativeDnsName $anotherChildProfileRelativeName -Ttl 50 -TrafficRoutingMethod "Performance" -MonitorProtocol "HTTP" -MonitorPort 80 -MonitorPath "/testpath.asp"
49+
Assert-NotNull $anotherCreatedChildProfile.Id
50+
51+
$anotherNestedEndpoint = New-AzureRmTrafficManagerEndpoint -Name "MySecondNestedEndpoint" -ProfileName $parentProfileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "NestedEndpoints" -TargetResourceId $anotherCreatedChildProfile.Id -EndpointStatus "Enabled" -EndpointLocation "West Europe" -MinChildEndpoints 3
52+
53+
Assert-NotNull $anotherNestedEndpoint
54+
Assert-AreEqual 3 $anotherNestedEndpoint.MinChildEndpoints
55+
Assert-AreEqual "West Europe" $anotherNestedEndpoint.Location
56+
57+
$retrievedParentProfile = Get-AzureRmTrafficManagerProfile -Name $parentProfileName -ResourceGroupName $resourceGroup.ResourceGroupName
58+
59+
Assert-NotNull $retrievedParentProfile
60+
Assert-AreEqual 2 $retrievedParentProfile.Endpoints.Count
61+
Assert-AreEqual 3 $retrievedParentProfile.Endpoints[1].MinChildEndpoints
62+
Assert-AreEqual "West Europe" $retrievedParentProfile.Endpoints[1].Location
63+
64+
$anotherNestedEndpoint.MinChildEndpoints = 4
65+
$anotherNestedEndpoint.Location = "West US"
66+
67+
$anotherNestedEndpoint = Set-AzureRmTrafficManagerEndpoint -TrafficManagerEndpoint $anotherNestedEndpoint
68+
69+
Assert-NotNull $anotherNestedEndpoint
70+
Assert-AreEqual 4 $anotherNestedEndpoint.MinChildEndpoints
71+
Assert-AreEqual "West US" $anotherNestedEndpoint.Location
72+
73+
$retrievedParentProfile = Get-AzureRmTrafficManagerProfile -Name $parentProfileName -ResourceGroupName $resourceGroup.ResourceGroupName
74+
75+
Assert-NotNull $retrievedParentProfile
76+
Assert-AreEqual 2 $retrievedParentProfile.Endpoints.Count
77+
Assert-AreEqual 4 $retrievedParentProfile.Endpoints[1].MinChildEndpoints
78+
Assert-AreEqual "West US" $retrievedParentProfile.Endpoints[1].Location
79+
}
80+
81+
<#
82+
.SYNOPSIS
83+
Tests the Get-Put pattern for a profile with a nested endpoint
84+
#>
85+
function Test-ProfileWithNestedEndpointsGetPut
86+
{
87+
$resourceGroup = TestSetup-CreateResourceGroup
88+
$childProfileName = getAssetName
89+
$childProfileRelativeName = getAssetName
90+
$parentProfileName = getAssetName
91+
$parentProfileRelativeName = getAssetName
92+
93+
$createdChildProfile = New-AzureRmTrafficManagerProfile -Name $childProfileName -ResourceGroupName $resourceGroup.ResourceGroupName -RelativeDnsName $childProfileRelativeName -Ttl 30 -TrafficRoutingMethod "Performance" -MonitorProtocol "HTTP" -MonitorPort 80 -MonitorPath "/testchild.asp"
94+
Assert-NotNull $createdChildProfile.Id
95+
96+
$createdParentProfile = New-AzureRmTrafficManagerProfile -Name $parentProfileName -ResourceGroupName $resourceGroup.ResourceGroupName -RelativeDnsName $parentProfileRelativeName -Ttl 51 -TrafficRoutingMethod "Performance" -MonitorProtocol "HTTPS" -MonitorPort 111 -MonitorPath "/testparent.asp"
97+
$nestedEndpoint = New-AzureRmTrafficManagerEndpoint -Name "MyNestedEndpoint" -ProfileName $parentProfileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "NestedEndpoints" -TargetResourceId $createdChildProfile.Id -EndpointStatus "Enabled" -EndpointLocation "West Europe" -MinChildEndpoints 1
98+
99+
$retrievedParentProfile = Get-AzureRmTrafficManagerProfile -Name $parentProfileName -ResourceGroupName $resourceGroup.ResourceGroupName
100+
$retrievedParentProfile | Set-AzureRmTrafficManagerProfile
101+
102+
$retrievedParentProfile = Get-AzureRmTrafficManagerProfile -Name $parentProfileName -ResourceGroupName $resourceGroup.ResourceGroupName
103+
104+
Assert-NotNull $retrievedParentProfile
105+
Assert-AreEqual 51 $retrievedParentProfile.Ttl
106+
Assert-AreEqual 111 $retrievedParentProfile.MonitorPort
107+
Assert-AreEqual "HTTPS" $retrievedParentProfile.MonitorProtocol
108+
Assert-AreEqual "/testparent.asp" $retrievedParentProfile.MonitorPath
109+
Assert-AreEqual "Performance" $retrievedParentProfile.TrafficRoutingMethod
110+
111+
Assert-AreEqual 1 $retrievedParentProfile.Endpoints.Count
112+
Assert-AreEqual 1 $retrievedParentProfile.Endpoints[0].MinChildEndpoints
113+
Assert-AreEqual 1 $retrievedParentProfile.Endpoints[0].Weight
114+
Assert-AreEqual 1 $retrievedParentProfile.Endpoints[0].Priority
115+
Assert-AreEqual "Microsoft.Network/trafficManagerProfiles/nestedEndpoints" $retrievedParentProfile.Endpoints[0].Type
116+
Assert-AreEqual "MyNestedEndpoint" $retrievedParentProfile.Endpoints[0].Name
117+
Assert-AreEqual "Enabled" $retrievedParentProfile.Endpoints[0].EndpointStatus
118+
Assert-AreEqual "West Europe" $retrievedParentProfile.Endpoints[0].Location
119+
Assert-AreEqual $createdChildProfile.Id $retrievedParentProfile.Endpoints[0].TargetResourceId
120+
Assert-AreEqual $retrievedParentProfile.Name $retrievedParentProfile.Endpoints[0].ProfileName
121+
}

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.EndpointTests/TestAddEndpoint.json

Lines changed: 49 additions & 148 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.EndpointTests/TestCreateExistingEndpoint.json

Lines changed: 80 additions & 179 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.EndpointTests/TestCreateExistingEndpointFromNonExistingProfile.json

Lines changed: 46 additions & 145 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.EndpointTests/TestDeleteEndpoint.json

Lines changed: 49 additions & 148 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.EndpointTests/TestDisableNonExistingEndpoint.json

Lines changed: 51 additions & 150 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.EndpointTests/TestEnableNonExistingEndpoint.json

Lines changed: 49 additions & 148 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.EndpointTests/TestEndpointCrud.json

Lines changed: 121 additions & 220 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.EndpointTests/TestEndpointCrudPiping.json

Lines changed: 112 additions & 211 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.EndpointTests/TestGetExistingEndpointFromNonExistingProfile.json

Lines changed: 38 additions & 137 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.EndpointTests/TestRemoveExistingEndpointFromNonExistingProfile.json

Lines changed: 29 additions & 128 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.EndpointTests/TestRemoveNonExistingEndpointFromProfile.json

Lines changed: 49 additions & 148 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)