tests are now run in a container; misc additional minor changes

This commit is contained in:
Matthias Bisping 2022-03-18 12:40:02 +01:00
parent 391bcc482f
commit c5287ef1d2
5 changed files with 134 additions and 14 deletions

View File

@ -1 +1,106 @@
data
/build_venv/
/.venv/
/misc/
/incl/image_service/test/
/scratch/
/bamboo-specs/
README.md
Dockerfile
*idea
*misc
*egg-innfo
*pycache*
# Git
.git
.gitignore
# CI
.codeclimate.yml
.travis.yml
.taskcluster.yml
# Docker
.docker
# Byte-compiled / optimized / DLL files
__pycache__/
*/__pycache__/
*/*/__pycache__/
*/*/*/__pycache__/
*.py[cod]
*/*.py[cod]
*/*/*.py[cod]
*/*/*/*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/**
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Virtual environment
.env/
.venv/
#venv/
# PyCharm
.idea
# Python mode for VIM
.ropeproject
*/.ropeproject
*/*/.ropeproject
*/*/*/.ropeproject
# Vim swap files
*.swp
*/*.swp
*/*/*.swp
*/*/*/*.swp

19
Dockerfile_tests Executable file
View File

@ -0,0 +1,19 @@
ARG BASE_ROOT="nexus.iqser.com:5001/red/"
ARG VERSION_TAG="latest"
FROM ${BASE_ROOT}pyinfra:${VERSION_TAG}
EXPOSE 5000
EXPOSE 8080
RUN python3 -m pip install coverage
# Make a directory for the service files and copy the service repo into the container.
WORKDIR /app/service
COPY . .
# Install module & dependencies
RUN python3 -m pip install -e .
RUN python3 -m pip install -r requirements.txt
CMD coverage run -m pytest pyinfra/test/ -x && coverage report -m && coverage xml

View File

@ -7,8 +7,8 @@ python3 -m venv build_venv
source build_venv/bin/activate
python3 -m pip install --upgrade pip
pip install -e .
pip install -r requirements.txt
echo "coverage report generation"
bash run_tests.sh
SERVICE_NAME=$1

View File

@ -13,18 +13,6 @@ logging.getLogger("azure").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)
def _retry(exceptions=Exception):
def inner(func):
@retry(exceptions=exceptions, delay=5, jitter=(0, 3), max_delay=60)
@wraps(func)
def inner(*args, **kwargs):
return func(*args, **kwargs)
return inner
return inner
class AzureStorageAdapter(StorageAdapter):
def __init__(self, client):
super().__init__(client=client)

8
run_tests.sh Executable file
View File

@ -0,0 +1,8 @@
docker build -f Dockerfile_tests -t pyinfra-tests .
docker-compose -remove-orphans up -d
echo "Sleeping for 30 seconds to wait for dependency containers to finish startup..."
sleep 30s
docker rm /pyinfra-tests
docker run --net=host --name pyinfra-tests pyinfra-tests
docker cp pyinfra-tests:/app/service/reports/coverage.xml reports/coverage.xml