Skip to content

Commit a0a4924

Browse files
committed
fixed test cmdlets to use new version 'Rm'
1 parent 0c240ce commit a0a4924

File tree

2 files changed

+78
-78
lines changed

2 files changed

+78
-78
lines changed

src/ResourceManager/Automation/Commands.Automation.Test/ScenarioTests/AutomationTests.ps1

Lines changed: 77 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ function CreateRunbook
4646
param([string] $runbookPath, [boolean] $byName=$false, [string[]] $tag, [string] $description)
4747

4848
$runbookName = gci $runbookPath | %{$_.BaseName}
49-
$runbook = Get-AzureAutomationRunbook $accountName | where {$_.Name -eq $runbookName}
49+
$runbook = Get-AzureRmAutomationRunbook $accountName | where {$_.Name -eq $runbookName}
5050
if ($runbook.Count -eq 1)
5151
{
52-
Remove-AzureAutomationRunbook $accountName -Name $runbookName -Force
52+
Remove-AzureRmAutomationRunbook $accountName -Name $runbookName -Force
5353
}
5454

5555
if(!$byName)
5656
{
57-
return New-AzureAutomationRunbook $accountName -Path $runbookPath -Tag $tag -Description $description
57+
return New-AzureRmAutomationRunbook $accountName -Path $runbookPath -Tag $tag -Description $description
5858
}
5959
else
6060
{
61-
return New-AzureAutomationRunbook $accountName -Name $runbookName -Tag $tag -Description $description
61+
return New-AzureRmAutomationRunbook $accountName -Name $runbookName -Tag $tag -Description $description
6262
}
6363
}
6464

@@ -81,7 +81,7 @@ function WaitForJobStatus
8181
{
8282
Wait-Seconds $interval
8383
$timeElapse = $timeElapse + $interval
84-
$job = Get-AzureAutomationJob -AutomationAccount $accountName -Id $Id
84+
$job = Get-AzureRmAutomationJob -AutomationAccount $accountName -Id $Id
8585
if($job.Status -eq $Status)
8686
{
8787
break
@@ -104,19 +104,19 @@ function Test-RunbookWithParameter
104104
param([string] $runbookPath, [HashTable] $parameters, [int]$expectedResult)
105105

106106
#Setup
107-
$automationAccount = Get-AzureAutomationAccount -Name $accountName
107+
$automationAccount = Get-AzureRmAutomationAccount -Name $accountName
108108
Assert-NotNull $automationAccount "Automation account $accountName does not exist."
109109

110110
$runbook = CreateRunbook $runbookPath
111111
Assert-NotNull $runbook "runBook $runbookPath does not import successfully."
112-
$automationAccount | Publish-AzureAutomationRunbook -Name $runbook.Name
112+
$automationAccount | Publish-AzureRmAutomationRunbook -Name $runbook.Name
113113

114114
#Test
115-
$job = $automationAccount | Start-AzureAutomationRunbook -Name $runbook.Name -Parameters $parameters
115+
$job = $automationAccount | Start-AzureRmAutomationRunbook -Name $runbook.Name -Parameters $parameters
116116
WaitForJobStatus -Id $job.Id -Status "Completed"
117-
$jobOutput = $automationAccount | Get-AzureAutomationJobOutput -Id $job.Id -Stream Output
118-
$automationAccount | Remove-AzureAutomationRunbook -Name $runbook.Name -Force
119-
Assert-Throws { $automationAccount | Get-AzureAutomationRunbook -Name $runbook.Name}
117+
$jobOutput = $automationAccount | Get-AzureRmAutomationJobOutput -Id $job.Id -Stream Output
118+
$automationAccount | Remove-AzureRmAutomationRunbook -Name $runbook.Name -Force
119+
Assert-Throws { $automationAccount | Get-AzureRmAutomationRunbook -Name $runbook.Name}
120120
}
121121

122122
<#
@@ -127,20 +127,20 @@ function Test-AutomationStartAndStopRunbook
127127
{
128128
param([string] $runbookPath)
129129

130-
$automationAccount = Get-AzureAutomationAccount -Name $accountName
130+
$automationAccount = Get-AzureRmAutomationAccount -Name $accountName
131131
Assert-NotNull $automationAccount "Automation account $accountName does not exist."
132132

133133
$runbook = CreateRunbook $runbookPath
134134
Assert-NotNull $runbook "runBook $runbookPath does not import successfully."
135-
$automationAccount | Publish-AzureAutomationRunbook -Name $runbook.Name
135+
$automationAccount | Publish-AzureRmAutomationRunbook -Name $runbook.Name
136136

137137
#Test
138-
$job = Start-AzureAutomationRunbook -Name $runbook.Name -AutomationAccountName $accountName
138+
$job = Start-AzureRmAutomationRunbook -Name $runbook.Name -AutomationAccountName $accountName
139139
WaitForJobStatus -Id $job.Id -Status "Running"
140-
$automationAccount | Stop-AzureAutomationJob -Id $job.Id
140+
$automationAccount | Stop-AzureRmAutomationJob -Id $job.Id
141141
WaitForJobStatus -Id $job.Id -Status "Stopped"
142-
$automationAccount | Remove-AzureAutomationRunbook -Name $runbook.Name -Force
143-
Assert-Throws { $automationAccount | Get-AzureAutomationRunbook -Name $runbook.Name}
142+
$automationAccount | Remove-AzureRmAutomationRunbook -Name $runbook.Name -Force
143+
Assert-Throws { $automationAccount | Get-AzureRmAutomationRunbook -Name $runbook.Name}
144144
}
145145

146146
<#
@@ -154,27 +154,27 @@ function Test-AutomationPublishAndEditRunbook
154154
$runbook = CreateRunbook $runbookPath $true
155155

156156
#Publish Runbook
157-
Publish-AzureAutomationRunbook $accountName -Name $runbook.Name
158-
$publishedRunbook = Get-AzureAutomationRunbook $accountName -Name $runbook.Name
157+
Publish-AzureRmAutomationRunbook $accountName -Name $runbook.Name
158+
$publishedRunbook = Get-AzureRmAutomationRunbook $accountName -Name $runbook.Name
159159
$runbookState = "Published"
160160
Assert-AreEqual $publishedRunbook.State $runbookState "Runbook should be in $runbookState state"
161-
$publishedRunbookDefn = Get-AzureAutomationRunbookDefinition $accountName -Name $runbook.Name
161+
$publishedRunbookDefn = Get-AzureRmAutomationRunbookDefinition $accountName -Name $runbook.Name
162162

163163
#Edit Runbook
164-
Set-AzureAutomationRunbookDefinition $accountName -Name $runbook.Name -Path $runbookPath -Overwrite
165-
$runbook = Get-AzureAutomationRunbook $accountName -Name $runbook.Name
164+
Set-AzureRmAutomationRunbookDefinition $accountName -Name $runbook.Name -Path $runbookPath -Overwrite
165+
$runbook = Get-AzureRmAutomationRunbook $accountName -Name $runbook.Name
166166
$runbookState = "Edit"
167167
Assert-AreEqual $runbook.State $runbookState "Runbook should be in $runbookState state"
168-
$editedRunbookDefn = Get-AzureAutomationRunbookDefinition $accountName -Name $runbook.Name -Slot "Draft"
168+
$editedRunbookDefn = Get-AzureRmAutomationRunbookDefinition $accountName -Name $runbook.Name -Slot "Draft"
169169
Assert-AreNotEqual $editedRunbookDefn.Content $publishedRunbookDefn.Content "Old content and edited content of the runbook shouldn't be equal"
170170

171-
Assert-Throws {Set-AzureAutomationRunbookDefinition $accountName -Name $runbook.Name -Path $editRunbookPath -PassThru -ErrorAction Stop}
172-
Set-AzureAutomationRunbookDefinition $accountName -Name $runbook.Name -Path $editRunbookPath -Overwrite
173-
$editedRunbookDefn2 = Get-AzureAutomationRunbookDefinition $accountName -Name $runbook.Name -Slot "Draft"
171+
Assert-Throws {Set-AzureRmAutomationRunbookDefinition $accountName -Name $runbook.Name -Path $editRunbookPath -PassThru -ErrorAction Stop}
172+
Set-AzureRmAutomationRunbookDefinition $accountName -Name $runbook.Name -Path $editRunbookPath -Overwrite
173+
$editedRunbookDefn2 = Get-AzureRmAutomationRunbookDefinition $accountName -Name $runbook.Name -Slot "Draft"
174174
Assert-AreNotEqual $editedRunbookDefn2.Content $editedRunbookDefn.Content "Old content and edited content of the runbook shouldn't be equal"
175175

176-
Remove-AzureAutomationRunbook $accountName -Name $runbook.Name -Force
177-
Assert-Throws {Get-AzureAutomationRunbook $accountName -Name $runbook.Name}
176+
Remove-AzureRmAutomationRunbook $accountName -Name $runbook.Name -Force
177+
Assert-Throws {Get-AzureRmAutomationRunbook $accountName -Name $runbook.Name}
178178

179179
}
180180

@@ -187,56 +187,56 @@ function Test-AutomationConfigureRunbook
187187
param([string] $runbookPath)
188188

189189
#Setup
190-
$automationAccount = Get-AzureAutomationAccount -Name $accountName
190+
$automationAccount = Get-AzureRmAutomationAccount -Name $accountName
191191
Assert-NotNull $automationAccount "Automation account $accountName does not exist."
192192
$runbook = CreateRunbook $runbookPath
193193
Assert-NotNull $runbook "runbook ($runbookPath) isn't imported successfully."
194-
Publish-AzureAutomationRunbook -Name $runbook.Name -AutomationAccountName $accountName
194+
Publish-AzureRmAutomationRunbook -Name $runbook.Name -AutomationAccountName $accountName
195195

196196
#Test
197197

198198
#Change the runbook configuration
199-
$automationAccount | Set-AzureAutomationRunbook -Name $runbook.Name -LogVerbose $true -LogProgress $false
200-
$runbook = $automationAccount | Get-AzureAutomationRunbook -Name $runbook.Name
199+
$automationAccount | Set-AzureRmAutomationRunbook -Name $runbook.Name -LogVerbose $true -LogProgress $false
200+
$runbook = $automationAccount | Get-AzureRmAutomationRunbook -Name $runbook.Name
201201
Assert-NotNull $runbook "Runbook shouldn't be Null"
202202
Assert-AreEqual $true $runbook.LogVerbose "Log Verbose mode should be true."
203203
Assert-AreEqual $false $runbook.LogProgress "Log Progress mode should be false."
204204

205205
#Start runbook and wait for job complete
206-
$job = $automationAccount | Start-AzureAutomationRunbook -Name $runbook.Name
206+
$job = $automationAccount | Start-AzureRmAutomationRunbook -Name $runbook.Name
207207
WaitForJobStatus -Id $job.Id -Status "Completed"
208208

209209
#Check job output streams
210-
$jobOutputs = $automationAccount | Get-AzureAutomationJobOutput -Id $job.Id -Stream "Output"
210+
$jobOutputs = $automationAccount | Get-AzureRmAutomationJobOutput -Id $job.Id -Stream "Output"
211211
Assert-AreEqual 1 $jobOutputs.Count
212212
AssertContains $jobOutputs[0].Text "output message" "The output stream is wrong."
213213
#Verify that verbose streams are logged
214-
$jobVerboseOutputs = Get-AzureAutomationJobOutput $accountName -Id $job.Id -Stream "Verbose"
214+
$jobVerboseOutputs = Get-AzureRmAutomationJobOutput $accountName -Id $job.Id -Stream "Verbose"
215215
Assert-AreEqual 1 $jobVerboseOutputs.Count
216216
AssertContains $jobVerboseOutputs[0].Text "verbose message" "The verbose stream is wrong."
217217
#Verify that progress stream isn't logged
218-
$jobProgressOutputs = Get-AzureAutomationJobOutput -AutomationAccountName $accountName -Id $job.Id -Stream "Progress"
218+
$jobProgressOutputs = Get-AzureRmAutomationJobOutput -AutomationAccountName $accountName -Id $job.Id -Stream "Progress"
219219
Assert-AreEqual 0 $jobProgressOutputs.Count
220220

