Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated testsettings and loadtest files folder not to use the source #4041

Merged
merged 3 commits into from
Apr 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Tasks/QuickPerfTest/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "QuickPerfTest",
"friendlyName": "Cloud-based Web Performance Test",
"description": "Runs a quick web performance test in the cloud with Visual Studio Team Services",
"helpMarkDown": "Triggers a cloud-based load test using Visual Studio Team Services. [Learn more](https://go.microsoft.com/fwlink/?linkid=613203).",
"helpMarkDown": "Triggers a cloud-based load test using Visual Studio Team Services. [Learn more](https://go.microsoft.com/fwlink/?linkid=613203)",
"category": "Test",
"visibility": [
"Build",
Expand All @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 21
"Patch": 22
},
"demands": [
"msbuild",
Expand Down Expand Up @@ -78,7 +78,7 @@
"type": "pickList",
"label": "Load Location",
"required": false,
"helpMarkDown": "Geographical region to generate the load from. See help for more details.",
"helpMarkDown": "Geographical region to generate the load from.",
"defaultValue": "Default",
"options": {
"Default": "Default",
Expand Down
4 changes: 2 additions & 2 deletions Tasks/RunJMeterLoadTest/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "ApacheJMeterLoadTest",
"friendlyName": "Cloud-based Apache JMeter Load Test",
"description": "Runs the Apache JMeter load test in cloud",
"helpMarkDown": "This task can be used to trigger an Apache JMeter load test in cloud using Visual Studio Team Services. [Learn more](https://go.microsoft.com/fwlink/?LinkId=784929).",
"helpMarkDown": "This task can be used to trigger an Apache JMeter load test in cloud using Visual Studio Team Services. [Learn more](https://go.microsoft.com/fwlink/?LinkId=784929)",
"category": "Test",
"visibility": [
"Build",
Expand All @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 12
"Patch": 13
},
"demands": [
"azureps"
Expand Down
110 changes: 79 additions & 31 deletions Tasks/RunLoadTest/CltTasksUtility.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function ComposeAccountUrl($connectedServiceUrl, $headers)
#Load all dependent files for execution
. $PSScriptRoot/VssConnectionHelper.ps1
$connectedServiceUrl = $connectedServiceUrl.TrimEnd('/')
Write-Host "Getting Clt Endpoint:"
Write-Host -NoNewline "Getting Clt Endpoint:"
$elsUrl = Get-CltEndpoint $connectedServiceUrl $headers

return $elsUrl
Expand All @@ -149,34 +149,74 @@ function isNumericValue ($str) {
return $isNum
}

function ValidateFiles($inputName, $fileName)
function ValidateFiles($inputName, $loadtestDrop, $fileName, $testSettings)
{
$file = Get-ChildItem -Path $TestDrop -recurse | where {$_.Name -eq $fileName} | Select -First 1
if ($file)
# Upgrade scenario start..
if (-Not([System.IO.Path]::IsPathRooted($loadtestDrop)))
{
# Check for fileName
$global:ScopedTestDrop = $file.Directory.FullName
Write-Host -NoNewline ("Selected {0} is '{1}' under '{2}'" -f $inputName, $file.FullName, $global:ScopedTestDrop)
$loadtestDrop=[System.IO.Path]::Combine($env:SYSTEM_DEFAULTWORKINGDIRECTORY,$loadtestDrop);
Write-Host -NoNewline "Updated test drop location is $loadtestDrop";

if (-Not([string]::IsNullOrWhiteSpace($testSettings)) -and
-Not([System.IO.Path]::IsPathRooted($testSettings)))
{
$testSettings=[System.IO.Path]::Combine($env:SYSTEM_DEFAULTWORKINGDIRECTORY,$testSettings);
Write-Host -NoNewline "Updated test settings file is $testSettings";
}
Copy link
Member

@dpksinghal dpksinghal Apr 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment#1 -
this doesnt seem to be related/dependent on the outer if block. it can come out and stay along with the test settings section. #WontFix

}
else
# Upgrade scenario end..

# Validate if the drop folder location is correct...
if (-Not (Test-Path $loadtestDrop))
{
ErrorMessage "No $inputName is present in the test drop."
ErrorMessage "The path for the load test files $loadtestDrop does not exist. Please provide a valid path."
}
}

function ValidateInputs($tfsCollectionUrl, $connectedServiceName, $testSettings, $testDrop, $loadtest)
{
if (-Not (Test-Path $testSettings))
$loadRunTestSettingsFile = $testSettings;
$file = Get-ChildItem -Path $loadtestDrop -recurse | Where-Object {$_.Name -eq $fileName} | Select-Object -First 1
if ($file)
{
ErrorMessage "The path for the test settings file does not exist. Please provide a valid path."
}
# Check for fileName
$global:ScopedTestDrop = $file.Directory.FullName;
$global:RunTestSettingsFile = "";
Write-Host -NoNewline ("Selected load test file is '{0}' under '{1}'" -f $file.FullName, $global:ScopedTestDrop)
Write-Host -NoNewline "Test Drop location used for the run is $global:ScopedTestDrop. Please ensure all required files (test dlls, plugin dlls, dependent files) are part of this output folder"
if ([string]::IsNullOrWhiteSpace($loadRunTestSettingsFile))
Copy link
Member

@dpksinghal dpksinghal Apr 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ([string]::IsNullOrWhiteSpace($loadRunTestSettingsFile)) [](start = 2, length = 59)

minor: you dont need to string check just doing if() would suffice. #WontFix

{
Write-Host -NoNewline "No test settings file specified";
return;
}

if (-Not (Test-Path $loadRunTestSettingsFile))
{
Write-Host -NoNewline "The path for the test settings file $loadRunTestSettingsFile does not exist"
if (-Not([System.IO.Path]::IsPathRooted($loadRunTestSettingsFile)))
Copy link
Member

@dpksinghal dpksinghal Apr 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (-Not([System.IO.Path]::IsPathRooted($loadRunTestSettingsFile))) [](start = 3, length = 67)

if comment #1 is resolved, you will not need this. #WontFix

{
$loadRunTestSettingsFile = [System.IO.Path]::Combine($global:ScopedTestDrop, [System.IO.Path]::GetFileName($loadRunTestSettingsFile));
Write-Host -NoNewline "Checking for test settings file $loadRunTestSettingsFile in the drop location"
}

if (Test-Path $loadRunTestSettingsFile)
{
Write-Host -NoNewline "Test settings file $loadRunTestSettingsFile found in the drop location"
}
else
{
ErrorMessage "TestSettings file $loadRunTestSettingsFile not found"
}
}

if (-Not (Test-Path $testDrop))
$global:RunTestSettingsFile = $loadRunTestSettingsFile;
}
else
{
ErrorMessage "The path for the load test files does not exist. Please provide a valid path."
ErrorMessage "LoadTest file $inputName is not present in the test drop."
}
}

ValidateFiles "load test file" $loadTest
function ValidateInputs($tfsCollectionUrl, $connectedServiceName, $testSettings, $loadtestDrop, $loadtest)
{
ValidateFiles "load test file" $loadtestDrop $loadTest $testSettings
}

function Get($headers, $uri)
Expand Down Expand Up @@ -226,7 +266,7 @@ function StopTestRun($headers, $run, $CltAccountUrl)
{
$stop = @"
{
"state": "aborted"
"state": "aborted"
}
"@
$uri = [String]::Format("{0}/_apis/clt/testruns/{1}?{2}", $CltAccountUrl, $run.id, $global:apiVersion)
Expand All @@ -238,22 +278,30 @@ function StopTestRun($headers, $run, $CltAccountUrl)

function ComposeTestRunJson($name, $tdid, $machineType)
{
$processPlatform = "x86"
$processPlatform = "x64"
$setupScript=""
$cleanupScript=""

[xml]$tsxml = Get-Content $TestSettings
if ($tsxml.TestSettings.Scripts.setupScript)
{
$setupScript = [System.IO.Path]::GetFileName($tsxml.TestSettings.Scripts.setupScript)
}
if ($tsxml.TestSettings.Scripts.cleanupScript)
if (-Not([string]::IsNullOrWhiteSpace($global:RunTestSettingsFile)))
{
$cleanupScript = [System.IO.Path]::GetFileName($tsxml.TestSettings.Scripts.cleanupScript)
}
if ($tsxml.TestSettings.Execution.hostProcessPlatform)
{
$processPlatform = $tsxml.TestSettings.Execution.hostProcessPlatform
[xml]$tsxml = Get-Content $global:RunTestSettingsFile
if ($tsxml.TestSettings.Scripts.setupScript)
{
$setupScript = [System.IO.Path]::GetFileName($tsxml.TestSettings.Scripts.setupScript)
Write-Host -NoNewline "RunSettings SetupScript : $setupScript"
}

if ($tsxml.TestSettings.Scripts.cleanupScript)
{
$cleanupScript = [System.IO.Path]::GetFileName($tsxml.TestSettings.Scripts.cleanupScript)
Write-Host -NoNewline "RunSettings CleanupScript : $cleanupScript"
}

if ($tsxml.TestSettings.Execution.hostProcessPlatform)
{
$processPlatform = $tsxml.TestSettings.Execution.hostProcessPlatform
Write-Host -NoNewline "RunSettings ProcessPlatform : $cleanupScript"
}
}

$trjson = @"
Expand Down
13 changes: 7 additions & 6 deletions Tasks/RunLoadTest/Start-CloudLoadTest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $env:BUILD_BUILDID,
[String] [Parameter(Mandatory = $false)]
$connectedServiceName,

[String] [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()]
[String] [Parameter(Mandatory = $false)]
$TestSettings,
[String] [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()]
$TestDrop,
Expand All @@ -24,6 +24,7 @@ $MachineType
$global:userAgent = "CloudLoadTestBuildTask"
$global:apiVersion = "api-version=1.0"
$global:ScopedTestDrop = $TestDrop
$global:RunTestSettingsFile = $TestSettings
$ThresholdExceeded = $false
$MonitorThresholds = $false

Expand Down Expand Up @@ -74,14 +75,14 @@ import-module "Microsoft.TeamFoundation.DistributedTask.Task.Common"
import-module "Microsoft.TeamFoundation.DistributedTask.Task.DTA"
import-module "Microsoft.TeamFoundation.DistributedTask.Task.DevTestLabs"

Write-Output "Test settings = $testSettings"
Write-Output "Test drop = $testDrop"
Write-Output "Load test = $loadTest"
Write-Output "Load generator machine type = $machineType"
Write-Output "Test settings = $TestSettings"
Write-Output "Test drop = $TestDrop"
Write-Output "Load test = $LoadTest"
Write-Output "Load generator machine type = $MachineType"
Write-Output "Run source identifier = build/$env:SYSTEM_DEFINITIONID/$env:BUILD_BUILDID"

#Validate Input
ValidateInputs $env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI $connectedServiceName $testSettings $testDrop $loadTest
ValidateInputs $env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI $connectedServiceName $TestSettings $TestDrop $LoadTest

#Setting monitoring of Threshold rule appropriately
if ($ThresholdLimit -and $ThresholdLimit -ge 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"loc.friendlyName": "Cloud-based Load Test",
"loc.helpMarkDown": "This task triggers a cloud-based load test using Visual Studio Team Services. [Learn more](https://go.microsoft.com/fwlink/?linkid=546976).",
"loc.helpMarkDown": "This task triggers a cloud-based load test using Visual Studio Team Services. [Learn more](https://go.microsoft.com/fwlink/?linkid=546976)",
"loc.description": "Runs the load test in the cloud with Visual Studio Team Services",
"loc.instanceNameFormat": "Cloud Load Test $(LoadTest)",
"loc.input.label.connectedServiceName": "VS Team Services Connection",
"loc.input.help.connectedServiceName": "Select a previously registered service connection to talk to the cloud-based load test service. Choose 'Manage' to register a new connection.",
"loc.input.label.TestSettings": "Test settings file",
"loc.input.help.TestSettings": "Relative path from repo root for the test settings file to use for the load test.",
"loc.input.label.TestDrop": "Load test files folder",
"loc.input.help.TestDrop": "Relative path from repo root where the load test solution build output will be available.",
"loc.input.help.TestDrop": "Output path where the load test and supporting files including plugins and data files are available. <ul><li><b>Build Example:</b><br /> $(System.DefaultWorkingDirectory)\\LoadTestproject\\bin\\$(BuildConfiguration) </li><li><b>Release Example:</b><br /> $(System.DefaultWorkingDirectory)\\SourceCI\\drop\\LoadTestproject\\bin\\Release <br />where SourceCI is the source alias and drop is artifact name</li></ul>",
"loc.input.label.LoadTest": "Load test file",
"loc.input.help.LoadTest": "The load test filename to be used under the load test folder specified above.",
"loc.input.help.LoadTest": "The load test filename to be used from the load test files folder specified.",
"loc.input.label.TestSettings": "Test settings file",
"loc.input.help.TestSettings": "The testsettings file name to be used from the load test folder specifed above or a full path. <ul><li><b>Build Example:</b><br /> $(System.DefaultWorkingDirectory)\\LoadTestproject\\bin\\$(BuildConfiguration)\\load.testsettings </li><li><b>Release Example:</b><br /> $(System.DefaultWorkingDirectory)\\SourceCI\\drop\\LoadTestproject\\bin\\Release\\load.testsettings <br />where SourceCI is the source alias and drop is artifact name</li></ul>",
"loc.input.label.ThresholdLimit": "Number of permissible threshold violations",
"loc.input.help.ThresholdLimit": "Number of threshold violations above which the load test outcome is considered unsuccessful.",
"loc.input.label.MachineType": "Run load test using"
Expand Down
7 changes: 4 additions & 3 deletions Tasks/RunLoadTest/VssConnectionHelper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function Get-CltEndpoint($connectedServiceUrl, $headers)
# Load all dependent files for execution
. $PSScriptRoot/CltTasksUtility.ps1
$vsoUrl = $connectedServiceUrl
Write-Host "Fetching the Clt endpoint for $vsoUrl"
Write-Host -NoNewline "Fetching the Clt endpoint for $vsoUrl"
$spsLocation = Get-SpsLocation $vsoUrl $headers
$cltLocation = Get-CltLocation $spsLocation $headers
return $cltLocation
Expand All @@ -12,15 +12,15 @@ function Get-CltEndpoint($connectedServiceUrl, $headers)

function Get-SpsLocation($vsoUrl, $headers)
{
Write-Host "Fetching the SPS endpoint for $vsoUrl"
Write-Host -NoNewline "Fetching the SPS endpoint for $vsoUrl"
$spsUniqueIdentifier = "951917AC-A960-4999-8464-E3F0AA25B381"
$spsLocation = Get-ServiceLocation $vsoUrl $headers $spsUniqueIdentifier
return $spsLocation
}

function Get-CltLocation($spsUrl, $headers)
{
Write-Host "Fetching the CLT endpoint for $vsoUrl"
Write-Host -NoNewline "Fetching the CLT endpoint for $vsoUrl"
$cltUniqueIdentifier = "6C404D78-EF65-4E65-8B6A-DF19D6361EAE"
return Get-ServiceLocation $spsUrl $headers $cltUniqueIdentifier
}
Expand All @@ -35,5 +35,6 @@ function Get-ServiceLocation($baseUrl, $headers, $serviceUniqueIdentifier)
{
return $locationCallJsonResponse.locationMappings.location|Select -First 1
}

return $null
}
28 changes: 14 additions & 14 deletions Tasks/RunLoadTest/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "CloudLoadTest",
"friendlyName": "Cloud-based Load Test",
"description": "Runs the load test in the cloud with Visual Studio Team Services",
"helpMarkDown": "This task triggers a cloud-based load test using Visual Studio Team Services. [Learn more](https://go.microsoft.com/fwlink/?linkid=546976).",
"helpMarkDown": "This task triggers a cloud-based load test using Visual Studio Team Services. [Learn more](https://go.microsoft.com/fwlink/?linkid=546976)",
"category": "Test",
"visibility": [
"Build",
Expand All @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 18
"Patch": 19
},
"demands": [
"msbuild",
Expand All @@ -28,29 +28,29 @@
"defaultValue": "",
"helpMarkDown": "Select a previously registered service connection to talk to the cloud-based load test service. Choose 'Manage' to register a new connection."
},
{
"name": "TestSettings",
"type": "filePath",
"label": "Test settings file",
"defaultValue": "",
"required": true,
"helpMarkDown": "Relative path from repo root for the test settings file to use for the load test."
},
{
"name": "TestDrop",
"type": "filePath",
"type": "string",
"label": "Load test files folder",
"defaultValue": "",
"defaultValue": "$(System.DefaultWorkingDirectory)",
"required": true,
"helpMarkDown": "Relative path from repo root where the load test solution build output will be available."
"helpMarkDown": "Output path where the load test and supporting files including plugins and data files are available. <ul><li><b>Build Example:</b><br /> $(System.DefaultWorkingDirectory)\\LoadTestproject\\bin\\$(BuildConfiguration) </li><li><b>Release Example:</b><br /> $(System.DefaultWorkingDirectory)\\SourceCI\\drop\\LoadTestproject\\bin\\Release <br />where SourceCI is the source alias and drop is artifact name</li></ul>"
},
{
"name": "LoadTest",
"type": "string",
"label": "Load test file",
"defaultValue": "",
"required": true,
"helpMarkDown": "The load test filename to be used under the load test folder specified above."
"helpMarkDown": "The load test filename to be used from the load test files folder specified."
},
{
"name": "TestSettings",
"type": "string",
"label": "Test settings file",
"defaultValue": "",
"required": false,
"helpMarkDown": "The testsettings file name to be used from the load test folder specifed above or a full path. <ul><li><b>Build Example:</b><br /> $(System.DefaultWorkingDirectory)\\LoadTestproject\\bin\\$(BuildConfiguration)\\load.testsettings </li><li><b>Release Example:</b><br /> $(System.DefaultWorkingDirectory)\\SourceCI\\drop\\LoadTestproject\\bin\\Release\\load.testsettings <br />where SourceCI is the source alias and drop is artifact name</li></ul>"
},
{
"name": "ThresholdLimit",
Expand Down
22 changes: 11 additions & 11 deletions Tasks/RunLoadTest/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 18
"Patch": 19
},
"demands": [
"msbuild",
Expand All @@ -28,19 +28,11 @@
"defaultValue": "",
"helpMarkDown": "ms-resource:loc.input.help.connectedServiceName"
},
{
"name": "TestSettings",
"type": "filePath",
"label": "ms-resource:loc.input.label.TestSettings",
"defaultValue": "",
"required": true,
"helpMarkDown": "ms-resource:loc.input.help.TestSettings"
},
{
"name": "TestDrop",
"type": "filePath",
"type": "string",
"label": "ms-resource:loc.input.label.TestDrop",
"defaultValue": "",
"defaultValue": "$(System.DefaultWorkingDirectory)",
"required": true,
"helpMarkDown": "ms-resource:loc.input.help.TestDrop"
},
Expand All @@ -52,6 +44,14 @@
"required": true,
"helpMarkDown": "ms-resource:loc.input.help.LoadTest"
},
{
"name": "TestSettings",
"type": "string",
"label": "ms-resource:loc.input.label.TestSettings",
"defaultValue": "",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.TestSettings"
},
{
"name": "ThresholdLimit",
"type": "string",
Expand Down