-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Combine DB container tests into single module, and improve error handling/display #243
Conversation
184b690
to
1ce1d9f
Compare
@@ -815,6 +815,10 @@ public ExecResult execInContainer(Charset outputCharset, String... command) | |||
|
|||
} | |||
|
|||
if (!isRunning()) { |
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.
nice catch!
@@ -67,6 +68,8 @@ public void registerContainerForCleanup(String containerId, String imageName) { | |||
*/ | |||
public void stopAndRemoveContainer(String containerId) { | |||
stopContainer(containerId, registeredContainers.get(containerId)); | |||
|
|||
registeredContainers.remove(containerId); |
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.
maybe we should do it in finally {}
block?
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.
Actually even though it's a little brittle I'd prefer to keep it that way. If stopContainer
fails for some reason, my feeling is that it's slightly better to potentially try again by leaving the containerId in the registered set.
@@ -83,6 +86,13 @@ public void stopAndRemoveContainer(String containerId, String imageName) { | |||
|
|||
private void stopContainer(String containerId, String imageName) { | |||
|
|||
List<Container> allContainers = dockerClient.listContainersCmd().withShowAll(true).exec(); | |||
|
|||
if (allContainers.stream().noneMatch(it -> it.getId().equals(containerId))) { |
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.
just FYI:
allContainers.stream().map(Container::getId).noneMatch(containerId::equals)
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.
Nice 😁
@@ -106,6 +116,13 @@ private void stopContainer(String containerId, String imageName) { | |||
} | |||
|
|||
try { | |||
InspectContainerResponse containerInfo = dockerClient.inspectContainerCmd(containerId).exec(); |
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.
we don't use containerInfo
anywhere
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.
Yep, will remove
4164e57
to
381d9c7
Compare
…r refactoring of common elements. Adopt MySQL and MariaDB default configuration with lighter resource requirements
…o enable them to be volume mounted into containers.
…path resources that have been extracted from JAR files.
* ensure that liveness `exec` calls don't fire when a container is not running * check that containers exist before trying to clean up in ResourceReaper * filter out common ANSI control code in stderr output * amend frame consumer result callback to suppress errors
…when DB containers are slow to start
a29d49e
to
408e983
Compare
This PR was created on top of #242, and should be merged after that.This change includes what was previously covered by #242: Refactoring of all DB container tests into a single separate module. The idea is that this will make it easier to reduce duplication between tests in the future. Along the way, some reliability issues with DB containers have been worked on:
This also goes through a few places where unnecessary stack traces or errors were indicated during tests. It emerged that some behaviour (container reaper and exec-based liveness checks) were running against stopped or deleted containers, causing loud error logging from docker-java.