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

Docs for multiple docker-compose files #69

Open
edinhodiluviano opened this issue Dec 23, 2021 · 4 comments
Open

Docs for multiple docker-compose files #69

edinhodiluviano opened this issue Dec 23, 2021 · 4 comments

Comments

@edinhodiluviano
Copy link

pytest-docker already supports shared compose files.
However I couldn't find it in the docs.
Is it really missing? If so, can I send a PR to add something to the README?

@Luminaar
Copy link
Collaborator

Hello. pytest-docker currently uses docker-compose v1. The feature you linked is available in docker-compose v2. This new version is not written in Python and so it's not possible to install it together with this library.

Support for a docker-compose v2 would require a major change to this library ― requiring users to provide their own installation of docker-compose or maybe allowing both.

I will try looking into this but please understand that it might take some time.

@edinhodiluviano
Copy link
Author

Hum... I'm not sure how it works on the docker-compose side. But pytest-docker already supports multiple files. It is just not documented.
The bellow example would work only with pytest-docker installed:

# test.py

import pytest


@pytest.fixture(scope="session")
def docker_compose_file(pytestconfig):
    return ("docker-compose-1.yml", "docker-compose-2.yml")  # here we define all compose files needed


@pytest.fixture(scope="module")
def containers(docker_services):
    docker_services.wait_until_responsive(
        timeout=30.0,
        pause=0.5,
        check=lambda: True,
    )


def test_dumb(containers):
    assert 1 == 1
# docker-compose-1.yml

version: "3"

services:
    container_1:
        image: python:3.9
        container_name: container_1
        command: ["python", "--version"]
# docker-compose-2.yml

services:
    container_2:
        image: python:3.9
        container_name: container_2
        command: ["python", "--version"]

Just run pytest test.py and for a while you will be able to see both containers running, started by pytest-docker.
I was using it in a bigger project with multiple files for integration and migration tests and it was working fine.

@n1ngu
Copy link
Contributor

n1ngu commented Jan 20, 2022

This new version is not written in Python and so it's not possible to install it together with this library.

Support for a docker-compose v2 would require a major change to this library ― requiring users to provide their own installation of docker-compose or maybe allowing both.

@Luminaar AFAIU, as long as the shell environment is configured in a way that the subprocess.check_output('docker-compose ...') finds the v2 installation, wouldn't everything work out of the box?

Obviously docker-compose v2 can't be installed as a python dependency anymore, but maybe this is what @edinhodiluviano is observing?

@edinhodiluviano
Copy link
Author

I see no problem on the behavior of the library. The library already work as I need.
My only concern is the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants