Skip to content

Commit a4fa77a

Browse files
committed
Changes per PR feedback.
1 parent 1c5b0e9 commit a4fa77a

File tree

2 files changed

+106
-101
lines changed

2 files changed

+106
-101
lines changed

src/ResourceManager/MachineLearning/Commands.MachineLearning.Test/ScenarioTests/CommitmentPlanTests.ps1

Lines changed: 100 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,38 @@
1717
Tests creating, getting and removing an AzureML commitment plan.
1818
#>
1919
function Test-CreateGetRemoveMLCommitmentPlan
20-
{
20+
{
2121
$planDeleted = $false
2222

2323
$actualTest = {
2424
param([string] $location)
2525

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"
5252
}
5353
finally
5454
{
@@ -58,7 +58,7 @@ function Test-CreateGetRemoveMLCommitmentPlan
5858
Clean-CommitmentPlan $resourceGroupName $commitmentPlanName
5959
}
6060

61-
Clean-ResourceGroup $resourceGroupName
61+
Clean-ResourceGroup $resourceGroupName
6262
}
6363
};
6464

@@ -76,46 +76,46 @@ function Test-UpdateMLCommitmentPlan
7676
$actualTest = {
7777
param([string] $location)
7878

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"
109109
}
110110
finally
111111
{
112112
# Cleanup
113-
if (!$planDeleted)
114-
{
113+
if (!$planDeleted)
114+
{
115115
Clean-CommitmentPlan $resourceGroupName $commitmentPlanName
116116
}
117117

118-
Clean-ResourceGroup $resourceGroupName
118+
Clean-ResourceGroup $resourceGroupName
119119
}
120120
};
121121

@@ -129,56 +129,56 @@ Tests the cmdlets for retrieving lists of AzureML commitment plans
129129
function Test-ListMLCommitmentPlans
130130
{
131131
$actualTest = {
132-
param([string] $location)
133-
134-
try
132+
param([string] $location)
133+
134+
try
135135
{
136136
# 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
140140

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)")
144144

145145
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
148148

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
152152

153153
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
156156

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
160160

161161
# 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
164164

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)")
168168

169169
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
172172

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
176176

177177
# List all commitment plans in the first resource group
178178
LogOutput "Listing all commitment plans in first resource group: $firstResourceGroupName"
179179
$plansInFirstGroup = Get-AzureRmMlCommitmentPlan -ResourceGroupName $firstResourceGroupName
180180
Assert-NotNull $plansInFirstGroup
181-
LogOutput "Group $firstResourceGroupName contains $($plansInFirstGroup.Count) commitment plans."
181+
LogOutput "Group $firstResourceGroupName contains $($plansInFirstGroup.Count) commitment plans."
182182
Assert-AreEqual 2 $plansInFirstGroup.Count
183183

184184
LogOutput "Checking that first commitment plan $($firstPlan.Id) is part of returned list."
@@ -190,8 +190,8 @@ function Test-ListMLCommitmentPlans
190190
# List all commitment plans in the second resource group
191191
LogOutput "Listing all commitment plans in second resource group: $secondResourceGroupName"
192192
$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."
195195
Assert-AreEqual 1 $plansInSecondGroup.Count
196196

197197
LogOutput "Checking that commitment plan $($thirdPlan.Id) is part of returned list."
@@ -200,7 +200,7 @@ function Test-ListMLCommitmentPlans
200200
# List all services in the subscription
201201
$plansInSubscription = Get-AzureRmMlCommitmentPlan
202202
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."
204204
Assert-False { $plansInSubscription.Count -lt 3 }
205205
LogOutput "Checking that commitment plan $($firstPlan.Id) is part of returned list."
206206
Assert-NotNull ($plansInSubscription | where { $_.Id -eq $firstPlan.Id })
@@ -210,13 +210,13 @@ function Test-ListMLCommitmentPlans
210210
Assert-NotNull ($plansInSubscription | where { $_.Id -eq $thirdPlan.Id })
211211
}
212212
finally
213-
{
213+
{
214214
Clean-WebService $firstResourceGroupName $firstCommitmentPlanName
215215
Clean-WebService $firstResourceGroupName $secondCommitmentPlanName
216216
Clean-WebService $secondResourceGroupName $thirdCommitmentPlanName
217217

218218
Clean-ResourceGroup $firstResourceGroupName
219-
Clean-ResourceGroup $secondResourceGroupName
219+
Clean-ResourceGroup $secondResourceGroupName
220220
}
221221
};
222222

@@ -248,16 +248,16 @@ function ValidateCommitmentPlanResult([string] $rgName, [string] $commitmentPlan
248248
{
249249
$subscriptionId = ((Get-AzureRmContext).Subscription).SubscriptionId
250250
$expectedResourceId = "/subscriptions/$subscriptionId/resourceGroups/$rgName/providers/Microsoft.MachineLearning/commitmentPlans/$commitmentPlanName"
251-
$planId = $plan.Id
251+
$planId = $plan.Id
252252
LogOutput "Checking that the created commitment plan's resource id ($planId) matches the expected value ($expectedResourceId)"
253253
Assert-AreEqual $expectedResourceId $planId
254254

255-
$planLocation = $plan.Location
255+
$planLocation = $plan.Location
256256
LogOutput "Checking that the commitment plan's location ($planLocation) is the expected value ($location)"
257257
Assert-True { [System.String]::Equals($planLocation.Replace(" ", ""), $location, [System.StringComparison]::OrdinalIgnoreCase) }
258258

259-
$expectedResourceType = "Microsoft.MachineLearning/commitmentPlans"
260-
$planType = $plan.Type
259+
$expectedResourceType = "Microsoft.MachineLearning/commitmentPlans"
260+
$planType = $plan.Type
261261
LogOutput "Checking the commitment plan's resource type: ($planType) matches the expected value ($expectedResourceType)"
262262
Assert-AreEqual $expectedResourceType $planType
263263

src/ResourceManager/MachineLearning/Commands.MachineLearning/Cmdlets/CommitmentPlans/MoveAzureMLCommitmentAssociation.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace Microsoft.Azure.Commands.MachineLearning
2020
{
21-
[Cmdlet(VerbsCommon.Move, CommitmentPlansCmdletBase.CommitmentAssociationCommandletSuffix)]
21+
[Cmdlet(VerbsCommon.Move, CommitmentPlansCmdletBase.CommitmentAssociationCommandletSuffix, SupportsShouldProcess = true)]
2222
[OutputType(typeof(CommitmentPlan), typeof(CommitmentPlan[]))]
2323
public class MoveAzureMLCommitmentAssociation : CommitmentPlansCmdletBase
2424
{
@@ -40,6 +40,11 @@ public class MoveAzureMLCommitmentAssociation : CommitmentPlansCmdletBase
4040

4141
protected override void RunCmdlet()
4242
{
43+
if (!ShouldProcess(this.Name, @"Moving Azure ML commitment association."))
44+
{
45+
return;
46+
}
47+
4348
CommitmentAssociation commitmentAssociation =
4449
this.CommitmentPlansClient.MoveCommitmentAssociationAsync(
4550
this.ResourceGroupName,

0 commit comments

Comments
 (0)