221221
#Change the runbook configuration again and start the runbook
222-
Set-AzureAutomationRunbook $accountName -Name $runbook.Name -LogVerbose $false -LogProgress $true
223-
$job = Start-AzureAutomationRunbook $accountName -Name $runbook.Name
222+
Set-AzureRmAutomationRunbook $accountName -Name $runbook.Name -LogVerbose $false -LogProgress $true
223+
$job = Start-AzureRmAutomationRunbook $accountName -Name $runbook.Name
224224
WaitForJobStatus -Id $job.Id -Status "Completed"
225225
#Verify that progress stream is logged
226-
$jobProgressOutputs = Get-AzureAutomationJobOutput $accountName -Id $job.Id -Stream "Progress"
226+
$jobProgressOutputs = Get-AzureRmAutomationJobOutput $accountName -Id $job.Id -Stream "Progress"
227227
Assert-AreNotEqual 0 $jobProgressOutputs.Count
228228
Assert-AreEqual $jobProgressOutputs[0].Type "Progress"
229229
#Verify that verbose streams aren't logged
230-
$jobVerboseOutputs = Get-AzureAutomationJobOutput $accountName -Id $job.Id -Stream "Verbose"
230+
$jobVerboseOutputs = Get-AzureRmAutomationJobOutput $accountName -Id $job.Id -Stream "Verbose"
231231
Assert-AreEqual 0 $jobVerboseOutputs.Count
232232

233233
#Check whether the total number of jobs for the runbook is correct
234-
$jobs = Get-AzureAutomationJob $accountName -RunbookName $runbook.Name
234+
$jobs = Get-AzureRmAutomationJob $accountName -RunbookName $runbook.Name
235235
Assert-AreEqual 2 $jobs.Count "There should be 2 jobs in total for this runbook."
236236

237237
#Remove runbook
238-
$automationAccount | Remove-AzureAutomationRunbook -Name $runbook.Name -Force
239-
Assert-Throws {$automationAccount | Get-AzureAutomationRunbook -Name $runbook.Name}
238+
$automationAccount | Remove-AzureRmAutomationRunbook -Name $runbook.Name -Force
239+
Assert-Throws {$automationAccount | Get-AzureRmAutomationRunbook -Name $runbook.Name}
240240
}
241241

242242
<#
@@ -248,24 +248,24 @@ function Test-AutomationSuspendAndResumeJob
248248
param([string] $runbookPath)
249249

250250
#Setup
251-
$automationAccount = Get-AzureAutomationAccount $accountName
251+
$automationAccount = Get-AzureRmAutomationAccount $accountName
252252
Assert-NotNull $automationAccount "Automation account $accountName does not exist."
253253
$runbook = CreateRunbook $runbookPath
254254

255255
#Test
256256

257-
$automationAccount | Publish-AzureAutomationRunbook -Name $runbook.Name
257+
$automationAccount | Publish-AzureRmAutomationRunbook -Name $runbook.Name
258258
#Start, suspend, and then resume job
259-
$job = Start-AzureAutomationRunbook $accountName -Name $runbook.Name
259+
$job = Start-AzureRmAutomationRunbook $accountName -Name $runbook.Name
260260
WaitForJobStatus -Id $job.Id -Status "Running"
261-
Suspend-AzureAutomationJob $accountName -Id $job.Id
261+
Suspend-AzureRmAutomationJob $accountName -Id $job.Id
262262
WaitForJobStatus -Id $job.Id -Status "Suspended"
263-
$automationAccount | Resume-AzureAutomationJob -Id $job.Id
263+
$automationAccount | Resume-AzureRmAutomationJob -Id $job.Id
264264
WaitForJobStatus -Id $job.Id -Status "Completed"
265265

266266
#Remove runbook
267-
Remove-AzureAutomationRunbook -AutomationAccountName $accountName -Name $runbook.Name -Force
268-
Assert-Throws {Get-AzureAutomationRunbook $accountName -Name $runbook.Name}
267+
Remove-AzureRmAutomationRunbook -AutomationAccountName $accountName -Name $runbook.Name -Force
268+
Assert-Throws {Get-AzureRmAutomationRunbook $accountName -Name $runbook.Name}
269269
}
270270

271271
<#
@@ -277,67 +277,67 @@ function Test-AutomationStartRunbookOnASchedule
277277
param([string] $runbookPath)
278278

