Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Testing] Populate AppHost environment from launch profile and support launch profile override #7363

Merged
merged 1 commit into from
Feb 1, 2025

Conversation

ReubenBond
Copy link
Member

Description

Fixes #5093

This PR simulates launch profile loading for the testing host. It does not mutate the process' environment since that could cause issues with concurrently running tests. Instead, it propagates the environment variables specified in the AppHost's launch profile to the AppHost's configuration.

This PR sets the DOTNET_LAUNCH_PROFILE environment variable to the name of the first launch profile if not overridden. It does not consider the DOTNET_LAUNCH_PROFILE from the test runner's environment.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • No
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?
    • No

Comment on lines 166 to 169
SetDefault("DcpPublisher:ContainerRuntimeInitializationTimeout", "00:00:30");
SetDefault("DcpPublisher:RandomizePorts", "true");
SetDefault("DcpPublisher:DeleteResourcesOnShutdown", "true");
SetDefault("DcpPublisher:ResourceNameSuffix", $"{Random.Shared.Next():x}");
Copy link
Member

Choose a reason for hiding this comment

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

We should consider making some of these first class.

Copy link
Member Author

Choose a reason for hiding this comment

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

Eg, by giving them a publicly accessible type or property? Agreed.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, file an issue for this one.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did a quick write-up #7365

@davidfowl davidfowl merged commit 84ca714 into main Feb 1, 2025
28 of 31 checks passed
@davidfowl davidfowl deleted the rebond/testing-launch-profiles branch February 1, 2025 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Aspire.Hosting.Testing should populate DOTNET_LAUNCH_PROFILE
2 participants