Skip to content

Log consumer for DockerComposeContainer #605

Closed

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?

Activity

  1. kshepitko commented on Mar 13, 2018

    @kshepitko
    Author

    Ability to use some wait strategies would be great, too

  2. barrycommins commented on Mar 14, 2018

    @barrycommins
    Contributor

    Hi @kshepitko,

    I have a PR out that addresses exactly this issue. #600

    Edit: well, it allows you to wait for log messages on docker-compose.
    It doesn't expose the API to to add your own consumer through DockerComposeContainer.

  3. kshepitko commented on Mar 22, 2018

    @kshepitko
    Author

    Thanks for update, @barrycommins !

    There's an impressive refactoring you performed there! Thank you for this.
    I think that new your feature would be pretty much enough for me.

    @kiview Do you think there's still a value in defining the log consumers for DockerCompose-managed containers? If not, I'll close this issue.

  4. kiview commented on Mar 23, 2018

    @kiview
    Member

    @kshepitko I think it's still a valuable feature request, if only to give compose the same expected feature set as the regular containers.

  5. barrycommins commented on Mar 25, 2018

    @barrycommins
    Contributor

    @kiview
    I think it should be pretty straightforward to add a withLogConsumer(String service, Consumer<OutputFrame> consumer) method to DockerComposeContainer now after the recent refactoring.

    I'm happy to implement it, if you'd like.

  6. kiview commented on Mar 25, 2018

    @kiview
    Member

    @barrycommins Thx, this would be awesome!
    If you encounter any strange race condition like problems while working on logging stuff please tell us, there are still some open issues with LogMessageWaitStrategy missing messages, we couldn't find out yet.

  7. added this to the next milestone on Apr 6, 2018
  8. added a commit that references this issue on Apr 7, 2018
    cacf0bc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions