Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -45,6 +45,7 @@
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasItemInArray;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyString;
Expand Down Expand Up @@ -191,21 +192,24 @@ public void createContainerWithVolumesFrom() throws DockerException {

@Test
public void createContainerWithEnv() throws Exception {
final String testVariable = "VARIABLE=success";

CreateContainerResponse container = dockerClient.createContainerCmd(BUSYBOX_IMAGE).withEnv("VARIABLE=success")
.withCmd("env").exec();
CreateContainerResponse container = dockerClient.createContainerCmd(BUSYBOX_IMAGE)
.withEnv(testVariable)
.withCmd("env")
.exec();

LOG.info("Created container {}", container.toString());

assertThat(container.getId(), not(isEmptyString()));

InspectContainerResponse inspectContainerResponse = dockerClient.inspectContainerCmd(container.getId()).exec();

assertThat(Arrays.asList(inspectContainerResponse.getConfig().getEnv()), containsInAnyOrder("VARIABLE=success"));
assertThat(Arrays.asList(inspectContainerResponse.getConfig().getEnv()), hasItem(testVariable));
Copy link
Member Author

Choose a reason for hiding this comment

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

arrays has two variables, so it should be hasItem


dockerClient.startContainerCmd(container.getId()).exec();

assertThat(containerLog(container.getId()), containsString("VARIABLE=success"));
assertThat(containerLog(container.getId()), containsString(testVariable));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public void updateContainer() throws DockerException, IOException {
// .withKernelMemory(52428800) Can not update kernel memory to a running container, please stop it first.
.exec();

// docker toolbox 1.10.1
assertThat(updateResponse.getWarnings(), hasSize(1));
assertThat(updateResponse.getWarnings().get(0),
is("Your kernel does not support Block I/O weight. Weight discarded."));
// true only on docker toolbox (1.10.1)
// assertThat(updateResponse.getWarnings(), hasSize(1));
// assertThat(updateResponse.getWarnings().get(0),
// is("Your kernel does not support Block I/O weight. Weight discarded."));

InspectContainerResponse inspectAfter = dockerClient.inspectContainerCmd(containerId).exec();
final HostConfig afterHostConfig = inspectAfter.getHostConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasItemInArray;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyString;
Expand Down Expand Up @@ -189,21 +190,24 @@ public void createContainerWithVolumesFrom() throws DockerException {

@Test
public void createContainerWithEnv() throws Exception {
final String testVariable = "VARIABLE=success";

CreateContainerResponse container = dockerClient.createContainerCmd("busybox").withEnv("VARIABLE=success")
.withCmd("env").exec();
CreateContainerResponse container = dockerClient.createContainerCmd("busybox")
.withEnv(testVariable)
.withCmd("env")
.exec();

LOG.info("Created container {}", container.toString());

assertThat(container.getId(), not(isEmptyString()));

InspectContainerResponse inspectContainerResponse = dockerClient.inspectContainerCmd(container.getId()).exec();

assertThat(Arrays.asList(inspectContainerResponse.getConfig().getEnv()), containsInAnyOrder("VARIABLE=success"));
assertThat(Arrays.asList(inspectContainerResponse.getConfig().getEnv()), hasItem(testVariable));

dockerClient.startContainerCmd(container.getId()).exec();

assertThat(containerLog(container.getId()), containsString("VARIABLE=success"));
assertThat(containerLog(container.getId()), containsString(testVariable));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public void updateContainer() throws DockerException, IOException {
// .withKernelMemory(52428800) Can not update kernel memory to a running container, please stop it first.
.exec();

// docker toolbox 1.10.1
assertThat(updateResponse.getWarnings(), hasSize(1));
assertThat(updateResponse.getWarnings().get(0),
is("Your kernel does not support Block I/O weight. Weight discarded."));
// found only on docker toolbox (1.10.1)
// assertThat(updateResponse.getWarnings(), hasSize(1));
// assertThat(updateResponse.getWarnings().get(0),
// is("Your kernel does not support Block I/O weight. Weight discarded."));

InspectContainerResponse inspectAfter = dockerClient.inspectContainerCmd(containerId).exec();
final HostConfig afterHostConfig = inspectAfter.getHostConfig();
Expand Down