avast / pytest-docker

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

Swarm support #109

Open towo opened 8 months ago

towo commented 8 months ago

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.

pyhedgehog commented 8 months ago

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")