Update Tobiko container

- allow to use fedora 35 as base image
- make base image configurable
- update docker compose file
- fix python code to satisfy linters with Python 3.10
- add linters, lower-constraints and fedora jobs

Change-Id: I1a786191d2529fe1d14a47f06f76405490bfb11c
This commit is contained in:
Federico Ressi 2022-01-04 12:08:09 +01:00
parent 5956937118
commit 31758b2400
5 changed files with 119 additions and 29 deletions

View File

@ -1,22 +1,43 @@
FROM python:3.10 as base ARG base_image=python
FROM python:3.10 as python
ENV INSTALL_PACKAGES="apt install -y"
ENV CONSTRAINS_FILE=upper-constraints.txt
RUN apt update && apt install -y iperf3 iputils-ping ncat
FROM python:3.8 as lower-constraints
ENV INSTALL_PACKAGES="apt install -y"
ENV CONSTRAINS_FILE=lower-constraints.txt
RUN apt update && apt install -y iperf3 iputils-ping ncat
FROM fedora:35 as fedora
ENV CONSTRAINS_FILE=upper-constraints.txt
ENV INSTALL_PACKAGES="dnf install -y"
RUN ${INSTALL_PACKAGES} iperf3 gcc python3-devel
FROM ${base_image} as base
ENV TOBIKO_DIR=/tobiko ENV TOBIKO_DIR=/tobiko
ENV WHEEL_DIR=/wheel ENV WHEEL_DIR=/wheel
ENV INSTALL_PACKAGES="apt install -y"
# Install binary dependencies
RUN apt update && \
${INSTALL_PACKAGES} git
RUN python3 -m ensurepip --upgrade && \ RUN python3 -m ensurepip --upgrade && \
python3 -m pip install --upgrade setuptools wheel python3 -m pip install --upgrade setuptools wheel
FROM base as source FROM base as source
# Populate tobiko source dir # Install binary dependencies
# RUN mkdir -p ${TOBIKO_DIR} RUN ${INSTALL_PACKAGES} git
ADD .gitignore \ ADD .gitignore \
extra-requirements.txt \ extra-requirements.txt \
@ -25,21 +46,18 @@ ADD .gitignore \
setup.cfg \ setup.cfg \
setup.py \ setup.py \
test-requirements.txt \ test-requirements.txt \
upper-constraints.txt \ ${CONSTRAINS_FILE} \
${TOBIKO_DIR}/ ${TOBIKO_DIR}/
ADD .git ${TOBIKO_DIR}/.git/
ADD tobiko/ ${TOBIKO_DIR}/tobiko/ ADD tobiko/ ${TOBIKO_DIR}/tobiko/
ADD .git ${TOBIKO_DIR}/.git/
FROM source as build FROM source as build
# Install binary dependencies
# RUN ${INSTALL_PACKAGES} gcc python3-devel
# Build wheel files # Build wheel files
RUN python3 -m pip wheel -w ${WHEEL_DIR} \ RUN python3 -m pip wheel -w ${WHEEL_DIR} \
-c ${TOBIKO_DIR}/upper-constraints.txt \ -c ${TOBIKO_DIR}/${CONSTRAINS_FILE} \
-r ${TOBIKO_DIR}/requirements.txt \ -r ${TOBIKO_DIR}/requirements.txt \
-r ${TOBIKO_DIR}/test-requirements.txt \ -r ${TOBIKO_DIR}/test-requirements.txt \
-r ${TOBIKO_DIR}/extra-requirements.txt \ -r ${TOBIKO_DIR}/extra-requirements.txt \
@ -56,9 +74,6 @@ RUN python3 -m pip install ${WHEEL_DIR}/*.whl
FROM source as tobiko FROM source as tobiko
# Install packages
RUN ${INSTALL_PACKAGES} iperf3 iputils-ping ncat
# Run tests variables # Run tests variables
ENV PYTHONWARNINGS=ignore::Warning ENV PYTHONWARNINGS=ignore::Warning
ENV OS_TEST_PATH=${TOBIKO_DIR}/tobiko/tests/unit ENV OS_TEST_PATH=${TOBIKO_DIR}/tobiko/tests/unit
@ -70,11 +85,27 @@ ENV TOBIKO_PREVENT_CREATE=false
RUN mkdir -p /etc/tobiko RUN mkdir -p /etc/tobiko
RUN printf "[DEFAULT]\nlog_dir=${TOBIKO_REPORT_DIR}" > /etc/tobiko/tobiko.conf RUN printf "[DEFAULT]\nlog_dir=${TOBIKO_REPORT_DIR}" > /etc/tobiko/tobiko.conf
# Copy python pacakges
COPY --from=install /usr/local /usr/local/
# Copy tobiko tools # Copy tobiko tools
ADD tools/ ${TOBIKO_DIR}/tools/ ADD tools/ ${TOBIKO_DIR}/tools/
# Copy python pacakges
COPY --from=install /usr/local /usr/local/
WORKDIR ${TOBIKO_DIR} WORKDIR ${TOBIKO_DIR}
CMD tools/run_tests.py ${OS_TEST_PATH} CMD tools/run_tests.py ${OS_TEST_PATH}
FROM tobiko as linters
ENV SKIP=check-executables-have-shebangs,pylint
# Copy configuration files
ADD .pre-commit-config.yaml \
linters-requirements.txt \
${TOBIKO_DIR}/
RUN python3 -m pip install -r ${TOBIKO_DIR}/linters-requirements.txt
RUN pre-commit install --install-hooks
WORKDIR ${TOBIKO_DIR}
CMD pre-commit run -a

View File

@ -15,6 +15,30 @@ services:
- .:/tobiko - .:/tobiko
- ~/.ssh:/root/.ssh - ~/.ssh:/root/.ssh
lower-constraints:
extends:
service: unit
build:
context: .
target: tobiko
args:
base_image: lower-constraints
linters:
extends:
service: unit
build:
target: linters
fedora:
extends:
service: unit
build:
context: .
target: tobiko
args:
base_image: fedora
functional: functional:
extends: extends:
service: unit service: unit

View File

@ -81,8 +81,8 @@ class Portal(abc.MutableMapping):
def _schedule_reaper(self): def _schedule_reaper(self):
timer = threading.Timer(interval=self.sweap, function=self.reap) timer = threading.Timer(interval=self.sweap, function=self.reap)
timer.setName('PortalReaper') timer.name = 'PortalReaper'
timer.setDaemon(True) timer.daemon = True
timer.start() timer.start()
def reap(self): def reap(self):

View File

@ -15,7 +15,7 @@
# under the License. # under the License.
from __future__ import absolute_import from __future__ import absolute_import
import collections from collections import abc
import random import random
import re import re
@ -91,7 +91,7 @@ class OpenStackTopologyTest(testtools.TestCase):
else: else:
self.fail(f"Any node {node.name} group matches " self.fail(f"Any node {node.name} group matches "
f"'{group}': {node.groups}") f"'{group}': {node.groups}")
elif isinstance(group, collections.Iterable): elif isinstance(group, abc.Iterable):
matching_groups = set(group) & set(node.groups) matching_groups = set(group) & set(node.groups)
self.assertNotEqual(set(), matching_groups, self.assertNotEqual(set(), matching_groups,
f"Any group of node {node.name} " f"Any group of node {node.name} "

View File

@ -6,9 +6,12 @@
Docker jobs intended to gate Tobiko container related changes Docker jobs intended to gate Tobiko container related changes
check: &CHECK check: &CHECK
jobs: jobs:
- tobiko-docker
- tobiko-docker-fedora
- tobiko-docker-functional - tobiko-docker-functional
- tobiko-docker-infrared - tobiko-docker-infrared
- tobiko-docker-unit - tobiko-docker-linters
- tobiko-docker-lower-constraints
gate: gate:
jobs: jobs:
- tobiko-docker-functional - tobiko-docker-functional
@ -18,7 +21,7 @@
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
- job: - job:
name: tobiko-docker-unit name: tobiko-docker
description: | description: |
Run unit tests for an OpenStack Python project inside a Docker container. Run unit tests for an OpenStack Python project inside a Docker container.
voting: true voting: true
@ -32,12 +35,23 @@
docker_compose_service: unit docker_compose_service: unit
- job:
name: tobiko-docker-fedora
description: |
Run functional tests for an OpenStack Python project inside a Docker container
based on Fedora 35
voting: true
parent: tobiko-docker
vars:
docker_compose_service: fedora
- job: - job:
name: tobiko-docker-functional name: tobiko-docker-functional
description: | description: |
Run functional tests for an OpenStack Python project inside a Docker container. Run functional tests for an OpenStack Python project inside a Docker container.
voting: true voting: true
parent: tobiko-docker-unit parent: tobiko-docker
timeout: 3600 timeout: 3600
vars: vars:
docker_compose_service: functional docker_compose_service: functional
@ -48,7 +62,28 @@
description: | description: |
Run functional tests for an OpenStack Python project inside a Docker container. Run functional tests for an OpenStack Python project inside a Docker container.
voting: true voting: true
parent: tobiko-docker-unit parent: tobiko-docker
timeout: 3600 timeout: 3600
vars: vars:
docker_compose_service: infrared docker_compose_service: infrared
- job:
name: tobiko-docker-linters
description: |
Run static analisys verifications
voting: true
parent: tobiko-docker
vars:
docker_compose_service: linters
- job:
name: tobiko-docker-lower-constraints
description: |
Run functional tests for an OpenStack Python project inside a Docker container
with lower-constrains.txt requirements file.
voting: true
parent: tobiko-docker
vars:
docker_compose_service: lower-constraints