Skip to content

Commit

Permalink
also error output read from containers
Browse files Browse the repository at this point in the history
  • Loading branch information
augi committed Aug 8, 2023
1 parent bbdf9c2 commit fdc2d02
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ abstract class ComposeExecutor implements BuildService<Parameters>, AutoCloseabl
}

Map<String,Iterable<String>> getContainerIds(List<String> serviceNames) {
// `docker-compose ps -q serviceName` returns an exit code of 1 when the service
// `docker compose ps -q serviceName` returns an exit code of 1 when the service
// doesn't exist. To guard against this, check the service list first.
def services = execute('ps', '--services').readLines()
def result = [:]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class DockerExecutor {
def finalArgs = [settings.dockerExecutable.get()]
finalArgs.addAll(args)
e.commandLine finalArgs
e.errorOutput = os
e.standardOutput = os
e.ignoreExitValue = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class DockerExecutorTest extends Specification {
}

def "reads container logs"() {
def f = Fixture.withHelloWorld()
def f = Fixture.withNginx()
f.project.tasks.composeBuild.build()
f.project.tasks.composeUp.up()
String containerId = f.extension.servicesInfos.hello.firstContainer.containerId
String containerId = f.extension.servicesInfos.web.firstContainer.containerId
when:
String output = f.extension.dockerExecutor.getContainerLogs(containerId)
then:
output.contains('Hello from Docker')
output.contains('nginx')
cleanup:
f.project.tasks.composeDown.down()
f.close()
Expand Down

0 comments on commit fdc2d02

Please sign in to comment.