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

A way to work with docker-compose ? #59

Open
aesteve opened this issue Feb 4, 2019 · 10 comments
Open

A way to work with docker-compose ? #59

aesteve opened this issue Feb 4, 2019 · 10 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@aesteve
Copy link

aesteve commented Feb 4, 2019

Hello, thanks for your work, and sorry to bother your issues with a question :\

Is there a way to use a docker-compose.yml file in order to setup our integration tests stack ?
Similar to: https://www.testcontainers.org/modules/docker_compose/

Or is it limited to only images defined in the images folder (redis etc.).

If not possible atm, is it a feature you'd like to have in the future ?

Thank you.

@thomaseizinger
Copy link
Collaborator

No need to apologize :)

At the moment, there is no docker-compose support and there are currently also no plans to add it.
We would probably need to put in some thoughts on how this can be useful as part of running tests from within Rust. We haven't had the need for this yet. If you do, it would be very helpful if you could write it down!

Regarding the availability of images: As soon as #58 lands, you should be able to very easily create containers for images that are not yet in images.
However, the long-term goal is to provide a rich set of images that just work out-of-the box, so if you are missing some, feel free to send a PR :)

@aesteve
Copy link
Author

aesteve commented Feb 5, 2019

Thanks for your answer!

One standard use-case of docker-compose in "tests within rust" would be Kafka I guess.
In fact, when opening the issue I was reading : https://github.com/spicavigo/kafka-rust/blob/master/tests/run-all-tests
Because a working Kafka cluster relies on two images : kafka & zookeeper.

So for instance, in order to test this library, one has to setup Kafka through docker-compose (obviously).
I guess this may be a common pattern among library developers.
And the most well-tested libraries, the better :)

@thomaseizinger
Copy link
Collaborator

Good point.

Reading up on how testcontainers-java does it, they actually run docker-compose using a docker container 😮

We could also start with a similar approach as we did for docker and simply call the native docker-compose binary :)

Unfortunately, we don't have the resources and the need to tackle this at the moment. Feel free to give it a go :)

@aesteve
Copy link
Author

aesteve commented Feb 6, 2019

I can give this a try although I'm a complete beginner.
Could you point me at what you mean by "as we did for docker" ? Please ?
It's not totally clear for me.
Thank you

@thomaseizinger
Copy link
Collaborator

To talk to the docker host, we currently simply shell out to the docker binary here: https://github.com/testcontainers/testcontainers-rs/blob/master/cli_client/src/cli.rs

The whole thing is abstracted over through the Docker trait so that we can replace it with an HTTP client at some point and talk to the docker daemon directly.

For docker-compose, we can do something similar although we don't need the a trait here.
I think having a separate crate tc_docker_compose would be sufficient.
You'd probably have a struct/module that represents the docker-compose binary and provides an interface for all the commands that you want to execute.

@aesteve
Copy link
Author

aesteve commented Feb 7, 2019

Perfect pointer! Thank you.
I think up, down would be sufficient.

If it's just calling the docker-compose command under the hood, it may be easy and I can give it a try.
Just curious about the "wait for container started" thing though. Maybe, it's not needed with the "health checks" provided by docker-compose ? Not sure, I need to try.

@thomaseizinger
Copy link
Collaborator

That one is a bit tricky.
What you could try to do is redirect all the traffic into individual files and read them again as things are starting up.

I am not too familiar with the healthchecks though. Will have to look it up :)

Looking at what testcontainers-java does might not hurt in terms of possible features ;)

@IgorLaborieWefox
Copy link

Hello,

I have a prototype that works with shell out and docker compose v2.x. The code is planned to be open-sourced later, but at the time it's still in a private crate.
It's async with Tokio, but if necessary I could create a sync version.

Are you interested in a PR?
Or maybe it's a better idea to create a separate crate?

@thomaseizinger
Copy link
Collaborator

Feel free to open a PR! I cant promise that it will be merged in though, that depends a lot on the design and how it fits into this crate :)

@DDtKey
Copy link
Collaborator

DDtKey commented Apr 22, 2024

Just informing everyone interested, we are doing a major revision of testcontainers and adding docker-compose in our plans. Please note the changed API (see readme)

So anyone who wants to help with this is welcome 🙂

@DDtKey DDtKey added enhancement New feature or request help wanted Extra attention is needed labels Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants