Skip to content

Log consumer for DockerComposeContainer #605

@kshepitko

Description

@kshepitko

Hi folks!

It's possible to define a log consumer for a GenericContainer, but DockerComposeContainer has a very limited API. The latter allows you to tail the included containers' output, but doesn't provide the means to monitor the output.

    private void tailChildContainerLogs() {
        listChildContainers().forEach(container ->
                LogUtils.followOutput(dockerClient,
                        container.getId(),
                        new Slf4jLogConsumer(logger()).withPrefix(container.getNames()[0]),
                        OutputFrame.OutputType.STDOUT,
                        OutputFrame.OutputType.STDERR)
        );
    }

That's it, it just redirects the containers' output to the standard output. But what if I need to monitor outout? For instance, my Spring Boot application has Vaadin UI, and it actually fully loads a few seconds later after Spring has announced that app has started and the port is opened now. If I open browser right away via BrowserWebDriverContainer, Vaadin pages do not work properly. So I'd like to wait for appropriate message from Vaadin to start my test.

I think it would be beneficial to allow to define a custom consumer here, or the ability to wait for a certain message to appear in the log (like it's done in GenericContainer).

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions