Skip to content
Snippets Groups Projects
Commit 85aff79c authored by Nicolas Karolak's avatar Nicolas Karolak
Browse files

Merge branch 't30039-reliability' into 'master'

make tests more reliable | refs #30039

See merge request mediaserver/envsetup!1
parents 85e1e697 4326a2b9
No related branches found
No related tags found
No related merge requests found
FROM ubuntu:bionic FROM registry.ubicast.net/docker/debian-dev:buster
# Set the default shell to bash instead of sh # avoid warnings by switching to noninteractive
ENV SHELL /bin/bash
# Update path to include virtualenv
ENV PATH "/usr/local/pyvenv/bin:${PATH}"
# Set locales
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
# Configure apt
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \ # local pyvenv to avoid conflicts with system
apt-get -y install --no-install-recommends apt-utils 2>&1 ENV PYVENV ${HOME}/pyvenv
# add pyvenv to path
ENV PATH ${PYVENV}/bin:${PATH}
# Install git, required tools RUN \
RUN apt-get update && \ # install required tools
apt-get install -y \ sudo apt-get update && \
apt-transport-https \ sudo apt-get install -y \
bash-completion \
build-essential \
ca-certificates \
curl \
git \
gnupg-agent \
libffi-dev \ libffi-dev \
libssl-dev \ libssl-dev \
lsb-release \ && \
procps \ # clean up
python3 \ sudo apt-get autoremove -y && \
python3-dev \ sudo apt-get clean -y && \
python3-venv \ sudo rm -rf /var/lib/apt/lists/* && \
shellcheck \ # create pyvenv
software-properties-common \ python3 -m venv ${PYVENV} && \
unzip \ # update pip tools into pyvenv
vim-tiny \ pip install -U \
2>&1 pip \
wheel \
# Configure shell && \
RUN sed -i 's/#force_color_prompt=yes/force_color_prompt=yes/' /root/.bashrc && \ :
echo ". /etc/bash_completion" >> /root/.bashrc
# Install Docker CE CLI.
RUN curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | apt-key add - 2>/dev/null && \
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" && \
apt-get update && \
apt-get install -y docker-ce-cli
# Install Poetry RUN \
RUN python3 -m venv /usr/local/pyvenv && \ # requirements
pip install -U pip wheel 2>&1 && \ pip install psutil pyOpenSSL pyspf requests defusedxml && \
pip install psutil pyOpenSSL pyspf requests defusedxml 2>&1 && \ # dev requirements
pip install black flake8 pre-commit pylint pysnooper 2>&1 pip install black flake8 pre-commit pylint pysnooper && \
:
# Clean up # switch back to dialog for any ad-hoc use of apt-get
RUN apt-get autoremove -y && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
ENV DEBIAN_FRONTEND=dialog ENV DEBIAN_FRONTEND=dialog
{ {
"name": "envsetup",
"dockerComposeFile": "docker-compose.yml", "dockerComposeFile": "docker-compose.yml",
"service": "app", "service": "app",
"workspaceFolder": "/workspace", "workspaceFolder": "/workspace",
"postCreateCommand": "bash .devcontainer/scripts/postcreate.sh",
"extensions": [ "extensions": [
// editor // python
"editorconfig.editorconfig", "ms-python.python",
"mikestead.dotenv", ],
// python "settings": {
"ms-python.python", },
// docker
"peterjausovec.vscode-docker"
]
} }
--- ---
version: '3' version: "3"
services: services:
app: app:
build: build:
context: .. context: ".."
dockerfile: .devcontainer/Dockerfile dockerfile: ".devcontainer/Dockerfile"
user: "vscode"
volumes: volumes:
- ..:/workspace - "~/.config/git:/home/vscode/.config/git:ro"
- ~/.config/git/config:/root/.config/git/config - "~/.ssh:/home/vscode/.ssh:ro"
- ~/.config/git/ignore:/root/.config/git/ignore - "${SSH_AUTH_SOCK}:/ssh-agent:ro"
- ${SSH_AUTH_SOCK}:/ssh-agent - "/var/run/docker.sock:/var/run/docker.sock"
- /var/run/docker.sock:/var/run/docker.sock - "..:/workspace"
environment: environment:
- SSH_AUTH_SOCK=/ssh-agent - "SSH_AUTH_SOCK=/ssh-agent"
working_dir: /workspace working_dir: "/workspace"
command: sleep infinity command: "sleep infinity"
... ...
#!/usr/bin/env bash
# make the GID match with docker on the host
sudo groupmod -g $(ls -ln /var/run/docker.sock | awk '{ print $4 }') docker
[flake8]
# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
# Ignored errors:
# - E501: line too long
# - W503: line break before binary operator (deprecated rule)
# - W505: doc line too long
ignore=E501,W503,W505
---
repos:
- repo: https://github.com/ambv/black
rev: 19.3b0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 45fc394c19e208123b8e9ec3f584c7ae3adef8c4
hooks:
- id: flake8
...
[metadata]
name = envsetup
long_description = file: README.md
long_description_content_type = text/markdown
[options]
setup_requires=
setuptools
wheel
[options.extras_require]
dev =
black
flake8
pylint
pysnooper
[flake8]
exclude =
.venv/
ignore =
E501
W503
W505
max-line-length = 88
[pylint]
ignore=
disable=
bad-continuation,
invalid-name,
missing-docstring,
too-few-public-methods,
too-many-locals,
#!/usr/bin/env python3
import setuptools
setuptools.setup()
...@@ -13,6 +13,7 @@ import subprocess ...@@ -13,6 +13,7 @@ import subprocess
import sys import sys
import uuid import uuid
import glob import glob
from time import sleep
import utils import utils
from utils import log from utils import log
...@@ -324,13 +325,20 @@ class Tester: ...@@ -324,13 +325,20 @@ class Tester:
start_date = datetime.datetime.utcnow() start_date = datetime.datetime.utcnow()
log("Test start: %s UTC." % start_date.strftime("%Y-%m-%d %H:%M:%S")) log("Test start: %s UTC." % start_date.strftime("%Y-%m-%d %H:%M:%S"))
# Run test # Run test
p = subprocess.Popen( count = 0
command, while count < 3:
stdin=sys.stdin, count += 1
stdout=subprocess.PIPE, log("Attempt: %s" % str(count))
stderr=subprocess.STDOUT, p = subprocess.Popen(
) command,
out, err = p.communicate() stdin=sys.stdin,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
out, err = p.communicate()
if p.returncode in (0, 2, 3):
break
sleep(5 * count * count)
if out: if out:
out = out.decode("utf-8").strip() out = out.decode("utf-8").strip()
out_of_support = out_of_support or "out of support" in out out_of_support = out_of_support or "out of support" in out
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment