pytest-docker icon indicating copy to clipboard operation
pytest-docker copied to clipboard

Swarm support

Open towo opened this issue 1 year ago • 1 comments

Currently, the code is fixed on using docker compose for managing services. Is there any interest in developing Swarm support as an addition? I'd probably chip in on that, since this might be in the best interesting of the project I'm currently handling.

towo avatar Mar 12 '24 18:03 towo

You can add following fixtures and it will be almost all required "support":

@pytest.fixture(scope="session")
def docker_compose_command():
    return "docker stack"
@pytest.fixture(scope="session")
def docker_cleanup():
    return ["up"]
@pytest.fixture(scope="session")
def docker_cleanup():
    return ["down"]
@pytest.fixture(scope="session")
def docker_ip() -> str:
    info = json.loads(pytest_docker.plugin.execute("docker info -f json"))
    if info["Name"] == os.environ.get("HOSTNAME"):
        return "127.0.0.1"
    return info.get("Swarm",{}).get("NodeAddr")

pyhedgehog avatar Mar 13 '24 12:03 pyhedgehog