Search in sources :

Example 1 with ContainerUpdate

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

the class DefaultDockerClientTest method testUpdateContainer.

@Test
public void testUpdateContainer() throws Exception {
    requireDockerApiVersionAtLeast("1.22", "update container");
    final String containerName = randomName();
    final HostConfig hostConfig = HostConfig.builder().cpuShares(256L).build();
    final ContainerConfig config = ContainerConfig.builder().hostConfig(hostConfig).image(BUSYBOX_LATEST).build();
    sut.pull(BUSYBOX_LATEST);
    final ContainerCreation container = sut.createContainer(config, containerName);
    final ContainerInfo containerInfo = sut.inspectContainer(container.id());
    assertThat(containerInfo.hostConfig().cpuShares(), is(256L));
    final HostConfig newHostConfig = HostConfig.builder().cpuShares(512L).build();
    final ContainerUpdate containerUpdate = sut.updateContainer(containerInfo.id(), newHostConfig);
    assertThat(containerUpdate.warnings(), is(nullValue()));
    final ContainerInfo newContainerInfo = sut.inspectContainer(container.id());
    assertThat(newContainerInfo.hostConfig().cpuShares(), is(512L));
}
Also used : ContainerConfig(com.spotify.docker.client.messages.ContainerConfig) ContainerCreation(com.spotify.docker.client.messages.ContainerCreation) HostConfig(com.spotify.docker.client.messages.HostConfig) ContainerInfo(com.spotify.docker.client.messages.ContainerInfo) Long.toHexString(java.lang.Long.toHexString) Matchers.isEmptyOrNullString(org.hamcrest.Matchers.isEmptyOrNullString) Matchers.containsString(org.hamcrest.Matchers.containsString) ContainerUpdate(com.spotify.docker.client.messages.ContainerUpdate) Test(org.junit.Test)

Aggregations

ContainerConfig (com.spotify.docker.client.messages.ContainerConfig)1 ContainerCreation (com.spotify.docker.client.messages.ContainerCreation)1 ContainerInfo (com.spotify.docker.client.messages.ContainerInfo)1 ContainerUpdate (com.spotify.docker.client.messages.ContainerUpdate)1 HostConfig (com.spotify.docker.client.messages.HostConfig)1 Long.toHexString (java.lang.Long.toHexString)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)1 Test (org.junit.Test)1