-
Notifications
You must be signed in to change notification settings - Fork 586
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
Final container logs missing when disposing DistributedApplicationTestingBuilder
#8206
Open
1 task done
Comments
DistributedApplicationTestingBuilder
DistributedApplicationTestingBuilder
afscrome
added a commit
to afscrome/aspire
that referenced
this issue
Mar 30, 2025
Fixes dotnet#8206 Updated `DcpExecutor` to wait for log streams to fully flush during `StopAsync`, rather than immediately cancelling them. Log streams should shut down once the associated resource is shut down and the logs have been processed. Previous behaviour could cause logs from the very end of a process to be lost as the log streams could be shut down before the logs were forwarded from DCP to ILogger. This was particularly problematic for DistributedApplicationBuilderTests failing whilst waiting for a resource to enter a particular state as the final lines of error are usually the ones you want to work out why a container / executable exited / failed to start.
17 tasks
afscrome
added a commit
to afscrome/aspire
that referenced
this issue
Mar 30, 2025
Updated `DcpExecutor` to wait for log streams to fully flush during `StopAsync`, rather than immediately cancelling them. Log streams should shut down once the associated resource is shut down and the logs have been processed. Previous behaviour could cause logs from the very end of a process to be lost as the log streams could be shut down before the logs were forwarded from DCP to ILogger. This was particularly problematic for DistributedApplicationBuilderTests failing whilst waiting for a resource to enter a particular state as the final lines of error are usually the ones you want to work out why a container / executable exited / failed to start. Fixes dotnet#8206
afscrome
added a commit
to afscrome/aspire
that referenced
this issue
Mar 30, 2025
Updated `DcpExecutor` to wait for log streams to fully flush during `StopAsync`, rather than immediately cancelling them. Log streams should shut down once the associated resource is shut down and the logs have been processed. Previous behaviour could cause logs from the very end of a process to be lost as the log streams could be shut down before the logs were forwarded from DCP to ILogger. This was particularly problematic for DistributedApplicationBuilderTests failing whilst waiting for a resource to enter a particular state as the final lines of error are usually the ones you want to work out why a container / executable exited / failed to start. Fixes dotnet#8206
I think I need to have to abandon my PR as this will need changes in DCP - I couldn't find a way to trigger DCP to shutdown in a way that the app host could fully read the logs before DCP shut down. The test cases in the PR are still good though. |
Note to myself: see #8423 (comment) and following for thoughts on where the problem might be. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there an existing issue for this?
Describe the bug
When troubleshooting test failures with
DistributedApplicationTestingBuilder
I've been facing problems where I'm missing logs - I'll get a container move toFailedToStart
, but no output to go alongside it - which makes fixing the failure very tricky.After a bit of investigation, I worked out that by adding a
Task.Delay
after an exception (but before disposingDistributedApplicationTestingBuilder
), the logs would come through, so it seems likeDistributedApplicationTestingBuilder
needs to do some kind of log flushing before disposing itself.Expected Behavior
Test output should include all stdout/stderr output from the container that failed to start - particularly the very last lines as this likely contains details of the error you need to fix.
Steps To Reproduce
The following example starts a container which writes "Some Error" to standard output, and then exists with exit
1234
to cause the container to fail to start.Some Error
somewhere int he output (It is not there)Task.Delay()
and re-run the testSome Error
in the logsExceptions (if any)
Without the
Task.Delay
, you get the following outputIf you uncomment the
Task.Delay()
, you will then get the following additional output.NET Version info
9.2.0-preview.1.25163.7+543a7dada97c3ec6a7758e1ce876889fd005873a
Anything else?
No response
The text was updated successfully, but these errors were encountered: