avast / pytest-docker

Docker-based integration tests
MIT License
427 stars 71 forks source link

Support for docker-compose V2 #71

Closed n1ngu closed 2 years ago

n1ngu commented 2 years ago

I guess the maintainers are already aware of all the context but I'll try to summarize it and still not bore anyone.

docker-compose V2 has been rewritten not in Python language and isn't distributed anymore as a python package.

In the V1 deprecation notice there is a commitment to fix security issues but no bugs or new features will ever be released https://github.com/docker/compose/tree/master#v1-vs-v2-transition-hourglass_flowing_sand

The V1 branch is effectively stale since V2 was first released 4 months ago.

The first signs of erosion are already showing up https://github.com/avast/pytest-docker/issues/70

Hopefully, the command line interface is still the only supported interface to docker-compose, and there is an explicit commitment to keep it stable and compatible, and by virtue of https://github.com/avast/pytest-docker/issues/19 we should have little to no trouble with the switch.

Effectively, after dropping the requirement on the docker-compose V1 python package, my first attempt to run pytest-docker test suite with my system's docker-compose 2.2.2 is a total success.

The main issue so far would be that: in common setups using a virtualenv the current hard dependency on docker-compose V1 will usually shadow any other version provided by the user. Or at least cause a confusion about what is actually being used (see https://github.com/avast/pytest-docker/issues/69 ?)

Therefore, aside from any future issue that could show up, the main challenges can be reduced to:

n1ngu commented 2 years ago

For the installation process, an extra dependency could be contributed so that docker-compose V1 was optionally required. Only requiring

pip install pytest-docker[composeV1]

or whatnot would actually pull the python package for docker-compose.

Obviously this should go along with some new documentation and a proper version bump.

n1ngu commented 2 years ago

For the tox test matrix, I think it'd be as easy as something like

[tox]
envlist = {py37,py38,py39,py310}-{V1,V2}

[testenv]
deps =
    {py37,py38,py39,py310}-V1: docker-compose
commands =
    pytest -c setup.cfg

I think I am missing to pull the extra pytest-docker[tests] requirements somehow, but it should neither be hard to figure out.

otetard commented 2 years ago

A first attempt to provide Docker Compose v2 support is available in this PR: #72.

n1ngu commented 2 years ago

Fixed by #72 , thanks @otetard !