@@ -183,12 +183,18 @@ function Invoke-LiveTestCommand {
183
183
184
184
do {
185
185
try {
186
- Write-Host " ##[section]Start to execute the command `" $Command `" " - ForegroundColor Green
187
- Write-Host " ##[command]The command `" $Command `" is running" - ForegroundColor Cyan
186
+ Write-Host " ##[section]Start to execute the command `" $Command `" . " - ForegroundColor Green
187
+ Write-Host " ##[command]The command `" $Command `" is running. " - ForegroundColor Cyan
188
188
189
189
$cmdResult = Invoke-Expression - Command $Command - ErrorAction Stop
190
190
191
- Write-Host " ##[section]Successfully executed the command `" $Command `" " - ForegroundColor Green
191
+ if ($LASTEXITCODE -eq 0 ) {
192
+ Write-Host " ##[section]Successfully executed the command `" $Command `" " - ForegroundColor Green
193
+ }
194
+ else {
195
+ throw " Error occurred when executing the command `" $Command `" ."
196
+ }
197
+
192
198
$cmdResult
193
199
break
194
200
}
@@ -280,14 +286,19 @@ function Invoke-LiveTestScenario {
280
286
281
287
do {
282
288
try {
283
- $sPrefs = @ ([psvariable ]::new(" ErrorActionPreference" , " Stop" ), [psvariable ]::new(" ConfirmPreference" , " None" ))
289
+ $prefs = @ ([psvariable ]::new(" ErrorActionPreference" , " Stop" ), [psvariable ]::new(" ConfirmPreference" , " None" ))
284
290
if ($snrRetryCount -eq $script :ScenarioMaxRetryCount ) {
285
291
$prefs += [psvariable ]::new(" DebugPreference" , " Continue" )
286
292
}
287
293
288
294
$ScenarioScript.InvokeWithContext ($null , $prefs , $snrResourceGroup )
289
295
290
- Write-Host " ##[section]Successfully executed the live scenario `" $Name `" ." - ForegroundColor Green
296
+ if ($LASTEXITCODE -eq 0 ) {
297
+ Write-Host " ##[section]Successfully executed the live scenario `" $Name `" ." - ForegroundColor Green
298
+ }
299
+ else {
300
+ throw " Error occurred when executing the live scenario `" $Name `" ."
301
+ }
291
302
break
292
303
}
293
304
catch {
@@ -377,7 +388,7 @@ function Clear-LiveTestResources {
377
388
[string ] $Name
378
389
)
379
390
380
- Invoke-LiveTestCommand - Command " Remove-AzResourceGroup -Name $Name -Force"
391
+ Invoke-LiveTestCommand - Command " Remove-AzResourceGroup -Name $Name -Force -AsJob "
381
392
}
382
393
383
394
function ConvertToLiveTestJsonErrors {
0 commit comments