Add tests around capturing logs from DistributedApplicationBuilder on failures#15266
Open
afscrome wants to merge 3 commits intomicrosoft:mainfrom
Open
Add tests around capturing logs from DistributedApplicationBuilder on failures#15266afscrome wants to merge 3 commits intomicrosoft:mainfrom
afscrome wants to merge 3 commits intomicrosoft:mainfrom
Conversation
… failures Note, some tests are commented that ought to pass, but don't due to various issues. - microsoft#13760 - microsoft#14262 - microsoft#10218 (comment) - microsoft#13756
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15266Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15266" |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds new test coverage to validate resource failure logging behavior for executable and container resources, ensuring stdout/stderr and common startup failures are surfaced via resource logging.
Changes:
- Add
ExecutableResourceFailureLoggingTeststo assert log forwarding when an executable exits immediately. - Add
ContainerResourceFailureLoggingTeststo assert log forwarding on common Docker startup failures (bad args/image/auth). - Include shared
AsyncTestHelpers.csinAspire.Hosting.Containers.Teststo enableDefaultTimeouthelpers.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| tests/Aspire.Hosting.Tests/ResourceFailureLoggingTests.cs | New executable-resource logging test and helper methods for collecting forwarded log lines |
| tests/Aspire.Hosting.Containers.Tests/ResourceFailureLoggingTests.cs | New container-resource logging tests for common failure scenarios and log extraction helper |
| tests/Aspire.Hosting.Containers.Tests/Aspire.Hosting.Containers.Tests.csproj | Adds shared AsyncTestHelpers compile include needed by new tests |
Comment on lines
+5
to
+8
| using Microsoft.AspNetCore.InternalTesting; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.Logging; | ||
| using Microsoft.Extensions.Logging.Testing; |
Comment on lines
+49
to
+61
| var container = builder.AddExecutable("pwsh", "pwsh", "") | ||
| .WithArgs("-Command", """ | ||
| Write-Host "Hello from Stdout" | ||
| [Console]::Error.WriteLine("Hello from Stderr") | ||
| """); | ||
| AddFakeLogging(container); | ||
|
|
||
| FakeLogCollector logCollector; | ||
| using (var app = builder.Build()) | ||
| { | ||
| logCollector = app.Services.GetFakeLogCollector(); | ||
| await app.StartAsync(cts.Token).DefaultTimeout(TestConstants.DefaultOrchestratorTestLongTimeout); | ||
| await app.ResourceNotifications.WaitForResourceAsync(container.Resource.Name, KnownResourceStates.Finished, cts.Token).DefaultTimeout(TestConstants.DefaultOrchestratorTestLongTimeout); |
| using Aspire.TestUtilities; | ||
| using Microsoft.AspNetCore.InternalTesting; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.Logging; |
Comment on lines
+156
to
+158
| var cts = CancellationTokenSource.CreateLinkedTokenSource(TestContext.Current.CancellationToken); | ||
| cts.CancelAfter(TimeSpan.FromMinutes(1)); | ||
| return cts; |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
075e00d to
da7dc57
Compare
adamint
reviewed
Mar 16, 2026
| [Fact] | ||
| [RequiresFeature(TestFeature.Docker)] | ||
| // https://github.com/dotnet/aspire/issues/13756 | ||
| public async Task IllegalBindMount() |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
This PR adds some test cases around making sure that logs get properly written on various resource failure cases. These have had a habit of workign fine one release, then breaking the next so adding these tests should help prevent regressions. (Or at least ensure changes are being made intentionally)
Note, some tests are commented that ought to pass, but don't due to other bugs:
FailedToStartif it starts then immediately exists #13760Fixes #14262
Checklist