logstash/docker/tests/conftest.py
João Duarte dc5db673ee
build docker images from logstash repo (#10603)
introduces two rake tasks: `rake artifact:docker_oss` and `rake artifact:docker`, which will create the docker images of the OSS and non OSS packages. These tasks depend on the tar artifacts being built.

Also `rake artifact:all` has been modified to also call these two tasks.

most code was moved from https://github.com/elastic/logstash-docker/
2019-04-04 11:27:06 +01:00

25 lines
887 B
Python

from subprocess import run
import pytest
from .constants import container_name, version
import docker
docker_engine = docker.from_env()
def pytest_addoption(parser):
"""Customize testinfra with config options via cli args"""
# Let us specify which docker-compose-(image_flavor).yml file to use
parser.addoption('--image-flavor', action='store', default='full',
help='Docker image flavor; the suffix used in docker-compose-<flavor>.yml')
@pytest.fixture(scope='session', autouse=True)
def start_container():
image = 'docker.elastic.co/logstash/logstash-%s:%s' % (pytest.config.getoption('--image-flavor'), version)
docker_engine.containers.run(image, name=container_name, detach=True, stdin_open=False)
def pytest_unconfigure(config):
container = docker_engine.containers.get(container_name)
container.stop()
container.remove()