Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
13 changes: 13 additions & 0 deletions .config/cts/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cts": {
"version": "2.13.0-alpha.26530.1",
"commands": [
"cts"
],
"rollForward": false
}
}
}
34 changes: 34 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ parameters:
displayName: "Enable Linux/macOS affected tests (requires verified collector support)"
type: boolean
default: false
- name: EnableCTSCollection
displayName: "Compare CTS collection on main (requires public CTS package)"
type: boolean
default: false

variables:
# Cannot use key:value syntax in root defined variables
Expand Down Expand Up @@ -132,6 +136,10 @@ stages:
clean: false
- pwsh: ./eng/validate-affected-tests.ps1 -SelfTest -EnableAffectedTests ${{ parameters.EnableAffectedTests }} -EnableNonWindowsAffectedTests ${{ parameters.EnableNonWindowsAffectedTests }}
displayName: Validate affected-test rollout
- pwsh: ./eng/collect-cts-comparison.ps1 -SelfTest
displayName: Validate CTS module selection
- pwsh: ./eng/validate-collection-module-pool.ps1
displayName: Validate bounded collection scheduling
- bash: |
set -euo pipefail

Expand Down Expand Up @@ -259,6 +267,32 @@ stages:
SkipTests: ${{ parameters.SkipTests }}
EnableAffectedTests: ${{ parameters.EnableAffectedTests }}

- ${{ if and(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(parameters.SkipTests, False), eq(parameters.EnableCTSCollection, true)) }}:
- job: WindowsCTSComparison
displayName: Windows CTS comparison
dependsOn: DetectChanges
condition: and(succeededOrFailed(), ne(dependencies.DetectChanges.outputs['detect.infrastructureOnly'], 'true'))
timeoutInMinutes: 360
pool:
name: NetCore-Public
demands: ImageOverride -equals windows.vs2026preview.scout.amd64.open
variables:
- template: /eng/pipelines/variables/test-env-vars.yml
- name: _XmlDocsOnly
value: $[ dependencies.DetectChanges.outputs['detect.xmlDocsOnly'] ]
- name: _BuildConfig
value: Release
- name: _CollectAffectedTests
value: false
- name: _TestArtifactsName
value: CTSComparison
steps:
- template: /eng/pipelines/steps/build-test-windows.yml
parameters:
SkipTests: ${{ parameters.SkipTests }}
EnableAffectedTests: ${{ parameters.EnableAffectedTests }}
CollectCTS: true

# Matrix variables aren't available when the service resolves the job timeout. Keep collection
# in a separate job so its six-hour budget cannot resolve to ordinary validation's four hours.
- ${{ if and(eq(variables['Build.SourceBranch'], 'refs/heads/main'), eq(parameters.SkipTests, False), eq(parameters.EnableAffectedTests, true)) }}:
Expand Down
525 changes: 525 additions & 0 deletions docs/affected-test-selection.md

Large diffs are not rendered by default.

83 changes: 83 additions & 0 deletions eng/collect-affected-test-maps.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
[CmdletBinding()]
param(
[string]$Repository = (Split-Path $PSScriptRoot -Parent),
[ValidateSet("Debug", "Release")]
[string]$Configuration = "Release",
[ValidateRange(1, 4)]
[int]$ChildBudget = [Math]::Min([Environment]::ProcessorCount, 4),
[ValidateRange(1, 2)]
[int]$MaximumParallelModules = 2,
[string]$ResultsDirectory,
[switch]$DisablePackageCacheReuse
)

$ErrorActionPreference = "Stop"
. (Join-Path $PSScriptRoot "collection-test-modules.ps1")
. (Join-Path $PSScriptRoot "collection-module-pool.ps1")

$Repository = [System.IO.Path]::GetFullPath($Repository)
$globalJson = Get-Content -LiteralPath (Join-Path $Repository "global.json") -Raw | ConvertFrom-Json
$concurrency = Get-CollectionModuleConcurrency -ConfiguredBatches $globalJson.test.affectedTests.maximumConcurrentBatches `
-ChildBudget $ChildBudget -MaximumParallelModules $MaximumParallelModules
$batchesPerModule = $concurrency.BatchesPerModule
$effectiveBudget = $concurrency.ChildBudget
$slots = $concurrency.MaximumParallelModules
$modules = @(Get-OrderedCollectionModule -Modules @(Get-CTSComparisonModule -Repository $Repository -Configuration $Configuration))
$dotnetPath = (Get-Command dotnet -CommandType Application | Select-Object -First 1).Source
$resultsRoot = if ([string]::IsNullOrEmpty($ResultsDirectory)) {
Join-Path -Path $Repository -ChildPath "artifacts" -AdditionalChildPath @("TestResults", $Configuration, "AffectedCollection")
} else {
[System.IO.Path]::GetFullPath($ResultsDirectory)
}
$resultsDirectory = Join-Path $resultsRoot ([guid]::NewGuid().ToString("N"))
Write-Host "Collecting $($modules.Count) modules with $slots SDK slots and at most $($slots * $batchesPerModule) instrumentation children."
$timer = [System.Diagnostics.Stopwatch]::StartNew()
$sourceRevision = & git -C $Repository rev-parse HEAD
if ($LASTEXITCODE -ne 0) {
throw "Could not read the collection source revision."
}

$result = $null
$packageCacheRoot = if ($DisablePackageCacheReuse) {
$null
} else {
Join-Path -Path $Repository -ChildPath "artifacts" -AdditionalChildPath @("tmp", $Configuration, "collection-cache", [guid]::NewGuid().ToString("N"))
}
try {
$result = Invoke-CollectionModulePool -Modules $modules -Repository $Repository -ResultsDirectory $resultsDirectory `
-DotnetPath $dotnetPath -MaximumParallelModules $slots -PackageCacheRoot $packageCacheRoot
} finally {
$timer.Stop()
$metadataError = $null
try {
@{
SourceRevision = $sourceRevision
ChildBudget = $effectiveBudget
BatchesPerModule = $batchesPerModule
PackageCacheReuse = -not $DisablePackageCacheReuse
DurationSeconds = $timer.Elapsed.TotalSeconds
Result = $result
CompletedNormally = $null -ne $result
} | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath (Join-Path $resultsDirectory "collection.json") -Encoding utf8
} catch {
$metadataError = $_
Write-Warning "Could not write collection metadata: $($_.Exception.Message)"
}
Comment thread
Evangelink marked this conversation as resolved.
Resolved
if ($null -ne $result -and $result.TeardownConfirmed -and $null -ne $packageCacheRoot -and (Test-Path -LiteralPath $packageCacheRoot)) {
try {
Remove-Item -LiteralPath $packageCacheRoot -Recurse -Force
} catch {
if ($result.ExitCode -eq 0) {
throw
}
Write-Warning "Collection failed with exit $($result.ExitCode); owned cache cleanup also failed: $($_.Exception.Message)"
}
} elseif ($null -ne $packageCacheRoot -and (Test-Path -LiteralPath $packageCacheRoot)) {
Write-Warning "Collection failed before confirming child teardown. Preserving the owned cache '$packageCacheRoot' for diagnosis."
}
if ($null -ne $metadataError -and $null -ne $result -and $result.ExitCode -eq 0) {
throw $metadataError
}
}
Write-Host "Collection finished: $($result.Completed)/$($result.Planned) modules, exit $($result.ExitCode), duration $($timer.Elapsed)."
exit $result.ExitCode
Loading
Loading