Skip to content

Wait for SCM deletion in Windows service tests - #138048

Merged
steveisok merged 1 commit into
dotnet:mainfrom
steveisok:steveisok-windows-service-disposal-failure
Nov 21, 2026
Merged

steveisok merged 1 commit into
dotnet:mainfrom
steveisok:steveisok-windows-service-disposal-failure

Conversation

@steveisok

Copy link
Copy Markdown
Member

Windows SCM can keep a stopped service queryable after DeleteService succeeds and the creation handle closes. The immediate deletion assertion in the Windows service cleanup tests can therefore fail despite successful cleanup.

Poll deletion in the shared AssertServiceDeleted helper using the existing three-minute service-test timeout, refreshing status on each check. Success still requires ERROR_SERVICE_DOES_NOT_EXIST (1060); other errors propagate immediately, and timeout failures report the service name and last status. Add a regression that retains an observer handle and closes it after confirming the deletion assertion remains pending. This changes test infrastructure only and preserves the existing disposal and remote-exception assertions.

Validation

  • CanWaitForServiceDeletionWhenHandleCloses failed with the old assertion on both net12.0-windows and net481, then passed with the fix.
  • build.cmd clr+libs -rc release — passed using the VS 2022 developer environment and a temporary short worktree alias; zero warnings/errors.
  • .\dotnet.cmd build /t:Test src\libraries\Microsoft.Extensions.Hosting.WindowsServices\tests\Microsoft.Extensions.Hosting.WindowsServices.Tests.csproj /p:RuntimeConfiguration=Release — passed: 16 .NET 12 tests and 15 .NET Framework 4.8.1 tests, zero failures/skips.
  • .\dotnet.cmd build /t:Test src\libraries\Microsoft.Extensions.Hosting.WindowsServices\tests\Microsoft.Extensions.Hosting.WindowsServices.Tests.csproj /p:RuntimeConfiguration=Release /p:TestNoBuild=true --no-restore "/p:XUnitOptions=-method Microsoft.Extensions.Hosting.UseWindowsServiceTests.CanDisposeServiceWithoutStarting -method Microsoft.Extensions.Hosting.UseWindowsServiceTests.CanDeleteServiceWhenRemoteProcessFails -method Microsoft.Extensions.Hosting.UseWindowsServiceTests.CanWaitForServiceDeletionWhenHandleCloses" — 25 iterations per framework; 200 test executions passed, zero failures/skips.

Validation used local Windows build 26100/x64. The original Windows 10/x86/checked-CoreCLR CI configuration was not rebuilt.

Resolves #137647
Resolves #137746

Note

This pull request was generated with GitHub Copilot.

@azure-pipelines

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

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-extensions-hosting
See info in area-owners.md if you want to be subscribed.

@steveisok
steveisok merged commit b1c3d1b into dotnet:main Nov 21, 2026
64 of 67 checks passed
@steveisok
steveisok deleted the steveisok-windows-service-disposal-failure branch November 21, 2026 02:15
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants