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

Docker.DotNet.Tests.ISystemOperationsTests.MonitorEventsAsync_Succeeds test fails #502

Open
Emdot opened this issue Feb 27, 2021 · 0 comments

Comments

@Emdot
Copy link
Contributor

Emdot commented Feb 27, 2021

Steps to reproduce the issue:

  1. Submit a PR
  2. Sometimes the CI build fails

What actually happened?:
Test case fails despite no changes to relevant code. See https://github.com/dotnet/Docker.DotNet/pull/496/checks?check_run_id=1992119140 for an example.

What did you expect to happen?:
Test case passes.

Additional information:
I see that this is a known bug in the test case. "// On CI/CD Pipeline exception is thrown, not always"

I think there's more of a problem here than I'm willing to fix:

  1. It looks like the event streams are delayed. Some of the events from CreateImageAsync don't arrive until after MonitorEventsAsync starts, so they show up in _onJSONMessageCalled. Some of the events from TagImageAsync don't arrive until after the assertion.
  2. I can't be sure that that's what's happening, since stdio might be buffered too. Adding some Console.Out.Flush and Console.Error.Flush calls between commands can help check for that.
  3. This probably isn't what's going wrong in this case, but it's a bug anyway: Using MonitorEventsAsync this way has a race condition. Unless you await MonitorEventsAsync's Task, you can't guarantee that the monitoring has started, so you can miss messages. The fix would is to replace MonitorEventsAsync with something like StartEventMonitorAsync that returns a subscription.
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

No branches or pull requests

1 participant