diff --git a/src/main/java/com/palantir/docker/compose/DockerComposeRule.java b/src/main/java/com/palantir/docker/compose/DockerComposeRule.java index 69a2dcf8e..386523f7a 100644 --- a/src/main/java/com/palantir/docker/compose/DockerComposeRule.java +++ b/src/main/java/com/palantir/docker/compose/DockerComposeRule.java @@ -135,9 +135,9 @@ public void after() { } } - public void exec(DockerComposeExecOption options, String containerName, + public String exec(DockerComposeExecOption options, String containerName, DockerComposeExecArgument arguments) throws IOException, InterruptedException { - dockerCompose().exec(options, containerName, arguments); + return dockerCompose().exec(options, containerName, arguments); } public static ImmutableDockerComposeRule.Builder builder() { diff --git a/src/main/java/com/palantir/docker/compose/DockerComposition.java b/src/main/java/com/palantir/docker/compose/DockerComposition.java index 566d6f932..7ce0b786d 100644 --- a/src/main/java/com/palantir/docker/compose/DockerComposition.java +++ b/src/main/java/com/palantir/docker/compose/DockerComposition.java @@ -84,9 +84,9 @@ public static DockerCompositionBuilder of(DockerCompose compose) { return new DockerCompositionBuilder().dockerCompose(compose); } - public void exec(DockerComposeExecOption options, String containerName, DockerComposeExecArgument arguments) + public String exec(DockerComposeExecOption options, String containerName, DockerComposeExecArgument arguments) throws IOException, InterruptedException { - rule.exec(options, containerName, arguments); + return rule.exec(options, containerName, arguments); } public DockerPort hostNetworkedPort(int port) { diff --git a/src/test/java/com/palantir/docker/compose/DockerCompositionIntegrationTest.java b/src/test/java/com/palantir/docker/compose/DockerCompositionIntegrationTest.java index 53be4dc67..890cb7e62 100644 --- a/src/test/java/com/palantir/docker/compose/DockerCompositionIntegrationTest.java +++ b/src/test/java/com/palantir/docker/compose/DockerCompositionIntegrationTest.java @@ -17,6 +17,9 @@ import static com.google.common.base.Throwables.propagate; import static com.palantir.docker.compose.connection.waiting.HealthChecks.toHaveAllPortsOpen; +import static com.palantir.docker.compose.execution.DockerComposeExecArgument.arguments; +import static com.palantir.docker.compose.execution.DockerComposeExecOption.options; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -27,6 +30,8 @@ import java.io.IOException; import java.util.List; import java.util.function.Consumer; + +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -97,4 +102,10 @@ public void can_access_external_port_for_internal_port_of_machine() throws IOExc }); } + @Ignore // This test will not run on Circle CI because it does not currently support docker-compose exec. + @Test + public void exec_returns_output() throws Exception { + assertThat(composition.exec(options(), CONTAINERS.get(0), arguments("echo", "hello")), is("hello")); + } + }