Skip to content

fix shutdown tests#129853

Open
rosebyte wants to merge 1 commit into
dotnet:mainfrom
rosebyte:shutdown-tests_deployer-fix
Open

fix shutdown tests#129853
rosebyte wants to merge 1 commit into
dotnet:mainfrom
rosebyte:shutdown-tests_deployer-fix

Conversation

@rosebyte

@rosebyte rosebyte commented Jun 25, 2026

Copy link
Copy Markdown
Member

Fixes #129832

Summary

This change makes the functional test deployer more robust in Helix environments where dotnet is not on PATH and where process start can fail transiently.

  • Resolve the default dotnet host from the active testhost layout (next to the shared framework) instead of assuming a global PATH entry.
  • Keep the x86-on-x64 override behaviour unchanged by still resolving the architecture-specific host when required.
  • Harden shutdown logic so cleanup does not throw when a Process object was created but never successfully started.
  • Add retry logic for self-host process launch (3 attempts with short delay) to tolerate transient CI/Helix launch failures.
  • Preserve existing startup signalling and error propagation semantics while improving diagnostics around failed launches.

Testing

  • Existing shutdown functional tests (the target failing scenarios in CI)

Note

This PR description was generated with AI assistance.

@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.

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.

Pull request overview

This PR updates the Microsoft.Extensions.Hosting functional-test deployment infrastructure to make shutdown-related tests more reliable on constrained/Helix environments by hardening process launch and shutdown handling.

Changes:

  • Add a retry loop when launching the self-hosted test process, and surface early-exit failures more consistently.
  • Resolve the dotnet muxer path relative to the currently running shared framework (with PATH fallback) for Helix environments that don’t provide a global dotnet.
  • Avoid Process.HasExited throwing during shutdown/cleanup when the Process object was never successfully started.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/Deployers/SelfHostDeployer.cs Adds start retry logic and reorders startup flow to reduce flaky failures from transient process-launch issues.
src/libraries/Microsoft.Extensions.Hosting/tests/FunctionalTests/IntegrationTesting/src/Deployers/ApplicationDeployer.cs Improves dotnet muxer resolution for Helix and hardens shutdown checks against unstarted Process instances.

Comment on lines 124 to +126
var started = new TaskCompletionSource<object>();
var hostExitTokenSource = new CancellationTokenSource();

Comment on lines +148 to 151
if (IsRunning(hostProcess))
{
Logger.LogWarning("Unable to terminate the host process with process Id '{processId}", hostProcess.Id);
}
}
}

// Launching the host process can fail transiently on constrained CI/Helix machines (for example a

@jkotas jkotas Jun 25, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this really the case?

RemoteExecutor is launching a ton of process in CI/Helix machines. It does not have a retry loop like this and we do not see a problems with that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hi, I'm trying to find out, the PR was generated by Copilot, please take the comments as WIP.

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.

Test failure: Microsoft.AspNetCore.Hosting.FunctionalTests.ShutdownTests.ShutdownTestRun

3 participants