Skip to content

Commit fa346c9

Browse files
authored
Merge pull request #8 from ZianWang02/feature/Cdn_origin
Add AzCdnOriginGroup Tests
2 parents 6a902a1 + a09abb1 commit fa346c9

File tree

5 files changed

+451
-16
lines changed

5 files changed

+451
-16
lines changed

src/Cdn/Cdn.Autorest/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,10 @@ directive:
159159
where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}"].delete
160160
transform: >-
161161
$["x-ms-long-running-operation-options"] = {"final-state-via": "azure-async-operation"}
162+
- from: swagger-document
163+
where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}"].delete
164+
transform: >-
165+
$["x-ms-long-running-operation-options"] = {"final-state-via": "azure-async-operation"}
162166
- from: swagger-document
163167
where: $.paths["/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}"].delete
164168
transform: >-

src/Cdn/Cdn.Autorest/test/Get-AzCdnOriginGroup.Tests.ps1

Lines changed: 146 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,155 @@ if(($null -eq $TestName) -or ($TestName -contains 'Get-AzCdnOriginGroup'))
1515
}
1616

1717
Describe 'Get-AzCdnOriginGroup' {
18-
It 'List' -skip {
19-
{ throw [System.NotImplementedException] } | Should -Not -Throw
18+
It 'List' {
19+
{
20+
$subId = $env.SubscriptionId
21+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
22+
try
23+
{
24+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
25+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location
26+
27+
$cdnProfileName = 'p-' + (RandomString -allChars $false -len 6);
28+
Write-Host -ForegroundColor Green "Use cdnProfileName : $($cdnProfileName)"
29+
30+
$profileSku = "Standard_Microsoft";
31+
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
32+
33+
$endpointName = 'e-' + (RandomString -allChars $false -len 6);
34+
Write-Host -ForegroundColor Green "Create endpointName : $($endpointName)"
35+
36+
$location = "westus"
37+
$origin = @{
38+
Name = "origin1"
39+
HostName = "host1.hello.com"
40+
};
41+
$originId = "/subscriptions/$subId/resourcegroups/$ResourceGroupName/providers/Microsoft.Cdn/profiles/$cdnProfileName/endpoints/$endpointName/origins/$($origin.Name)"
42+
$originGroup = @{
43+
Name = "originGroup1"
44+
HealthProbeSettingProbeIntervalInSecond = 240
45+
HealthProbeSettingProbePath = "/health.aspx"
46+
HealthProbeSettingProbeProtocol = "Https"
47+
HealthProbeSettingProbeRequestType = "GET"
48+
Origin = @(@{
49+
Id = $originId
50+
})
51+
}
52+
$defaultOriginGroup = "/subscriptions/$subId/resourcegroups/$ResourceGroupName/providers/Microsoft.Cdn/profiles/$cdnProfileName/endpoints/$endpointName/origingroups/$($originGroup.Name)"
53+
New-AzCdnEndpoint -Name $endpointName -ResourceGroupName $ResourceGroupName -ProfileName $cdnProfileName -Location $location `
54+
-Origin $origin -OriginGroup $originGroup -DefaultOriginGroupId $defaultOriginGroup
55+
$originGroups = Get-AzCdnOriginGroup -EndpointName $endpointName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName
56+
57+
$originGroups.Count | Should -Be 1
58+
} Finally
59+
{
60+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
61+
}
62+
} | Should -Not -Throw
2063
}
2164

22-
It 'Get' -skip {
23-
{ throw [System.NotImplementedException] } | Should -Not -Throw
65+
It 'Get' {
66+
{
67+
$subId = $env.SubscriptionId
68+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
69+
try
70+
{
71+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
72+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location
73+
74+
$cdnProfileName = 'p-' + (RandomString -allChars $false -len 6);
75+
Write-Host -ForegroundColor Green "Use cdnProfileName : $($cdnProfileName)"
76+
77+
$profileSku = "Standard_Microsoft";
78+
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
79+
80+
$endpointName = 'e-' + (RandomString -allChars $false -len 6);
81+
Write-Host -ForegroundColor Green "Create endpointName : $($endpointName)"
82+
83+
$location = "westus"
84+
$origin = @{
85+
Name = "origin1"
86+
HostName = "host1.hello.com"
87+
};
88+
$originId = "/subscriptions/$subId/resourcegroups/$ResourceGroupName/providers/Microsoft.Cdn/profiles/$cdnProfileName/endpoints/$endpointName/origins/$($origin.Name)"
89+
$originGroup = @{
90+
Name = "originGroup1"
91+
HealthProbeSettingProbeIntervalInSecond = 240
92+
HealthProbeSettingProbePath = "/health.aspx"
93+
HealthProbeSettingProbeProtocol = "Https"
94+
HealthProbeSettingProbeRequestType = "GET"
95+
Origin = @(@{
96+
Id = $originId
97+
})
98+
}
99+
$defaultOriginGroup = "/subscriptions/$subId/resourcegroups/$ResourceGroupName/providers/Microsoft.Cdn/profiles/$cdnProfileName/endpoints/$endpointName/origingroups/$($originGroup.Name)"
100+
New-AzCdnEndpoint -Name $endpointName -ResourceGroupName $ResourceGroupName -ProfileName $cdnProfileName -Location $location `
101+
-Origin $origin -OriginGroup $originGroup -DefaultOriginGroupId $defaultOriginGroup
102+
$endpointOriginGroup = Get-AzCdnOriginGroup -Name $originGroup.Name -EndpointName $endpointName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName
103+
104+
$endpointOriginGroup.Name | Should -Be $originGroup.Name
105+
$endpointOriginGroup.HealthProbeSettingProbeIntervalInSecond | Should -Be $originGroup.HealthProbeSettingProbeIntervalInSecond
106+
$endpointOriginGroup.HealthProbeSettingProbePath | Should -Be $originGroup.HealthProbeSettingProbePath
107+
$endpointOriginGroup.HealthProbeSettingProbeProtocol | Should -Be $originGroup.HealthProbeSettingProbeProtocol
108+
$endpointOriginGroup.HealthProbeSettingProbeRequestType | Should -Be $originGroup.HealthProbeSettingProbeRequestType
109+
$endpointOriginGroup.Origin[0].Id | Should -Be $originGroup.Origin[0].Id
110+
} Finally
111+
{
112+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
113+
}
114+
} | Should -Not -Throw
24115
}
25116

26-
It 'GetViaIdentity' -skip {
27-
{ throw [System.NotImplementedException] } | Should -Not -Throw
117+
It 'GetViaIdentity' {
118+
{
119+
$PSDefaultParameterValues['Disabled'] = $true
120+
$subId = $env.SubscriptionId
121+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
122+
try
123+
{
124+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
125+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location
126+
127+
$cdnProfileName = 'p-' + (RandomString -allChars $false -len 6);
128+
Write-Host -ForegroundColor Green "Use cdnProfileName : $($cdnProfileName)"
129+
130+
$profileSku = "Standard_Microsoft";
131+
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
132+
133+
$endpointName = 'e-' + (RandomString -allChars $false -len 6);
134+
Write-Host -ForegroundColor Green "Create endpointName : $($endpointName)"
135+
136+
$location = "westus"
137+
$origin = @{
138+
Name = "origin1"
139+
HostName = "host1.hello.com"
140+
};
141+
$originId = "/subscriptions/$subId/resourcegroups/$ResourceGroupName/providers/Microsoft.Cdn/profiles/$cdnProfileName/endpoints/$endpointName/origins/$($origin.Name)"
142+
$originGroup = @{
143+
Name = "originGroup1"
144+
HealthProbeSettingProbeIntervalInSecond = 240
145+
HealthProbeSettingProbePath = "/health.aspx"
146+
HealthProbeSettingProbeProtocol = "Https"
147+
HealthProbeSettingProbeRequestType = "GET"
148+
Origin = @(@{
149+
Id = $originId
150+
})
151+
}
152+
$defaultOriginGroup = "/subscriptions/$subId/resourcegroups/$ResourceGroupName/providers/Microsoft.Cdn/profiles/$cdnProfileName/endpoints/$endpointName/origingroups/$($originGroup.Name)"
153+
New-AzCdnEndpoint -Name $endpointName -ResourceGroupName $ResourceGroupName -ProfileName $cdnProfileName -Location $location `
154+
-Origin $origin -OriginGroup $originGroup -DefaultOriginGroupId $defaultOriginGroup
155+
$endpointOriginGroup = Get-AzCdnOriginGroup -Name $originGroup.Name -EndpointName $endpointName -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName | Get-AzCdnOriginGroup
156+
157+
$endpointOriginGroup.Name | Should -Be $originGroup.Name
158+
$endpointOriginGroup.HealthProbeSettingProbeIntervalInSecond | Should -Be $originGroup.HealthProbeSettingProbeIntervalInSecond
159+
$endpointOriginGroup.HealthProbeSettingProbePath | Should -Be $originGroup.HealthProbeSettingProbePath
160+
$endpointOriginGroup.HealthProbeSettingProbeProtocol | Should -Be $originGroup.HealthProbeSettingProbeProtocol
161+
$endpointOriginGroup.HealthProbeSettingProbeRequestType | Should -Be $originGroup.HealthProbeSettingProbeRequestType
162+
$endpointOriginGroup.Origin[0].Id | Should -Be $originGroup.Origin[0].Id
163+
} Finally
164+
{
165+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
166+
}
167+
} | Should -Not -Throw
28168
}
29169
}

src/Cdn/Cdn.Autorest/test/New-AzCdnOriginGroup.Tests.ps1

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,65 @@ if(($null -eq $TestName) -or ($TestName -contains 'New-AzCdnOriginGroup'))
1515
}
1616

1717
Describe 'New-AzCdnOriginGroup' {
18-
It 'CreateExpanded' -skip {
19-
{ throw [System.NotImplementedException] } | Should -Not -Throw
18+
It 'CreateExpanded' {
19+
{
20+
$subId = $env.SubscriptionId
21+
$ResourceGroupName = 'testps-rg-' + (RandomString -allChars $false -len 6)
22+
try
23+
{
24+
Write-Host -ForegroundColor Green "Create test group $($ResourceGroupName)"
25+
New-AzResourceGroup -Name $ResourceGroupName -Location $env.location
26+
27+
$cdnProfileName = 'p-' + (RandomString -allChars $false -len 6);
28+
Write-Host -ForegroundColor Green "Use cdnProfileName : $($cdnProfileName)"
29+
30+
$profileSku = "Standard_Microsoft";
31+
New-AzCdnProfile -SkuName $profileSku -Name $cdnProfileName -ResourceGroupName $ResourceGroupName -Location Global
32+
33+
$endpointName = 'e-' + (RandomString -allChars $false -len 6);
34+
Write-Host -ForegroundColor Green "Create endpointName : $($endpointName)"
35+
36+
$location = "westus"
37+
$origin = @{
38+
Name = "origin1"
39+
HostName = "host1.hello.com"
40+
};
41+
$originId = "/subscriptions/$subId/resourcegroups/$ResourceGroupName/providers/Microsoft.Cdn/profiles/$cdnProfileName/endpoints/$endpointName/origins/$($origin.Name)"
42+
$originGroup = @{
43+
Name = "originGroup1"
44+
HealthProbeSettingProbeIntervalInSecond = 240
45+
HealthProbeSettingProbePath = "/health.aspx"
46+
HealthProbeSettingProbeProtocol = "Https"
47+
HealthProbeSettingProbeRequestType = "GET"
48+
Origin = @(@{
49+
Id = $originId
50+
})
51+
}
52+
$defaultOriginGroup = "/subscriptions/$subId/resourcegroups/$ResourceGroupName/providers/Microsoft.Cdn/profiles/$cdnProfileName/endpoints/$endpointName/origingroups/$($originGroup.Name)"
53+
$createdEndpoint = New-AzCdnEndpoint -Name $endpointName -ResourceGroupName $ResourceGroupName -ProfileName $cdnProfileName -Location $location `
54+
-Origin $origin -OriginGroup $originGroup -DefaultOriginGroupId $defaultOriginGroup
55+
56+
$originGroupName2 = "originGroup2"
57+
$probeInterval2 = 120
58+
$probePath2 = "/check-health.aspx"
59+
$probeProtocol2 = "Http"
60+
$probeRequestType2 = "HEAD"
61+
62+
$createdOriginGroup = New-AzCdnOriginGroup -EndpointName $endpointName -Name $originGroupName2 -ProfileName $cdnProfileName -ResourceGroupName $ResourceGroupName `
63+
-HealthProbeSettingProbeIntervalInSecond $probeInterval2 -HealthProbeSettingProbePath $probePath2 -HealthProbeSettingProbeProtocol $probeProtocol2 `
64+
-HealthProbeSettingProbeRequestType $probeRequestType2 -Origin @(@{ Id = $originId })
65+
66+
$createdEndpoint.DefaultOriginGroupId | Should -Be $defaultOriginGroup
67+
$createdOriginGroup.Name | Should -Be $originGroupName2
68+
$createdOriginGroup.HealthProbeSettingProbeIntervalInSecond | Should -Be $probeInterval2
69+
$createdOriginGroup.HealthProbeSettingProbePath | Should -Be $probePath2
70+
$createdOriginGroup.HealthProbeSettingProbeProtocol | Should -Be $probeProtocol2
71+
$createdOriginGroup.HealthProbeSettingProbeRequestType | Should -Be $probeRequestType2
72+
$createdOriginGroup.Origin[0].Id | Should -Be $originId
73+
} Finally
74+
{
75+
Remove-AzResourceGroup -Name $ResourceGroupName -NoWait
76+
}
77+
} | Should -Not -Throw
2078
}
2179
}

0 commit comments

Comments
 (0)