Skip to content

Commit

Permalink
Additional changes to the task parameters description and made the te…
Browse files Browse the repository at this point in the history
…st settings non-mandatory
  • Loading branch information
cltshivash committed Apr 17, 2017
1 parent b0646a2 commit de134d3
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Tasks/QuickPerfTest/task.json
Original file line number Diff line number Diff line change
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
85 changes: 60 additions & 25 deletions Tasks/RunLoadTest/CltTasksUtility.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,53 @@ function isNumericValue ($str) {
return $isNum
}

function ValidateFiles($inputName, $fileName, $testSettings)
function ValidateFiles($inputName, $loadtestDrop, $fileName, $testSettings)
{
$file = Get-ChildItem -Path $TestDrop -recurse | where {$_.Name -eq $fileName} | Select -First 1
# Upgrade scenario start..
if (-Not([System.IO.Path]::IsPathRooted($loadtestDrop)))
{
$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";
}
}
# Upgrade scenario end..

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

$loadRunTestSettingsFile = $testSettings;
$file = Get-ChildItem -Path $loadtestDrop -recurse | Where-Object {$_.Name -eq $fileName} | Select-Object -First 1
if ($file)
{
# Check for fileName
$global:ScopedTestDrop = $file.Directory.FullName
Write-Host -NoNewline ("Selected {0} is '{1}' under '{2}'" -f $inputName, $file.FullName, $global:ScopedTestDrop)
$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))
{
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"
$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 (-Not([System.IO.Path]::IsPathRooted($loadRunTestSettingsFile)))
{
$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"
Expand All @@ -182,14 +214,9 @@ function ValidateFiles($inputName, $fileName, $testSettings)
}
}

function ValidateInputs($tfsCollectionUrl, $connectedServiceName, $testSettings, $testDrop, $loadtest)
function ValidateInputs($tfsCollectionUrl, $connectedServiceName, $testSettings, $loadtestDrop, $loadtest)
{
if (-Not (Test-Path $testDrop))
{
ErrorMessage "The path for the load test files does not exist. Please provide a valid path."
}

ValidateFiles "load test file" $loadTest $testSettings
ValidateFiles "load test file" $loadtestDrop $loadTest $testSettings
}

function Get($headers, $uri)
Expand Down Expand Up @@ -251,22 +278,30 @@ function StopTestRun($headers, $run, $CltAccountUrl)

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

[xml]$tsxml = Get-Content $global:RunTestSettingsFile
if ($tsxml.TestSettings.Scripts.setupScript)
{
$setupScript = [System.IO.Path]::GetFileName($tsxml.TestSettings.Scripts.setupScript)
}
if ($tsxml.TestSettings.Scripts.cleanupScript)
{
$cleanupScript = [System.IO.Path]::GetFileName($tsxml.TestSettings.Scripts.cleanupScript)
}
if ($tsxml.TestSettings.Execution.hostProcessPlatform)
if (-Not([string]::IsNullOrWhiteSpace($global:RunTestSettingsFile)))
{
$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
2 changes: 1 addition & 1 deletion 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 Down
8 changes: 4 additions & 4 deletions Tasks/RunLoadTest/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@
"label": "Load test files folder",
"defaultValue": "$(System.DefaultWorkingDirectory)",
"required": true,
"helpMarkDown": "Path where the load test solution build output will be available. eg. $(System.DefaultWorkingDirectory)\\LoadTestproject\\bin\\$(BuildConfiguration)"
"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": true,
"helpMarkDown": "The testsettings file name to be used under the load test folder specifed above or a full path eg. $(System.DefaultWorkingDirectory)\\LoadTestproject\\bin\\$(BuildConfiguration)\\loadtest.testsettings"
"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

0 comments on commit de134d3

Please sign in to comment.