dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.91k stars 476 forks source link

Tests keep DCP instances running until the whole test run ends #6561

Open karolz-ms opened 3 weeks ago

karolz-ms commented 3 weeks ago

Is there an existing issue for this?

Describe the bug

When running multiple tests that use app host/DCP, DCP instances (and associated resources such as containers) are kept running until the test run ends. They are not shut down, and resources are not freed, until all the tests complete running. This puts unnecessary strain on the machine and contributes to test instability.

Expected Behavior

What should happen instead is that as soon as a test ends, regardless of the outcome, the DCP instance is allowed to do a graceful shutdown and has the opportunity to release all resources.

Steps To Reproduce

  1. Clone dotnet/Aspire-Samples GitHub repository
  2. Run build.cmd
  3. Run all tests
  4. Open Task Manager and observe dcp/dcpctrl instances piling up as the tests are executed.

Exceptions (if any)

No response

.NET Version info

No response

Anything else?

No response

DamianEdwards commented 3 weeks ago

What is the lifetime relationship between the app host process and the launched dcp processes today? Does the app host process request the shutdown of dcp, or does dcp monitor the launching process and shut itself down when the launching process ends?

karolz-ms commented 3 weeks ago

There is no good way for the app host process to request DCP shutdown, so the second part is true (dcp monitor the launching process and shut itself down when the launching process ends). Part of the fix for this will be to add a new type of request to DCP that will allow the (test) app host to say "I am done, please perform resource cleanup and shut yourself down".