-
-
Notifications
You must be signed in to change notification settings - Fork 500
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
Verify Reaper state to create new or return existing instance #782
Merged
mdelapenya
merged 8 commits into
testcontainers:main
from
mdonkers:764-reaper-recreate-on-failure-or-exit
Jan 31, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
02a5664
Verify Reaper state to create new or return existing instance
d7bb01c
Merge branch 'main' into 764-reaper-recreate-on-failure-or-exit
mdonkers f880f40
Merge branch 'main' into 764-reaper-recreate-on-failure-or-exit
mdonkers 7ce945e
Merge branch 'main' into 764-reaper-recreate-on-failure-or-exit
mdonkers 9a660dc
Play nice with other integration tests
983e517
Rename reaperSingleton to reaperInstance
82b8372
Don't skip for short tests, always run
fb64671
Merge remote-tracking branch 'origin/main' into 764-reaper-recreate-o…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meanwhile the CI runs (tests will pass) can you elaborate a bit on this comment? Do you think that bool should be updated in consequence (probably here? in a follow-up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the
Container.IsRunning
is simply a boolean flag (testcontainers-go/docker.go
Line 63 in fb64671
testcontainers-go/docker.go
Line 233 in fb64671
Stop()
orTerminate()
methods. Instead, it terminates automatically by itself by closing the connection to it (testcontainers-go/docker.go
Line 241 in fb64671
Which makes the
IsRunning()
unreliable for the Reaper container as it would never returnfalse
.That's why I chose to poll Docker and get the state from there, as it should be reliable.
What I think would be better, is if the
IsRunning()
method (testcontainers-go/docker.go
Line 89 in fb64671
I did not want to touch this code in the PR because I don't know the history behind it. Perhaps
IsRunning
is regularly checked and would be relatively heavy on the Docker calls?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for such a clear explanation, now I see what you mean.
I think checking the state from Docker would be more accurate than the one we have now, and I understand your concerns about performance if that method is called many times. I've checked their usages and are just a few of them at this moment (particularly worried on the GenericContainer function calling it).
Adding that code, we could also take the situation to a place where multiple goroutines in tests are trying to read the container state at the same time, and one decides to see it as not running, and the next one as running, which could be worse.
I'd keep this simple as in your submission, and evaluate if we need to check for the state more frequently.