Update Dockerfile to use bindep and tox

Change-Id: I1fd2e966863908751ab5cba685e99c1ddf07b582
This commit is contained in:
Federico Ressi 2020-06-19 07:35:13 +02:00
parent 187fd10ddb
commit 69ea632d3e
4 changed files with 132 additions and 49 deletions

View File

@ -37,11 +37,5 @@ doc/source/_static/config-samples/*.sample
Pipfile.lock Pipfile.lock
# Tobiko configuration file
tobiko.conf
clouds.yaml
ssh_config
# Infrared things # Infrared things
.infrared .infrared
workspace.tgz

View File

@ -1,39 +1,107 @@
ARG base_image="docker.io/library/centos:8" ARG base_image="docker.io/library/centos:8"
FROM "${base_image}" as tobiko FROM "${base_image}" as base
# Install binary dependencies # Make sure Git and Python 3 are installed on your system.
RUN dnf install -y gcc git python3 python3-devel && \ RUN yum install -y git python3 rsync which
alternatives --set python /usr/bin/python3
# Get Tobiko source files # Check your Python 3 version is greater than 3.6
ARG tobiko_src_dir=. RUN python3 -c 'import sys; sys.version_info >= (3, 6)'
ENV TOBIKO_DIR=/src/tobiko
# Copy Tobiko source files
RUN mkdir /src
ADD "${tobiko_src_dir}" "${TOBIKO_DIR}"
WORKDIR "${TOBIKO_DIR}"
# Install Python requirements # Ensure Pip is installed and up-to date
ARG constraints_file=https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt RUN curl https://bootstrap.pypa.io/get-pip.py | python3
ENV PIP_INSTALL="python -m pip install -c ${constraints_file}"
RUN set -x && \ # Check installed Pip version
python --version && \ RUN python3 -m pip --version
${PIP_INSTALL} --upgrade pip && \
${PIP_INSTALL} --upgrade setuptools wheel && \ # Ensure basic Python packages are installed and up-to-date
${PIP_INSTALL} -r ./requirements.txt && \ RUN python3 -m pip install --upgrade setuptools wheel virtualenv tox six
${PIP_INSTALL} ./
# Check installed Tox version
RUN tox --version
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
FROM tobiko as tests FROM base as sources
RUN ${PIP_INSTALL} -r ./test-requirements.txt # Get Tobiko source code using Git
RUN mkdir -p /src
ADD . /src/tobiko
WORKDIR /src/tobiko
# Run test cases
ENV OS_LOG_CAPTURE=true # -----------------------------------------------------------------------------
ENV OS_STDOUT_CAPTURE=true
ENV OS_STDERR_CAPTURE=true FROM sources as bindeps
ENV OS_TEST_PATH=tobiko/tests/unit
ENTRYPOINT ./tools/run_tests.py # Ensure required binary packages are installed
RUN ./tools/install-bindeps.sh
# Check bindeps are installed
CMD tox -e bindeps
# -----------------------------------------------------------------------------
FROM bindeps as py3
# Prepare py3 Tox virtualenv
RUN tox -e py3 --notest
# Run unit yest cases
CMD tox -e py3
# -----------------------------------------------------------------------------
FROM py3 as venv
# Run bash inside py3 Tox environment
CMD tox -e venv
# -----------------------------------------------------------------------------
FROM py3 as functional
# Run functional test cases
CMD tox -e functional
# -----------------------------------------------------------------------------
FROM py3 as scenario
# Run scenario test cases
CMD tox -e scenario
# -----------------------------------------------------------------------------
FROM py3 as neutron
# Run scenario test cases
CMD tox -e neutron
# -----------------------------------------------------------------------------
FROM py3 as faults
# Run faults test cases
CMD tox -e faults
# -----------------------------------------------------------------------------
from bindeps as infrared
# Set Python 3 as default alternative for python command
RUN alternatives --set python /usr/bin/python3
# Prepare infrared Tox virtualenv
RUN tox -e infrared --notest
# Run Tobiko InfraRed plugin
CMD tox -e infrared

View File

@ -2,31 +2,52 @@
version: '3.4' version: '3.4'
services: services:
base:
build:
context: .
target: base
sources:
build:
context: .
target: sources
bindeps:
build:
context: .
target: bindeps
py3: py3:
build: build:
context: . context: .
target: tests target: py3
args:
OS_TEST_PATH: ./tests/unit venv:
build:
context: .
target: venv
functional: functional:
build: build:
context: . context: .
target: tests target: functional
args:
OS_TEST_PATH: ./tests/functional
scenario: scenario:
build: build:
context: . context: .
target: tests target: scenario
args:
OS_TEST_PATH: ./tests/scenario neutron:
build:
context: .
target: neutron
faults: faults:
build: build:
context: . context: .
target: tests target: faults
args:
OS_TEST_PATH: ./tests/faults
infrared: infrared:
build: build:
context: ./infrared_plugin context: .
target: tobiko_plugin target: infrared

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
set -ex set -ex