Merge "Refactor container files"

This commit is contained in:
Zuul 2021-11-12 18:04:06 +00:00 committed by Gerrit Code Review
commit 23718d05f2
3 changed files with 108 additions and 130 deletions

View File

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

View File

@ -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 apt update
RUN yum install -y git python3 rsync which
# Check your Python 3 version is greater than 3.6 # Set the locale
RUN python3 -c 'import sys; sys.version_info >= (3, 6)' RUN apt install -y locales
ENV LANG en_US.UTF-8
# Ensure Pip is installed and up-to date ENV LANGUAGE en_US:en
RUN curl https://bootstrap.pypa.io/get-pip.py | python3 ENV LC_ALL en_US.UTF-8
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
# Check installed Pip version locale-gen
RUN python3 -m pip --version
# Ensure basic Python packages are installed and up-to-date
RUN python3 -m pip install --upgrade setuptools wheel virtualenv tox six
# Check installed Tox version
RUN tox --version
# ----------------------------------------------------------------------------- FROM base as source
FROM base as sources # Populate tobiko source dir
# RUN mkdir -p ${TOBIKO_DIR}
# Get Tobiko source code using Git ADD .gitignore \
RUN mkdir -p /src extra-requirements.txt \
ADD . /src/tobiko requirements.txt \
WORKDIR /src/tobiko 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 source as build
FROM sources as bindeps # Install binary dependencies
RUN apt install -y git
# Ensure required binary packages are installed # Build wheel files
RUN ./tools/install-bindeps.sh RUN python3 -m pip wheel -w ${WHEEL_DIR} \
-c ${TOBIKO_DIR}/upper-constraints.txt \
# Check bindeps are installed -r ${TOBIKO_DIR}/requirements.txt \
CMD tox -e bindeps -r ${TOBIKO_DIR}/test-requirements.txt \
-r ${TOBIKO_DIR}/extra-requirements.txt \
--src ${TOBIKO_DIR}/
# ----------------------------------------------------------------------------- FROM base as install
FROM bindeps as py3 # Install wheels
RUN mkdir -p ${WHEEL_DIR}
# Prepare py3 Tox virtualenv COPY --from=build ${WHEEL_DIR} ${WHEEL_DIR}
RUN tox -e py3 --notest RUN pip install ${WHEEL_DIR}/*.whl
# Run unit yest cases
CMD tox -e py3
# ----------------------------------------------------------------------------- FROM source as tobiko
FROM py3 as venv # Install packages
RUN apt install -y iperf3 iputils-ping ncat
# Run bash inside py3 Tox environment # Run tests variables
CMD tox -e venv 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
# Write log files to report directory
RUN mkdir -p /etc/tobiko
RUN printf "[DEFAULT]\nlog_dir=${TOBIKO_REPORT_DIR}" > /etc/tobiko/tobiko.conf
# ----------------------------------------------------------------------------- # Copy python pacakges
COPY --from=install /usr/local /usr/local/
FROM py3 as functional # Copy tobiko tools
ADD tools/ ${TOBIKO_DIR}/tools/
# Run functional test cases WORKDIR ${TOBIKO_DIR}
CMD tox -e functional ENTRYPOINT tools/run_tests.py ${OS_TEST_PATH}
# -----------------------------------------------------------------------------
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,52 +2,46 @@
version: '3.4' version: '3.4'
services: services:
base: unit:
build: build:
context: . context: .
target: base target: tobiko
hostname: tobiko
environment:
OS_TEST_PATH: tobiko/tests/unit
TOX_REPORT_NAME: tobiko_results_unit
volumes:
- ./report:/report
sources: shell:
build: extends:
context: . service: unit
target: sources entrypoint: /bin/bash
bindeps:
build:
context: .
target: bindeps
py3:
build:
context: .
target: py3
venv:
build:
context: .
target: venv
functional: functional:
build: extends:
context: . service: unit
target: functional environment:
OS_TEST_PATH: tobiko/tests/functional
TOX_REPORT_NAME: tobiko_results_functional
scenario: create:
build: extends:
context: . service: unit
target: scenario environment:
OS_TEST_PATH: tobiko/tests/scenario
TOX_REPORT_NAME: tobiko_results_create
neutron: disrupt:
build: extends:
context: . service: unit
target: neutron environment:
OS_TEST_PATH: tobiko/tests/faults
TOX_REPORT_NAME: tobiko_results_disrupt
faults: verify:
build: extends:
context: . service: create
target: faults environment:
PREVENT_CREATE: true
infrared: TOX_REPORT_NAME: tobiko_results_verify
build:
context: .
target: infrared