Skip to content

Commit dfe87e6

Browse files
author
anshii03
authored
Update Utility task for Jmeter test to show proper error message for … (#14727)
* Update Utility task for Jmeter test to show proper error message for soft shutdown * Update task.json * Update task.loc.json * Update CltTasksUtility.ps1 * Update CltTasksUtility.ps1 * Update CltTasksUtility.ps1 * Update CltTasksUtility.ps1
1 parent 3132bdd commit dfe87e6

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

Tasks/RunJMeterLoadTestV1/CltTasksUtility.ps1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@ function InvokeRestMethod($headers, $contentType, $uri , $method= "Get", $body)
22
{
33
$restTimeout = 60
44
$ServicePoint = [System.Net.ServicePointManager]::FindServicePoint($uri)
5-
$result = Invoke-RestMethod -ContentType "application/json" -UserAgent $global:userAgent -TimeoutSec $restTimeout -Uri $uri -Method $method -Headers $headers -Body $body
5+
try
6+
{
7+
$result = Invoke-RestMethod -ContentType "application/json" -UserAgent $global:userAgent -TimeoutSec $restTimeout -Uri $uri -Method $method -Headers $headers -Body $body
8+
}
9+
catch
10+
{
11+
Write-Host "An error occurred:"
12+
$errorObject = ConvertFrom-Json -InputObject $_.ErrorDetails
13+
$errorMessage = $errorObject.message
14+
Write-Error $errorMessage
15+
throw "Error occurred while calling API: $method $uri. Please check error messages for more details."
16+
}
617
$ServicePoint.CloseConnectionGroup("")
718
return $result
819
}

Tasks/RunJMeterLoadTestV1/task.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 1,
16-
"Minor": 0,
17-
"Patch": 33
16+
"Minor": 186,
17+
"Patch": 0
1818
},
1919
"deprecated": true,
2020
"demands": [
@@ -133,4 +133,4 @@
133133
"workingDirectory": "$(currentDirectory)"
134134
}
135135
}
136-
}
136+
}

Tasks/RunJMeterLoadTestV1/task.loc.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"author": "Microsoft Corporation",
1414
"version": {
1515
"Major": 1,
16-
"Minor": 0,
17-
"Patch": 33
16+
"Minor": 186,
17+
"Patch": 0
1818
},
1919
"deprecated": true,
2020
"demands": [
@@ -133,4 +133,4 @@
133133
"workingDirectory": "$(currentDirectory)"
134134
}
135135
}
136-
}
136+
}

0 commit comments

Comments
 (0)