Search in sources :

Example 1 with ConfigSpec

use of com.spotify.docker.client.messages.swarm.ConfigSpec in project docker-client by spotify.

the class DefaultDockerClientUnitTest method testUpdateConfig_NotFound.

@Test(expected = NotFoundException.class)
public void testUpdateConfig_NotFound() throws Exception {
    final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
    enqueueServerApiVersion("1.30");
    server.enqueue(new MockResponse().setResponseCode(404).addHeader("Content-Type", "application/json"));
    final ConfigSpec configSpec = ConfigSpec.builder().data(Base64.encodeAsString("foobar")).name("foo.yaml").build();
    dockerClient.updateConfig("ktnbjxoalbkvbvedmg1urrz8h", 11L, configSpec);
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) ConfigSpec(com.spotify.docker.client.messages.swarm.ConfigSpec) Test(org.junit.Test)

Example 2 with ConfigSpec

use of com.spotify.docker.client.messages.swarm.ConfigSpec in project docker-client by spotify.

the class DefaultDockerClientUnitTest method testCreateConfig_ConflictingName.

@Test(expected = ConflictException.class)
public void testCreateConfig_ConflictingName() throws Exception {
    final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
    enqueueServerApiVersion("1.30");
    server.enqueue(new MockResponse().setResponseCode(409).addHeader("Content-Type", "application/json"));
    final ConfigSpec configSpec = ConfigSpec.builder().data(Base64.encodeAsString("foobar")).name("foo.yaml").build();
    dockerClient.createConfig(configSpec);
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) ConfigSpec(com.spotify.docker.client.messages.swarm.ConfigSpec) Test(org.junit.Test)

Example 3 with ConfigSpec

use of com.spotify.docker.client.messages.swarm.ConfigSpec in project docker-client by spotify.

the class DefaultDockerClientUnitTest method testInspectConfig.

@Test
public void testInspectConfig() throws Exception {
    final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
    enqueueServerApiVersion("1.30");
    server.enqueue(new MockResponse().setResponseCode(200).addHeader("Content-Type", "application/json").setBody(fixture("fixtures/1.30/inspectConfig.json")));
    final Config config = dockerClient.inspectConfig("ktnbjxoalbkvbvedmg1urrz8h");
    assertThat(config, notNullValue());
    assertThat(config.id(), equalTo("ktnbjxoalbkvbvedmg1urrz8h"));
    assertThat(config.version().index(), equalTo(11L));
    final ConfigSpec configSpec = config.configSpec();
    assertThat(configSpec.name(), equalTo("app-dev.crt"));
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) HostConfig(com.spotify.docker.client.messages.HostConfig) ContainerConfig(com.spotify.docker.client.messages.ContainerConfig) EngineConfig(com.spotify.docker.client.messages.swarm.EngineConfig) Config(com.spotify.docker.client.messages.swarm.Config) ConfigSpec(com.spotify.docker.client.messages.swarm.ConfigSpec) Test(org.junit.Test)

Example 4 with ConfigSpec

use of com.spotify.docker.client.messages.swarm.ConfigSpec in project docker-client by spotify.

the class DefaultDockerClientUnitTest method testUpdateConfig_NonSwarmNode.

@Test(expected = NonSwarmNodeException.class)
public void testUpdateConfig_NonSwarmNode() throws Exception {
    final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
    enqueueServerApiVersion("1.30");
    server.enqueue(new MockResponse().setResponseCode(503).addHeader("Content-Type", "application/json"));
    final ConfigSpec configSpec = ConfigSpec.builder().data(Base64.encodeAsString("foobar")).name("foo.yaml").build();
    dockerClient.updateConfig("ktnbjxoalbkvbvedmg1urrz8h", 11L, configSpec);
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) ConfigSpec(com.spotify.docker.client.messages.swarm.ConfigSpec) Test(org.junit.Test)

Example 5 with ConfigSpec

use of com.spotify.docker.client.messages.swarm.ConfigSpec in project docker-client by spotify.

the class DefaultDockerClientUnitTest method testCreateServiceWithConfig.

@Test
public void testCreateServiceWithConfig() throws Exception {
    final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
    // build() calls /version to check what format of header to send
    enqueueServerApiVersion("1.30");
    enqueueServerApiResponse(201, "fixtures/1.30/configCreateResponse.json");
    final ConfigSpec configSpec = ConfigSpec.builder().data(Base64.encodeAsString("foobar")).name("foo.yaml").build();
    final ConfigCreateResponse configCreateResponse = dockerClient.createConfig(configSpec);
    assertThat(configCreateResponse.id(), equalTo("ktnbjxoalbkvbvedmg1urrz8h"));
    final ConfigBind configBind = ConfigBind.builder().configName(configSpec.name()).configId(configCreateResponse.id()).file(ConfigFile.builder().gid("1000").uid("1000").mode(600L).name(configSpec.name()).build()).build();
    final TaskSpec taskSpec = TaskSpec.builder().containerSpec(ContainerSpec.builder().image("this_image_is_found_in_the_registry").configs(ImmutableList.of(configBind)).build()).build();
    final ServiceSpec spec = ServiceSpec.builder().name("test").taskTemplate(taskSpec).build();
    enqueueServerApiVersion("1.30");
    enqueueServerApiResponse(201, "fixtures/1.30/createServiceResponse.json");
    final ServiceCreateResponse response = dockerClient.createService(spec);
    assertThat(response.id(), equalTo("ak7w3gjqoa3kuz8xcpnyy0pvl"));
}
Also used : ConfigBind(com.spotify.docker.client.messages.swarm.ConfigBind) TaskSpec(com.spotify.docker.client.messages.swarm.TaskSpec) ServiceSpec(com.spotify.docker.client.messages.swarm.ServiceSpec) ConfigSpec(com.spotify.docker.client.messages.swarm.ConfigSpec) ServiceCreateResponse(com.spotify.docker.client.messages.ServiceCreateResponse) ConfigCreateResponse(com.spotify.docker.client.messages.swarm.ConfigCreateResponse) Test(org.junit.Test)

Aggregations

ConfigSpec (com.spotify.docker.client.messages.swarm.ConfigSpec)8 Test (org.junit.Test)8 MockResponse (okhttp3.mockwebserver.MockResponse)7 ContainerConfig (com.spotify.docker.client.messages.ContainerConfig)2 HostConfig (com.spotify.docker.client.messages.HostConfig)2 Config (com.spotify.docker.client.messages.swarm.Config)2 ConfigCreateResponse (com.spotify.docker.client.messages.swarm.ConfigCreateResponse)2 EngineConfig (com.spotify.docker.client.messages.swarm.EngineConfig)2 ServiceCreateResponse (com.spotify.docker.client.messages.ServiceCreateResponse)1 ConfigBind (com.spotify.docker.client.messages.swarm.ConfigBind)1 ServiceSpec (com.spotify.docker.client.messages.swarm.ServiceSpec)1 TaskSpec (com.spotify.docker.client.messages.swarm.TaskSpec)1