279279
#Setup
280-
$automationAccount = Get-AzureAutomationAccount -Name $accountName
280+
$automationAccount = Get-AzureRmAutomationAccount -Name $accountName
281281
$runbook = CreateRunbook $runbookPath
282-
Publish-AzureAutomationRunbook $accountName -Name $runbook.Name
282+
Publish-AzureRmAutomationRunbook $accountName -Name $runbook.Name
283283

284284
#Test
285285

286286
#Create one time schedule
287287
$oneTimeScheName = "oneTimeSchedule"
288-
$schedule = Get-AzureAutomationSchedule $accountName | where {$_.Name -eq $oneTimeScheName}
288+
$schedule = Get-AzureRmAutomationSchedule $accountName | where {$_.Name -eq $oneTimeScheName}
289289
if ($schedule.Count -eq 1)
290290
{
291-
Remove-AzureAutomationSchedule $accountName -Name $oneTimeScheName -Force
291+
Remove-AzureRmAutomationSchedule $accountName -Name $oneTimeScheName -Force
292292
}
293293
$startTime = (Get-Date).AddMinutes(7)
294-
New-AzureAutomationSchedule $accountName -Name $oneTimeScheName -OneTime -StartTime $startTime
295-
$oneTimeSchedule = Get-AzureAutomationSchedule $accountName -Name $oneTimeScheName
294+
New-AzureRmAutomationSchedule $accountName -Name $oneTimeScheName -OneTime -StartTime $startTime
295+
$oneTimeSchedule = Get-AzureRmAutomationSchedule $accountName -Name $oneTimeScheName
296296
Assert-NotNull $oneTimeSchedule "$oneTimeScheName doesn't exist!"
297297

298298
#Create daily schedule
299299
$dailyScheName = "dailySchedule"
300-
$schedule = Get-AzureAutomationSchedule $accountName | where {$_.Name -eq $dailyScheName}
300+
$schedule = Get-AzureRmAutomationSchedule $accountName | where {$_.Name -eq $dailyScheName}
301301
if ($schedule.Count -eq 1)
302302
{
303-
Remove-AzureAutomationSchedule $accountName -Name $dailyScheName -Force
303+
Remove-AzureRmAutomationSchedule $accountName -Name $dailyScheName -Force
304304
}
305305
$startTime = (Get-Date).AddDays(1)
306306
$expiryTime = (Get-Date).AddDays(3)
307-
New-AzureAutomationSchedule $accountName -Name $DailyScheName -StartTime $startTime -ExpiryTime $expiryTime -DayInterval 1
308-
$dailySchedule = Get-AzureAutomationSchedule $accountName -Name $dailyScheName
307+
New-AzureRmAutomationSchedule $accountName -Name $DailyScheName -StartTime $startTime -ExpiryTime $expiryTime -DayInterval 1
308+
$dailySchedule = Get-AzureRmAutomationSchedule $accountName -Name $dailyScheName
309309
Assert-NotNull $dailySchedule "$dailyScheName doesn't exist!"
310310

311-
$runbook = Register-AzureAutomationScheduledRunbook $accountName -Name $runbook.Name -ScheduleName $oneTimeScheName
311+
$runbook = Register-AzureRmAutomationScheduledRunbook $accountName -Name $runbook.Name -ScheduleName $oneTimeScheName
312312
Assert-AreEqual $oneTimeScheName $runbook.ScheduleNames "The runbook should be associated with $oneTimeScheName"
313-
$runbook = Register-AzureAutomationScheduledRunbook $accountName -Name $runbook.Name -ScheduleName $dailyScheName
313+
$runbook = Register-AzureRmAutomationScheduledRunbook $accountName -Name $runbook.Name -ScheduleName $dailyScheName
314314
Assert-True { $runbook.ScheduleNames -Contains $dailyScheName} "The runbook should be associated with $dailyScheName"
315315

316316
#waiting for seven minutes
317317
Wait-Seconds 420
318-
$job = Get-AzureAutomationJob $accountName -Name $runbook.Name | where {$_.ScheduleName -eq $oneTimeScheName}
319-
$jobSchedule = Get-AzureAutomationScheduledRunbook $accountName -RunbookName $runbook.Name -ScheduleName $oneTimeScheName
318+
$job = Get-AzureRmAutomationJob $accountName -Name $runbook.Name | where {$_.ScheduleName -eq $oneTimeScheName}
319+
$jobSchedule = Get-AzureRmAutomationScheduledRunbook $accountName -RunbookName $runbook.Name -ScheduleName $oneTimeScheName
320320
Assert-AreEqual 1 $jobSchedule.Count
321321
Assert-AreEqual 1 $job.Count
322322
WaitForJobStatus -Id $job.Id -Status "Completed"
323323

