Repository navigation
Enable safe Razor tool test parallelization - #56035
Conversation
Co-authored-by: Copilot App <[email protected]>
|
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. |
|
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. |
There was a problem hiding this comment.
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.Testsinto MSTest class-level parallelization viaMSTestParallelizeScope=ClassLevel. - Add
ResourceLock(WellKnownResources.EnvironmentVariables)to server-related tests and restoreDOTNET_BUILD_PIDFILE_DIRECTORYto its prior value. - Explicitly set
MSTestParallelizeScope=NoneforMicrosoft.NET.Sdk.Razor.Testswith 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. |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. |
Local before/after benchmarkLocal gain confirmed on my Windows machine using the SDK repo test runner.
Comparable clean total: 6m 21.5s before -> 5m 01.1s after (1m 20.3s saved, 21.1%).
Single local run; timings can vary with machine load, but this gives a direct before/after signal on this machine. |
Summary
This independent replacement contains the Razor-owned slice of #56015.
Microsoft.NET.Sdk.Razor.Tool.Tests.DOTNET_BUILD_PIDFILE_DIRECTORYwith the shared environment-variable resource lock and restores the previous value.Microsoft.NET.Sdk.Razor.TestsatNoneintentionally: 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.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.