diff options
author | valerijf <valerijf@yahoo-inc.com> | 2016-10-19 09:35:35 +0200 |
---|---|---|
committer | valerijf <valerijf@yahoo-inc.com> | 2016-10-19 09:35:35 +0200 |
commit | 622371dd3c024cec74f4867f7fd832cddd911e29 (patch) | |
tree | 9498c9273bdaa75ac6b3c3cf05df0cc42b845c6f /docker-api/src | |
parent | 4780bb4c5a3905438ea7c331cb0a587eb51c040a (diff) |
Fix failing docker test
Diffstat (limited to 'docker-api/src')
-rw-r--r-- | docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/DockerTestUtils.java | 26 | ||||
-rw-r--r-- | docker-api/src/test/java/com/yahoo/vespa/hosted/dockerapi/DockerTest.java | 2 |
2 files changed, 18 insertions, 10 deletions
diff --git a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/DockerTestUtils.java b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/DockerTestUtils.java index 87584e6e1fe..63f333af7ac 100644 --- a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/DockerTestUtils.java +++ b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/DockerTestUtils.java @@ -16,35 +16,41 @@ import java.util.concurrent.ExecutionException; public class DockerTestUtils { private static final OS operatingSystem = getSystemOS(); private static final String prefix = "/Users/" + System.getProperty("user.name") + "/.docker/machine/machines/default/"; - public static final DockerConfig dockerConfig = new DockerConfig(new DockerConfig.Builder() + private static final DockerConfig dockerConfig = new DockerConfig(new DockerConfig.Builder() .caCertPath( operatingSystem == OS.Mac_OS_X ? prefix + "ca.pem" : "") .clientCertPath(operatingSystem == OS.Mac_OS_X ? prefix + "cert.pem" : "") .clientKeyPath( operatingSystem == OS.Mac_OS_X ? prefix + "key.pem" : "") .uri( operatingSystem == OS.Mac_OS_X ? "tcp://192.168.99.100:2376" : "tcp://localhost:2376")); - + private static DockerImpl docker; public static boolean dockerDaemonIsPresent() { + if (docker != null) return true; if (operatingSystem == OS.Unsupported) { System.out.println("This test does not support " + System.getProperty("os.name") + " yet, ignoring test."); return false; } try { + getDocker(); // Will throw an exception if docker is not installed/incorrectly configured return true; } catch (Exception e) { - System.out.println("Please install Docker Toolbox and start Docker Quick Start Terminal once, ignoring test."); - e.printStackTrace(); + System.err.println("Please install Docker Toolbox and start Docker Quick Start Terminal once, ignoring test."); + System.err.println(e.getMessage()); return false; } } public static DockerImpl getDocker() { - return new DockerImpl( - dockerConfig, - false, /* fallback to 1.23 on errors */ - false, /* try setup network */ - 100 /* dockerConnectTimeoutMillis */, - new MetricReceiverWrapper(MetricReceiver.nullImplementation)); + if (docker == null) { + docker = new DockerImpl( + dockerConfig, + false, /* fallback to 1.23 on errors */ + false, /* try setup network */ + 100 /* dockerConnectTimeoutMillis */, + new MetricReceiverWrapper(MetricReceiver.nullImplementation)); + } + + return docker; } public static void createDockerTestNetworkIfNeeded(DockerImpl docker) { diff --git a/docker-api/src/test/java/com/yahoo/vespa/hosted/dockerapi/DockerTest.java b/docker-api/src/test/java/com/yahoo/vespa/hosted/dockerapi/DockerTest.java index 6b7dc7787a0..88541ef999e 100644 --- a/docker-api/src/test/java/com/yahoo/vespa/hosted/dockerapi/DockerTest.java +++ b/docker-api/src/test/java/com/yahoo/vespa/hosted/dockerapi/DockerTest.java @@ -58,6 +58,7 @@ public class DockerTest { assertFalse("Failed to delete " + dockerImage.asString() + " image", docker.imageIsDownloaded(dockerImage)); } + @Test public void testContainerCycle() throws IOException, InterruptedException, ExecutionException { ContainerName containerName = new ContainerName("foo"); docker.createContainerCommand(dockerImage, containerName, "hostName1").create(); @@ -82,6 +83,7 @@ public class DockerTest { assertThat(docker.getAllManagedContainers().isEmpty(), is(true)); } + @Test public void testDockerNetworking() throws InterruptedException, ExecutionException, IOException { String hostName1 = "docker10.test.yahoo.com"; String hostName2 = "docker11.test.yahoo.com"; |