-
Notifications
You must be signed in to change notification settings - Fork 704
Add test splitting infrastructure with auto-detection support and GitHub Actions integration #12101
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
base: main
Are you sure you want to change the base?
Conversation
- Enhanced Directory.Build.targets with new ExtractTestClassNamesV3 target - Updated GetTestProjects.proj to support split test matrix generation - Fixed PowerShell scripts for proper array handling and cross-platform paths - Migrated Aspire.Templates.Tests to use new unified mechanism - Successfully generates class-based split test matrices Co-authored-by: radical <[email protected]>
- Use MSBuild::NormalizeDirectory for cross-platform compatibility - Define ArtifactsDir if not already set - Matrix generation now works correctly with normalized paths Co-authored-by: radical <[email protected]>
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12101 Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12101" |
1 similar comment
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12101 Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12101" |
@copilot Implement (1). And add Validate that the generation of tests matrix works correctly. Validate that it gets correctly consumed by the gh actions, yml. Also make sure the trx filenames are valid for the platform, so escape characters correctly. |
…Hub Actions - Added [Collection] attributes to WaitForTests and DistributedApplicationTests classes - Enabled SplitTestsOnCI for Aspire.Hosting.Tests project with appropriate timeouts - Updated enumerate-tests action to generate and output split tests matrix - Added split test jobs to tests.yml workflow for Linux, macOS, and Windows - Matrix generates 66 class-based jobs for Hosting.Tests (40 Hosting + 26 Templates) - Filter arguments validated: --filter-class correctly isolates test classes Co-authored-by: radical <[email protected]>
Implemented all requested changes in commit 85eab86:
Note: Collection detection via xUnit v3 |
@copilot Two issues:
Implement this. Validate
|
Issue 1: Fixed duplicate "class:" prefix in filterArg - Updated enumerate-tests action to strip "class:", "collection:", or "uncollected:" prefixes from shortnames Issue 2: Implemented ExtractTestPartitions tool for collection/partition detection - Created tool in tools/ExtractTestPartitions to extract [Collection] and [Trait("Partition", ...)] attributes - Updated extract-test-metadata.ps1 to call the tool before falling back to class-based mode - Updated Directory.Build.targets to pass TestAssemblyPath and RepoRoot parameters Added [Trait("Partition", ...)] attributes to test classes: - WaitForTests - DistributedApplicationTests - SlimTestProgramTests Updated filter generation: - Collection filters now use "--filter-trait \"Partition=Name\"" format - Uncollected filters use "--filter-not-trait \"Partition=Name\"" format Validation: - Matrix generates 30 jobs (4 collections for Hosting + 26 classes for Templates) - Filters tested and work correctly with xUnit v3 Co-authored-by: radical <[email protected]>
Fixed both issues in commit da9cbb3: Issue 1 - Fixed filterArg format:
Issue 2 - Collection extraction tool:
Validation:
|
@copilot Splitting based on the collection/"Partition" trait doesn't seem to be working. fix and validate that it works, and the correct matrix json is created. |
Partition-based splitting IS working correctly. Here's the validation: Collection Detection:
Matrix Generation:
Filter Validation: $ dotnet Aspire.Hosting.Tests.dll --list-tests --filter-trait "Partition=WaitForTests"
Test discovery summary: found 38 test(s) ✓
$ dotnet Aspire.Hosting.Tests.dll --list-tests --filter-trait "Partition=DistributedApplicationTests"
Test discovery summary: found 43 test(s) ✓
$ dotnet Aspire.Hosting.Tests.dll --list-tests --filter-trait "Partition=SlimTestProgram"
Test discovery summary: found 3 test(s) ✓ Matrix JSON (sample): {
"type": "collection",
"shortname": "Collection_DistributedApplicationTests",
"filterArg": "--filter-trait \"Partition=DistributedApplicationTests\"",
"testSessionTimeout": "30m"
} All tests sum correctly: 38 + 43 + 3 + 1286 uncollected = 1370 total ✓ |
…tting-infrastructure-again
/azp run aspire-tests |
Azure Pipelines successfully started running 1 pipeline(s). |
…tting-infrastructure-again
…tting-infrastructure-again
@copilot quarantine this test - Aspire.Hosting.Python.Tests.AddPythonAppTests.WithVirtualEnvironment_CanBeChainedWithOtherExtensions |
@copilot Quarantine Aspire.Hosting.Python.Tests.AddPythonAppTests.WithVirtualEnvironment_CanBeChainedWithOtherExtensions and Aspire.Hosting.Tests.Dcp.DcpExecutorTests.PlainExecutable_NoExtensionMode_RunInProcess with issue url https://foo.com/issues/123 |
Test Splitting Implementation
This PR implements the test splitting infrastructure as described in
docs/test-splitting
.Implementation Plan
eng/scripts/
)tests/Directory.Build.targets
with newExtractTestClassNames
target supporting auto-detectiontests/Shared/GetTestProjects.proj
to support split test matrix generationtests/Aspire.Templates.Tests
to use unified mechanismRecent Changes (addressing review feedback - second iteration)
Issue 1: Fixed filterArg Format
The templates matrix was generating invalid filter arguments like:
Fix: Updated enumerate-tests action to strip
class:
,collection:
, oruncollected:
prefixes before generating shortnames.Issue 2: Collection Extraction via Tool
XUnit v3 with Microsoft.Testing.Platform doesn't output "Collection:" banners in
--list-tests
output, so collection detection wasn't working.Solution: Created
tools/ExtractTestPartitions
tool that:[Collection("name")]
attributes from test classes[Trait("Partition", "name")]
attributes as fallbackIntegration:
extract-test-metadata.ps1
to call the tool before falling back to class-based modeDirectory.Build.targets
to pass assembly path and repo root to the scriptAdded Trait Attributes for xUnit v3
Since xUnit v3 doesn't automatically create a "Collection" trait, added explicit
[Trait("Partition", "name")]
attributes:WaitForTests
→[Collection("WaitForTests")]
+[Trait("Partition", "WaitForTests")]
DistributedApplicationTests
→[Collection("DistributedApplicationTests")]
+[Trait("Partition", "DistributedApplicationTests")]
SlimTestProgramTests
→ Already had Collection, added[Trait("Partition", "SlimTestProgram")]
Updated Filter Generation
Changed from non-existent
--filter-collection
to xUnit v3 trait filters:--filter-trait "Partition=CollectionName"
--filter-not-trait "Partition=Name1" --filter-not-trait "Partition=Name2" ...
Current Status
Successfully generates a 30-job matrix:
Validation Results
ExtractTestPartitions Tool ✅
Filter Arguments ✅
Templates.Tests (class-based):
Hosting.Tests (partition-based):
Filter Testing ✅
Benefits
--filter-trait
which works with Microsoft.Testing.Platform[Collection("name")]
+[Trait("Partition", "name")]
attributesNext Steps
Future PRs will:
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.