Skip to content

Commit 3ed40f7

Browse files
committed
Adding session records
1 parent aa30ba3 commit 3ed40f7

27 files changed

+9514
-26
lines changed

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

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -113,29 +113,8 @@
113113
<None Include="ScenarioTests\ProfileTests.ps1">
114114
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
115115
</None>
116-
<None Include="SessionRecords\Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.EndpointTests\TestAddEndpoint.json">
117-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
118-
</None>
119-
<None Include="SessionRecords\Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.EndpointTests\TestDeleteEndpoint.json">
120-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
121-
</None>
122-
<None Include="SessionRecords\Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests\TestCreateDeleteUsingProfile.json">
123-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
124-
</None>
125-
<None Include="SessionRecords\Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests\TestCrudWithEndpoint.json">
126-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
127-
</None>
128-
<None Include="SessionRecords\Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests\TestProfileCrud.json">
129-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
130-
</None>
131-
<None Include="SessionRecords\Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests\TestProfileCrudWithPiping.json">
132-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
133-
</None>
134-
<None Include="SessionRecords\Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests\TestProfileNewAlreadyExists.json">
135-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
136-
</None>
137-
<None Include="SessionRecords\Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests\TestProfileRemoveNonExisting.json">
138-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
116+
<None Include="SessionRecords\**\*.json">
117+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
139118
</None>
140119
</ItemGroup>
141120
<ItemGroup>

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,47 @@ public void TestRemoveNonExistingEndpointFromProfile()
8181
{
8282
TestController.NewInstance.RunPowerShellTest("Test-RemoveNonExistingEndpointFromProfile");
8383
}
84+
85+
[Fact(Skip = "Bug")]
86+
[Trait(Category.AcceptanceType, Category.CheckIn)]
87+
public void TestEnableEndpoint()
88+
{
89+
TestController.NewInstance.RunPowerShellTest("Test-EnableEndpoint");
90+
}
91+
92+
[Fact(Skip = "Bug")]
93+
[Trait(Category.AcceptanceType, Category.CheckIn)]
94+
public void TestDisableEndpoint()
95+
{
96+
TestController.NewInstance.RunPowerShellTest("Test-DisableEndpoint");
97+
}
98+
99+
[Fact(Skip = "Bug")]
100+
[Trait(Category.AcceptanceType, Category.CheckIn)]
101+
public void TestEnableEndpointUsingPiping()
102+
{
103+
TestController.NewInstance.RunPowerShellTest("Test-EnableEndpointUsingPiping");
104+
}
105+
106+
[Fact(Skip = "Bug")]
107+
[Trait(Category.AcceptanceType, Category.CheckIn)]
108+
public void TestDisableEndpointUsingPiping()
109+
{
110+
TestController.NewInstance.RunPowerShellTest("Test-DisableEndpointUsingPiping");
111+
}
112+
113+
[Fact]
114+
[Trait(Category.AcceptanceType, Category.CheckIn)]
115+
public void TestEnableNonExistingEndpoint()
116+
{
117+
TestController.NewInstance.RunPowerShellTest("Test-EnableNonExistingEndpoint");
118+
}
119+
120+
[Fact]
121+
[Trait(Category.AcceptanceType, Category.CheckIn)]
122+
public void TestDisableNonExistingEndpoint()
123+
{
124+
TestController.NewInstance.RunPowerShellTest("Test-DisableNonExistingEndpoint");
125+
}
84126
}
85127
}

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

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,136 @@ function Test-RemoveNonExistingEndpointFromProfile
203203
$profile = TestSetup-CreateProfile $profileName $resourceGroup.ResourceGroupName
204204

