Clean up distributed app builders to fix test failures#3093
Merged
Conversation
davidfowl
approved these changes
Mar 22, 2024
mitchdenny
approved these changes
Mar 22, 2024
radical
reviewed
Mar 22, 2024
| /// This class wraps the builder and provides a way to automatically dispose it to prevent test failures from excessive | ||
| /// FileSystemWatcher instances from many tests. | ||
| /// </summary> | ||
| public sealed class TestDistrubtedApplicationBuilder : IDisposable, IDistributedApplicationBuilder |
Member
There was a problem hiding this comment.
Suggested change
| public sealed class TestDistrubtedApplicationBuilder : IDisposable, IDistributedApplicationBuilder | |
| public sealed class TestDistributedApplicationBuilder : IDisposable, IDistributedApplicationBuilder |
radical
approved these changes
Mar 22, 2024
Merged
Member
|
Thanks for fixing this James! |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem:
DistributedApplicationBuilder.DistributedApplicationBuildercreatesHostApplicationBuilder.HostApplicationBuildercreates configuration, including aFileSystemWatcher.FileSystemWatcherhangs around until finalizer runs.There are many tests like this. Too many watchers exceeds a Linux limit and errors start.
Fix proposed here:
Have an internal method onDistributedApplicationBuilderto clean upHostApplicationBuilder's config. Tests will need to be updated to use it.Have a test helper typeBuilderContainerthat makes it easy to create and "dispose" builders.TestDistributedApplicationBuilderthat wraps an innerDistributedApplicationBuilder. It implements dispose, and disposing the test builder will create a host and then dispose it.Only tests inAWSCloudFormationResourceTestsare updated. All tests that create a builder but never create a host that is disposed will need to be changed.I updated the tests I could find that didn't build and dispose a host.
Microsoft Reviewers: Open in CodeFlow