forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResizeContainerCmdIT.java
More file actions
39 lines (28 loc) · 1.49 KB
/
Copy pathResizeContainerCmdIT.java
File metadata and controls
39 lines (28 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.github.dockerjava.cmd;
import com.github.dockerjava.api.command.CreateContainerResponse;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.security.SecureRandom;
import java.util.concurrent.TimeUnit;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
public class ResizeContainerCmdIT extends CmdIT {
private static final Logger LOG = LoggerFactory.getLogger(ResizeContainerCmdIT.class);
private static final int TTY_HEIGHT = 30;
private static final int TTY_WIDTH = 120;
@Test
public void resizeContainerTtyTest() {
String containerName = "generated_" + new SecureRandom().nextInt();
// wait until tty size changed to target size
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withUser("root")
.withCmd("sh", "-c", String.format("until stty size | grep '%d %d'; do : ; done", TTY_HEIGHT, TTY_WIDTH))
.withName(containerName).withTty(true).withStdinOpen(true).exec();
dockerRule.getClient().startContainerCmd(container.getId()).exec();
dockerRule.getClient().resizeContainerCmd(container.getId()).withSize(TTY_HEIGHT, TTY_WIDTH).exec();
int exitCode = dockerRule.getClient().waitContainerCmd(container.getId()).start()
.awaitStatusCode(10, TimeUnit.SECONDS);
LOG.info("Container exit code: {}", exitCode);
assertThat(exitCode, equalTo(0));
}
}