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