Browse Source

Merge "Refactor container files"

changes/56/817756/4
Zuul 6 months ago committed by Gerrit Code Review
parent
commit
23718d05f2
  1. 18
      .dockerignore
  2. 142
      Dockerfile
  3. 82
      docker-compose.yml

18
.dockerignore

@ -7,12 +7,14 @@
# Hidden files
.coverage
.coverage.*
.dockerignore
.eggs
.mypy_cache
.stestr
.test
.testrepository
.tobiko-env
.tobiko
.tox
.vagrant
.venv
@ -21,21 +23,29 @@ __pycache__
AUTHORS
build/*
ChangeLog
doc/build/*
doc/
cover/
dist/
etc/*.sample
playbooks/
releasenotes/
report/
roles/
test_results*
zuul/versioninfo
# Files created by releasenotes build
releasenotes/build
# Docs related files
doc/source/_static/config-samples/*.sample
Pipfile.lock
# Infrared things
.infrared
# Docker files
Dockerfile
docker-compose.yaml
docker-compose.yml
# Tobiko configuration files
tobiko.conf

142
Dockerfile

@ -1,107 +1,81 @@
ARG base_image="docker.io/library/centos:8"
FROM python:3.9 as base
FROM "${base_image}" as base
ENV TOBIKO_DIR=/tobiko
ENV WHEEL_DIR=/wheel
# Make sure Git and Python 3 are installed on your system.
RUN yum install -y git python3 rsync which
RUN apt update
# Check your Python 3 version is greater than 3.6
RUN python3 -c 'import sys; sys.version_info >= (3, 6)'
# Set the locale
RUN apt install -y locales
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
locale-gen
# Ensure Pip is installed and up-to date
RUN curl https://bootstrap.pypa.io/get-pip.py | python3
# Check installed Pip version
RUN python3 -m pip --version
FROM base as source
# Ensure basic Python packages are installed and up-to-date
RUN python3 -m pip install --upgrade setuptools wheel virtualenv tox six
# Populate tobiko source dir
# RUN mkdir -p ${TOBIKO_DIR}
# Check installed Tox version
RUN tox --version
ADD .gitignore \
extra-requirements.txt \
requirements.txt \
README.rst \
setup.cfg \
setup.py \
test-requirements.txt \
upper-constraints.txt \
${TOBIKO_DIR}/
ADD .git ${TOBIKO_DIR}/.git/
ADD tobiko/ ${TOBIKO_DIR}/tobiko/
# -----------------------------------------------------------------------------
FROM base as sources
FROM source as build
# Get Tobiko source code using Git
RUN mkdir -p /src
ADD . /src/tobiko
WORKDIR /src/tobiko
# Install binary dependencies
RUN apt install -y git
# Build wheel files
RUN python3 -m pip wheel -w ${WHEEL_DIR} \
-c ${TOBIKO_DIR}/upper-constraints.txt \
-r ${TOBIKO_DIR}/requirements.txt \
-r ${TOBIKO_DIR}/test-requirements.txt \
-r ${TOBIKO_DIR}/extra-requirements.txt \
--src ${TOBIKO_DIR}/
# -----------------------------------------------------------------------------
FROM sources as bindeps
FROM base as install
# Ensure required binary packages are installed
RUN ./tools/install-bindeps.sh
# Install wheels
RUN mkdir -p ${WHEEL_DIR}
COPY --from=build ${WHEEL_DIR} ${WHEEL_DIR}
RUN pip install ${WHEEL_DIR}/*.whl
# Check bindeps are installed
CMD tox -e bindeps
FROM source as tobiko
# -----------------------------------------------------------------------------
# Install packages
RUN apt install -y iperf3 iputils-ping ncat
FROM bindeps as py3
# Run tests variables
ENV PYTHONWARNINGS=ignore::Warning
ENV OS_TEST_PATH=${TOBIKO_DIR}/tobiko/tests/unit
ENV TOX_REPORT_DIR=/report
ENV TOX_REPORT_NAME=tobiko_results
ENV TOBIKO_PREVENT_CREATE=false
# Prepare py3 Tox virtualenv
RUN tox -e py3 --notest
# Write log files to report directory
RUN mkdir -p /etc/tobiko
RUN printf "[DEFAULT]\nlog_dir=${TOBIKO_REPORT_DIR}" > /etc/tobiko/tobiko.conf
# Run unit yest cases
CMD tox -e py3
# Copy python pacakges
COPY --from=install /usr/local /usr/local/
# Copy tobiko tools
ADD tools/ ${TOBIKO_DIR}/tools/
# -----------------------------------------------------------------------------
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
WORKDIR ${TOBIKO_DIR}
ENTRYPOINT tools/run_tests.py ${OS_TEST_PATH}

82
docker-compose.yml

@ -2,52 +2,46 @@
version: '3.4'
services:
base:
unit:
build:
context: .
target: base
target: tobiko
hostname: tobiko
environment:
OS_TEST_PATH: tobiko/tests/unit
TOX_REPORT_NAME: tobiko_results_unit
volumes:
- ./report:/report
sources:
build:
context: .
target: sources
bindeps:
build:
context: .
target: bindeps
py3:
build:
context: .
target: py3
venv:
build:
context: .
target: venv
shell:
extends:
service: unit
entrypoint: /bin/bash
functional:
build:
context: .
target: functional
scenario:
build:
context: .
target: scenario
neutron:
build:
context: .
target: neutron
faults:
build:
context: .
target: faults
infrared:
build:
context: .
target: infrared
extends:
service: unit
environment:
OS_TEST_PATH: tobiko/tests/functional
TOX_REPORT_NAME: tobiko_results_functional
create:
extends:
service: unit
environment:
OS_TEST_PATH: tobiko/tests/scenario
TOX_REPORT_NAME: tobiko_results_create
disrupt:
extends:
service: unit
environment:
OS_TEST_PATH: tobiko/tests/faults
TOX_REPORT_NAME: tobiko_results_disrupt
verify:
extends:
service: create
environment:
PREVENT_CREATE: true
TOX_REPORT_NAME: tobiko_results_verify

Loading…
Cancel
Save