Skip to content

Enable safe Razor tool test parallelization - #56035

Merged
Evangelink merged 1 commit into
mainfrom
dev/amauryleve/razor-parallel-tests
Sep 9, 2026
Merged

Evangelink merged 1 commit into
mainfrom
dev/amauryleve/razor-parallel-tests

Conversation

@Evangelink

@Evangelink Evangelink commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

Summary

This independent replacement contains the Razor-owned slice of #56015.

  • Enables class-level parallelization for Microsoft.NET.Sdk.Razor.Tool.Tests.
  • Isolates tests that mutate DOTNET_BUILD_PIDFILE_DIRECTORY with the shared environment-variable resource lock and restores the previous value.
  • Keeps Microsoft.NET.Sdk.Razor.Tests at None intentionally: empirical validation exposed cross-project contamination through the shared Razor build server.

Ownership: @dotnet/razor-tooling

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.

Razor integration intentionally remained serialized after detecting build-server contamination; its median changed from 357.586s to 376.514s. Razor Tool tests changed from 19.128s to 22.450s.

@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 17:05
@Evangelink
Evangelink requested review from a team and a lite review from Copilot August 31, 2026 17:05
@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

Enables safer MSTest parallel execution for the Razor tool test assembly by opting Microsoft.NET.Sdk.Razor.Tool.Tests into class-level parallelization and adding explicit environment-variable locking/cleanup for tests that read or mutate DOTNET_BUILD_PIDFILE_DIRECTORY. It also documents and enforces that Microsoft.NET.Sdk.Razor.Tests remains non-parallel due to shared Razor build server contamination across projects.

Changes:

  • Opt Microsoft.NET.Sdk.Razor.Tool.Tests into MSTest class-level parallelization via MSTestParallelizeScope=ClassLevel.
  • Add ResourceLock(WellKnownResources.EnvironmentVariables) to server-related tests and restore DOTNET_BUILD_PIDFILE_DIRECTORY to its prior value.
  • Explicitly set MSTestParallelizeScope=None for Microsoft.NET.Sdk.Razor.Tests with an explanatory comment.
File Description
test/​Microsoft.NET.Sdk.Razor.Tool.Tests/​ServerLifecycleTest.cs Serializes this test class against other env-var mutators via ResourceLock(WellKnownResources.EnvironmentVariables).
test/​Microsoft.NET.Sdk.Razor.Tool.Tests/​ServerCommandTest.cs Adds env-var resource locking and restores DOTNET_BUILD_PIDFILE_DIRECTORY to its previous value after mutation.
test/​Microsoft.NET.Sdk.Razor.Tool.Tests/​Microsoft.NET.Sdk.Razor.Tool.Tests.csproj Enables MSTest class-level parallelization for the Razor tool test assembly.
test/​Microsoft.NET.Sdk.Razor.Tests/​Microsoft.NET.Sdk.Razor.Tests.csproj Explicitly keeps MSTest parallelization disabled (None) with rationale about shared Razor build server contamination.

@Evangelink
Evangelink enabled auto-merge (squash) September 1, 2026 08:10
@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

Local before/after benchmark

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/razor-parallel-tests (86da623)
  • 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: 6m 21.5s before -> 5m 01.1s after (1m 20.3s saved, 21.1%).

Project Before After Delta Result
Microsoft.NET.Sdk.Razor.Tests 6m 08.9s 4m 49.9s 1m 18.9s passed
Microsoft.NET.Sdk.Razor.Tool.Tests 12.613s 11.218s 1.395s passed

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

@Evangelink
Evangelink merged commit eae9e90 into main Sep 9, 2026
34 checks passed
@Evangelink
Evangelink deleted the dev/amauryleve/razor-parallel-tests branch September 9, 2026 04:59
@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 — 86da6234 Deployed Sep 9, 2026 by Evangelink via pre_activation #3607
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