Dependencies: Upgrade NUnit and related test dependencies to latest major versions#22155
Merged
AndyButland merged 7 commits intoMar 19, 2026
Merged
Conversation
…eConfigurationHttpTests
- Use Task.Run in CreateHost to escape NUnit 4's SynchronizationContext
which deadlocks sync-over-async calls from async test methods.
- Use await using for factory disposal to avoid same deadlock on shutdown
- Remove WithWebHostBuilder which wraps the factory in a
DelegatedWebApplicationFactory that bypasses the CreateHost override.
- Add ContentRoot property to UmbracoWebApplicationFactory so content
root can be set without WithWebHostBuilder.
- Set ModelsBuilder mode to Nothing to prevent BootFailedException.
- Add AddTestServices for infrastructure test doubles (MainDom, etc.).
Contributor
|
I'll revert the changes to the build pipeline now we've (hopefully) diagnosed the issue with the hanging test, but note them here just in case we have a need to do similar again and remember this issue: |
AndyButland
approved these changes
Mar 19, 2026
andr317c
added a commit
that referenced
this pull request
Apr 21, 2026
Reverts commit 7014f9a on this branch only, as a diagnostic experiment to validate the root-cause hypothesis for the Part3Of4 SQL Server nightly hang on v18/dev. Blame-hang dump showed the test host deadlocking inside ContentCacheRefresher.HandleMemoryCache on a sync-over-async .GetAwaiter().GetResult() call. Main and v17/dev have the identical production code but do not hang, because they still run NUnit 3.14.0 whose pumping synchronization context masks sync-over-async deadlocks. v18/dev's NUnit 4.5.1 removes that mask. If the nightly passes with this revert, the hypothesis is confirmed and the proper fix is to make ContentCacheRefresher async (separate change, not included here). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
andr317c
added a commit
that referenced
this pull request
Apr 21, 2026
Two test files used NUnit 4 APIs added by later commits (outside #22155's scope, so untouched by the revert in a50f89b): - UdiTests.cs: removed unused `using NUnit.Framework.Legacy;` (namespace introduced in NUnit 4). - BackOfficeAuthorizationInitializationMiddlewareTests.cs: swapped `[CancelAfter(5000)]` (NUnit 4) for its NUnit 3 equivalent `[Timeout(5000)]`. Same intent: fail fast on semaphore deadlock. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
andr317c
added a commit
that referenced
this pull request
Apr 21, 2026
Sets ThreadPool.SetMinThreads to max(ProcessorCount * 4, 32) in the assembly-level [OneTimeSetUp]. Prevents thread-pool starvation deadlocks on low-core CI agents when production sync-over-async paths (e.g. ContentCacheRefresher.HandleMemoryCache) hold worker threads while awaiting continuations. Why: NUnit 4 (PR #22155) dropped the single-threaded pumping synchronization context that NUnit 3 used, so sync-over-async that used to complete via the test thread now strictly requires a free thread-pool thread for its continuation. On Azure Pipelines hosted agents with small core counts, the pool can be fully blocked by the waiting threads, producing the 180-minute Part3Of4 SQL Server nightly timeouts observed on v18/dev since 2026-04-10. This is a test-only mitigation. The underlying sync-over-async pattern in ContentCacheRefresher remains a latent production issue and should be fixed separately by making Refresh async end-to-end. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
andr317c
added a commit
that referenced
this pull request
Apr 21, 2026
… test hang" This reverts commit a50f89b.
andr317c
added a commit
that referenced
this pull request
Apr 22, 2026
…2562) Revert "Dependencies: Upgrade NUnit and related test dependencies to latest major versions (#22155)" This reverts commit 7014f9a on v18/dev to resolve the Part3Of4 SQL Server integration test nightly hangs that started around 2026-04-10. Root cause was confirmed by hang-dump analysis: a sync-over-async call in ContentCacheRefresher.HandleMemoryCache (.GetAwaiter().GetResult() on an async cache method) that NUnit 3's pumping synchronization context had been quietly completing on the test thread. NUnit 4 dropped that behaviour, so the continuation now requires a free thread-pool thread; under CI conditions it deadlocks. Reverting #22155 on a branch was verified to make the nightly pass. This is a temporary rollback to unblock v18; the proper fix is to make ContentCacheRefresher.Refresh async end-to-end, tracked separately. Additional adjustments beyond the pure revert to keep the branch compiling: - CoreConfigurationHttpTests.cs: added `using Umbraco.Cms.Core.Services;` for IUserService (referenced by post-#22155 code unaffected by the revert). - ContentVersionCleanupServiceTest.cs: merged imports so both AutoFixture.NUnit3 (from revert) and Microsoft.Extensions.Options (from unrelated later commit) stay. - UdiTests.cs and ContentPermissionResourceTests.cs: removed unused `using NUnit.Framework.Legacy;` (namespace introduced in NUnit 4). - BackOfficeAuthorizationInitializationMiddlewareTests.cs: replaced `[CancelAfter(5000)]` with its NUnit 3 equivalent `[Timeout(5000)]`. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Upgrade
NUnitfrom 3.x to 4.5.1 and update related test dependencies and test code to align withNUnit 4.xbreaking changes and deprecations.Package upgrades
NUnit: 3.x → 4.5.1AutoFixture.NUnit3→AutoFixture.NUnit4(to resolve compatibility constraint with NUnit 4.x)Test code migrations
CollectionAssertand use Constraint model (Assert.That)Timeoutand useCancelAfterReferences