Skip to content

Launch, manage and monitor containers via docker-py

License

Notifications You must be signed in to change notification settings

pikers/pytest-dockerctl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pytest-dockerctl

Docker control integrated with pytest for system testing.

pytest-dockerctl is a pytest plugin for managing all things docker using the docker-py API.

Install

For now install from this repo:

pip install git+git://github.com/tgoodlet/pytest-dockerctl.git

Usage

Provides a dockerctl fixture for spinning up and tearing down containers:

import pytest
import subprocess

@pytest.fixture
def server_addrs(dockerctl):
    addrs = []

    # spin up 4 of the same container
    with dockerctl.run(
        'docker_repo/my_image'
        volumes={'/local/config/path': {'bind': '/etc/server/config'}},
        num=4,
    ) as containers:
        for container in containers:
            addrs.append(container.attrs['NetworkSettings']['IPAddress'])

        yield addrs

    # all containers are stopped and removed when the context manager exits

def test_startup_ping(server_addrs):
    for addr in server_addrs:
        subprocess.check_call("ping -c 1 {}".format(addr))

The dockerctl object is a DockerCtl instance which (for now) is just a simple wrapper around a docker-py DockerClient. You can access the underlying client via dockerctl.client.

About

Launch, manage and monitor containers via docker-py

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages