Skip to content

Parallelize TemplateEngine tests - #56032

Merged
Evangelink merged 1 commit into
dotnet:mainfrom
Evangelink:dev/amauryleve/parallelize-templateengine-tests
Sep 9, 2026
Merged

Evangelink merged 1 commit into
dotnet:mainfrom
Evangelink:dev/amauryleve/parallelize-templateengine-tests

Conversation

@Evangelink

@Evangelink Evangelink commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Opt TemplateEngine test assemblies into audited MSTest parallel execution, using ClassLevel where methods share class-scoped state and MethodLevel where methods are independently isolated.
  • Keep export failure tests isolated with a randomized per-instance working directory and restore the original current cultures during cleanup.
  • Ownership: @dotnet/templating-engine-maintainers.

This is the independent replacement for the templates slice of #56015, extracted as 12 files from source 84e283b69ce8f087114b5adba1016c8ce1f0e5d0 onto base 198ec8f3f13efc148f464688a6523341f856e03c.

10× benchmark results

The combined Razor-fixed branch was measured on the same machine under an exclusive benchmark lock. Each iteration ran the identical 54 affected projects sequentially through scripts/RunTests.cs, with the same 90-minute per-project timeout and the same exclusion for the pre-existing hanging interruption test.

Fleet statistic Baseline Changed Improvement
Mean 14,773.837s 7,341.516s 50.31%
Median 14,276.260s 6,742.966s 52.77%
Min 14,193.833s 5,426.805s —
Max 18,277.595s 10,443.242s —

All 10 changed iterations completed with zero timeouts and retained exactly the same 10-project local-environment/prerequisite failure set as all 10 baseline iterations; there were no new or resolved failing projects. These combined-branch measurements provide performance and stability context, not isolated attribution or a per-slice tests-passed claim.

The short TemplateEngine project medians generally regressed by 2–13 seconds under the complete benchmark; the aggregate fleet still improved because savings in long-running projects dominated. The largest TemplateEngine median regressions were Authoring Tasks integration (+13.324s) and TemplateVerifier integration (+11.384s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@Evangelink
Evangelink marked this pull request as ready for review August 31, 2026 16:56
@Evangelink
Evangelink requested a review from a team as a code owner August 31, 2026 16:56
Copilot AI lite review requested due to automatic review settings August 31, 2026 16:56
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Review tier: Lite
Findings: None

What changed in this PR

This PR opts TemplateEngine-area test projects into MSTest parallel execution by overriding the repo-wide default of MSTestParallelizeScope=None, selecting ClassLevel or MethodLevel per assembly to balance speed with isolation. It also updates an integration test fixture to better isolate cleanup and culture state when running concurrently.

Changes:

  • Enabled MSTest parallelization (per-project override) across multiple TemplateEngine test projects, using ClassLevel or MethodLevel as appropriate.
  • Updated ExportCommandFailureTests to restore original cultures during cleanup (and use a per-instance temp working directory).
File Description
test/​TemplateEngine/​Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests/​Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests.csproj Opts the integration test assembly into ClassLevel parallelization.
test/​TemplateEngine/​Microsoft.TemplateSearch.Common.UnitTests/​Microsoft.TemplateSearch.Common.UnitTests.csproj Opts the unit test assembly into ClassLevel parallelization.
test/​TemplateEngine/​Microsoft.TemplateEngine.Utils.UnitTests/​Microsoft.TemplateEngine.Utils.UnitTests.csproj Opts the unit test assembly into ClassLevel parallelization.
test/​TemplateEngine/​Microsoft.TemplateEngine.TemplateLocalizer.Core.UnitTests/​Microsoft.TemplateEngine.TemplateLocalizer.Core.UnitTests.csproj Opts the unit test assembly into ClassLevel parallelization.
test/​TemplateEngine/​Microsoft.TemplateEngine.Edge.UnitTests/​Microsoft.TemplateEngine.Edge.UnitTests.csproj Opts the unit test assembly into ClassLevel parallelization.
test/​TemplateEngine/​Microsoft.TemplateEngine.Authoring.TemplateVerifier.UnitTests/​Microsoft.TemplateEngine.Authoring.TemplateVerifier.UnitTests.csproj Opts the unit test assembly into MethodLevel parallelization.
test/​TemplateEngine/​Microsoft.TemplateEngine.Authoring.TemplateVerifier.IntegrationTests/​Microsoft.TemplateEngine.Authoring.TemplateVerifier.IntegrationTests.csproj Opts the integration test assembly into ClassLevel parallelization.
test/​TemplateEngine/​Microsoft.TemplateEngine.Authoring.Templates.IntegrationTests/​Microsoft.TemplateEngine.Authoring.Templates.IntegrationTests.csproj Opts the integration test assembly into MethodLevel parallelization.
test/​TemplateEngine/​Microsoft.TemplateEngine.Authoring.Tasks.IntegrationTests/​Microsoft.TemplateEngine.Authoring.Tasks.IntegrationTests.csproj Opts the integration test assembly into ClassLevel parallelization.
test/​TemplateEngine/​Microsoft.TemplateEngine.Authoring.CLI.UnitTests/​Microsoft.TemplateEngine.Authoring.CLI.UnitTests.csproj Opts the unit test assembly into ClassLevel parallelization.
test/​TemplateEngine/​Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/​Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests.csproj Opts the integration test assembly into ClassLevel parallelization.
test/​TemplateEngine/​Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/​ExportCommandFailureTests.cs Restores cultures during cleanup to reduce cross-test leakage under parallel execution.
Suppressed comments (1)

test/TemplateEngine/Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/ExportCommandFailureTests.cs:29

  • Culture is set to invariant in the constructor and only restored in Dispose. If any later constructor step (e.g., Directory.CreateDirectory) throws, Dispose won't run and the test host can keep the invariant culture for subsequent tests on the same thread/execution context.
            CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
            CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture;

            _workingDirectory = Path.Combine(Path.GetTempPath(), "Microsoft.TemplateEngine.TemplateLocalizer.IntegrationTests", Path.GetRandomFileName());
            Directory.CreateDirectory(_workingDirectory);

@Evangelink

Copy link
Copy Markdown
Member Author

Local before/after benchmark

Partial local gain confirmed on my Windows machine using the SDK repo test runner.

  • Machine: Microsoft Windows 11 Enterprise, AMD RYZEN AI MAX+ 395 w/ Radeon 8060S , 32 logical processors
  • Baseline: origin/main (890dd7f)
  • PR head: dev/amauryleve/parallelize-templateengine-tests (883232c)
  • Command shape: .\.dotnet\dotnet.exe scripts\RunTests.cs -- --project <project>
  • Reported numbers use the test run duration from the runner output; build/setup wall-clock is excluded.

Comparable clean total: 1m 28.2s before -> 1m 01.0s after (27.205s saved, 30.9%).

Project Before After Delta Result
Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests 2.417s 1.273s 1.144s passed
Microsoft.TemplateEngine.Authoring.CLI.UnitTests 0.855s 0.51s 0.345s passed
Microsoft.TemplateEngine.Authoring.Tasks.IntegrationTests failed failed n/a base/head failed: NuGet.Frameworks 7.12/7.11 assembly mismatch in local redist/bootstrap load context
Microsoft.TemplateEngine.Authoring.Templates.IntegrationTests 3.791s 2.132s 1.659s passed
Microsoft.TemplateEngine.Authoring.TemplateVerifier.IntegrationTests 6.428s 4.639s 1.789s passed
Microsoft.TemplateEngine.Authoring.TemplateVerifier.UnitTests 1.295s 0.884s 0.411s passed
Microsoft.TemplateEngine.Edge.UnitTests 25.006s 16.193s 8.813s passed
Microsoft.TemplateEngine.TemplateLocalizer.Core.UnitTests 0.812s 0.574s 0.238s passed
Microsoft.TemplateEngine.Utils.UnitTests 0.791s 0.582s 0.209s passed
Microsoft.TemplateSearch.Common.UnitTests 11.729s 6.064s 5.665s passed
Microsoft.TemplateSearch.TemplateDiscovery.IntegrationTests 35.049s 28.117s 6.932s passed

Single local run; timings can vary with machine load, but this gives a direct before/after signal on this machine.

@Evangelink

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.

@Evangelink

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.

@Evangelink
Evangelink merged commit 19de2da into dotnet:main Sep 9, 2026
35 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 10, 2026

This branch had an error being deployed

1 failed deployment
copilot-pat-pool — 883232c8 Deployed Sep 9, 2026 by Evangelink via pre_activation #3888
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants