Ejemplo n.º 1
0
def test_instance_creation_with_kwargs(runner, dockerenv_remote):
    runner = DockerRunner()
    kwargs = {'key': 'val', 'host': '', 'int_key': 1, 'port_mapping': {8000: 8000}}
    instance = runner.create_instance('instance', **kwargs)
    assert 'port_mapping' not in instance.params
    assert instance.port_mapping == {8000: 8000}

    kwargs = {'key': 'val', 'host': '', 'int_key': 1}
    instance = runner.create_instance('instance_2', **kwargs)
    assert instance.port_mapping == {}
Ejemplo n.º 2
0
def run_good_attached():
    container_name = 'test'

    img_registry = DockerRegistry()
    img = DockerImage('mike0sv/ebaklya', registry=img_registry)
    instance = DockerContainer(container_name, port_mapping={80: 8080})
    host = DockerEnv()

    runner = DockerRunner()
    runner.run(instance, img, host, detach=False, rm=True)
Ejemplo n.º 3
0
def run_detached_and_remove():
    container_name = 'test'

    img_registry = DockerRegistry()
    img = DockerImage('test_broken_image', registry=img_registry)
    instance = DockerContainer(container_name)
    host = DockerEnv()

    runner = DockerRunner()
    runner.run(instance, img, host, detach=True, rm=True)
Ejemplo n.º 4
0
def run_attached():
    container_name = 'test'

    img_registry = DockerRegistry()
    img = DockerImage('test_broken_image', registry=img_registry)
    instance = DockerContainer(container_name, port_mapping={80: 8080})
    host = DockerEnv()

    runner = DockerRunner()
    runner.run(instance, img, host, detach=False, rm=False)
Ejemplo n.º 5
0
def runner(pytestconfig):
    if not has_docker() or 'not docker' in pytestconfig.getoption('markexpr'):
        pytest.skip('skipping docker tests')
    args = []

    def _runner(docker_env: DockerEnv, image: DockerImage, container_name: str):
        args.append((docker_env, image, container_name))
        return DockerRunner()

    yield _runner

    runner = DockerRunner()
    for env, img, container in args:
        runner.remove_instance(DockerContainer(container), env, force=True)
        with env.daemon.client() as client:
            env.registry.delete_image(client, img)
Ejemplo n.º 6
0
 def _runner(docker_env: DockerEnv, image: DockerImage, container_name: str):
     args.append((docker_env, image, container_name))
     return DockerRunner()