Skip to content

Commit

Permalink
Merge with latest master
Browse files Browse the repository at this point in the history
  • Loading branch information
abchakra25 committed May 11, 2015
2 parents 50d4102 + 2658af7 commit 16c4227
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 48 deletions.
6 changes: 0 additions & 6 deletions Tasks/DeployAzureResourceGroup/DtlServiceHelper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ function Create-ProviderData

$propertyBag = Get-ServiceEndPointDetails -ConnectedServiceName $ConnectedServiceName

if($propertyBag -eq $null)
{
$propertyBag = New-Object 'System.Collections.Generic.Dictionary[string, Microsoft.VisualStudio.Services.DevTestLabs.Model.PropertyBagData]'
$subscriptionIdPropertyBagData = New-Object 'Microsoft.VisualStudio.Services.DevTestLabs.Model.PropertyBagData' -ArgumentList $false, $subscriptionId
$propertyBag.Add("SubscriptionId", $subscriptionIdPropertyBagData)
}
#TODO Figure out authentication mechanism and store it
$providerData = Register-ProviderData -Name $providerDataName -Type $providerDataType -ProviderName $providerName -PropertyBagValue $propertyBag -Connection $connection -ErrorAction Stop

Expand Down
8 changes: 5 additions & 3 deletions Tasks/DeployVisualStudioTestAgent/DeployTestAgent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ param(
[string]$testMachines,
[string]$runAsProcess,
[string]$machineUserName,
[string]$machinePassword,
[string]$machinePassword,
[string]$agentLocation,
[string]$updateTestAgent
[string]$updateTestAgent,
[string]$isDataCollectionOnly
)

# If Run as process (Run UI Tests) is true both autologon and disable screen saver needs to be true.
Expand All @@ -19,6 +20,7 @@ Write-Verbose "runAsProcess = $runAsProcess"
Write-Verbose "logonAutomatically = $logonAutomatically"
Write-Verbose "disableScreenSaver = $disableScreenSaver"
Write-Verbose "updateTestAgent = $updateTestAgent"
Write-Verbose "isDataCollectionOnly = $isDataCollectionOnly"


if ([string]::IsNullOrWhiteSpace($agentLocation))
Expand Down Expand Up @@ -58,6 +60,6 @@ if ( [string]::IsNullOrEmpty($personalAccessToken))
}

Write-Verbose "Calling Invoke-DeployTestAgent"
Invoke-DeployTestAgent -MachineNames $testMachines -UserName $machineUserName -Password $machinePassword -PowerShellPort 5985 -EnvironmentName $environment -RunAsProcess $runAsProcess -LogonAutomatically $logonAutomatically -DisableScreenSaver $disableScreenSaver -AgentLocation $agentLocation -UpdateTestAgent $updateTestAgent -InstallAgentScriptLocation $installAgentScriptLocation -ConfigureTestAgentScriptLocation $configureTestAgentScriptLocation -CheckAgentInstallationScriptLocation $checkAgentInstallationScriptLocation -Connection $connection -PersonalAccessToken $personalAccessToken
Invoke-DeployTestAgent -MachineNames $testMachines -UserName $machineUserName -Password $machinePassword -PowerShellPort 5985 -EnvironmentName $environment -RunAsProcess $runAsProcess -LogonAutomatically $logonAutomatically -DisableScreenSaver $disableScreenSaver -AgentLocation $agentLocation -UpdateTestAgent $updateTestAgent -InstallAgentScriptLocation $installAgentScriptLocation -ConfigureTestAgentScriptLocation $configureTestAgentScriptLocation -CheckAgentInstallationScriptLocation $checkAgentInstallationScriptLocation -Connection $connection -PersonalAccessToken $personalAccessToken -DataCollectionOnly $isDataCollectionOnly