205205
Assert-Throws { Remove-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints" }
206+
}
207+
208+
<#
209+
.SYNOPSIS
210+
Enable Endpoint
211+
#>
212+
function Test-EnableEndpoint
213+
{
214+
$endpointName = getAssetname
215+
$profileName = getAssetname
216+
$resourceGroup = TestSetup-CreateResourceGroup
217+
218+
$profile = TestSetup-CreateProfile $profileName $resourceGroup.ResourceGroupName
219+
220+
$endpoint = New-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints" -Target "www.contoso.com" -EndpointStatus "Disabled" -EndpointLocation "North Europe"
221+
222+
Assert-AreEqual "Disabled" $endpoint.EndpointStatus
223+
224+
$endpoint = Get-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints"
225+
226+
Assert-True { Enable-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints" }
227+
228+
$endpoint = Get-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints"
229+
230+
Assert-AreEqual "Enabled" $endpoint.EndpointStatus
231+
}
232+
233+
<#
234+
.SYNOPSIS
235+
Disable Endpoint
236+
#>
237+
function Test-DisableEndpoint
238+
{
239+
$endpointName = getAssetname
240+
$profileName = getAssetname
241+
$resourceGroup = TestSetup-CreateResourceGroup
242+
243+
$profile = TestSetup-CreateProfile $profileName $resourceGroup.ResourceGroupName
244+
245+
$endpoint = New-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints" -Target "www.contoso.com" -EndpointStatus "Enabled" -EndpointLocation "North Europe"
246+
247+
Assert-AreEqual "Enabled" $endpoint.EndpointStatus
248+
249+
$endpoint = Get-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints"
250+
251+
Assert-True { Disable-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints" -Force }
252+
253+
$endpoint = Get-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints"
254+
255+
Assert-NotNull $endpoint
256+
Assert-AreEqual "Disabled" $endpoint.EndpointStatus
257+
}
258+
259+
<#
260+
.SYNOPSIS
261+
Enable Endpoint using piping
262+
#>
263+
function Test-EnableEndpointUsingPiping
264+
{
265+
$endpointName = getAssetname
266+
$profileName = getAssetname
267+
$resourceGroup = TestSetup-CreateResourceGroup
268+
269+
$profile = TestSetup-CreateProfile $profileName $resourceGroup.ResourceGroupName
270+
271+
$endpoint = New-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints" -Target "www.contoso.com" -EndpointStatus "Disabled" -EndpointLocation "North Europe"
272+
273+
Assert-AreEqual "Disabled" $endpoint.EndpointStatus
274+
275+
$endpoint = Get-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints"
276+
277+
Assert-True { Enable-AzureTrafficManagerEndpoint -TrafficManagerEndpoint $endpoint }
278+
279+
$endpoint = Get-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints"
280+
281+
Assert-AreEqual "Enabled" $endpoint.EndpointStatus
282+
}
283+
284+
<#
285+
.SYNOPSIS
286+
Disable Endpoint
287+
#>
288+
function Test-DisableEndpoint
289+
{
290+
$endpointName = getAssetname
291+
$profileName = getAssetname
292+
$resourceGroup = TestSetup-CreateResourceGroup
293+
294+
$profile = TestSetup-CreateProfile $profileName $resourceGroup.ResourceGroupName
295+
296+
$endpoint = New-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints" -Target "www.contoso.com" -EndpointStatus "Enabled" -EndpointLocation "North Europe"
297+
298+
Assert-AreEqual "Enabled" $endpoint.EndpointStatus
299+
300+
$endpoint = Get-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints"
301+
302+
Assert-True { Disable-AzureTrafficManagerEndpoint -TrafficManagerEndpoint $endpoint -Force }
303+
304+
$endpoint = Get-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints"
305+
306+
Assert-NotNull $endpoint
307+
Assert-AreEqual "Disabled" $endpoint.EndpointStatus
308+
}
309+
310+
<#
311+
.SYNOPSIS
312+
Enable non existing Endpoint
313+
#>
314+
function Test-EnableNonExistingEndpoint
315+
{
316+
$endpointName = getAssetname
317+
$profileName = getAssetname
318+
$resourceGroup = TestSetup-CreateResourceGroup
319+
320+
$profile = TestSetup-CreateProfile $profileName $resourceGroup.ResourceGroupName
321+
322+
Assert-Throws { Enable-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints" }
323+
}
324+
325+
<#
326+
.SYNOPSIS
327+
Disable non existing Endpoint
328+
#>
329+
function Test-DisableNonExistingEndpoint
330+
{
331+
$endpointName = getAssetname
332+
$profileName = getAssetname
333+
$resourceGroup = TestSetup-CreateResourceGroup
334+
335+
$profile = TestSetup-CreateProfile $profileName $resourceGroup.ResourceGroupName
336+
337+
Assert-Throws { Disable-AzureTrafficManagerEndpoint -Name $endpointName -ProfileName $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -Type "ExternalEndpoints" }
206338
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ public void TestCrudWithEndpoint()
4747
TestController.NewInstance.RunPowerShellTest("Test-CrudWithEndpoint");
4848
}
4949

50+
[Fact]
51+
[Trait(Category.AcceptanceType, Category.CheckIn)]
52+
public void TestListProfilesInResourceGroup()
53+
{
54+
TestController.NewInstance.RunPowerShellTest("Test-ListProfilesInResourceGroup");
55+
}
56+
57+
[Fact]
58+
[Trait(Category.AcceptanceType, Category.CheckIn)]
59+
public void TestListProfilesInSubscription()
60+
{
61+
TestController.NewInstance.RunPowerShellTest("Test-ListProfilesInSubscription");
62+
}
63+
5064
[Fact]
5165
[Trait(Category.AcceptanceType, Category.CheckIn)]
5266
public void TestProfileNewAlreadyExists()

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,38 @@ function Test-CrudWithEndpoint
109109
Assert-AreEqual 1 $updatedProfile.Endpoints.Count
110110
}
111111

112+
<#
113+
.SYNOPSIS
114+
List profiles in resource group
115+
#>
116+
function Test-ListProfilesInResourceGroup
117+
{
118+
$profileName = getAssetName
119+
$resourceGroup = TestSetup-CreateResourceGroup
120+
$relativeName = getAssetName
121+
$createdProfile = New-AzureTrafficManagerProfile -Name $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -RelativeDnsName $relativeName -Ttl 50 -TrafficRoutingMethod "Performance" -MonitorProtocol "HTTP" -MonitorPort 80 -MonitorPath "/testpath.asp"
122+
123+
$profiles = Get-AzureTrafficManagerProfile -ResourceGroupName $resourceGroup.ResourceGroupName
124+
125+
Assert-AreEqual 1 $profiles.Count
126+
}
127+
128+
<#
129+
.SYNOPSIS
130+
List profiles in subscription
131+
#>
132+
function Test-ListProfilesInSubscription
133+
{
134+
$profileName = getAssetName
135+
$resourceGroup = TestSetup-CreateResourceGroup
136+
$relativeName = getAssetName
137+
$createdProfile = New-AzureTrafficManagerProfile -Name $profileName -ResourceGroupName $resourceGroup.ResourceGroupName -RelativeDnsName $relativeName -Ttl 50 -TrafficRoutingMethod "Performance" -MonitorProtocol "HTTP" -MonitorPort 80 -MonitorPath "/testpath.asp"
138+
139+
$profiles = Get-AzureTrafficManagerProfile
140+
141+
Assert-NotNull $profiles
142+
}
143+
112144
<#
113145
.SYNOPSIS
114146
Create a Profile that already exists

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

Lines changed: 543 additions & 0 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: 368 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 603 additions & 0 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: 375 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 543 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 603 additions & 0 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: 375 additions & 0 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: 762 additions & 0 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: 708 additions & 0 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: 314 additions & 0 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: 266 additions & 0 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: 375 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests/TestListProfilesInResourceGroup.json

Lines changed: 428 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests/TestListProfilesInSubscription.json

Lines changed: 428 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests/TestProfileDisable.json

Lines changed: 488 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests/TestProfileDisableNonExisting.json

Lines changed: 319 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests/TestProfileDisablePipeline.json

Lines changed: 488 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests/TestProfileEnable.json

Lines changed: 488 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests/TestProfileEnableNonExisting.json

Lines changed: 319 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2.Test/SessionRecords/Microsoft.Azure.Commands.TrafficManager.Test.ScenarioTests.ProfileTests/TestProfileEnablePipeline.json

Lines changed: 488 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/TrafficManager/Commands.TrafficManager2/Endpoint/DisableAzureTrafficManagerEndpoint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public override void ExecuteCmdlet()
5757
endpointToDisable = new TrafficManagerEndpoint
5858
{
5959
Name = this.Name,
60-
Target = this.Type,
60+
Type = this.Type,
6161
ProfileName = this.ProfileName,
6262
ResourceGroupName = this.ResourceGroupName
6363
};

src/ResourceManager/TrafficManager/Commands.TrafficManager2/Utilities/TrafficManagerClient.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,17 @@ public bool EnableDisableTrafficManagerEndpoint(TrafficManagerEndpoint endpoint,
220220
{
221221
endpoint.EndpointStatus = shouldEnableEndpointStatus ? Constants.StatusEnabled : Constants.StatusDisabled;
222222

223+
Endpoint sdkEndpoint = endpoint.ToSDKEndpoint();
224+
sdkEndpoint.Properties.EndpointLocation = null;
225+
sdkEndpoint.Properties.EndpointMonitorStatus = null;
226+
sdkEndpoint.Properties.Priority = null;
227+
sdkEndpoint.Properties.Weight = null;
228+
sdkEndpoint.Properties.Target = null;
229+
sdkEndpoint.Properties.TargetResourceId = null;
230+
223231
var parameters = new EndpointUpdateParameters
224232
{
225-
Endpoint = endpoint.ToSDKEndpoint()
233+
Endpoint = sdkEndpoint
226234
};
227235

228236
AzureOperationResponse response = this.TrafficManagerManagementClient.Endpoints.Update(
@@ -232,7 +240,7 @@ public bool EnableDisableTrafficManagerEndpoint(TrafficManagerEndpoint endpoint,
232240
endpoint.Name,
233241
parameters);
234242

235-
return response.StatusCode.Equals(HttpStatusCode.OK);
243+
return response.StatusCode.Equals(HttpStatusCode.Created);
236244
}
237245

238246
private static TrafficManagerProfile GetPowershellTrafficManagerProfile(string resourceGroupName, string profileName, ProfileProperties mamlProfileProperties)

0 commit comments

Comments
 (0)