Skip to content

Commit 5e234e8

Browse files
authored
TestKit time-warp backend (neo4j#1245)
1 parent dc4b033 commit 5e234e8

File tree

13 files changed

+1180
-749
lines changed

13 files changed

+1180
-749
lines changed

.dockerignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@ dist
44
venv*/
55
.coverage
66
tests/
7-
testkit/
8-
testkitbackend/

testkit/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.py
2+
!backend.py

testkit/Dockerfile

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
FROM ubuntu:20.04
1+
ARG TIME_WARP=""
2+
FROM ubuntu:20.04 AS base
23

34
ENV DEBIAN_FRONTEND=noninteractive
45
RUN apt-get update && \
56
apt-get install -y locales && \
67
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
7-
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \
8-
&& rm -rf /var/lib/apt/lists/*
8+
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 && \
9+
rm -rf /var/lib/apt/lists/*
910
ENV LANG=en_US.UTF-8
1011

1112
# Using apt-get update alone in a RUN statement causes caching issues and subsequent apt-get install instructions fail.
@@ -29,21 +30,24 @@ RUN apt-get update && \
2930
ca-certificates && \
3031
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
3132

32-
# Install our own CAs on the image.
33-
# Assumes Linux Debian based image.
34-
COPY CAs/* /usr/local/share/ca-certificates/
35-
# Store custom CAs somewhere where the backend can find them later.
36-
COPY CustomCAs/* /usr/local/share/custom-ca-certificates/
37-
RUN update-ca-certificates
38-
3933
# Install pyenv
4034
RUN git clone https://github.com/pyenv/pyenv.git .pyenv
4135
ENV PYENV_ROOT=/.pyenv
4236
ENV PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH"
37+
ENV PIP_NO_CACHE_DIR=1
38+
39+
40+
FROM base AS base-py-arg
41+
# Install all supported Python versions
42+
ARG PYTHON_VERSIONS="3.13 3.12 3.11 3.10 3.9 3.8 3.7"
43+
4344

44-
# Setup python version
45-
ENV PYTHON_VERSIONS="3.13 3.12 3.11 3.10 3.9 3.8 3.7"
45+
FROM base AS base-py-arg-single-python
46+
# Only install Python 3.7 in time warp mode
47+
ARG PYTHON_VERSIONS="3.7"
4648

49+
50+
FROM base-py-arg${TIME_WARP:+"-single-python"} AS base-py-install
4751
RUN for version in $PYTHON_VERSIONS; do \
4852
pyenv install $version; \
4953
done
@@ -57,3 +61,34 @@ RUN for version in $PYTHON_VERSIONS; do \
5761
python$version -m pip install -U pip && \
5862
python$version -m pip install -U coverage tox; \
5963
done
64+
65+
66+
FROM base-py-install AS backend-timewarp
67+
WORKDIR /home/root/testkit
68+
COPY requirements*.txt .
69+
COPY testkit/backend.py testkit/build.py testkit/_common.py .
70+
RUN sed -i 's|-e \..*$||' requirements*.txt
71+
72+
ARG TIME_WARP
73+
RUN for version in $PYTHON_VERSIONS; do \
74+
TEST_BACKEND_VERSION="python$version" python build.py && \
75+
python$version -m pip install --force-reinstall neo4j==${TIME_WARP}; \
76+
done
77+
COPY testkitbackend ./testkitbackend
78+
ENTRYPOINT ["python", "backend.py"]
79+
80+
81+
FROM base-py-install AS backend
82+
# Install our own CAs on the image.
83+
# Assumes Linux Debian based image.
84+
COPY CAs/* /usr/local/share/ca-certificates/
85+
# Store custom CAs somewhere where the backend can find them later.
86+
COPY CustomCAs/* /usr/local/share/custom-ca-certificates/
87+
RUN update-ca-certificates
88+
89+
90+
FROM backend${TIME_WARP:+"-timewarp"} AS final
91+
ARG TIME_WARP
92+
ENV DRIVER_TIME_WARP=$TIME_WARP
93+
WORKDIR /home/root/testkit
94+
EXPOSE 9876/tcp

testkit/backend.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@
2323
cmd = ["-m", "testkitbackend"]
2424
if "TEST_BACKEND_SERVER" in os.environ:
2525
cmd.append(os.environ["TEST_BACKEND_SERVER"])
26-
run_python(cmd)
26+
is_time_warp = bool(os.environ.get("DRIVER_TIME_WARP"))
27+
run_python(cmd, warning_as_error=not is_time_warp)

0 commit comments

Comments
 (0)