17
17
Tests creating, getting and removing an AzureML commitment plan.
18
18
#>
19
19
function Test-CreateGetRemoveMLCommitmentPlan
20
- {
20
+ {
21
21
$planDeleted = $false
22
22
23
23
$actualTest = {
24
24
param ([string ] $location )
25
25
26
- try
27
- {
28
- $resourceGroupName = Get-ResourceGroupName
29
- $commitmentPlanName = Get-CommitmentPlanName
30
-
31
- LogOutput " Creating resource group: $resourceGroupName "
32
- $group = New-AzureRmResourceGroup - Name $resourceGroupName - Location $location
33
- LogOutput(" Created resource group: $ ( $group.ResourceId ) " )
34
-
35
- # Create a commitment plan and validate it
36
- LogOutput " Creating commitment plan: $commitmentPlanName "
37
- $plan = New-AzureRmMlCommitmentPlan - ResourceGroupName $resourceGroupName - Location $location - Name $commitmentPlanName - SkuName " S1" - SkuTier " Standard" - Force
38
- Assert-NotNull $plan
39
-
40
- $planId = $plan.Id
41
- LogOutput " Created commitment plan: $planId "
42
- ValidateCommitmentPlanResult $resourceGroupName $commitmentPlanName $location $plan
43
-
44
- # Delete the commitment plan
45
- LogOutput " Removing commitment plan $commitmentPlanName from resource group $resourceGroupName "
46
- $plan | Remove-AzureRmMlCommitmentPlan - Force
47
- LogOutput " Commitment plan $commitmentPlanName was removed."
48
- $planDeleted = $true
49
-
50
- # Validate that the commitment plan no longer exists
51
- Assert-ThrowsContains { Get-AzureRmMlCommitmentPlan - ResourceGroupName $resourceGroupName - Name $commitmentPlanName } " ResourceNotFound"
26
+ try
27
+ {
28
+ $resourceGroupName = Get-ResourceGroupName
29
+ $commitmentPlanName = Get-CommitmentPlanName
30
+
31
+ LogOutput " Creating resource group: $resourceGroupName "
32
+ $group = New-AzureRmResourceGroup - Name $resourceGroupName - Location $location
33
+ LogOutput(" Created resource group: $ ( $group.ResourceId ) " )
34
+
35
+ # Create a commitment plan and validate it
36
+ LogOutput " Creating commitment plan: $commitmentPlanName "
37
+ $plan = New-AzureRmMlCommitmentPlan - ResourceGroupName $resourceGroupName - Location $location - Name $commitmentPlanName - SkuName " S1" - SkuTier " Standard" - Force
38
+ Assert-NotNull $plan
39
+
40
+ $planId = $plan.Id
41
+ LogOutput " Created commitment plan: $planId "
42
+ ValidateCommitmentPlanResult $resourceGroupName $commitmentPlanName $location $plan
43
+
44
+ # Delete the commitment plan
45
+ LogOutput " Removing commitment plan $commitmentPlanName from resource group $resourceGroupName "
46
+ $plan | Remove-AzureRmMlCommitmentPlan - Force
47
+ LogOutput " Commitment plan $commitmentPlanName was removed."
48
+ $planDeleted = $true
49
+
50
+ # Validate that the commitment plan no longer exists
51
+ Assert-ThrowsContains { Get-AzureRmMlCommitmentPlan - ResourceGroupName $resourceGroupName - Name $commitmentPlanName } " ResourceNotFound"
52
52
}
53
53
finally
54
54
{
@@ -58,7 +58,7 @@ function Test-CreateGetRemoveMLCommitmentPlan
58
58
Clean - CommitmentPlan $resourceGroupName $commitmentPlanName
59
59
}
60
60
61
- Clean - ResourceGroup $resourceGroupName
61
+ Clean - ResourceGroup $resourceGroupName
62
62
}
63
63
};
64
64
@@ -76,46 +76,46 @@ function Test-UpdateMLCommitmentPlan
76
76
$actualTest = {
77
77
param ([string ] $location )
78
78
79
- try
80
- {
81
- $resourceGroupName = Get-ResourceGroupName
82
- $commitmentPlanName = Get-CommitmentPlanName
83
-
84
- LogOutput " Creating resource group: $resourceGroupName "
85
- $group = New-AzureRmResourceGroup - Name $resourceGroupName - Location $location
86
- LogOutput(" Created resource group: $ ( $group.ResourceId ) " )
87
-
88
- # Create a commitment plan and validate it
89
- LogOutput " Creating commitment plan: $commitmentPlanName "
90
- $plan = New-AzureRmMlCommitmentPlan - ResourceGroupName $resourceGroupName - Location $location - Name $commitmentPlanName - SkuName " S1" - SkuTier " Standard" - Force
91
- Assert-NotNull $plan
92
-
93
- $planId = $plan.Id
94
- LogOutput " Created commitment plan: $planId "
95
- ValidateCommitmentPlanResult $resourceGroupName $commitmentPlanName $location $plan
96
-
97
- # Update the commitment plan
98
- LogOutput " Updating commitment plan $planId "
99
- Update-AzureRmMlCommitmentPlan - ResourceGroupName $resourceGroupName - Name $commitmentPlanName - SkuName " S2" - SkuTier " Standard" - SkuCapacity 2 - Tags @ {" tag1" = " value1" } - Force
100
-
101
- # Delete the commitment plan
102
- LogOutput " Removing commitment plan $commitmentPlanName from resource group $resourceGroupName "
103
- $plan | Remove-AzureRmMlCommitmentPlan - Force
104
- LogOutput " Commitment plan $commitmentPlanName was removed."
105
- $planDeleted = $true
106
-
107
- # Validate that the commitment plan no longer exists
108
- Assert-ThrowsContains { Get-AzureRmMlCommitmentPlan - ResourceGroupName $resourceGroupName - Name $commitmentPlanName } " ResourceNotFound"
79
+ try
80
+ {
81
+ $resourceGroupName = Get-ResourceGroupName
82
+ $commitmentPlanName = Get-CommitmentPlanName
83
+
84
+ LogOutput " Creating resource group: $resourceGroupName "
85
+ $group = New-AzureRmResourceGroup - Name $resourceGroupName - Location $location
86
+ LogOutput(" Created resource group: $ ( $group.ResourceId ) " )
87
+
88
+ # Create a commitment plan and validate it
89
+ LogOutput " Creating commitment plan: $commitmentPlanName "
90
+ $plan = New-AzureRmMlCommitmentPlan - ResourceGroupName $resourceGroupName - Location $location - Name $commitmentPlanName - SkuName " S1" - SkuTier " Standard" - Force
91
+ Assert-NotNull $plan
92
+
93
+ $planId = $plan.Id
94
+ LogOutput " Created commitment plan: $planId "
95
+ ValidateCommitmentPlanResult $resourceGroupName $commitmentPlanName $location $plan
96
+
97
+ # Update the commitment plan
98
+ LogOutput " Updating commitment plan $planId "
99
+ Update-AzureRmMlCommitmentPlan - ResourceGroupName $resourceGroupName - Name $commitmentPlanName - SkuName " S2" - SkuTier " Standard" - SkuCapacity 2 - Tags @ {" tag1" = " value1" } - Force
100
+
101
+ # Delete the commitment plan
102
+ LogOutput " Removing commitment plan $commitmentPlanName from resource group $resourceGroupName "
103
+ $plan | Remove-AzureRmMlCommitmentPlan - Force
104
+ LogOutput " Commitment plan $commitmentPlanName was removed."
105
+ $planDeleted = $true
106
+
107
+ # Validate that the commitment plan no longer exists
108
+ Assert-ThrowsContains { Get-AzureRmMlCommitmentPlan - ResourceGroupName $resourceGroupName - Name $commitmentPlanName } " ResourceNotFound"
109
109
}
110
110
finally
111
111
{
112
112
# Cleanup
113
- if (! $planDeleted )
114
- {
113
+ if (! $planDeleted )
114
+ {
115
115
Clean - CommitmentPlan $resourceGroupName $commitmentPlanName
116
116
}
117
117
118
- Clean - ResourceGroup $resourceGroupName
118
+ Clean - ResourceGroup $resourceGroupName
119
119
}
120
120
};
121
121
@@ -129,56 +129,56 @@ Tests the cmdlets for retrieving lists of AzureML commitment plans
129
129
function Test-ListMLCommitmentPlans
130
130
{
131
131
$actualTest = {
132
- param ([string ] $location )
133
-
134
- try
132
+ param ([string ] $location )
133
+
134
+ try
135
135
{
136
136
# Create two commitment plans in the first resource group
137
- $firstResourceGroupName = Get-ResourceGroupName
138
- $firstCommitmentPlanName = Get-CommitmentPlanName
139
- $secondCommitmentPlanName = Get-CommitmentPlanName
137
+ $firstResourceGroupName = Get-ResourceGroupName
138
+ $firstCommitmentPlanName = Get-CommitmentPlanName
139
+ $secondCommitmentPlanName = Get-CommitmentPlanName
140
140
141
- LogOutput " Creating first resource group: $firstResourceGroupName "
142
- $firstGroup = New-AzureRmResourceGroup - Name $firstResourceGroupName - Location $location
143
- LogOutput(" Created first resource group: $ ( $firstGroup.ResourceId ) " )
141
+ LogOutput " Creating first resource group: $firstResourceGroupName "
142
+ $firstGroup = New-AzureRmResourceGroup - Name $firstResourceGroupName - Location $location
143
+ LogOutput(" Created first resource group: $ ( $firstGroup.ResourceId ) " )
144
144
145
145
LogOutput " Creating first commitment plan: $firstCommitmentPlanName "
146
- $firstPlan = New-AzureRmMlCommitmentPlan - ResourceGroupName $firstResourceGroupName - Location $location - Name $firstCommitmentPlanName - SkuName " S1" - SkuTier " Standard" - Force
147
- Assert-NotNull $firstPlan
146
+ $firstPlan = New-AzureRmMlCommitmentPlan - ResourceGroupName $firstResourceGroupName - Location $location - Name $firstCommitmentPlanName - SkuName " S1" - SkuTier " Standard" - Force
147
+ Assert-NotNull $firstPlan
148
148
149
- $firstPlanId = $firstPlan.Id
150
- LogOutput " Created first commitment plan: $firstPlanId "
151
- ValidateCommitmentPlanResult $firstResourceGroupName $firstCommitmentPlanName $location $firstPlan
149
+ $firstPlanId = $firstPlan.Id
150
+ LogOutput " Created first commitment plan: $firstPlanId "
151
+ ValidateCommitmentPlanResult $firstResourceGroupName $firstCommitmentPlanName $location $firstPlan
152
152
153
153
LogOutput " Creating second commitment plan: $secondCommitmentPlanName "
154
- $secondPlan = New-AzureRmMlCommitmentPlan - ResourceGroupName $firstResourceGroupName - Location $location - Name $secondCommitmentPlanName - SkuName " S1" - SkuTier " Standard" - Force
155
- Assert-NotNull $secondPlan
154
+ $secondPlan = New-AzureRmMlCommitmentPlan - ResourceGroupName $firstResourceGroupName - Location $location - Name $secondCommitmentPlanName - SkuName " S1" - SkuTier " Standard" - Force
155
+ Assert-NotNull $secondPlan
156
156
157
- $secondPlanId = $secondPlan.Id
158
- LogOutput " Created second commitment plan: $secondPlanId "
159
- ValidateCommitmentPlanResult $firstResourceGroupName $secondCommitmentPlanName $location $secondPlan
157
+ $secondPlanId = $secondPlan.Id
158
+ LogOutput " Created second commitment plan: $secondPlanId "
159
+ ValidateCommitmentPlanResult $firstResourceGroupName $secondCommitmentPlanName $location $secondPlan
160
160
161
161
# Create a third commitment plan in the second resource group
162
- $secondResourceGroupName = Get-ResourceGroupName
163
- $thirdCommitmentPlanName = Get-CommitmentPlanName
162
+ $secondResourceGroupName = Get-ResourceGroupName
163
+ $thirdCommitmentPlanName = Get-CommitmentPlanName
164
164
165
- LogOutput " Creating second resource group: $secondResourceGroupName "
166
- $secondGroup = New-AzureRmResourceGroup - Name $secondResourceGroupName - Location $location
167
- LogOutput(" Created second resource group: $ ( $secondResourceGroupName.ResourceId ) " )
165
+ LogOutput " Creating second resource group: $secondResourceGroupName "
166
+ $secondGroup = New-AzureRmResourceGroup - Name $secondResourceGroupName - Location $location
167
+ LogOutput(" Created second resource group: $ ( $secondResourceGroupName.ResourceId ) " )
168
168
169
169
LogOutput " Creating third commitment plan: $thirdCommitmentPlanName "
170
- $thirdPlan = New-AzureRmMlCommitmentPlan - ResourceGroupName $secondResourceGroupName - Location $location - Name $thirdCommitmentPlanName - SkuName " S1" - SkuTier " Standard" - Force
171
- Assert-NotNull $thirdPlan
170
+ $thirdPlan = New-AzureRmMlCommitmentPlan - ResourceGroupName $secondResourceGroupName - Location $location - Name $thirdCommitmentPlanName - SkuName " S1" - SkuTier " Standard" - Force
171
+ Assert-NotNull $thirdPlan
172
172
173
- $thirdPlanId = $thirdPlan.Id
174
- LogOutput " Created third commitment plan: $thirdPlanId "
175
- ValidateCommitmentPlanResult $secondResourceGroupName $thirdCommitmentPlanName $location $thirdPlan
173
+ $thirdPlanId = $thirdPlan.Id
174
+ LogOutput " Created third commitment plan: $thirdPlanId "
175
+ ValidateCommitmentPlanResult $secondResourceGroupName $thirdCommitmentPlanName $location $thirdPlan
176
176
177
177
# List all commitment plans in the first resource group
178
178
LogOutput " Listing all commitment plans in first resource group: $firstResourceGroupName "
179
179
$plansInFirstGroup = Get-AzureRmMlCommitmentPlan - ResourceGroupName $firstResourceGroupName
180
180
Assert-NotNull $plansInFirstGroup
181
- LogOutput " Group $firstResourceGroupName contains $ ( $plansInFirstGroup.Count ) commitment plans."
181
+ LogOutput " Group $firstResourceGroupName contains $ ( $plansInFirstGroup.Count ) commitment plans."
182
182
Assert-AreEqual 2 $plansInFirstGroup.Count
183
183
184
184
LogOutput " Checking that first commitment plan $ ( $firstPlan.Id ) is part of returned list."
@@ -190,8 +190,8 @@ function Test-ListMLCommitmentPlans
190
190
# List all commitment plans in the second resource group
191
191
LogOutput " Listing all commitment plans in second resource group: $secondResourceGroupName "
192
192
$plansInSecondGroup = Get-AzureRmMlCommitmentPlan - ResourceGroupName $secondResourceGroupName
193
- Assert-NotNull $plansInSecondGroup
194
- LogOutput " Group $secondResourceGroupName contains $ ( $plansInSecondGroup.Count ) commitment plans."
193
+ Assert-NotNull $plansInSecondGroup
194
+ LogOutput " Group $secondResourceGroupName contains $ ( $plansInSecondGroup.Count ) commitment plans."
195
195
Assert-AreEqual 1 $plansInSecondGroup.Count
196
196
197
197
LogOutput " Checking that commitment plan $ ( $thirdPlan.Id ) is part of returned list."
@@ -200,7 +200,7 @@ function Test-ListMLCommitmentPlans
200
200
# List all services in the subscription
201
201
$plansInSubscription = Get-AzureRmMlCommitmentPlan
202
202
Assert-NotNull $plansInSubscription
203
- LogOutput " Found $ ( $plansInSubscription.Count ) commitment plans in the current subscription."
203
+ LogOutput " Found $ ( $plansInSubscription.Count ) commitment plans in the current subscription."
204
204
Assert-False { $plansInSubscription.Count -lt 3 }
205
205
LogOutput " Checking that commitment plan $ ( $firstPlan.Id ) is part of returned list."
206
206
Assert-NotNull ($plansInSubscription | where { $_.Id -eq $firstPlan.Id })
@@ -210,13 +210,13 @@ function Test-ListMLCommitmentPlans
210
210
Assert-NotNull ($plansInSubscription | where { $_.Id -eq $thirdPlan.Id })
211
211
}
212
212
finally
213
- {
213
+ {
214
214
Clean - WebService $firstResourceGroupName $firstCommitmentPlanName
215
215
Clean - WebService $firstResourceGroupName $secondCommitmentPlanName
216
216
Clean - WebService $secondResourceGroupName $thirdCommitmentPlanName
217
217
218
218
Clean - ResourceGroup $firstResourceGroupName
219
- Clean - ResourceGroup $secondResourceGroupName
219
+ Clean - ResourceGroup $secondResourceGroupName
220
220
}
221
221
};
222
222
@@ -248,16 +248,16 @@ function ValidateCommitmentPlanResult([string] $rgName, [string] $commitmentPlan
248
248
{
249
249
$subscriptionId = ((Get-AzureRmContext ).Subscription).SubscriptionId
250
250
$expectedResourceId = " /subscriptions/$subscriptionId /resourceGroups/$rgName /providers/Microsoft.MachineLearning/commitmentPlans/$commitmentPlanName "
251
- $planId = $plan.Id
251
+ $planId = $plan.Id
252
252
LogOutput " Checking that the created commitment plan's resource id ($planId ) matches the expected value ($expectedResourceId )"
253
253
Assert-AreEqual $expectedResourceId $planId
254
254
255
- $planLocation = $plan.Location
255
+ $planLocation = $plan.Location
256
256
LogOutput " Checking that the commitment plan's location ($planLocation ) is the expected value ($location )"
257
257
Assert-True { [System.String ]::Equals($planLocation.Replace (" " , " " ), $location , [System.StringComparison ]::OrdinalIgnoreCase) }
258
258
259
- $expectedResourceType = " Microsoft.MachineLearning/commitmentPlans"
260
- $planType = $plan.Type
259
+ $expectedResourceType = " Microsoft.MachineLearning/commitmentPlans"
260
+ $planType = $plan.Type
261
261
LogOutput " Checking the commitment plan's resource type: ($planType ) matches the expected value ($expectedResourceType )"
262
262
Assert-AreEqual $expectedResourceType $planType
263
263
0 commit comments