Skip to content

Commit cc1de66

Browse files
authored
Merge pull request #2776 from vinitsuri/releases/m106
Rest Point leak fix
2 parents 8dc71b3 + 2700f36 commit cc1de66

File tree

6 files changed

+57
-32
lines changed

6 files changed

+57
-32
lines changed

Tasks/QuickPerfTest/Invoke-QuickPerfTest.ps1

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ function InitializeRestHeaders()
3838
return $restHeaders
3939
}
4040

41+
function InvokeRestMethod($headers, $contentType, $uri , $method= "Get", $body)
42+
{
43+
$ServicePoint = [System.Net.ServicePointManager]::FindServicePoint($uri)
44+
$result = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -TimeoutSec $global:RestTimeout -Uri $uri -Method $method -Headers $headers -Body $body
45+
$ServicePoint.CloseConnectionGroup("")
46+
return $result
47+
}
48+
4149
function ComposeTestDropJson($name, $duration, $homepage, $vu)
4250
{
4351
$tdjson = @"
@@ -66,15 +74,15 @@ $tdjson = @"
6674
function CreateTestDrop($headers, $dropJson)
6775
{
6876
$uri = [String]::Format("{0}/_apis/clt/testdrops?api-version=1.0", $CltAccountUrl)
69-
$drop = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Method Post -Headers $headers -Body $dropJson
77+
$drop = InvokeRestMethod -contentType "application/json" -uri $uri -method Post -headers $headers -body $dropJson
7078

7179
return $drop
7280
}
7381

7482
function GetTestDrop($headers, $drop)
7583
{
7684
$uri = [String]::Format("{0}/_apis/clt/testdrops/{1}?api-version=1.0", $CltAccountUrl, $drop.id)
77-
$testdrop = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -TimeoutSec $global:RestTimeout -Uri $uri -Headers $headers
85+
$testdrop = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers
7886

7987
return $testdrop
8088
}
@@ -91,15 +99,15 @@ function UploadTestDrop($testdrop)
9199
function GetTestRuns($headers)
92100
{
93101
$uri = [String]::Format("{0}/_apis/clt/testruns?api-version=1.0", $CltAccountUrl)
94-
$runs = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -TimeoutSec $global:RestTimeout -Uri $uri -Headers $headers
102+
$runs = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers
95103

96104
return $runs
97105
}
98106

99107
function GetTestRunUri($testRunId, $headers)
100108
{
101109
$uri = [String]::Format("{0}/_apis/clt/testruns/{1}?api-version=1.0", $CltAccountUrl,$testRunId)
102-
$run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -TimeoutSec $global:RestTimeout -Uri $uri -Headers $headers
110+
$run = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers
103111

104112
return $run.WebResultUrl
105113
}
@@ -119,7 +127,7 @@ function MonitorTestRun($headers, $run)
119127
do
120128
{
121129
Start-Sleep -s 5
122-
$run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers
130+
$run = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers
123131
if ($prevState -ne $run.state -or $prevSubState -ne $run.subState)
124132
{
125133
$prevState = $run.state
@@ -129,10 +137,10 @@ function MonitorTestRun($headers, $run)
129137
}
130138
while (RunInProgress $run)
131139

132-
$run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers
140+
$run = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers
133141
Write-Output "------------------------------------"
134142
$uri = [String]::Format("{0}/_apis/clt/testruns/{1}/messages?api-version=1.0", $CltAccountUrl, $run.id)
135-
$messages = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers
143+
$messages = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers
136144

137145
if ($messages)
138146
{
@@ -172,7 +180,7 @@ $trjson = @"
172180
function QueueTestRun($headers, $runJson)
173181
{
174182
$uri = [String]::Format("{0}/_apis/clt/testruns?api-version=1.0", $CltAccountUrl)
175-
$run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Method Post -Headers $headers -Body $runJson
183+
$run = InvokeRestMethod -contentType "application/json" -uri $uri -method Post -headers $headers -body $runJson
176184

177185
$start = @"
178186
{
@@ -181,8 +189,8 @@ $start = @"
181189
"@
182190

183191
$uri = [String]::Format("{0}/_apis/clt/testruns/{1}?api-version=1.0", $CltAccountUrl, $run.id)
184-
Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Method Patch -Headers $headers -Body $start
185-
$run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers
192+
InvokeRestMethod -contentType "application/json" -uri $uri -method Patch -headers $headers -body $start
193+
$run = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers
186194

187195
return $run
188196
}
@@ -286,5 +294,5 @@ else
286294
}
287295

288296

289-
Write-Output "Finished Quick Perf Test Script"
297+
Write-Output "Quick Perf Test Script execution completed"
290298

Tasks/QuickPerfTest/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"version": {
1414
"Major": 1,
1515
"Minor": 0,
16-
"Patch": 9
16+
"Patch": 11
1717
},
1818
"demands": [
1919
"msbuild",

Tasks/RunJMeterLoadTest/Start-ApacheJMeterTest.ps1

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,26 @@ function InitializeRestHeaders()
4141
return $restHeaders
4242
}
4343

44+
function InvokeRestMethod($headers, $contentType, $uri , $method= "Get", $body)
45+
{
46+
$ServicePoint = [System.Net.ServicePointManager]::FindServicePoint($uri)
47+
$result = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -TimeoutSec $global:RestTimeout -Uri $uri -Method $method -Headers $headers -Body $body
48+
$ServicePoint.CloseConnectionGroup("")
49+
return $result
50+
}
51+
4452
function CreateTestDrop($headers)
4553
{
4654
$uri = [String]::Format("{0}/_apis/clt/testdrops?{1}", $global:ElsAccountUrl, $apiVersion)
47-
$drop = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers -Method Post -Body "{ ""dropType"": ""TestServiceBlobDrop"" }"
55+
$drop = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers -method Post -body "{ ""dropType"": ""TestServiceBlobDrop"" }"
4856
return $drop
4957
}
5058

5159
function Get($headers, $uri)
5260
{
5361
try
5462
{
55-
$result = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -TimeoutSec $global:RestTimeout -Uri $uri -Headers $headers
63+
$result = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers
5664
return $result
5765
}
5866
catch
@@ -85,7 +93,7 @@ function GetTestErrors($headers, $run)
8593
function QueueTestRun($headers, $runJson)
8694
{
8795
$uri = [String]::Format("{0}/_apis/clt/testruns?{1}", $global:ElsAccountUrl, $apiVersion)
88-
$run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Method Post -Headers $headers -Body $runJson
96+
$run = InvokeRestMethod -contentType "application/json" -uri $uri -method Post -headers $headers -body $runJson
8997

9098
$start = @"
9199
{
@@ -94,8 +102,8 @@ $start = @"
94102
"@
95103

96104
$uri = [String]::Format("{0}/_apis/clt/testruns/{1}?{2}", $global:ElsAccountUrl, $run.id, $apiVersion)
97-
Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Method Patch -Headers $headers -Body $start
98-
$run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers
105+
InvokeRestMethod -contentType "application/json" -uri $uri -method Patch -headers $headers -body $start
106+
$run = InvokeRestMethod -contentType "application/json" -userAgent $userAgent -uri $uri -headers $headers
99107

100108
return $run
101109
}
@@ -127,7 +135,7 @@ function PrintErrorSummary($headers, $run)
127135
function ShowMessages($headers, $run)
128136
{
129137
$uri = [String]::Format("{0}/_apis/clt/testruns/{1}/messages?{2}", $global:ElsAccountUrl, $run.id, $apiVersion)
130-
$messages = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers
138+
$messages = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers
131139
if ($messages)
132140
{
133141
$sMessages = $messages.value | Sort-Object loggedDate
@@ -360,5 +368,5 @@ else
360368
("Connection '{0}' failed for service '{1}'" -f $connectedServiceName, $connectedServiceDetails.Url.AbsoluteUri) >> $summaryFile
361369
}
362370

363-
WriteTaskMessages "Finished JMeter Test Script"
371+
WriteTaskMessages "JMeter Test Script execution completed"
364372

Tasks/RunJMeterLoadTest/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"version": {
1414
"Major": 1,
1515
"Minor": 0,
16-
"Patch": 5
16+
"Patch": 7
1717
},
1818
"demands": [
1919
"azureps"

Tasks/RunLoadTest/Start-CloudLoadTest.ps1

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
4654
function 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

5361
function 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)
8795
function 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)
177185
function 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

198206
function 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

@@ -468,5 +477,5 @@ else
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

Tasks/RunLoadTest/task.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"version": {
1414
"Major": 1,
1515
"Minor": 0,
16-
"Patch": 10
16+
"Patch": 12
1717
},
1818
"demands": [
1919
"msbuild",

0 commit comments

Comments
 (0)