Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log consumer for DockerComposeContainer #605

Closed
kshepitko opened this issue Mar 13, 2018 · 6 comments
Closed

Log consumer for DockerComposeContainer #605

kshepitko opened this issue Mar 13, 2018 · 6 comments

Comments

@kshepitko
Copy link

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?

@kshepitko
Copy link
Author

Ability to use some wait strategies would be great, too

@barrycommins
Copy link
Contributor

barrycommins commented Mar 14, 2018

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.

@kshepitko
Copy link
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.

@kiview
Copy link
Member

kiview commented Mar 23, 2018

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

@barrycommins
Copy link
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.

@kiview
Copy link
Member

kiview commented Mar 25, 2018

@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.

@bsideup bsideup added this to the next milestone Apr 6, 2018
bsideup pushed a commit that referenced this issue Apr 7, 2018
* Added withLogConsumer() method to DockerComposeContainer

Fixes #605

* Added try-finally block to DockerComposeLogConsumerTest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants