Create Docker files for Tobiko project

- Dockerfile file is intended for running test cases
  without using tox
- infrared_plugin/Dockerfile file is intended to run
  Tobiko IR plugin
- docker-compose file is intended to emulate the tox
  experience by using docker

All images are build staring from official CentOS 8
image.

Change-Id: I2f57f6e1c9c6161cef9448d25027d784ebd37e2c
This commit is contained in:
Federico Ressi 2020-05-27 16:54:00 +02:00
parent 64308b3eb4
commit c50ab412a0
6 changed files with 181 additions and 1 deletions

47
.dockerignore Normal file
View File

@ -0,0 +1,47 @@
*.sw?
*.egg
*.egg-info
*.pyc
*.log
# Hidden files
.coverage
.coverage.*
.eggs
.mypy_cache
.stestr
.test
.testrepository
.tobiko-env
.tox
.vagrant
.venv
__pycache__
AUTHORS
build/*
ChangeLog
doc/build/*
cover/
dist/
etc/*.sample
report/
test_results*
zuul/versioninfo
# Files created by releasenotes build
releasenotes/build
# Docs related files
doc/source/_static/config-samples/*.sample
Pipfile.lock
# Tobiko configuration file
tobiko.conf
clouds.yaml
ssh_config
# Infrared things
.infrared
workspace.tgz

39
Dockerfile Normal file
View File

@ -0,0 +1,39 @@
ARG base_image="docker.io/library/centos:8"
FROM "${base_image}" as tobiko
# Install binary dependencies
RUN dnf install -y gcc git python3 python3-devel && \
alternatives --set python /usr/bin/python3
# Get Tobiko source files
ARG tobiko_src_dir=.
ENV TOBIKO_DIR=/src/tobiko
# Copy Tobiko source files
RUN mkdir /src
ADD "${tobiko_src_dir}" "${TOBIKO_DIR}"
WORKDIR "${TOBIKO_DIR}"
# Install Python requirements
ARG constraints_file=https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt
ENV PIP_INSTALL="python -m pip install -c ${constraints_file}"
RUN set -x && \
python --version && \
${PIP_INSTALL} --upgrade pip && \
${PIP_INSTALL} --upgrade setuptools wheel && \
${PIP_INSTALL} -r ./requirements.txt && \
${PIP_INSTALL} ./
# -----------------------------------------------------------------------------
FROM tobiko as tests
RUN ${PIP_INSTALL} -r ./test-requirements.txt
# Run test cases
ENV OS_LOG_CAPTURE=true
ENV OS_STDOUT_CAPTURE=true
ENV OS_STDERR_CAPTURE=true
ENV OS_TEST_PATH=tobiko/tests/unit
ENTRYPOINT ./tools/run_tests.py

32
docker-compose.yml Normal file
View File

@ -0,0 +1,32 @@
---
version: '3.4'
services:
py3:
build:
context: .
target: tests
args:
OS_TEST_PATH: ./tests/unit
functional:
build:
context: .
target: tests
args:
OS_TEST_PATH: ./tests/functional
scenario:
build:
context: .
target: tests
args:
OS_TEST_PATH: ./tests/scenario
faults:
build:
context: .
target: tests
args:
OS_TEST_PATH: ./tests/faults
infrared:
build:
context: ./infrared_plugin
target: tobiko_plugin

View File

@ -0,0 +1,61 @@
# Dockerfile that sets up InfraRed as documented here:
# https://infrared.readthedocs.io/en/latest/bootstrap.html#setup
ARG base_image="docker.io/library/centos:8"
FROM "${base_image}" AS infrared
# Install required binary dependencies
RUN dnf install -y git \
libselinux-python3 \
python3 \
rsync \
which && \
alternatives --set python /usr/bin/python3
# Get InfraRed sources with Git
ARG ir_src_dir=/src/infrared
ARG ir_git_url=https://github.com/redhat-openstack/infrared.git
ARG ir_git_refspec=master
ARG ir_git_remote=origin
RUN mkdir -p "${ir_src_dir}" && \
cd "${ir_src_dir}" && \
git init && \
git remote add "${ir_git_remote}" "${ir_git_url}" && \
git fetch "${ir_git_remote}" "${ir_git_refspec}" && \
git checkout FETCH_HEAD
WORKDIR "${ir_src_dir}"
ENV IR_HOME=/opt/infrared
# Install InfraRed and its default plugins
# - First installs infrared requirements to workaround the too-may-files
# problem related to temporary files removal final step
# - Then installs infrared itself
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install --upgrade setuptools wheel && \
(python3 -m pip install . || python3 -m pip install .) && \
infrared plugin list && \
(python3 -m pip cache purge || true)
# Creates persistent volume for IR workspaces
VOLUME ${IR_HOME}/.workspaces
# Sets default entry point
ENTRYPOINT ["infrared"]
CMD ["--help"]
# -----------------------------------------------------------------------------
FROM infrared as tobiko_plugin
# Add Tobiko plugin directory
ARG ir_tobiko_plugin=${ir_tobiko_plugin:-/src/infrared-tobiko}
RUN mkdir -p "${ir_tobiko_plugin}"
ADD . "${ir_tobiko_plugin}"
# Installs Tobiko plugin
RUN infrared plugin add "${ir_tobiko_plugin}"
# Sets tobiko as default command
CMD ["tobiko"]

View File

@ -1,7 +1,6 @@
# Tobiko framework requirements # Tobiko framework requirements
docker>=4.0 # Apache-2.0 docker>=4.0 # Apache-2.0
podman>=1.6.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD fixtures>=3.0.0 # Apache-2.0/BSD
keystoneauth1>=3.4.0 # Apache-2.0 keystoneauth1>=3.4.0 # Apache-2.0
Jinja2>=2.8.0 # BSD Jinja2>=2.8.0 # BSD
@ -13,6 +12,7 @@ oslo.log>=3.36.0 # Apache-2.0
pandas>=0.24.2 # BSD pandas>=0.24.2 # BSD
paramiko>=2.4.0 # LGPLv2.1 paramiko>=2.4.0 # LGPLv2.1
pbr>=4.0.0 # Apache-2.0 pbr>=4.0.0 # Apache-2.0
podman>=1.6.0 # Apache-2.0
python-heatclient>=1.5.0 # Apache-2.0 python-heatclient>=1.5.0 # Apache-2.0
python-glanceclient>=2.16.0 # Apache-2.0 python-glanceclient>=2.16.0 # Apache-2.0
python-neutronclient>=6.7.0 # Apache-2.0 python-neutronclient>=6.7.0 # Apache-2.0

1
tools/run_tests.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
# Copyright 2018 Red Hat # Copyright 2018 Red Hat
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may # Licensed under the Apache License, Version 2.0 (the "License"); you may