use of com.spotify.docker.client.messages.LogConfig in project docker-client by spotify.
the class DefaultDockerClientTest method testLogDriver.
@Test
public void testLogDriver() throws Exception {
requireDockerApiVersionAtLeast("1.21", "Container Creation with HostConfig.LogConfig");
sut.pull(BUSYBOX_LATEST);
final String name = randomName();
final Map<String, String> logOptions = new HashMap<>();
logOptions.put("max-size", "10k");
logOptions.put("max-file", "2");
logOptions.put("labels", name);
final LogConfig logConfig = LogConfig.create("json-file", logOptions);
assertThat(logConfig.logType(), equalTo("json-file"));
assertThat(logConfig.logOptions(), equalTo(logOptions));
final HostConfig expected = HostConfig.builder().logConfig(logConfig).build();
final ContainerConfig config = ContainerConfig.builder().image(BUSYBOX_LATEST).hostConfig(expected).build();
final ContainerCreation creation = sut.createContainer(config, name);
final String id = creation.id();
sut.startContainer(id);
final HostConfig actual = sut.inspectContainer(id).hostConfig();
assertThat(actual.logConfig(), equalTo(expected.logConfig()));
}
use of com.spotify.docker.client.messages.LogConfig in project helios by spotify.
the class SyslogRedirectingContainerDecoratorTest method testWithDockerVersionPost1_9.
@Test
public void testWithDockerVersionPost1_9() {
final Optional<String> dockerVersion = Optional.of("1.12.1");
final SyslogRedirectingContainerDecorator decorator = new SyslogRedirectingContainerDecorator(SYSLOG_HOST_PORT);
final HostConfig.Builder hostBuilder = HostConfig.builder();
decorator.decorateHostConfig(JOB, dockerVersion, hostBuilder);
final ContainerConfig.Builder containerBuilder = ContainerConfig.builder();
decorator.decorateContainerConfig(JOB, imageInfo, dockerVersion, containerBuilder);
final ContainerConfig containerConfig = containerBuilder.build();
assertThat(containerConfig.entrypoint(), not(hasItem("/helios/syslog-redirector")));
final HostConfig hostConfig = hostBuilder.build();
final LogConfig logConfig = hostConfig.logConfig();
assertEquals("syslog", logConfig.logType());
assertEquals(JOB.getId().toString(), logConfig.logOptions().get("tag"));
assertEquals("udp://" + SYSLOG_HOST_PORT, logConfig.logOptions().get("syslog-address"));
}
Aggregations