Write-Verbose "Leaving script DeployTestAgent.ps1"
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// GENERATED FILE - DO NOT EDIT DIRECTLY
// *******************************************************
{
"loc.friendlyName": "Deploy Visual Studio Test Agent",
"loc.friendlyName": "Visual Studio Test Agent Deployment",
"loc.description": "Deploy and configure Test Agent to run tests on a lab machine group.",
"loc.group.displayName.environment": "Test Machine Group",
"loc.group.displayName.agentConfiguration": "Agent Configuration",
Expand All @@ -13,5 +13,6 @@
"loc.input.label.machineUserName": "Username",
"loc.input.label.machinePassword": "Password",
"loc.input.label.agentLocation": "Test Agent Location",
"loc.input.label.updateTestAgent": "Update Test Agent"
"loc.input.label.updateTestAgent": "Update Test Agent",
"loc.input.label.isDataCollectionOnly": "Enable Data Collection Only"
}
45 changes: 35 additions & 10 deletions Tasks/DeployVisualStudioTestAgent/TestAgentConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,12 @@ function Get-TestAgentConfiguration
{
$personalAccessTokenUserName = GetConfigValue($line)
}
elseif ($line.StartsWith("Capabilities"))
{
$capabilities = GetConfigValue($line)
}
}
}

Write-Verbose -Message ("Existing Configuration : TfsCollection : {0}" -f $tfsCollection) -Verbose
Write-Verbose -Message ("Existing Configuration : EnvUrl : {0}" -f $envUrl) -Verbose
Expand All @@ -149,6 +153,7 @@ function Get-TestAgentConfiguration
Write-Verbose -Message ("Existing Configuration : DisableScreenSaver : {0}" -f $disableScreenSaver) -Verbose
Write-Verbose -Message ("Existing Configuration : RunningAsProcess : {0}" -f $runningAsProcess) -Verbose
Write-Verbose -Message ("Existing Configuration : PersonalAccessTokenUser : {0}" -f $personalAccessTokenUserName) -Verbose
Write-Verbose -Message ("Existing Configuration : Capabilities : {0}" -f $capabilities) -Verbose

@{
UserName = $userName
Expand All @@ -159,7 +164,8 @@ function Get-TestAgentConfiguration
EnvironmentUrl = $envUrl
MachineName = $machineName
PersonalAccessTokenUser = $personalAccessTokenUserName
}
Capabilities = $capabilities
}
}

function Set-TestAgentConfiguration
Expand All @@ -176,6 +182,7 @@ function Set-TestAgentConfiguration
[String] $PersonalAccessToken,
[String] $EnvironmentUrl,
[String] $MachineName,
[String] $Capabilities,
[System.Management.Automation.PSCredential] $AgentUserCredential
)

Expand Down Expand Up @@ -233,7 +240,11 @@ function Set-TestAgentConfiguration
{
$configArgs = $configArgs + ("/dtlMachineName:{0}" -f $MachineName)
}

if (-not [string]::IsNullOrWhiteSpace($Capabilities))
{
$configArgs = $configArgs + ("/Capabilities:{0}" -f $Capabilities)
}

$configOut = InvokeTestAgentConfigExe -Arguments $configArgs -Version $TestAgentVersion -UserCredential $MachineUserCredential

# 3010 is exit code to indicate a reboot is required
Expand Down Expand Up @@ -345,6 +356,7 @@ function CanSkipTestAgentConfiguration
[String] $EnvironmentUrl,
[String] $MachineName,
[String] $PersonalAccessToken,
[String] $Capabilities,
[System.Management.Automation.PSCredential] $AgentUserCredential
)

Expand Down Expand Up @@ -432,10 +444,10 @@ function CanSkipTestAgentConfiguration
{
Write-Verbose -Message "No personal access token found in the credential store" -Verbose
return $false
}
}

if($creds.Credentials -eq $null)
{
{
Write-Verbose -Message "No credentials found in stored identity" -Verbose
return $false
}
Expand All @@ -444,8 +456,20 @@ function CanSkipTestAgentConfiguration
{
Write-Verbose -Message "Stored Personal Access Token doesn't match with supplied value" -Verbose
return $false
}
}
}
}

if ($PSBoundParameters.ContainsKey('Capabilities'))
{
#todo: should not do String match but rather break string based on delimiters and compare individual strings
#but as of now We have only one capability so it is fine
if ($Capabilities -ne $existingConfiguration.Capabilities)
{
Write-Verbose -Message ("Capabilities mismatch. Expected : {0}, Current {1}. Reconfiguration required." -f $Capabilities, $existingConfiguration.Capabilities) -Verbose
return $false
}
}

Write-Verbose -Message ("TestAgent reconfiguration not required.") -Verbose
return $true
}
Expand Down Expand Up @@ -592,6 +616,7 @@ function ConfigureTestAgent
[String] $EnvironmentUrl,
[String] $PersonalAccessToken,
[String] $MachineName,
[String] $Capabilities,
[System.Management.Automation.PSCredential] $AgentUserCredential
)

Expand All @@ -600,11 +625,11 @@ function ConfigureTestAgent
$ret = -1
if ($AsServiceOrProcess -eq "Service")
{
$ret = Set-TestAgentConfiguration -TfsCollection $TfsCollection -AsServiceOrProcess $AsServiceOrProcess -MachineUserCredential $MachineUserCredential -TestAgentVersion $TestAgentVersion -EnvironmentUrl $EnvironmentUrl -PersonalAccessToken $PersonalAccessToken -MachineName $MachineName -AgentUserCredential $AgentUserCredential
$ret = Set-TestAgentConfiguration -TfsCollection $TfsCollection -AsServiceOrProcess $AsServiceOrProcess -UserCredential $UserCredential -TestAgentVersion $TestAgentVersion -EnvironmentUrl $EnvironmentUrl -PersonalAccessToken $PersonalAccessToken -MachineName $MachineName -Capabilities $Capabilities -AgentUserCredential $AgentUserCredential
}
else
{
$ret = Set-TestAgentConfiguration -TfsCollection $TfsCollection -AsServiceOrProcess $AsServiceOrProcess -MachineUserCredential $MachineUserCredential -DisableScreenSaver $DisableScreenSaver -EnableAutoLogon $EnableAutoLogon -TestAgentVersion $TestAgentVersion -EnvironmentUrl $EnvironmentUrl -PersonalAccessToken $PersonalAccessToken -MachineName $MachineName -AgentUserCredential $AgentUserCredential
$ret = Set-TestAgentConfiguration -TfsCollection $TfsCollection -AsServiceOrProcess $AsServiceOrProcess -UserCredential $UserCredential -DisableScreenSaver $DisableScreenSaver -EnableAutoLogon $EnableAutoLogon -TestAgentVersion $TestAgentVersion -EnvironmentUrl $EnvironmentUrl -PersonalAccessToken $PersonalAccessToken -MachineName $MachineName -Capabilities $Capabilities -AgentUserCredential $AgentUserCredential
}

if ($ret -eq 0)
Expand Down Expand Up @@ -634,8 +659,8 @@ $enableAutoLogon = [Boolean] $enableAutoLogon
$machineCredential = New-Object System.Management.Automation.PSCredential -ArgumentList $userName, (ConvertTo-SecureString -String $password -AsPlainText -Force)
$agentCredential = New-Object System.Management.Automation.PSCredential -ArgumentList $testAgentConfigUserName, (ConvertTo-SecureString -String $testAgentConfigPassword -AsPlainText -Force)

$ret = CanSkipTestAgentConfiguration -TfsCollection $tfsCollectionUrl -AsServiceOrProcess $asServiceOrProcess -EnvironmentUrl $environmentUrl -MachineName $machineName -UserCredential $machineCredential -DisableScreenSaver $disableScreenSaver -EnableAutoLogon $enableAutoLogon -PersonalAccessToken $PersonalAccessToken -AgentUserCredential $agentCredential
$ret = CanSkipTestAgentConfiguration -TfsCollection $tfsCollectionUrl -AsServiceOrProcess $asServiceOrProcess -EnvironmentUrl $environmentUrl -MachineName $machineName -UserCredential $machineCredential -DisableScreenSaver $disableScreenSaver -EnableAutoLogon $enableAutoLogon -PersonalAccessToken $PersonalAccessToken -Capabilities $capabilities -AgentUserCredential $agentCredential
if ($ret -eq $false)
{
ConfigureTestAgent -TfsCollection $tfsCollectionUrl -AsServiceOrProcess $asServiceOrProcess -EnvironmentUrl $environmentUrl -MachineName $machineName -MachineUserCredential $machineCredential -DisableScreenSaver $disableScreenSaver -EnableAutoLogon $enableAutoLogon -PersonalAccessToken $PersonalAccessToken -AgentUserCredential $agentCredential
ConfigureTestAgent -TfsCollection $tfsCollectionUrl -AsServiceOrProcess $asServiceOrProcess -EnvironmentUrl $environmentUrl -MachineName $machineName -MachineUserCredential $machineCredential -DisableScreenSaver $disableScreenSaver -EnableAutoLogon $enableAutoLogon -PersonalAccessToken $PersonalAccessToken -Capabilities $capabilities -AgentUserCredential $agentCredential
}
13 changes: 11 additions & 2 deletions Tasks/DeployVisualStudioTestAgent/task.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "52A38A6A-1517-41D7-96CC-73EE0C60D2B6",
"name": "DeployVisualStudioTestAgent",
"friendlyName": "Deploy Visual Studio Test Agent",
"friendlyName": "Visual Studio Test Agent Deployment",
"description": "Deploy and configure Test Agent to run tests on a lab machine group.",
"category": "Test",
"visibility": [
Expand Down Expand Up @@ -52,7 +52,7 @@
"defaultValue": "",
"required": false,
"helpMarkDown": "Comma separated list of machines where test agent needs to be deployed. For example: 'Machine1,Machine2,Machine3'",
"groupName": "agentConfiguration"
"groupName": "environment"
},
{
"name": "runAsProcess",
Expand Down Expand Up @@ -98,6 +98,15 @@
"required": false,
"helpMarkDown": "Optionally specify if test agent needs to be updated.",
"groupName": "advanced"
},
{
"name": "isDataCollectionOnly",
"type": "boolean",
"label": "Enable Data Collection Only",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Optionally specify if test agent needs to be used only for datacollection and not for running tests. Typically done on application under test(AUT) machine group.",
"groupName": "advanced"
}
],
"sourceDefinitions": [
Expand Down
11 changes: 10 additions & 1 deletion Tasks/DeployVisualStudioTestAgent/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"defaultValue": "",
"required": false,
"helpMarkDown": "Comma separated list of machines where test agent needs to be deployed. For example: 'Machine1,Machine2,Machine3'",
"groupName": "agentConfiguration"
"groupName": "environment"
},
{
"name": "runAsProcess",
Expand Down Expand Up @@ -99,6 +99,15 @@
"required": false,
"helpMarkDown": "Optionally specify if test agent needs to be updated.",
"groupName": "advanced"
},
{
"name": "isDataCollectionOnly",
"type": "boolean",
"label": "ms-resource:loc.input.label.isDataCollectionOnly",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Optionally specify if test agent needs to be used only for datacollection and not for running tests. Typically done on application under test(AUT) machine group.",
"groupName": "advanced"
}
],
"sourceDefinitions": [
Expand Down
6 changes: 4 additions & 2 deletions Tasks/RunDistributedTests/RunDistributedTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ param(
[string]$runSettingsFile,
[string]$codeCoverageEnabled,
[string]$overrideRunParams,
[string]$testConfigurations
[string]$testConfigurations,
[string]$autEnvironmentName
)

Write-Verbose "Entering script RunDistributedTests.ps1"
Expand All @@ -22,6 +23,7 @@ Write-Verbose "Build Configuration = $configuration"
Write-Verbose "CodeCoverage Enabled = $codeCoverageEnabled"
Write-Verbose "TestRun Parameters to override = $overrideRunParams"
Write-Verbose "TestConfiguration = $testConfigurations"
Write-Verbose "Application Under Test Machine Group = $autEnvironmentName"

# Import the Task.Internal dll that has all the cmdlets we need for Build
import-module "Microsoft.TeamFoundation.DistributedTask.Task.Internal"
Expand All @@ -31,6 +33,6 @@ Write-Verbose "Getting the connection object"
$connection = Get-VssConnection -TaskContext $distributedTaskContext

Write-Verbose "Calling Invoke-RunDistributedTests"
Invoke-RunDistributedTests -EnvironmentName $environment -SourceFilter $sourcefilters -TestCaseFilter $testFilterCriteria -RunSettingsPath $runSettingsFile -Platform $platform -Configuration $configuration -CodeCoverageEnabled $codeCoverageEnabled -TestRunParams $overrideRunParams -TestDropLocation $dropLocation -Connection $connection -TestConfiguration $testConfigurations
Invoke-RunDistributedTests -EnvironmentName $environment -SourceFilter $sourcefilters -TestCaseFilter $testFilterCriteria -RunSettingsPath $runSettingsFile -Platform $platform -Configuration $configuration -CodeCoverageEnabled $codeCoverageEnabled -TestRunParams $overrideRunParams -TestDropLocation $dropLocation -Connection $connection -TestConfiguration $testConfigurations -AutEnvironmentName $autEnvironmentName

Write-Verbose "Leaving script RunDistributedTests.ps1"
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
// GENERATED FILE - DO NOT EDIT DIRECTLY
// *******************************************************
{
"loc.friendlyName": "Run Visual Studio Tests using Test Agent",
"loc.friendlyName": "Visual Studio Test Run using Test Agent",
"loc.description": "Run tests distributedly using multiple test agents in a lab machine group.",
"loc.group.displayName.testEnvironment": "Test Machine Group",
"loc.group.displayName.testSettings": "Test Settings",
"loc.group.displayName.advanced": "Advanced",
"loc.input.label.environment": "Test Machine Group",
"loc.input.label.dropLocation": "Test Drop Location",
"loc.input.label.sourcefilters": "Test Assembly",
"loc.input.label.testFilterCriteria": "Test Filter criteria",
"loc.input.label.platform": "Platform",
"loc.input.label.configuration": "Configuration",
"loc.input.label.runSettingsFile": "Run Settings File",
"loc.input.label.codeCoverageEnabled": "Code Coverage Enabled",
"loc.input.label.overrideRunParams": "Override TestRun Parameters",
"loc.input.label.testConfigurations": "Test Configurations"
"loc.input.label.testConfigurations": "Test Configurations",
"loc.input.label.codeCoverageEnabled": "Code Coverage Enabled",
"loc.input.label.autEnvironmentName": "Application Under Test Machine Group"
}
34 changes: 24 additions & 10 deletions Tasks/RunDistributedTests/task.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "D353D6A2-E361-4A8F-8D8C-123BEBB71028",
"name": "RunVisualStudioTestsusingTestAgent",
"friendlyName": "Run Visual Studio Tests using Test Agent",
"friendlyName": "Visual Studio Test Run using Test Agent",
"description": "Run tests distributedly using multiple test agents in a lab machine group.",
"category": "Test",
"visibility": [
Expand All @@ -27,6 +27,11 @@
"name": "testSettings",
"displayName": "Test Settings",
"isExpanded": true
},
{
"name": "advanced",
"displayName": "Advanced",
"isExpanded": false
}
],
"inputs": [
Expand Down Expand Up @@ -91,15 +96,6 @@
"helpMarkDown": "Path to runsettings file to use with the tests. Use $(agent.BuildDirectory)\\$(system.teamProject) to access the Project folder.",
"groupName": "testSettings"
},
{
"name": "codeCoverageEnabled",
"type": "boolean",
"label": "Code Coverage Enabled",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Whether code coverage needs to be enabled.",
"groupName": "testSettings"
},
{
"name": "overrideRunParams",
"type": "string",
Expand All @@ -117,6 +113,24 @@
"required": false,
"helpMarkDown": "Optionally associate a testcase filter against a testconfiguration id. Syntax: <Filter1>:<Id1>;DefaultTestConfiguration:<Id3>. For example: FullyQualifiedName~Chrome:12.",
"groupName": "testSettings"
},
{
"name": "codeCoverageEnabled",
"type": "boolean",
"label": "Code Coverage Enabled",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Whether code coverage needs to be enabled.",
"groupName": "testSettings"
},
{
"name": "autEnvironmentName",
"type": "string",
"label": "Application Under Test Machine Group",
"defaultValue": "",
"required": false,
"helpMarkDown": "The name of the application under test(AUT) machine group on which server processes such as W3WP.exe is running.",
"groupName": "advanced"
}
],
"sourceDefinitions": [
Expand Down
Loading

0 comments on commit 16c4227

Please sign in to comment.