use of com.spotify.docker.client.LogStream in project helios by spotify.
the class DnsServerTest method testDnsParam.
@Test
public void testDnsParam() throws Exception {
final String server1 = "127.0.0.1";
final String server2 = "127.0.0.2";
startDefaultMaster();
startDefaultAgent(testHost(), "--dns", server1, "--dns", server2);
awaitHostStatus(testHost(), UP, LONG_WAIT_SECONDS, SECONDS);
final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX, asList("cat", "/etc/resolv.conf"));
deployJob(jobId, testHost());
final TaskStatus taskStatus = awaitTaskState(jobId, testHost(), EXITED);
try (final DockerClient dockerClient = getNewDockerClient()) {
final LogStream logs = dockerClient.logs(taskStatus.getContainerId(), stdout(), stderr());
final String log = logs.readFully();
assertThat(log, containsString(server1));
assertThat(log, containsString(server2));
}
}
use of com.spotify.docker.client.LogStream in project helios by spotify.
the class AddExtraHostTest method test.
@Test
public void test() throws Exception {
try (final DockerClient docker = getNewDockerClient()) {
// Start Helios agent, configured to bind host /etc/hostname into container /mnt/hostname
startDefaultMaster();
startDefaultAgent(testHost(), "--add-host", "secrethost:169.254.169.254");
awaitHostStatus(testHost(), UP, LONG_WAIT_SECONDS, SECONDS);
// a job that cat's /etc/hosts
final List<String> command = ImmutableList.of("cat", "/etc/hosts");
final JobId jobId = createJob(testJobName, testJobVersion, BUSYBOX, command);
deployJob(jobId, testHost());
final TaskStatus taskStatus = awaitTaskState(jobId, testHost(), EXITED);
final String log;
try (LogStream logs = docker.logs(taskStatus.getContainerId(), stdout(), stderr())) {
log = logs.readFully();
assertThat(log, containsString("169.254.169.254\tsecrethost"));
}
}
}
use of com.spotify.docker.client.LogStream in project linuxtools by eclipse.
the class DockerConnection method execShell.
public void execShell(final String id) throws DockerException {
try {
final ExecCreation execCreation = client.execCreate(id, // $NON-NLS-1$
new String[] { "/bin/sh" }, ExecCreateParam.attachStdout(), ExecCreateParam.attachStderr(), ExecCreateParam.attachStdin(), ExecCreateParam.tty());
final String execId = execCreation.id();
final LogStream pty_stream = client.execStart(execId, DockerClient.ExecStartParameter.TTY);
final IDockerContainerInfo info = getContainerInfo(id);
// $NON-NLS-1$
openTerminal(pty_stream, info.name() + " [shell]", null);
} catch (Exception e) {
throw new DockerException(e.getMessage(), e.getCause());
}
}
Aggregations