Repository: jclouds-labs Updated Branches: refs/heads/master 933f31b73 -> e3c6a6f5a
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/e3c6a6f5/docker/src/test/java/org/jclouds/docker/features/ContainerApiMockTest.java ---------------------------------------------------------------------- diff --git a/docker/src/test/java/org/jclouds/docker/features/ContainerApiMockTest.java b/docker/src/test/java/org/jclouds/docker/features/ContainerApiMockTest.java new file mode 100644 index 0000000..4bbff66 --- /dev/null +++ b/docker/src/test/java/org/jclouds/docker/features/ContainerApiMockTest.java @@ -0,0 +1,248 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.docker.features; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; +import java.util.List; + +import org.jclouds.docker.DockerApi; +import org.jclouds.docker.domain.Config; +import org.jclouds.docker.domain.Container; +import org.jclouds.docker.domain.ContainerSummary; +import org.jclouds.docker.internal.BaseDockerMockTest; +import org.jclouds.docker.options.ListContainerOptions; +import org.jclouds.rest.ResourceNotFoundException; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMultimap; +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; + +/** + * Mock tests for the {@link org.jclouds.docker.features.ContainerApi} class. + */ +@Test(groups = "unit", testName = "ContainerApiMockTest") +public class ContainerApiMockTest extends BaseDockerMockTest { + + public void testListContainers() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setBody(payloadFromResource("/containers.json"))); + + DockerApi dockerApi = api(server.getUrl("/")); + ContainerApi api = dockerApi.getContainerApi(); + + try { + List<ContainerSummary> containerSummaries = api.listContainers(); + assertRequestHasCommonFields(server.takeRequest(), "/containers/json"); + assertEquals(containerSummaries.size(), 1); + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testListNonexistentContainers() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + DockerApi dockerApi = api(server.getUrl("/")); + ContainerApi api = dockerApi.getContainerApi(); + try { + List<ContainerSummary> containerSummaries = api.listContainers(); + assertRequestHasCommonFields(server.takeRequest(), "/containers/json"); + assertTrue(containerSummaries.isEmpty()); + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + + @Test(timeOut = 10000l) + public void testListAllContainers() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setBody(payloadFromResource("/containers.json"))); + DockerApi dockerApi = api(server.getUrl("/")); + ContainerApi api = dockerApi.getContainerApi(); + try { + List<ContainerSummary> containerSummaries = api.listContainers(ListContainerOptions.Builder.all(true)); + assertRequestHasParameters(server.takeRequest(), "/containers/json", ImmutableMultimap.of("all", "true")); + assertEquals(containerSummaries.size(), 1); + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testGetContainer() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setBody(payloadFromResource("/container.json"))); + DockerApi dockerApi = api(server.getUrl("/")); + ContainerApi api = dockerApi.getContainerApi(); + String containerId = "b03d4cd15b76f8876110615cdeed15eadf77c9beb408d62f1687dcc69192cd6d"; + try { + Container container = api.inspectContainer(containerId); + assertRequestHasCommonFields(server.takeRequest(), "/containers/" + containerId + "/json"); + assertNotNull(container); + assertNotNull(container.id(), containerId); + assertNotNull(container.config()); + assertNotNull(container.hostConfig()); + assertTrue(container.name().contains("/weave")); + assertEquals(container.state().running(), true); + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testGetNonExistingContainer() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + DockerApi dockerApi = api(server.getUrl("/")); + ContainerApi api = dockerApi.getContainerApi(); + String containerId = "notExisting"; + try { + Container container = api.inspectContainer(containerId); + assertRequestHasCommonFields(server.takeRequest(), "/containers/" + containerId + "/json"); + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testCreateContainer() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setBody(payloadFromResource("/container-creation.json"))); + DockerApi dockerApi = api(server.getUrl("/")); + ContainerApi api = dockerApi.getContainerApi(); + Config containerConfig = Config.builder().cmd(ImmutableList.of("date")) + .attachStdin(false) + .attachStderr(true) + .attachStdout(true) + .tty(false) + .image("base") + .build(); + try { + Container container = api.createContainer("test", containerConfig); + assertRequestHasCommonFields(server.takeRequest(), "POST", "/containers/create?name=test"); + assertNotNull(container); + assertEquals(container.id(), "c6c74153ae4b1d1633d68890a68d89c40aa5e284a1ea016cbc6ef0e634ee37b2"); + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testRemoveContainer() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(204)); + DockerApi dockerApi = api(server.getUrl("/")); + ContainerApi api = dockerApi.getContainerApi(); + String containerId = "6d35806c1bd2b25cd92bba2d2c2c5169dc2156f53ab45c2b62d76e2d2fee14a9"; + + try { + api.removeContainer(containerId); + assertRequestHasCommonFields(server.takeRequest(), "DELETE", "/containers/" + containerId); + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testRemoveNonExistingContainer() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + DockerApi dockerApi = api(server.getUrl("/")); + ContainerApi api = dockerApi.getContainerApi(); + String containerId = "nonExisting"; + try { + api.removeContainer(containerId); + fail("Remove container must fail on 404"); + } catch (ResourceNotFoundException ex) { + // Expected exception + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testStartContainer() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(200)); + DockerApi dockerApi = api(server.getUrl("/")); + ContainerApi api = dockerApi.getContainerApi(); + try { + api.startContainer("1"); + assertRequestHasCommonFields(server.takeRequest(), "POST", "/containers/1/start"); + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testStartNonExistingContainer() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + DockerApi dockerApi = api(server.getUrl("/")); + ContainerApi api = dockerApi.getContainerApi(); + try { + try { + api.startContainer("1"); + fail("Start container must fail on 404"); + } catch (ResourceNotFoundException ex) { + // Expected exception + } + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testStopContainer() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(200)); + DockerApi dockerApi = api(server.getUrl("/")); + ContainerApi api = dockerApi.getContainerApi(); + try { + api.stopContainer("1"); + assertRequestHasCommonFields(server.takeRequest(), "POST", "/containers/1/stop"); + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testStopNonExistingContainer() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + DockerApi dockerApi = api(server.getUrl("/")); + ContainerApi api = dockerApi.getContainerApi(); + try { + api.stopContainer("1"); + fail("Stop container must fail on 404"); + } catch (ResourceNotFoundException ex) { + // Expected exception + } finally { + dockerApi.close(); + server.shutdown(); + } + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/e3c6a6f5/docker/src/test/java/org/jclouds/docker/features/ImageApiLiveTest.java ---------------------------------------------------------------------- diff --git a/docker/src/test/java/org/jclouds/docker/features/ImageApiLiveTest.java b/docker/src/test/java/org/jclouds/docker/features/ImageApiLiveTest.java new file mode 100644 index 0000000..a145417 --- /dev/null +++ b/docker/src/test/java/org/jclouds/docker/features/ImageApiLiveTest.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.docker.features; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; +import java.io.InputStream; + +import org.jclouds.docker.compute.BaseDockerApiLiveTest; +import org.jclouds.docker.options.CreateImageOptions; +import org.testng.annotations.Test; + +@Test(groups = "live", testName = "RemoteApiLiveTest", singleThreaded = true) +public class ImageApiLiveTest extends BaseDockerApiLiveTest { + + private static final String DEFAULT_IMAGE = "busybox"; + private static final String DEFAULT_TAG = "ubuntu-14.04"; + + @Test + public void testCreateImage() { + InputStream createImageStream = api().createImage(CreateImageOptions.Builder.fromImage(DEFAULT_IMAGE).tag(DEFAULT_TAG)); + consumeStream(createImageStream); + } + + @Test(dependsOnMethods = "testCreateImage") + public void testInspectImage() { + assertNotNull(api.getImageApi().inspectImage(String.format("%s:%s", DEFAULT_IMAGE, DEFAULT_TAG))); + } + + @Test(dependsOnMethods = "testInspectImage") + public void testListImages() { + assertNotNull(api().listImages()); + } + + @Test(dependsOnMethods = "testListImages") + public void testDeleteImage() { + consumeStream(api().deleteImage(String.format("%s:%s", DEFAULT_IMAGE, DEFAULT_TAG))); + assertNull(api().inspectImage(String.format("%s:%s", DEFAULT_IMAGE, DEFAULT_TAG))); + } + + private ImageApi api() { + return api.getImageApi(); + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/e3c6a6f5/docker/src/test/java/org/jclouds/docker/features/ImageApiMockTest.java ---------------------------------------------------------------------- diff --git a/docker/src/test/java/org/jclouds/docker/features/ImageApiMockTest.java b/docker/src/test/java/org/jclouds/docker/features/ImageApiMockTest.java new file mode 100644 index 0000000..7ad6414 --- /dev/null +++ b/docker/src/test/java/org/jclouds/docker/features/ImageApiMockTest.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.docker.features; + +import static org.testng.Assert.fail; + +import org.jclouds.docker.DockerApi; +import org.jclouds.docker.internal.BaseDockerMockTest; +import org.jclouds.docker.options.CreateImageOptions; +import org.jclouds.rest.ResourceNotFoundException; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMultimap; +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; + +/** + * Mock tests for the {@link org.jclouds.docker.features.ImageApi} class. + */ +@Test(groups = "unit", testName = "ImageApiMockTest") +public class ImageApiMockTest extends BaseDockerMockTest { + + public void testCreateImage() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(200)); + DockerApi dockerApi = api(server.getUrl("/")); + ImageApi api = dockerApi.getImageApi(); + try { + api.createImage(CreateImageOptions.Builder.fromImage("base")); + assertRequestHasParameters(server.takeRequest(), "POST", "/images/create", ImmutableMultimap.of("fromImage", "base")); + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testCreateImageFailure() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + DockerApi dockerApi = api(server.getUrl("/")); + ImageApi api = dockerApi.getImageApi(); + try { + api.createImage(CreateImageOptions.Builder.fromImage("base")); + fail("Create image must fail on 404"); + } catch (ResourceNotFoundException ex) { + // Expected exception + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testDeleteImage() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(204)); + DockerApi dockerApi = api(server.getUrl("/")); + ImageApi api = dockerApi.getImageApi(); + try { + api.deleteImage("1"); + assertRequestHasCommonFields(server.takeRequest(), "DELETE", "/images/1"); + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testDeleteNotExistingImage() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + DockerApi dockerApi = api(server.getUrl("/")); + ImageApi api = dockerApi.getImageApi(); + try { + api.deleteImage("1"); + fail("Delete image must fail on 404"); + } catch (ResourceNotFoundException ex) { + // Expected exception + } finally { + dockerApi.close(); + server.shutdown(); + } + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/e3c6a6f5/docker/src/test/java/org/jclouds/docker/features/MiscApiLiveTest.java ---------------------------------------------------------------------- diff --git a/docker/src/test/java/org/jclouds/docker/features/MiscApiLiveTest.java b/docker/src/test/java/org/jclouds/docker/features/MiscApiLiveTest.java new file mode 100644 index 0000000..b14a108 --- /dev/null +++ b/docker/src/test/java/org/jclouds/docker/features/MiscApiLiveTest.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.docker.features; + +import org.jclouds.docker.compute.BaseDockerApiLiveTest; +import org.jclouds.docker.options.BuildOptions; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import java.io.IOException; +import java.io.InputStream; +import java.net.URISyntaxException; + +import com.google.common.base.Splitter; +import com.google.common.collect.Iterables; + +@Test(groups = "live", testName = "MiscApiLiveTest", singleThreaded = true) +public class MiscApiLiveTest extends BaseDockerApiLiveTest { + + private static final String API_VERSION = "1.15"; + private static final String VERSION = "1.3.0"; + private static final String GIT_COMMIT = "c78088f"; + private static final String GO_VERSION = "go1.3.3"; + private static final String KERNEL_VERSION = "3.16.4-tinycore64"; + private static final String ARCH = "amd64"; + private static final String OS = "linux"; + + private static String imageId; + + @Test + public void testVersion() { + assertEquals(api().getVersion().apiVersion(), API_VERSION); + assertEquals(api().getVersion().version(), VERSION); + assertEquals(api().getVersion().gitCommit(), GIT_COMMIT); + assertEquals(api().getVersion().goVersion(), GO_VERSION); + assertEquals(api().getVersion().kernelVersion(), KERNEL_VERSION); + assertEquals(api().getVersion().arch(), ARCH); + assertEquals(api().getVersion().os(), OS); + } + + @Test + public void testInfo() { + assertNotNull(api().getInfo()); + } + + @Test + public void testBuildImageFromDockerfile() throws IOException, InterruptedException, URISyntaxException { + BuildOptions options = BuildOptions.Builder.tag("testBuildImage").verbose(false).nocache(false); + InputStream buildImageStream = api().build(tarredDockerfile(), options); + String buildStream = consumeStream(buildImageStream); + Iterable<String> splitted = Splitter.on("\n").split(buildStream.replace("\r", "").trim()); + String lastStreamedLine = Iterables.getLast(splitted).trim(); + String rawImageId = Iterables.getLast(Splitter.on("Successfully built ").split(lastStreamedLine)); + imageId = rawImageId.substring(0, 11); + assertNotNull(imageId); + } + + @AfterClass + protected void tearDown() { + if (imageId != null) { + consumeStream(api.getImageApi().deleteImage(imageId)); + } + } + + private MiscApi api() { + return api.getMiscApi(); + } + + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/e3c6a6f5/docker/src/test/java/org/jclouds/docker/features/MiscApiMockTest.java ---------------------------------------------------------------------- diff --git a/docker/src/test/java/org/jclouds/docker/features/MiscApiMockTest.java b/docker/src/test/java/org/jclouds/docker/features/MiscApiMockTest.java new file mode 100644 index 0000000..e7b1e5b --- /dev/null +++ b/docker/src/test/java/org/jclouds/docker/features/MiscApiMockTest.java @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.docker.features; + +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; +import org.jclouds.docker.DockerApi; +import org.jclouds.docker.domain.Info; +import org.jclouds.docker.domain.Version; +import org.jclouds.docker.internal.BaseDockerMockTest; +import org.jclouds.docker.options.BuildOptions; +import org.jclouds.io.Payload; +import org.jclouds.io.Payloads; +import org.jclouds.rest.ResourceNotFoundException; +import org.testng.annotations.Test; + +import static org.jclouds.docker.compute.BaseDockerApiLiveTest.tarredDockerfile; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.fail; +import java.io.File; +import java.io.FileInputStream; + +/** + * Mock tests for the {@link org.jclouds.docker.features.MiscApi} class. + */ +@Test(groups = "unit", testName = "MiscApiMockTest") +public class MiscApiMockTest extends BaseDockerMockTest { + + private static final String API_VERSION = "1.15"; + private static final String VERSION = "1.3.0"; + private static final String GIT_COMMIT = "c78088f"; + private static final String GO_VERSION = "go1.3.3"; + private static final String KERNEL_VERSION = "3.16.4-tinycore64"; + private static final String ARCH = "amd64"; + private static final String OS = "linux"; + + public void testGetVersion() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setBody(payloadFromResource("/version.json"))); + DockerApi dockerApi = api(server.getUrl("/")); + MiscApi api = dockerApi.getMiscApi(); + try { + Version version = api.getVersion(); + assertRequestHasCommonFields(server.takeRequest(), "/version"); + assertNotNull(version); + assertEquals(version.version(), VERSION); + assertEquals(version.gitCommit(), GIT_COMMIT); + assertEquals(version.apiVersion(), API_VERSION); + assertEquals(version.goVersion(), GO_VERSION); + assertEquals(version.kernelVersion(), KERNEL_VERSION); + assertEquals(version.arch(), ARCH); + assertEquals(version.os(), OS); + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testGetInfo() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setBody(payloadFromResource("/info.json"))); + DockerApi dockerApi = api(server.getUrl("/")); + MiscApi api = dockerApi.getMiscApi(); + + try { + Info info = api.getInfo(); + assertRequestHasCommonFields(server.takeRequest(), "/info"); + assertNotNull(info); + assertNotNull(info.containers()); + assertNotNull(info.debug()); + assertNotNull(info.driver()); + assertNotNull(info.executionDriver()); + assertNotNull(info.images()); + assertNotNull(info.indexServerAddress()); + assertNotNull(info.initPath()); + assertNotNull(info.iPv4Forwarding()); + assertNotNull(info.kernelVersion()); + assertNotNull(info.memoryLimit()); + assertNotNull(info.nEventsListener()); + assertNotNull(info.nFd()); + assertNotNull(info.nGoroutines()); + assertNotNull(info.swapLimit()); + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testBuildContainer() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(200)); + DockerApi dockerApi = api(server.getUrl("/")); + MiscApi api = dockerApi.getMiscApi(); + File dockerFile = File.createTempFile("docker", "tmp"); + try { + api.build(tarredDockerfile(), BuildOptions.NONE); + assertRequestHasCommonFields(server.takeRequest(), "POST", "/build"); + } finally { + dockerFile.delete(); + dockerApi.close(); + server.shutdown(); + } + } + + public void testBuildContainerUsingPayload() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(200)); + DockerApi dockerApi = api(server.getUrl("/")); + MiscApi api = dockerApi.getMiscApi(); + File file = File.createTempFile("docker", "tmp"); + FileInputStream data = new FileInputStream(file); + Payload payload = Payloads.newInputStreamPayload(data); + payload.getContentMetadata().setContentLength(file.length()); + + try { + api.build(payload, BuildOptions.NONE); + assertRequestHasCommonFields(server.takeRequest(), "POST", "/build"); + } finally { + dockerApi.close(); + server.shutdown(); + } + } + + public void testBuildNonexistentContainer() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + DockerApi dockerApi = api(server.getUrl("/")); + MiscApi api = dockerApi.getMiscApi(); + File dockerFile = File.createTempFile("docker", "tmp"); + try { + try { + api.build(tarredDockerfile(), BuildOptions.NONE); + fail("Build container must fail on 404"); + } catch (ResourceNotFoundException ex) { + // Expected exception + } + } finally { + dockerFile.delete(); + dockerApi.close(); + server.shutdown(); + } + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/e3c6a6f5/docker/src/test/java/org/jclouds/docker/features/RemoteApiLiveTest.java ---------------------------------------------------------------------- diff --git a/docker/src/test/java/org/jclouds/docker/features/RemoteApiLiveTest.java b/docker/src/test/java/org/jclouds/docker/features/RemoteApiLiveTest.java deleted file mode 100644 index 3f23212..0000000 --- a/docker/src/test/java/org/jclouds/docker/features/RemoteApiLiveTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.features; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.io.IOException; -import java.net.URISyntaxException; - -import org.jclouds.docker.compute.BaseDockerApiLiveTest; -import org.jclouds.docker.domain.Config; -import org.jclouds.docker.domain.Container; -import org.jclouds.docker.domain.Image; -import org.jclouds.docker.options.BuildOptions; -import org.jclouds.docker.options.CreateImageOptions; -import org.jclouds.docker.options.DeleteImageOptions; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -@Test(groups = "live", testName = "RemoteApiLiveTest", singleThreaded = true) -public class RemoteApiLiveTest extends BaseDockerApiLiveTest { - - private static final String BUSYBOX_IMAGE = "busybox"; - private Container container = null; - private Image image = null; - - @Test - public void testVersion() { - assertEquals(api().getVersion().version(), "1.0.0"); - } - - @Test(dependsOnMethods = "testVersion") - public void testCreateImage() throws IOException, InterruptedException { - CreateImageOptions options = CreateImageOptions.Builder.fromImage(BUSYBOX_IMAGE); - consumeStream(api().createImage(options)); - image = api().inspectImage(BUSYBOX_IMAGE); - assertNotNull(image); - } - - @Test(dependsOnMethods = "testCreateImage") - public void testListImages() { - assertNotNull(api().listImages()); - } - - @Test(dependsOnMethods = "testListImages") - public void testCreateContainer() throws IOException, InterruptedException { - Config containerConfig = Config.builder().image(image.id()) - .cmd(ImmutableList.of("/bin/sh", "-c", "while true; do echo hello world; sleep 1; done")) - .build(); - container = api().createContainer("testCreateContainer", containerConfig); - assertNotNull(container); - assertNotNull(container.id()); - } - - @Test(dependsOnMethods = "testCreateContainer") - public void testStartContainer() throws IOException, InterruptedException { - api().startContainer(container.id()); - assertTrue(api().inspectContainer(container.id()).state().running()); - } - - @Test(dependsOnMethods = "testStartContainer") - public void testStopContainer() { - api().stopContainer(container.id()); - assertFalse(api().inspectContainer(container.id()).state().running()); - } - - @Test(dependsOnMethods = "testStopContainer", expectedExceptions = NullPointerException.class) - public void testRemoveContainer() { - api().removeContainer(container.id()); - assertFalse(api().inspectContainer(container.id()).state().running()); - } - - @Test(dependsOnMethods = "testRemoveContainer", expectedExceptions = ResourceNotFoundException.class) - public void testDeleteImage() { - consumeStream(api().deleteImage(image.id())); - assertNull(api().inspectImage(image.id())); - } - - public void testBuildImage() throws IOException, InterruptedException, URISyntaxException { - BuildOptions options = BuildOptions.Builder.tag("testBuildImage").verbose(false).nocache(false); - String buildStream = consumeStream(api().build(tarredDockerfile(), options)); - Iterable<String> splitted = Splitter.on("\n").split(buildStream.replace("\r", "").trim()); - String lastStreamedLine = Iterables.getLast(splitted).trim(); - String rawImageId = Iterables.getLast(Splitter.on("Successfully built ").split(lastStreamedLine)); - String imageId = rawImageId.substring(0, 11); - Image image = api().inspectImage(imageId); - api().deleteImage(image.id(), DeleteImageOptions.Builder.force(true)); - } - - private RemoteApi api() { - return api.getRemoteApi(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/e3c6a6f5/docker/src/test/java/org/jclouds/docker/features/RemoteApiMockTest.java ---------------------------------------------------------------------- diff --git a/docker/src/test/java/org/jclouds/docker/features/RemoteApiMockTest.java b/docker/src/test/java/org/jclouds/docker/features/RemoteApiMockTest.java deleted file mode 100644 index b164c7b..0000000 --- a/docker/src/test/java/org/jclouds/docker/features/RemoteApiMockTest.java +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.docker.features; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMultimap; -import com.squareup.okhttp.mockwebserver.MockResponse; -import com.squareup.okhttp.mockwebserver.MockWebServer; -import org.jclouds.docker.DockerApi; -import org.jclouds.docker.domain.Config; -import org.jclouds.docker.domain.Container; -import org.jclouds.docker.internal.BaseDockerMockTest; -import org.jclouds.docker.options.BuildOptions; -import org.jclouds.docker.options.CreateImageOptions; -import org.jclouds.docker.options.ListContainerOptions; -import org.jclouds.io.Payload; -import org.jclouds.io.Payloads; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -import java.io.File; -import java.io.FileInputStream; -import java.util.Set; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -/** - * Mock tests for the {@link org.jclouds.docker.DockerApi} class. - */ -@Test(groups = "unit", testName = "RemoteApiMockTest") -public class RemoteApiMockTest extends BaseDockerMockTest { - - public void testListContainers() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setBody(payloadFromResource("/containers.json"))); - - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - - try { - Set<Container> containers = remoteApi.listContainers(); - assertRequestHasCommonFields(server.takeRequest(), "/containers/json"); - assertEquals(containers.size(), 1); - } finally { - api.close(); - server.shutdown(); - } - } - - public void testListNonexistentContainers() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - - try { - Set<Container> containers = remoteApi.listContainers(); - assertRequestHasCommonFields(server.takeRequest(), "/containers/json"); - assertTrue(containers.isEmpty()); - } finally { - api.close(); - server.shutdown(); - } - } - - - @Test(timeOut = 10000l) - public void testListAllContainers() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setBody(payloadFromResource("/containers.json"))); - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - try { - Set<Container> containers = remoteApi.listContainers(ListContainerOptions.Builder.all(true)); - assertRequestHasParameters(server.takeRequest(), "/containers/json", ImmutableMultimap.of("all", "true")); - assertEquals(containers.size(), 1); - } finally { - api.close(); - server.shutdown(); - } - } - - public void testGetContainer() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setBody(payloadFromResource("/container.json"))); - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - String containerId = "b03d4cd15b76f8876110615cdeed15eadf77c9beb408d62f1687dcc69192cd6d"; - try { - Container container = remoteApi.inspectContainer(containerId); - assertRequestHasCommonFields(server.takeRequest(), "/containers/" + containerId + "/json"); - assertNotNull(container); - assertNotNull(container.id(), containerId); - assertNotNull(container.config()); - assertNotNull(container.hostConfig()); - assertEquals(container.name(), "/tender_lumiere"); - assertEquals(container.state().running(), true); - } finally { - api.close(); - server.shutdown(); - } - } - - public void testGetNonExistingContainer() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - String containerId = "notExisting"; - try { - remoteApi.inspectContainer(containerId); - assertRequestHasCommonFields(server.takeRequest(), "/containers/" + containerId + "/json"); - } finally { - api.close(); - server.shutdown(); - } - } - - public void testCreateContainer() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setBody(payloadFromResource("/container-creation.json"))); - - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - Config containerConfig = Config.builder().cmd(ImmutableList.of("date")) - .attachStdin(false) - .attachStderr(true) - .attachStdout(true) - .tty(false) - .image("base") - .build(); - try { - Container container = remoteApi.createContainer("test", containerConfig); - assertRequestHasCommonFields(server.takeRequest(), "POST", "/containers/create?name=test"); - assertNotNull(container); - assertEquals(container.id(), "c6c74153ae4b1d1633d68890a68d89c40aa5e284a1ea016cbc6ef0e634ee37b2"); - } finally { - api.close(); - server.shutdown(); - } - } - - public void testRemoveContainer() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(204)); - - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - String containerId = "6d35806c1bd2b25cd92bba2d2c2c5169dc2156f53ab45c2b62d76e2d2fee14a9"; - - try { - remoteApi.removeContainer(containerId); - assertRequestHasCommonFields(server.takeRequest(), "DELETE", "/containers/" + containerId); - } finally { - api.close(); - server.shutdown(); - } - } - - public void testRemoveNonExistingContainer() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - String containerId = "nonExisting"; - try { - remoteApi.removeContainer(containerId); - fail("Remove container must fail on 404"); - } catch (ResourceNotFoundException ex) { - // Expected exception - } finally { - api.close(); - server.shutdown(); - } - } - - public void testStartContainer() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(200)); - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - try { - remoteApi.startContainer("1"); - assertRequestHasCommonFields(server.takeRequest(), "POST", "/containers/1/start"); - } finally { - api.close(); - server.shutdown(); - } - } - - public void testStartNonExistingContainer() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - try { - try { - remoteApi.startContainer("1"); - fail("Start container must fail on 404"); - } catch (ResourceNotFoundException ex) { - // Expected exception - } - } finally { - api.close(); - server.shutdown(); - } - } - - public void testStopContainer() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(200)); - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - try { - remoteApi.stopContainer("1"); - assertRequestHasCommonFields(server.takeRequest(), "POST", "/containers/1/stop"); - } finally { - api.close(); - server.shutdown(); - } - } - - public void testStopNonExistingContainer() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - try { - remoteApi.stopContainer("1"); - fail("Stop container must fail on 404"); - } catch (ResourceNotFoundException ex) { - // Expected exception - } finally { - api.close(); - server.shutdown(); - } - } - - public void testCreateImage() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(200)); - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - try { - remoteApi.createImage(CreateImageOptions.Builder.fromImage("base")); - assertRequestHasParameters(server.takeRequest(), "POST", "/images/create", ImmutableMultimap.of("fromImage", - "base")); - } finally { - api.close(); - server.shutdown(); - } - } - - public void testCreateImageFailure() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - try { - remoteApi.createImage(CreateImageOptions.Builder.fromImage("base")); - fail("Create image must fail on 404"); - } catch (ResourceNotFoundException ex) { - // Expected exception - } finally { - api.close(); - server.shutdown(); - } - } - - public void testDeleteImage() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(204)); - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - try { - remoteApi.deleteImage("1"); - assertRequestHasCommonFields(server.takeRequest(), "DELETE", "/images/1"); - } finally { - api.close(); - server.shutdown(); - } - } - - public void testDeleteNotExistingImage() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(404)); - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - try { - remoteApi.deleteImage("1"); - fail("Delete image must fail on 404"); - } catch (ResourceNotFoundException ex) { - // Expected exception - } finally { - api.close(); - server.shutdown(); - } - } - - public void testBuildContainerUsingPayload() throws Exception { - MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(200)); - DockerApi api = api(server.getUrl("/")); - RemoteApi remoteApi = api.getRemoteApi(); - - File file = File.createTempFile("docker", "tmp"); - FileInputStream data = new FileInputStream(file); - Payload payload = Payloads.newInputStreamPayload(data); - payload.getContentMetadata().setContentLength(file.length()); - - try { - remoteApi.build(payload, BuildOptions.NONE); - assertRequestHasCommonFields(server.takeRequest(), "POST", "/build"); - } finally { - api.close(); - server.shutdown(); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/e3c6a6f5/docker/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java ---------------------------------------------------------------------- diff --git a/docker/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java b/docker/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java index 146b2a0..efdc9b5 100644 --- a/docker/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java +++ b/docker/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java @@ -58,8 +58,8 @@ public class BaseDockerMockTest { return ContextBuilder.newBuilder(provider) .credentials("clientid", "apikey") .endpoint(url.toString()) - .modules(modules) - .overrides(setupProperties()) + .modules(modules) + .overrides(setupProperties()) .buildApi(DockerApi.class); } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/e3c6a6f5/docker/src/test/resources/Dockerfile ---------------------------------------------------------------------- diff --git a/docker/src/test/resources/Dockerfile b/docker/src/test/resources/Dockerfile index 1318715..3c3b30e 100644 --- a/docker/src/test/resources/Dockerfile +++ b/docker/src/test/resources/Dockerfile @@ -14,16 +14,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # +FROM ubuntu:14.04 +MAINTAINER Sven Dowideit <[email protected]> -FROM centos:6.4 -MAINTAINER Andrea Turli <[email protected]> +RUN apt-get update && apt-get install -y openssh-server +RUN mkdir /var/run/sshd +RUN echo 'root:screencast' | chpasswd +RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config -# RUN yum -y groupinstall 'Development Tools' -RUN yum -y install openssh-server openssh-clients +# SSH login fix. Otherwise user is kicked off after login +RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd -RUN chkconfig sshd on -RUN service sshd start -RUN echo 'root:password' | chpasswd +ENV NOTVISIBLE "in users profile" +RUN echo "export VISIBLE=now" >> /etc/profile EXPOSE 22 CMD ["/usr/sbin/sshd", "-D"] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/e3c6a6f5/docker/src/test/resources/SimpleDockerfile ---------------------------------------------------------------------- diff --git a/docker/src/test/resources/SimpleDockerfile b/docker/src/test/resources/SimpleDockerfile new file mode 100644 index 0000000..ecce563 --- /dev/null +++ b/docker/src/test/resources/SimpleDockerfile @@ -0,0 +1,18 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +FROM scratch \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/e3c6a6f5/docker/src/test/resources/container.json ---------------------------------------------------------------------- diff --git a/docker/src/test/resources/container.json b/docker/src/test/resources/container.json index 839abb6..1356e9f 100644 --- a/docker/src/test/resources/container.json +++ b/docker/src/test/resources/container.json @@ -1,81 +1,129 @@ { - "Args": [ - "-c", - "yum -y install openssh-server openssh-clients" - ], - "Config": { - "AttachStderr": false, - "AttachStdin": false, - "AttachStdout": false, - "Cmd": [ - "/bin/sh", - "-c", - "yum -y install openssh-server openssh-clients" + "Args": [ + "-iface", + "ethwe", + "-wait", + "5", + "-name", + "7a:63:a2:39:7b:0f" ], - "CpuShares": 0, - "Cpuset": "", - "Domainname": "", - "Entrypoint": [ "/usr/bin/sshd", "-d" ], - "Env": [ - "HOME=/", - "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" - ], - "ExposedPorts": null, - "Hostname": "9088c45a9592", - "Image": "1e2d12a45cd57ae3fe3c31ede149d800aaf6a711c61646fad340080f531775c8", - "Memory": 0, - "MemorySwap": 0, - "NetworkDisabled": false, - "OnBuild": [], - "OpenStdin": false, - "PortSpecs": null, - "StdinOnce": false, - "Tty": false, - "User": "", - "Volumes": null, - "WorkingDir": "" - }, - "Created": "2014-06-18T08:49:25.36448943Z", - "Driver": "aufs", - "ExecDriver": "native-0.2", - "HostConfig": { - "Binds": null, - "ContainerIDFile": "", - "Dns": null, - "DnsSearch": null, - "Links": null, - "LxcConf": null, - "NetworkMode": "", - "PortBindings": null, - "Privileged": false, - "PublishAllPorts": false, - "VolumesFrom": null - }, - "HostnamePath": "/mnt/sda1/var/lib/docker/containers/be1d295c091720abc9a3105219ab75a0a7367d74156cc6048aa599fcc7d650e2/hostname", - "HostsPath": "/mnt/sda1/var/lib/docker/containers/be1d295c091720abc9a3105219ab75a0a7367d74156cc6048aa599fcc7d650e2/hosts", - "Id": "be1d295c091720abc9a3105219ab75a0a7367d74156cc6048aa599fcc7d650e2", - "Image": "1e2d12a45cd57ae3fe3c31ede149d800aaf6a711c61646fad340080f531775c8", - "MountLabel": "", - "Name": "/tender_lumiere", - "NetworkSettings": { - "Bridge": "docker0", - "Gateway": "172.17.42.1", - "IPAddress": "172.17.0.100", - "IPPrefixLen": 16, - "PortMapping": null, - "Ports": {} - }, - "Path": "/bin/sh", - "ProcessLabel": "", - "ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/be1d295c091720abc9a3105219ab75a0a7367d74156cc6048aa599fcc7d650e2/resolv.conf", - "State": { - "ExitCode": 0, - "FinishedAt": "0001-01-01T00:00:00Z", - "Paused": false, - "Pid": 16422, - "Running": true, - "StartedAt": "2014-06-18T08:49:25.63685385Z" - }, - "Volumes": {}, - "VolumesRW": {} + "Config": { + "AttachStderr": false, + "AttachStdin": false, + "AttachStdout": false, + "Cmd": [ + "-name", + "7a:63:a2:39:7b:0f" + ], + "CpuShares": 0, + "Cpuset": "", + "Domainname": "", + "Entrypoint": [ + "/home/weave/weaver", + "-iface", + "ethwe", + "-wait", + "5" + ], + "Env": [ + "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + ], + "ExposedPorts": { + "6783/tcp": {}, + "6783/udp": {} + }, + "Hostname": "6c9932f478bd", + "Image": "zettio/weave", + "Memory": 0, + "MemorySwap": 0, + "NetworkDisabled": false, + "OnBuild": null, + "OpenStdin": false, + "PortSpecs": null, + "SecurityOpt": null, + "StdinOnce": false, + "Tty": false, + "User": "", + "Volumes": null, + "WorkingDir": "/home/weave" + }, + "Created": "2014-10-31T17:00:21.544197943Z", + "Driver": "aufs", + "ExecDriver": "native-0.2", + "HostConfig": { + "Binds": null, + "CapAdd": null, + "CapDrop": null, + "ContainerIDFile": "", + "Devices": [], + "Dns": null, + "DnsSearch": null, + "ExtraHosts": null, + "Links": null, + "LxcConf": [], + "NetworkMode": "bridge", + "PortBindings": { + "6783/tcp": [ + { + "HostIp": "", + "HostPort": "6783" + } + ], + "6783/udp": [ + { + "HostIp": "", + "HostPort": "6783" + } + ] + }, + "Privileged": true, + "PublishAllPorts": false, + "RestartPolicy": { + "MaximumRetryCount": 0, + "Name": "" + }, + "VolumesFrom": null + }, + "HostnamePath": "/var/lib/docker/containers/6c9932f478bd761f32ddb54ed28ab42ab6fac6f2a279f561ea31503ee9d39524/hostname", + "HostsPath": "/var/lib/docker/containers/6c9932f478bd761f32ddb54ed28ab42ab6fac6f2a279f561ea31503ee9d39524/hosts", + "Id": "6c9932f478bd761f32ddb54ed28ab42ab6fac6f2a279f561ea31503ee9d39524", + "Image": "57e570db16baba1e8c0d6f3c15868ddb400f64ff76ec948e65c3ca3f15fb3587", + "MountLabel": "", + "Name": "/weave", + "NetworkSettings": { + "Bridge": "docker0", + "Gateway": "172.17.42.1", + "IPAddress": "172.17.0.7", + "IPPrefixLen": 16, + "MacAddress": "02:42:ac:11:00:07", + "PortMapping": null, + "Ports": { + "6783/tcp": [ + { + "HostIp": "0.0.0.0", + "HostPort": "6783" + } + ], + "6783/udp": [ + { + "HostIp": "0.0.0.0", + "HostPort": "6783" + } + ] + } + }, + "Path": "/home/weave/weaver", + "ProcessLabel": "", + "ResolvConfPath": "/var/lib/docker/containers/6c9932f478bd761f32ddb54ed28ab42ab6fac6f2a279f561ea31503ee9d39524/resolv.conf", + "State": { + "ExitCode": 0, + "FinishedAt": "0001-01-01T00:00:00Z", + "Paused": false, + "Pid": 3939, + "Restarting": false, + "Running": true, + "StartedAt": "2014-10-31T17:00:21.802008706Z" + }, + "Volumes": {}, + "VolumesRW": {} } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/e3c6a6f5/docker/src/test/resources/info.json ---------------------------------------------------------------------- diff --git a/docker/src/test/resources/info.json b/docker/src/test/resources/info.json new file mode 100644 index 0000000..6697993 --- /dev/null +++ b/docker/src/test/resources/info.json @@ -0,0 +1,28 @@ +{ + "Containers": 0, + "Debug": 1, + "Driver": "aufs", + "DriverStatus": [ + [ + "Root Dir", + "/mnt/sda1/var/lib/docker/aufs" + ], + [ + "Dirs", + "15" + ] + ], + "ExecutionDriver": "native-0.2", + "IPv4Forwarding": 1, + "Images": 15, + "IndexServerAddress": "https://index.docker.io/v1/", + "InitPath": "/usr/local/bin/docker", + "InitSha1": "", + "KernelVersion": "3.16.4-tinycore64", + "MemoryLimit": 1, + "NEventsListener": 0, + "NFd": 10, + "NGoroutines": 11, + "OperatingSystem": "Boot2Docker 1.3.0 (TCL 5.4); master : a083df4 - Thu Oct 16 17:05:03 UTC 2014", + "SwapLimit": 1 +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/e3c6a6f5/docker/src/test/resources/version.json ---------------------------------------------------------------------- diff --git a/docker/src/test/resources/version.json b/docker/src/test/resources/version.json new file mode 100644 index 0000000..53706b7 --- /dev/null +++ b/docker/src/test/resources/version.json @@ -0,0 +1,9 @@ +{ + "ApiVersion": "1.15", + "Arch": "amd64", + "GitCommit": "c78088f", + "GoVersion": "go1.3.3", + "KernelVersion": "3.16.4-tinycore64", + "Os": "linux", + "Version": "1.3.0" +} \ No newline at end of file
