DefaultDockerClientFacade extends BaseDockerClientFacade { @Nonnull @Override public CharSequence getLogs(@Nonnull String containerId) { StreamHandler streamHandler = client.streamLogs(containerId, 10000, StdioType.all(), false, !hasTty(containerId)); return demuxLogs(streamHandler); } DefaultDockerClientFacade(@Nonnull DockerClient client); @Nonnull @Override NewAgentHolderInfo createAgent(@Nonnull CreateAgentParameters createAgentParameters); @Override String startAgent(@Nonnull String containerId); @Override String restartAgent(@Nonnull String containerId); @Nonnull @Override List<AgentHolderInfo> listAgentHolders(@Nonnull String labelFilter, @Nonnull String valueFilter); @Override boolean terminateAgentContainer(@Nonnull String containerId, @Nonnull Duration timeout, boolean removeContainer); @Nonnull @Override CharSequence getLogs(@Nonnull String containerId); @Nonnull @Override StreamHandler streamLogs(@Nonnull String containerId); @Override boolean supportQueryingLogs(); static final String CONTAINER_RUNNING_STATE; }
@Test public void getDemuxedLogs() { DefaultDockerClientFacade facade = new DefaultDockerClientFacade(dockerClient); Container container = new Container(); container.getLogStreamHandler(). fragment("txt on stdout, ", StdioType.STDOUT). fragment("txt on stdin, ", StdioType.STDIN). fragment("txt unknown std type", null); dockerClient.container(container); CharSequence logs = facade.getLogs(container.getId()); assertThat(logs.toString()).isEqualTo("txt on stdout, txt on stdin, txt unknown std type"); }
@Test public void getCompositeLogs() { DefaultDockerClientFacade facade = new DefaultDockerClientFacade(dockerClient); Container container = new Container().tty(true); container.getLogStreamHandler(). fragment("txt on stdout, ", StdioType.STDOUT). fragment("txt on stdin, ", StdioType.STDIN). fragment("txt unknown std type", null); dockerClient.container(container); CharSequence logs = facade.getLogs(container.getId()); assertThat(logs.toString()).isEqualTo("txt on stdout, txt on stdin, txt unknown std type"); }