Skip to content

Commit c570be8

Browse files
EvangelinkCopilot
andauthored
Fix CTS and affected-test pipeline failures (#12604)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 207bd78 commit c570be8

6 files changed

Lines changed: 165 additions & 7 deletions

‎docs/affected-test-selection.md‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,37 @@ the production or test-helper fix. Tests are run from `artifacts\bin\<project>\D
656656
each image, and the next `Windows AffectedTests` and `Windows CTS comparison` runs are the first end-to-end proof.
657657
Media is inapplicable to these CI and test fixes.
658658

659+
## CI fixes for build 1696417 (2026-11-24)
660+
661+
In [build 1696417](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1696417), the Windows
662+
affected-test job failed when `MSTestAdapter.PlatformServices.UnitTests` on `net10.0-windows10.0.18362.0`
663+
exceeded the collector's 128-MiB map limit. Like the two previously excluded Framework hosts, that exact
664+
module/TFM is now omitted from collection; a missing shard conservatively runs the entire module on PRs.
665+
The concurrently running `net10.0` module had not finished when the failed module stopped the pool, so it remains
666+
enabled rather than being excluded without evidence.
667+
668+
The CTS collector itself exited zero for 48 modules. Its test-results artifact upload failed with `TF205023`:
669+
the Azure DevOps container rejected map paths longer than 399 characters. Before publication, the CTS-only
670+
pipeline step archives each run's `maps` directory as `maps.zip`, preserving relative paths and keeping TRX,
671+
logs, and `comparison.json` as separate files. Extract `maps.zip` into a `maps` directory to restore the previous
672+
layout. Preparation also runs after collection failures to preserve partial maps; a failed archive leaves the
673+
original maps in place and fails the step. The archive is created before the original tree is removed.
674+
`PublishBuildArtifacts@1`'s `StoreAsTar` is not an alternative on this Windows agent: the
675+
[task documentation](https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/publish-build-artifacts-v1)
676+
says that setting is ignored on Windows.
677+
678+
**Test-value evidence:** base `8321e6cf4ceeba5bd68579aa631384b531f0c117`, with these local changes:
679+
`pwsh -NoLogo -NoProfile -File .\eng\validate-collection-module-pool.ps1` exited 1 at
680+
`ModulePoolSkipsOnlyOversizedMaps` with the new expectation and the original exclusion list, then exited 0
681+
with the fix. `pwsh -NoLogo -NoProfile -File .\eng\collect-cts-comparison.ps1 -SelfTest` exited 1 at
682+
`CTSMapsAreArchivedForPublication` with the archive function replaced by a no-op, then exited 0 with the
683+
implementation; the test checks a path longer than 399 characters, hidden-file contents, and unchanged
684+
diagnostics. `CTSArchiveCollisionPreservesMaps` verifies that an existing archive is not overwritten or the maps
685+
deleted. `pwsh -NoLogo -NoProfile -File .\eng\validate-affected-tests.ps1 -SelfTest -EnableAffectedTests true
686+
-EnableNonWindowsAffectedTests false` verifies the CTS archive step and rejects its removal or a success-only
687+
condition. The actual Azure DevOps upload and the remaining module collections require a hosted run and are not
688+
validated by these local tests.
689+
659690
## CI layout
660691

661692
- `global.json` defines the repository-specific `test.affectedTests` change policy and selects Azure DevOps artifact
@@ -672,7 +703,8 @@ Media is inapplicable to these CI and test fixes.
672703
writes to `TestFx_AffectedTestsMaps`; see [CTS comparison activation](#cts-comparison-activation-2026-11-19).
673704
- With the rollout enabled, the Windows Release PR test runs `--affected-tests`.
674705
- Affected-test collection and selection cover all repository test TFMs, including .NET Framework through the
675-
package's `netstandard2.0` assets. The exception is MSTestAdapter.PlatformServices.UnitTests on net462 and net48:
706+
package's `netstandard2.0` assets. The exceptions are MSTestAdapter.PlatformServices.UnitTests on net462, net48,
707+
and net10.0-windows10.0.18362.0:
676708
their maps exceed the collector's 128-MiB limit, so they are not collected and selection runs all of their tests
677709
([CI fixes for build 1691751](#ci-fixes-for-build-1691751-2026-11-20)). The build restores the collector's required x64 native files beneath
678710
`runtimes/win-x64/native`, because NuGet otherwise flattens them for .NET Framework and `win-x64` RID-specific

‎eng/collect-cts-comparison.ps1‎

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[CmdletBinding()]
22
param(
33
[switch]$SelfTest,
4+
[switch]$PrepareArtifacts,
45
[string]$Repository = (Split-Path $PSScriptRoot -Parent),
56
[ValidateSet("Debug", "Release")]
67
[string]$Configuration = "Release",
@@ -11,6 +12,99 @@ param(
1112
$ErrorActionPreference = "Stop"
1213
. (Join-Path $PSScriptRoot "collection-test-modules.ps1")
1314

15+
function Prepare-CTSComparisonArtifacts {
16+
param([string]$ResultsDirectory)
17+
18+
if ([string]::IsNullOrWhiteSpace($ResultsDirectory)) {
19+
throw "CTS artifact preparation requires a results directory."
20+
}
21+
if (-not (Test-Path -LiteralPath $ResultsDirectory -PathType Container)) {
22+
Write-Host "No CTS results directory to prepare: $ResultsDirectory"
23+
return
24+
}
25+
26+
foreach ($run in Get-ChildItem -LiteralPath $ResultsDirectory -Directory) {
27+
$maps = Join-Path $run.FullName "maps"
28+
if (-not (Test-Path -LiteralPath $maps -PathType Container)) {
29+
continue
30+
}
31+
$archive = Join-Path $run.FullName "maps.zip"
32+
if (Test-Path -LiteralPath $archive) {
33+
throw "CTS map archive already exists: $archive"
34+
}
35+
$temporaryArchive = Join-Path $run.FullName ("maps-" + [guid]::NewGuid().ToString("N") + ".tmp")
36+
try {
37+
[System.IO.Compression.ZipFile]::CreateFromDirectory($maps, $temporaryArchive)
38+
Move-Item -LiteralPath $temporaryArchive -Destination $archive
39+
Remove-Item -LiteralPath $maps -Recurse -Force
40+
Write-Host "Archived CTS maps for publication: $archive"
41+
} finally {
42+
if (Test-Path -LiteralPath $temporaryArchive) {
43+
Remove-Item -LiteralPath $temporaryArchive -Force
44+
}
45+
}
46+
}
47+
}
48+
49+
function Invoke-CTSArchiveSelfTest {
50+
$fixture = Join-Path ([System.IO.Path]::GetTempPath()) ("testfx-cts-archive-" + [guid]::NewGuid().ToString("N"))
51+
$run = Join-Path $fixture "run"
52+
$maps = Join-Path $run "maps"
53+
$nested = Join-Path $maps (("long-directory-" + ("x" * 60) + "\") * 6)
54+
New-Item -ItemType Directory -Path $nested -Force | Out-Null
55+
try {
56+
Set-Content -LiteralPath (Join-Path $maps "committed") -Value "first" -NoNewline
57+
Set-Content -LiteralPath (Join-Path $nested ".hidden-map") -Value "second" -NoNewline
58+
Set-Content -LiteralPath (Join-Path $run "comparison.json") -Value "comparison"
59+
Prepare-CTSComparisonArtifacts -ResultsDirectory $fixture
60+
$archivePath = Join-Path $run "maps.zip"
61+
if (-not (Test-Path -LiteralPath $archivePath -PathType Leaf) -or (Test-Path -LiteralPath $maps) -or
62+
-not (Test-Path -LiteralPath (Join-Path $run "comparison.json") -PathType Leaf)) {
63+
throw "CTSMapsAreArchivedForPublication: the archive must replace only the maps tree."
64+
}
65+
66+
$archive = [System.IO.Compression.ZipFile]::OpenRead($archivePath)
67+
try {
68+
$entries = @($archive.Entries | Where-Object { -not $_.FullName.EndsWith("/") })
69+
$committed = @($entries | Where-Object FullName -eq "committed")
70+
$hidden = @($entries | Where-Object { $_.FullName.EndsWith("/.hidden-map") })
71+
if ($entries.Count -ne 2 -or $committed.Count -ne 1 -or $hidden.Count -ne 1 -or
72+
$hidden[0].FullName.Length -le 399) {
73+
throw "CTSMapsAreArchivedForPublication: long and hidden map paths must be retained."
74+
}
75+
foreach ($case in @(@{ Entry = $committed[0]; Expected = "first" }, @{ Entry = $hidden[0]; Expected = "second" })) {
76+
$reader = [System.IO.StreamReader]::new($case.Entry.Open())
77+
try {
78+
if ($reader.ReadToEnd() -cne $case.Expected) {
79+
throw "CTSMapsAreArchivedForPublication: archive contents changed."
80+
}
81+
} finally {
82+
$reader.Dispose()
83+
}
84+
}
85+
} finally {
86+
$archive.Dispose()
87+
}
88+
Write-Output "PASS CTSMapsAreArchivedForPublication"
89+
90+
New-Item -ItemType Directory -Path $maps | Out-Null
91+
Set-Content -LiteralPath (Join-Path $maps "committed") -Value "preserve"
92+
$rejected = $false
93+
try {
94+
Prepare-CTSComparisonArtifacts -ResultsDirectory $fixture
95+
} catch {
96+
$rejected = $_.Exception.Message.StartsWith("CTS map archive already exists:")
97+
}
98+
if (-not $rejected -or -not (Test-Path -LiteralPath (Join-Path $maps "committed")) -or
99+
(Get-Content -LiteralPath (Join-Path $maps "committed") -Raw).Trim() -ne "preserve") {
100+
throw "CTSArchiveCollisionPreservesMaps: an existing archive must not overwrite or delete maps."
101+
}
102+
Write-Output "PASS CTSArchiveCollisionPreservesMaps"
103+
} finally {
104+
Remove-Item -LiteralPath $fixture -Recurse -Force
105+
}
106+
}
107+
14108
function Invoke-CTSModuleSelectionSelfTest {
15109
$fixture = Join-Path -Path ([System.IO.Path]::GetTempPath()) -ChildPath ("testfx-cts-selection-" + [guid]::NewGuid().ToString("N"))
16110
New-Item -ItemType Directory -Path $fixture | Out-Null
@@ -316,6 +410,12 @@ function Invoke-CTSArtifactSelfTest {
316410
if ($SelfTest) {
317411
Invoke-CTSModuleSelectionSelfTest
318412
Invoke-CTSArtifactSelfTest
413+
Invoke-CTSArchiveSelfTest
414+
exit 0
415+
}
416+
417+
if ($PrepareArtifacts) {
418+
Prepare-CTSComparisonArtifacts -ResultsDirectory $ResultsDirectory
319419
exit 0
320420
}
321421

‎eng/collection-module-pool.ps1‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ function Get-CollectionModuleConcurrency {
3838
}
3939

4040
# The pinned collector refuses to persist a map larger than its fixed 128-MiB limit and fails that module.
41-
# These module/TFM maps reached 127.64 MiB at 1,620 tests and exceeded the limit at 1,626, so they are not collected;
42-
# without a shard, PR selection conservatively runs all of their tests. See docs/affected-test-selection.md.
41+
# These specific module/TFM maps exceeded the limit in CI. Without a shard, PR selection
42+
# conservatively runs all of their tests. See docs/affected-test-selection.md.
4343
$script:CollectionMapSizeExclusions = @(
44-
[pscustomobject]@{ Project = "MSTestAdapter.PlatformServices.UnitTests"; Frameworks = @("net462", "net48") }
44+
[pscustomobject]@{ Project = "MSTestAdapter.PlatformServices.UnitTests"; Frameworks = @("net462", "net48", "net10.0-windows10.0.18362.0") }
4545
)
4646

4747
function Get-MappableCollectionModule {

‎eng/pipelines/steps/build-test-windows.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ steps:
8282
displayName: Compare TRX, CTRF, and JUnit reports
8383
condition: and(succeededOrFailed(), ne(variables._XmlDocsOnly, 'true'), ne(variables._CollectAffectedTests, 'true'), eq(variables.HasTestReports, 'true'))
8484

85+
- ${{ if eq(parameters.CollectCTS, true) }}:
86+
- pwsh: ./eng/collect-cts-comparison.ps1 -PrepareArtifacts -ResultsDirectory "$(Build.SourcesDirectory)/artifacts/TestResults/$(_BuildConfig)/CTS"
87+
displayName: Archive CTS maps for publication
88+
condition: and(always(), ne(variables._XmlDocsOnly, 'true'))
89+
8590
- task: PublishBuildArtifacts@1
8691
displayName: 'Publish Test Results folders'
8792
inputs:

‎eng/validate-affected-tests.ps1‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,13 @@ function Assert-CTSComparisonWiring {
169169
throw "CTSComparisonPreservesNativeCollection: run the actual CTS tool, preserve failures, and store its maps separately."
170170
}
171171

172+
$archiveStep = [regex]::Match($WindowsBuildTemplate,
173+
'(?ms)^ - \$\{\{ if eq\(parameters\.CollectCTS, true\) \}\}:\r?\n - pwsh: \./eng/collect-cts-comparison\.ps1 -PrepareArtifacts -ResultsDirectory "[^"\r\n]+/CTS"\r?\n displayName: Archive CTS maps for publication\r?\n condition: and\(always\(\), ne\(variables\._XmlDocsOnly, ''true''\)\)')
174+
$publishIndex = $WindowsBuildTemplate.IndexOf("- task: PublishBuildArtifacts@1", [StringComparison]::Ordinal)
175+
if (-not $archiveStep.Success -or $publishIndex -lt 0 -or $archiveStep.Index -ge $publishIndex) {
176+
throw "CTSComparisonArchivesMapsBeforePublication: archive CTS maps even after failures, before the results artifact is published."
177+
}
178+
172179
$manifest = $ManifestText | ConvertFrom-Json
173180
if (-not $manifest.isRoot -or @($manifest.tools.PSObject.Properties).Count -ne 1 -or
174181
$manifest.tools.cts.version -notmatch '^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$' -or
@@ -261,6 +268,19 @@ function Invoke-CTSComparisonSelfTest {
261268
" - template: /eng/pipelines/steps/test-cts-comparison.yml`n - template: /eng/pipelines/steps/test-windows-configuration-tests.yml")
262269
ExpectedFailure = "CTSComparisonAndValidationAreExclusive"
263270
},
271+
@{
272+
Name = "CTSComparisonMissingArchiveStepIsRejected"
273+
WindowsBuildTemplate = $WindowsBuildTemplate.Replace("-PrepareArtifacts -ResultsDirectory", "-MissingArchive -ResultsDirectory")
274+
ExpectedFailure = "CTSComparisonArchivesMapsBeforePublication"
275+
},
276+
@{
277+
Name = "CTSComparisonArchiveSkippedOnFailureIsRejected"
278+
WindowsBuildTemplate = [regex]::Replace(
279+
$WindowsBuildTemplate,
280+
'(displayName: Archive CTS maps for publication\r?\n condition: and\()always\(\)',
281+
'$1succeeded()')
282+
ExpectedFailure = "CTSComparisonArchivesMapsBeforePublication"
283+
},
264284
@{
265285
Name = "CTSComparisonRuntimeRollForwardIsRejected"
266286
ManifestText = $ManifestText.Replace('"rollForward": false', '"rollForward": true')

‎eng/validate-collection-module-pool.ps1‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,11 @@ try {
7474
$mappable = @(Get-MappableCollectionModule -Modules @(
7575
[pscustomobject]@{ Project = "MSTestAdapter.PlatformServices.UnitTests"; Framework = "net462"; RelativePath = "a" },
7676
[pscustomobject]@{ Project = "MSTestAdapter.PlatformServices.UnitTests"; Framework = "net48"; RelativePath = "b" },
77-
[pscustomobject]@{ Project = "MSTestAdapter.PlatformServices.UnitTests"; Framework = "net10.0"; RelativePath = "c" },
78-
[pscustomobject]@{ Project = "TestFramework.UnitTests"; Framework = "net48"; RelativePath = "d" }
77+
[pscustomobject]@{ Project = "MSTestAdapter.PlatformServices.UnitTests"; Framework = "net10.0-windows10.0.18362.0"; RelativePath = "c" },
78+
[pscustomobject]@{ Project = "MSTestAdapter.PlatformServices.UnitTests"; Framework = "net10.0"; RelativePath = "d" },
79+
[pscustomobject]@{ Project = "TestFramework.UnitTests"; Framework = "net10.0-windows10.0.18362.0"; RelativePath = "e" }
7980
) 6>$null)
80-
if (($mappable.RelativePath -join ",") -ne "c,d") {
81+
if (($mappable.RelativePath -join ",") -ne "d,e") {
8182
throw "ModulePoolSkipsOnlyOversizedMaps: only the module/TFM maps above the collector's 128-MiB limit may be skipped."
8283
}
8384
Write-PassedCheck "ModulePoolSkipsOnlyOversizedMaps"

0 commit comments

Comments
 (0)