Further cleanup the GetContainerId logic for tests#9481
Merged
danegsta merged 1 commit intomicrosoft:mainfrom May 23, 2025
Merged
Further cleanup the GetContainerId logic for tests#9481danegsta merged 1 commit intomicrosoft:mainfrom
danegsta merged 1 commit intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors container ID retrieval in functional tests to improve reliability by centralizing the wait-for-healthy and container ID check into an async helper.
- Introduces
GetContainerIdAsynclocal functions that await both resource health and the presence ofcontainer.id. - Updates Postgres and MySQL tests to call
GetContainerIdAsyncinstead of manually awaiting health. - Removes redundant
WaitForResourceHealthyAsynccalls in each test and consolidates the logic.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/Aspire.Hosting.PostgreSQL.Tests/PostgresFunctionalTests.cs | Replaced manual health waits with GetContainerIdAsync calls |
| tests/Aspire.Hosting.MySql.Tests/MySqlFunctionalTests.cs | Swapped in GetContainerIdAsync, removed explicit health waits |
Comments suppressed due to low confidence (2)
tests/Aspire.Hosting.MySql.Tests/MySqlFunctionalTests.cs:587
- Remove the extra semicolon at the end of this line to avoid redundant syntax.
var phpMyAdminId = await GetContainerIdAsync(rns, "phpmyadmin", cts.Token);;
tests/Aspire.Hosting.MySql.Tests/MySqlFunctionalTests.cs:589
- Consider adding a timeout to
WaitAsync(e.g.,.WaitAsync(TimeSpan.FromMinutes(1), cts.Token)) to prevent the test from hanging indefinitely and align with the PostgreSQL tests.
await app.StopAsync(cts.Token).WaitAsync(cts.Token);
mitchdenny
approved these changes
May 23, 2025
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.
Description
Make tests that look for container ID more reliable against slight timing issues in healthy status and container ID being updated.