diff --git a/Tasks/QuickPerfTest/Invoke-QuickPerfTest.ps1 b/Tasks/QuickPerfTest/Invoke-QuickPerfTest.ps1 index 7d19fae7d684..36e29d593d02 100644 --- a/Tasks/QuickPerfTest/Invoke-QuickPerfTest.ps1 +++ b/Tasks/QuickPerfTest/Invoke-QuickPerfTest.ps1 @@ -38,6 +38,14 @@ function InitializeRestHeaders() return $restHeaders } +function InvokeRestMethod($headers, $contentType, $uri , $method= "Get", $body) +{ + $ServicePoint = [System.Net.ServicePointManager]::FindServicePoint($uri) + $result = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -TimeoutSec $global:RestTimeout -Uri $uri -Method $method -Headers $headers -Body $body + $ServicePoint.CloseConnectionGroup("") + return $result +} + function ComposeTestDropJson($name, $duration, $homepage, $vu) { $tdjson = @" @@ -66,7 +74,7 @@ $tdjson = @" function CreateTestDrop($headers, $dropJson) { $uri = [String]::Format("{0}/_apis/clt/testdrops?api-version=1.0", $CltAccountUrl) - $drop = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Method Post -Headers $headers -Body $dropJson + $drop = InvokeRestMethod -contentType "application/json" -uri $uri -method Post -headers $headers -body $dropJson return $drop } @@ -74,7 +82,7 @@ function CreateTestDrop($headers, $dropJson) function GetTestDrop($headers, $drop) { $uri = [String]::Format("{0}/_apis/clt/testdrops/{1}?api-version=1.0", $CltAccountUrl, $drop.id) - $testdrop = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -TimeoutSec $global:RestTimeout -Uri $uri -Headers $headers + $testdrop = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers return $testdrop } @@ -91,7 +99,7 @@ function UploadTestDrop($testdrop) function GetTestRuns($headers) { $uri = [String]::Format("{0}/_apis/clt/testruns?api-version=1.0", $CltAccountUrl) - $runs = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -TimeoutSec $global:RestTimeout -Uri $uri -Headers $headers + $runs = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers return $runs } @@ -99,7 +107,7 @@ function GetTestRuns($headers) function GetTestRunUri($testRunId, $headers) { $uri = [String]::Format("{0}/_apis/clt/testruns/{1}?api-version=1.0", $CltAccountUrl,$testRunId) - $run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -TimeoutSec $global:RestTimeout -Uri $uri -Headers $headers + $run = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers return $run.WebResultUrl } @@ -119,7 +127,7 @@ function MonitorTestRun($headers, $run) do { Start-Sleep -s 5 - $run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers + $run = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers if ($prevState -ne $run.state -or $prevSubState -ne $run.subState) { $prevState = $run.state @@ -129,10 +137,10 @@ function MonitorTestRun($headers, $run) } while (RunInProgress $run) - $run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers + $run = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers Write-Output "------------------------------------" $uri = [String]::Format("{0}/_apis/clt/testruns/{1}/messages?api-version=1.0", $CltAccountUrl, $run.id) - $messages = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers + $messages = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers if ($messages) { @@ -172,7 +180,7 @@ $trjson = @" function QueueTestRun($headers, $runJson) { $uri = [String]::Format("{0}/_apis/clt/testruns?api-version=1.0", $CltAccountUrl) - $run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Method Post -Headers $headers -Body $runJson + $run = InvokeRestMethod -contentType "application/json" -uri $uri -method Post -headers $headers -body $runJson $start = @" { @@ -181,8 +189,8 @@ $start = @" "@ $uri = [String]::Format("{0}/_apis/clt/testruns/{1}?api-version=1.0", $CltAccountUrl, $run.id) - Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Method Patch -Headers $headers -Body $start - $run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers + InvokeRestMethod -contentType "application/json" -uri $uri -method Patch -headers $headers -body $start + $run = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers return $run } @@ -286,5 +294,5 @@ else } -Write-Output "Finished Quick Perf Test Script" +Write-Output "Quick Perf Test Script execution completed" diff --git a/Tasks/QuickPerfTest/task.json b/Tasks/QuickPerfTest/task.json index fb16e0a7f663..dd9009d306ea 100644 --- a/Tasks/QuickPerfTest/task.json +++ b/Tasks/QuickPerfTest/task.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 9 + "Patch": 11 }, "demands": [ "msbuild", diff --git a/Tasks/RunJMeterLoadTest/Start-ApacheJMeterTest.ps1 b/Tasks/RunJMeterLoadTest/Start-ApacheJMeterTest.ps1 index 762fdf3fab63..f5ef8d2494bb 100644 --- a/Tasks/RunJMeterLoadTest/Start-ApacheJMeterTest.ps1 +++ b/Tasks/RunJMeterLoadTest/Start-ApacheJMeterTest.ps1 @@ -41,10 +41,18 @@ function InitializeRestHeaders() return $restHeaders } +function InvokeRestMethod($headers, $contentType, $uri , $method= "Get", $body) +{ + $ServicePoint = [System.Net.ServicePointManager]::FindServicePoint($uri) + $result = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -TimeoutSec $global:RestTimeout -Uri $uri -Method $method -Headers $headers -Body $body + $ServicePoint.CloseConnectionGroup("") + return $result +} + function CreateTestDrop($headers) { $uri = [String]::Format("{0}/_apis/clt/testdrops?{1}", $global:ElsAccountUrl, $apiVersion) - $drop = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers -Method Post -Body "{ ""dropType"": ""TestServiceBlobDrop"" }" + $drop = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers -method Post -body "{ ""dropType"": ""TestServiceBlobDrop"" }" return $drop } @@ -52,7 +60,7 @@ function Get($headers, $uri) { try { - $result = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -TimeoutSec $global:RestTimeout -Uri $uri -Headers $headers + $result = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers return $result } catch @@ -85,7 +93,7 @@ function GetTestErrors($headers, $run) function QueueTestRun($headers, $runJson) { $uri = [String]::Format("{0}/_apis/clt/testruns?{1}", $global:ElsAccountUrl, $apiVersion) - $run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Method Post -Headers $headers -Body $runJson + $run = InvokeRestMethod -contentType "application/json" -uri $uri -method Post -headers $headers -body $runJson $start = @" { @@ -94,8 +102,8 @@ $start = @" "@ $uri = [String]::Format("{0}/_apis/clt/testruns/{1}?{2}", $global:ElsAccountUrl, $run.id, $apiVersion) - Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Method Patch -Headers $headers -Body $start - $run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers + InvokeRestMethod -contentType "application/json" -uri $uri -method Patch -headers $headers -body $start + $run = InvokeRestMethod -contentType "application/json" -userAgent $userAgent -uri $uri -headers $headers return $run } @@ -127,7 +135,7 @@ function PrintErrorSummary($headers, $run) function ShowMessages($headers, $run) { $uri = [String]::Format("{0}/_apis/clt/testruns/{1}/messages?{2}", $global:ElsAccountUrl, $run.id, $apiVersion) - $messages = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers + $messages = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers if ($messages) { $sMessages = $messages.value | Sort-Object loggedDate @@ -360,5 +368,5 @@ else ("Connection '{0}' failed for service '{1}'" -f $connectedServiceName, $connectedServiceDetails.Url.AbsoluteUri) >> $summaryFile } -WriteTaskMessages "Finished JMeter Test Script" +WriteTaskMessages "JMeter Test Script execution completed" diff --git a/Tasks/RunJMeterLoadTest/task.json b/Tasks/RunJMeterLoadTest/task.json index 474ddb833b94..37d24fae9159 100644 --- a/Tasks/RunJMeterLoadTest/task.json +++ b/Tasks/RunJMeterLoadTest/task.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 5 + "Patch": 7 }, "demands": [ "azureps" diff --git a/Tasks/RunLoadTest/Start-CloudLoadTest.ps1 b/Tasks/RunLoadTest/Start-CloudLoadTest.ps1 index 8a796dab1eb5..12b008fe23c1 100644 --- a/Tasks/RunLoadTest/Start-CloudLoadTest.ps1 +++ b/Tasks/RunLoadTest/Start-CloudLoadTest.ps1 @@ -43,10 +43,18 @@ function InitializeRestHeaders() return $restHeaders } +function InvokeRestMethod($headers, $contentType, $uri , $method= "Get", $body) +{ + $ServicePoint = [System.Net.ServicePointManager]::FindServicePoint($uri) + $result = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -TimeoutSec $global:RestTimeout -Uri $uri -Method $method -Headers $headers -Body $body + $ServicePoint.CloseConnectionGroup("") + return $result +} + function CreateTestDrop($headers) { $uri = [String]::Format("{0}/_apis/clt/testdrops?{1}", $global:ElsAccountUrl, $apiVersion) - $drop = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers -Method Post -Body "{ ""dropType"": ""TestServiceBlobDrop"" }" + $drop = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers -method Post -body "{ ""dropType"": ""TestServiceBlobDrop"" }" return $drop } @@ -54,7 +62,7 @@ function Get($headers, $uri) { try { - $result = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -TimeoutSec $global:RestTimeout -Uri $uri -Headers $headers + $result = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers return $result } catch @@ -87,7 +95,7 @@ function GetTestErrors($headers, $run) function QueueTestRun($headers, $runJson) { $uri = [String]::Format("{0}/_apis/clt/testruns?{1}", $global:ElsAccountUrl, $apiVersion) - $run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Method Post -Headers $headers -Body $runJson + $run = InvokeRestMethod -contentType "application/json" -uri $uri -method Post -headers $headers -body $runJson $start = @" { @@ -96,8 +104,8 @@ $start = @" "@ $uri = [String]::Format("{0}/_apis/clt/testruns/{1}?{2}", $global:ElsAccountUrl, $run.id, $apiVersion) - Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Method Patch -Headers $headers -Body $start - $run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers + InvokeRestMethod -contentType "application/json" -uri $uri -method Patch -headers $headers -body $start + $run = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers return $run } @@ -110,8 +118,8 @@ $stop = @" } "@ $uri = [String]::Format("{0}/_apis/clt/testruns/{1}?{2}", $global:ElsAccountUrl, $run.id, $apiVersion) - Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Method Patch -Headers $headers -Body $stop - $run = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers + InvokeRestMethod -contentType "application/json" -uri $uri -method Patch -headers $headers -body $stop + $run = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers return $run } @@ -157,7 +165,7 @@ function CheckTestErrors($headers, $run) if ($global:MonitorThresholds) { $uri = [String]::Format("{0}/_apis/clt/testruns/{1}/errors?type=ThresholdMessage&detailed=True&{2}", $global:ElsAccountUrl, $run.id, $apiVersion) - $errors = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers + $errors = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers if ($errors -and $errors.count -gt 0 -and $errors.types.count -gt 0) { @@ -177,7 +185,7 @@ function CheckTestErrors($headers, $run) function ShowMessages($headers, $run) { $uri = [String]::Format("{0}/_apis/clt/testruns/{1}/messages?{2}", $global:ElsAccountUrl, $run.id, $apiVersion) - $messages = Invoke-RestMethod -ContentType "application/json" -UserAgent $userAgent -Uri $uri -Headers $headers + $messages = InvokeRestMethod -contentType "application/json" -uri $uri -headers $headers if ($messages) { $sMessages = $messages.value | Sort-Object loggedDate @@ -196,7 +204,7 @@ function ShowMessages($headers, $run) } function UploadTestDrop($testdrop, $src) -{ +{ $dest = $testdrop.accessData.dropContainerUrl $sas = $testdrop.accessData.sasKey @@ -397,6 +405,7 @@ if ($drop.dropType -eq "TestServiceBlobDrop") #Queue the test run $runJson = ComposeTestRunJson $LoadTest $drop.id + $run = QueueTestRun $headers $runJson MonitorAcquireResource $headers $run @@ -468,5 +477,5 @@ else Write-Error ("Connection '{0}' failed for service '{1}'" -f $connectedServiceName, $connectedServiceDetails.Url.AbsoluteUri) } -WriteTaskMessages "Finished Load Test Script" +WriteTaskMessages "Load Test Script execution completed" diff --git a/Tasks/RunLoadTest/task.json b/Tasks/RunLoadTest/task.json index 16d5ec385372..f379f22df1fa 100644 --- a/Tasks/RunLoadTest/task.json +++ b/Tasks/RunLoadTest/task.json @@ -13,7 +13,7 @@ "version": { "Major": 1, "Minor": 0, - "Patch": 10 + "Patch": 12 }, "demands": [ "msbuild",