Skip to content

Commit 36eb338

Browse files
themarcelorMarcelo Costa
andauthored
task(sdet): Introduce gen3 qa test controller (#493)
* task(sdet): Introduce gen3-qa-controller to trigger automated tests in Kubernetes * move Dockerfile to root folder, replace legacy/unused dockerfile * introduce poetry config * fix container cmd * trying to make this work with Poetry * applying poetry best practices and copying gen3-qa framework * grant execute permissions to the poetry binary * fix poetry lock * re-organize poetry folders * setting workdir to location with pyproject.toml * moving controller scripts to the correct folder * switching to sdet user earlier in the flow * adopting quay copy of alpine * moving everything to sdet_home * remove chmod * install everything as root and change owner recursively to sdet * debugging * debugging2 * alpine sux, adopting python:slim img * Revert "alpine sux, adopting python:slim img" This reverts commit b84431a. * running with poetry run python Co-authored-by: Marcelo Costa <marceloc@uchicago.edu>
1 parent e26669b commit 36eb338

File tree

4 files changed

+411
-21
lines changed

4 files changed

+411
-21
lines changed

Dockerfile

Lines changed: 80 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,88 @@
1-
# To run: docker run -d --name=dataportal -p 80:80 quay.io/cdis/data-portal
2-
# To check running container: docker exec -it dataportal /bin/bash
1+
FROM quay.io/cdis/alpine:3.12.1
32

4-
FROM ubuntu:18.04
3+
USER root
4+
5+
ENV SDET_HOME /var/sdet_home
6+
7+
ARG user=sdet
8+
ARG group=sdet
9+
ARG uid=1000
10+
ARG gid=1000
11+
12+
RUN addgroup -g ${gid} ${group} \
13+
&& adduser --home "$SDET_HOME" --uid ${uid} --ingroup ${group} --disabled-password --shell /bin/sh ${user}
514

615
ENV DEBIAN_FRONTEND=noninteractive
716

8-
RUN apt-get update && apt-get install -y --no-install-recommends \
9-
build-essential \
10-
ca-certificates \
11-
curl \
12-
libssl-dev \
13-
libcurl4-openssl-dev \
14-
git \
15-
nginx \
17+
# Install python/pip
18+
ENV PYTHONUNBUFFERED=1 \
19+
PYTHONDONTWRITEBYTECODE=1 \
20+
PIP_NO_CACHE_DIR=off \
21+
PIP_DISABLE_PIP_VERSION_CHECK=on \
22+
PIP_DEFAULT_TIMEOUT=100 \
23+
POETRY_VERSION=1.1.4 \
24+
POETRY_HOME="${SDET_HOME}/poetry" \
25+
POETRY_VIRTUALENVS_IN_PROJECT=true \
26+
POETRY_NO_INTERACTION=1 \
27+
PYSETUP_PATH="${SDET_HOME}/pysetup" \
28+
VENV_PATH="${SDET_HOME}/pysetup/.venv"
29+
30+
# prepend poetry and venv to path
31+
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"
32+
33+
RUN apk add --update --no-cache python3 \
34+
&& ln -sf python3 /usr/bin/python \
35+
&& python3 -m ensurepip \
36+
&& pip3 install --no-cache --upgrade pip setuptools
37+
38+
# install everything else
39+
RUN set -xe && apk add --no-cache --virtual .build-deps \
40+
zip \
41+
unzip \
42+
less \
1643
vim \
17-
&& pip install pip==9.0.3 \
18-
&& pip install requests \
19-
&& curl -sL https://deb.nodesource.com/setup_8.x | bash - \
20-
&& apt-get install -y --no-install-recommends nodejs \
21-
&& ln -sf /dev/stdout /var/log/nginx/access.log \
22-
&& ln -sf /dev/stderr /var/log/nginx/error.log
44+
gcc \
45+
libc-dev \
46+
libffi-dev \
47+
make \
48+
openssl-dev \
49+
pcre-dev \
50+
zlib-dev \
51+
linux-headers \
52+
curl \
53+
wget \
54+
jq \
55+
nodejs \
56+
npm
57+
58+
# Copy the gen3-qa framework scripts (test suites + service and utils modules)
59+
COPY codecept.conf.js \
60+
package.json \
61+
package-lock.json \
62+
test_setup.js \
63+
.eslintrc.js \
64+
helpers \
65+
hooks \
66+
services \
67+
suites \
68+
utils ${SDET_HOME}/
69+
70+
# install poetry - respects $POETRY_VERSION & $POETRY_HOME
71+
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
72+
73+
# Copy only requirements to cache them in docker layer
74+
RUN mkdir -p ${SDET_HOME}/controller/gen3qa-controller
75+
WORKDIR ${SDET_HOME}/controller
76+
COPY controller/poetry.lock controller/pyproject.toml ${SDET_HOME}/controller/
77+
78+
# copy controller scripts
79+
COPY controller/gen3qa-controller ${SDET_HOME}/controller/gen3qa-controller/
2380

24-
COPY . /gen3-qa
81+
# Project initialization:
82+
# install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally
83+
RUN poetry install --no-dev
2584

26-
WORKDIR /gen3-qa
85+
RUN chown -R ${user}:${group} ${SDET_HOME}
86+
USER sdet
2787

28-
ARG APP=dev
29-
ARG BASENAME
88+
CMD ["poetry", "run", "python", "gen3qa-controller/gen3qa-controller.py"]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import kubernetes
2+
import os
3+
4+
kubernetes.config.load_incluster_config()
5+
v1 = kubernetes.client.CoreV1Api()
6+
7+
w = kubernetes.watch.Watch()
8+
9+
for event in w.stream(v1.list_namespaced_pod, os.environ["MY_POD_NAMESPACE"]):
10+
print(event)
11+
# TODO: Parse tests-config.json and trigger tests for target services

0 commit comments

Comments
 (0)