324324
#Edit schedule
325325
$description = "Daily Schedule Description"
326-
Set-AzureAutomationSchedule $accountName -Name $dailyScheName -Description $description
327-
$dailySchedule = Get-AzureAutomationSchedule $accountName -Name $dailyScheName
326+
Set-AzureRmAutomationSchedule $accountName -Name $dailyScheName -Description $description
327+
$dailySchedule = Get-AzureRmAutomationSchedule $accountName -Name $dailyScheName
328328
Assert-AreEqual $description $dailySchedule.Description
329329

330-
Unregister-AzureAutomationScheduledRunbook $accountName -Name $runbook.Name -ScheduleName $dailyScheName
331-
$jobSchedule = Get-AzureAutomationScheduledRunbook $accountName -RunbookName $runbook.Name -ScheduleName $dailyScheName
330+
Unregister-AzureRmAutomationScheduledRunbook $accountName -Name $runbook.Name -ScheduleName $dailyScheName
331+
$jobSchedule = Get-AzureRmAutomationScheduledRunbook $accountName -RunbookName $runbook.Name -ScheduleName $dailyScheName
332332
Assert-Null $jobSchedule "The runbook shouldn't have an association with $dailyScheName"
333333

334334
#Remove runbook and schedule
335-
Remove-AzureAutomationSchedule $accountName -Name $oneTimeScheName -Force
336-
Assert-Throws {$automationAccount | Get-AzureAutomationSchedule -Name $oneTimeScheName}
337-
$automationAccount | Remove-AzureAutomationSchedule -Name $dailyScheName -Force
338-
Assert-Throws {$automationAccount | Get-AzureAutomationSchedule -Name $dailyScheName}
339-
Remove-AzureAutomationRunbook $accountName -Name $runbook.Name -Force
340-
Assert-Throws {Get-AzureAutomationRunbook $accountName -Name $runbook.Name}
335+
Remove-AzureRmAutomationSchedule $accountName -Name $oneTimeScheName -Force
336+
Assert-Throws {$automationAccount | Get-AzureRmAutomationSchedule -Name $oneTimeScheName}
337+
$automationAccount | Remove-AzureRmAutomationSchedule -Name $dailyScheName -Force
338+
Assert-Throws {$automationAccount | Get-AzureRmAutomationSchedule -Name $dailyScheName}
339+
Remove-AzureRmAutomationRunbook $accountName -Name $runbook.Name -Force
340+
Assert-Throws {Get-AzureRmAutomationRunbook $accountName -Name $runbook.Name}
341341
}
342342

343343
<#
@@ -356,8 +356,8 @@ function Test-AutomationStartUnpublishedRunbook
356356
Assert-NotNull $runbook "runBook $runbookPath does not import successfully."
357357
Assert-NotNull $runbook.Tags "Tags of the runbook shouldn't be Null."
358358
Assert-NotNull $runbook.Description "Description of the runbook shouldn't be Null."
359-
Assert-Throws {Start-AzureAutomationRunbook $accountName -Name $runbook.Name -Parameters $runbookParameters -PassThru -ErrorAction Stop}
359+
Assert-Throws {Start-AzureRmAutomationRunbook $accountName -Name $runbook.Name -Parameters $runbookParameters -PassThru -ErrorAction Stop}
360360

361-
Remove-AzureAutomationRunbook $accountName -Name $runbook.Name -Force
362-
Assert-Throws {Get-AzureAutomationRunbook $accountName -Name $runbook.Name -Parameters $runbookParameters -PassThru -ErrorAction Stop}
361+
Remove-AzureRmAutomationRunbook $accountName -Name $runbook.Name -Force
362+
Assert-Throws {Get-AzureRmAutomationRunbook $accountName -Name $runbook.Name -Parameters $runbookParameters -PassThru -ErrorAction Stop}
363363
}

0 commit comments

Comments
 (0)