private String runCommandInCliContainer(String... arguments) throws IOException, InterruptedException { return dockerComposeRule.run( ImmutableDockerComposeRunOption.of(ImmutableList.of()), ThreeNodeCassandraCluster.CLI_CONTAINER_NAME, DockerComposeRunArgument.arguments(arguments)); } }
private static String[] constructFullDockerComposeRunArguments(DockerComposeRunOption dockerComposeRunOption, String containerName, DockerComposeRunArgument dockerComposeRunArgument) { ImmutableList<String> fullArgs = new ImmutableList.Builder<String>().add("run") .addAll(dockerComposeRunOption.options()) .add(containerName) .addAll(dockerComposeRunArgument.arguments()) .build(); return fullArgs.toArray(new String[fullArgs.size()]); }
private String[] constructFullDockerComposeRunArguments(DockerComposeRunOption dockerComposeRunOption, String containerName, DockerComposeRunArgument dockerComposeRunArgument) { ImmutableList<String> fullArgs = new ImmutableList.Builder<String>().add("run") .addAll(dockerComposeRunOption.options()) .add(containerName) .addAll(dockerComposeRunArgument.arguments()) .build(); return fullArgs.toArray(new String[fullArgs.size()]); }
private static String[] constructFullDockerComposeRunArguments(DockerComposeRunOption dockerComposeRunOption, String containerName, DockerComposeRunArgument dockerComposeRunArgument) { ImmutableList<String> fullArgs = new ImmutableList.Builder<String>().add("run") .addAll(dockerComposeRunOption.options()) .add(containerName) .addAll(dockerComposeRunArgument.arguments()) .build(); return fullArgs.toArray(new String[fullArgs.size()]); }
@Test public void run_returns_output() throws Exception { assertThat(docker.run(DockerComposeRunOption.options("--entrypoint", "echo"), CONTAINERS.get(0), DockerComposeRunArgument.arguments("hello")), is("hello")); } }
@Test public void pass_concatenated_arguments_to_executor_on_docker_compose_run() throws IOException, InterruptedException { compose.run(DockerComposeRunOption.options("-d"), "container_1", DockerComposeRunArgument.arguments("ls")); verify(executor, times(1)).execute("run", "-d", "container_1", "ls"); }
@Test public void calls_run_on_the_underlying_docker_compose_and_not_invoke_retryer() throws IOException, InterruptedException { retryingDockerCompose.run(DockerComposeRunOption.options("-d"), CONTAINER_NAME, DockerComposeRunArgument.arguments("ls")); verifyRetryerWasNotUsed(); verify(dockerCompose).run(DockerComposeRunOption.options("-d"), CONTAINER_NAME, DockerComposeRunArgument.arguments("ls")); } }
@Test public void return_the_output_from_the_executed_process_on_docker_compose_run() throws Exception { String lsString = String.format("-rw-r--r-- 1 user 1318458867 11326 Mar 9 17:47 LICENSE%n" + "-rw-r--r-- 1 user 1318458867 12570 May 12 14:51 README.md"); DockerComposeExecutable processExecutor = mock(DockerComposeExecutable.class); addProcessToExecutor(processExecutor, processWithOutput(lsString), "run", "-it", "container_1", "ls", "-l"); DockerCompose processCompose = new DefaultDockerCompose(processExecutor, dockerMachine); assertThat(processCompose.run(DockerComposeRunOption.options("-it"), "container_1", DockerComposeRunArgument.arguments("ls", "-l")), is(lsString)); }