@@ -43,18 +43,26 @@ function InitializeRestHeaders()
4343 return $restHeaders
4444}
4545
46+ function InvokeRestMethod ($headers , $contentType , $uri , $method = " Get" , $body )
47+ {
48+ $ServicePoint = [System.Net.ServicePointManager ]::FindServicePoint($uri )
49+ $result = Invoke-RestMethod - ContentType " application/json" - UserAgent $userAgent - TimeoutSec $global :RestTimeout - Uri $uri - Method $method - Headers $headers - Body $body
50+ $ServicePoint.CloseConnectionGroup (" " )
51+ return $result
52+ }
53+
4654function CreateTestDrop ($headers )
4755{
4856 $uri = [String ]::Format(" {0}/_apis/clt/testdrops?{1}" , $global :ElsAccountUrl , $apiVersion )
49- $drop = Invoke-RestMethod - ContentType " application/json" - UserAgent $userAgent - Uri $ uri - Headers $headers - Method Post - Body " { "" dropType"" : "" TestServiceBlobDrop"" }"
57+ $drop = InvokeRestMethod - contentType " application/json" - uri $ uri - headers $headers - method Post - body " { "" dropType"" : "" TestServiceBlobDrop"" }"
5058 return $drop
5159}
5260
5361function Get ($headers , $uri )
5462{
5563 try
5664 {
57- $result = Invoke-RestMethod - ContentType " application/json" - UserAgent $userAgent - TimeoutSec $ global :RestTimeout - Uri $ uri - Headers $headers
65+ $result = InvokeRestMethod - contentType " application/json" - uri $ uri - headers $headers
5866 return $result
5967 }
6068 catch
@@ -87,7 +95,7 @@ function GetTestErrors($headers, $run)
8795function QueueTestRun ($headers , $runJson )
8896{
8997 $uri = [String ]::Format(" {0}/_apis/clt/testruns?{1}" , $global :ElsAccountUrl , $apiVersion )
90- $run = Invoke-RestMethod - ContentType " application/json" - UserAgent $userAgent - Uri $ uri - Method Post - Headers $headers - Body $runJson
98+ $run = InvokeRestMethod - contentType " application/json" - uri $ uri - method Post - headers $headers - body $runJson
9199
92100$start = @"
93101 {
@@ -96,8 +104,8 @@ $start = @"
96104"@
97105
98106 $uri = [String ]::Format(" {0}/_apis/clt/testruns/{1}?{2}" , $global :ElsAccountUrl , $run.id , $apiVersion )
99- Invoke-RestMethod - ContentType " application/json" - UserAgent $userAgent - Uri $ uri - Method Patch - Headers $headers - Body $start
100- $run = Invoke-RestMethod - ContentType " application/json" - UserAgent $userAgent - Uri $ uri - Headers $headers
107+ InvokeRestMethod - contentType " application/json" - uri $ uri - method Patch - headers $headers - body $start
108+ $run = InvokeRestMethod - contentType " application/json" - uri $ uri - headers $headers
101109
102110 return $run
103111}
@@ -110,8 +118,8 @@ $stop = @"
110118 }
111119"@
112120 $uri = [String ]::Format(" {0}/_apis/clt/testruns/{1}?{2}" , $global :ElsAccountUrl , $run.id , $apiVersion )
113- Invoke-RestMethod - ContentType " application/json" - UserAgent $userAgent - Uri $ uri - Method Patch - Headers $headers - Body $stop
114- $run = Invoke-RestMethod - ContentType " application/json" - UserAgent $userAgent - Uri $ uri - Headers $headers
121+ InvokeRestMethod - contentType " application/json" - uri $ uri - method Patch - headers $headers - body $stop
122+ $run = InvokeRestMethod - contentType " application/json" - uri $ uri - headers $headers
115123 return $run
116124
117125}
@@ -157,7 +165,7 @@ function CheckTestErrors($headers, $run)
157165 if ($global :MonitorThresholds )
158166 {
159167 $uri = [String ]::Format(" {0}/_apis/clt/testruns/{1}/errors?type=ThresholdMessage&detailed=True&{2}" , $global :ElsAccountUrl , $run.id , $apiVersion )
160- $errors = Invoke-RestMethod - ContentType " application/json" - UserAgent $userAgent - Uri $ uri - Headers $headers
168+ $errors = InvokeRestMethod - contentType " application/json" - uri $ uri - headers $headers
161169
162170 if ($errors -and $errors.count -gt 0 -and $errors.types.count -gt 0 )
163171 {
@@ -177,7 +185,7 @@ function CheckTestErrors($headers, $run)
177185function ShowMessages ($headers , $run )
178186{
179187 $uri = [String ]::Format(" {0}/_apis/clt/testruns/{1}/messages?{2}" , $global :ElsAccountUrl , $run.id , $apiVersion )
180- $messages = Invoke-RestMethod - ContentType " application/json" - UserAgent $userAgent - Uri $ uri - Headers $headers
188+ $messages = InvokeRestMethod - contentType " application/json" - uri $ uri - headers $headers
181189 if ($messages )
182190 {
183191 $sMessages = $messages.value | Sort-Object loggedDate
@@ -196,7 +204,7 @@ function ShowMessages($headers, $run)
196204}
197205
198206function UploadTestDrop ($testdrop , $src )
199- {
207+ {
200208 $dest = $testdrop.accessData.dropContainerUrl
201209 $sas = $testdrop.accessData.sasKey
202210
@@ -397,6 +405,7 @@ if ($drop.dropType -eq "TestServiceBlobDrop")
397405
398406 # Queue the test run
399407 $runJson = ComposeTestRunJson $LoadTest $drop.id
408+
400409 $run = QueueTestRun $headers $runJson
401410 MonitorAcquireResource $headers $run
402411
468477 Write-Error (" Connection '{0}' failed for service '{1}'" -f $connectedServiceName , $connectedServiceDetails.Url.AbsoluteUri )
469478}
470479
471- WriteTaskMessages " Finished Load Test Script"
480+ WriteTaskMessages " Load Test Script execution completed "
472481
0 commit comments