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 for Windows: Use command-based port checker #309

Merged
merged 2 commits into from
Mar 12, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.testcontainers.containers.ContainerLaunchException;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.dockerclient.ProxiedUnixSocketClientProviderStrategy;
import org.testcontainers.dockerclient.WindowsClientProviderStrategy;

import java.net.Socket;
import java.util.List;
Expand All @@ -32,8 +33,7 @@ protected void waitUntilReady() {

Callable<Boolean> checkStrategy;

// Special case for Docker for Mac, see #160
if (isUsingSocketProxyOnMac()) {
if (isApplicable()) {
List<Integer> exposedPorts = container.getExposedPorts();

Integer exposedPort = exposedPorts.stream()
Expand Down Expand Up @@ -91,8 +91,18 @@ protected void waitUntilReady() {
}
}

private boolean isUsingSocketProxyOnMac() {
return DockerClientFactory.instance().isUsing(ProxiedUnixSocketClientProviderStrategy.class)
&& System.getProperty("os.name").toLowerCase().contains("mac");
private boolean isApplicable() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be named more clearly? Something like doesDockerPrematurelyListen or shouldApplyProxyWorkaround?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to shouldCheckWithCommand, but still not sure :) Does it sound fine to you? )

// Special case for Docker for Mac, see #160
if(DockerClientFactory.instance().isUsing(ProxiedUnixSocketClientProviderStrategy.class)
&& System.getProperty("os.name").toLowerCase().contains("mac")) {
return true;
}

// Special case for Docker for Windows, see #160
if (DockerClientFactory.instance().isUsing(WindowsClientProviderStrategy.class)) {
return true;
}

return false;
}
}