This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update postgresql testing script (#10906)
- Use sytest:bionic. Sytest:latest is two years old (do we want CI to push out latest at all?) and comes with Python 3.5, which we explictly no longer support. The script now runs under PostgreSQL 10 as a result. - Advertise script in the docs - Move pg testing script to scripts-dev directory - Write to host as the script's exector, not root A few changes to make it speedier to re-run the tests: - Create blank DB in the container, not the script, so we don't have to `initdb` each time - Use a named volume to persist the tox environment, so we don't have to fetch and install a bunch of packages from PyPI each time Co-authored-by: reivilibre <[email protected]>
- Loading branch information
1 parent
0420d4e
commit ea01d4c
Showing
7 changed files
with
92 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ __pycache__/ | |
/.coverage* | ||
/.mypy_cache/ | ||
/.tox | ||
/.tox-pg-container | ||
/build/ | ||
/coverage.* | ||
/dist/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Update development testing script `test_postgresql.sh` to use a supported Python version and make re-runs quicker. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,30 @@ | ||
# Use the Sytest image that comes with a lot of the build dependencies | ||
# pre-installed | ||
FROM matrixdotorg/sytest:latest | ||
FROM matrixdotorg/sytest:bionic | ||
|
||
# The Sytest image doesn't come with python, so install that | ||
RUN apt-get update && apt-get -qq install -y python3 python3-dev python3-pip | ||
|
||
# We need tox to run the tests in run_pg_tests.sh | ||
RUN python3 -m pip install tox | ||
|
||
ADD run_pg_tests.sh /pg_tests.sh | ||
ENTRYPOINT /pg_tests.sh | ||
# Initialise the db | ||
RUN su -c '/usr/lib/postgresql/10/bin/initdb -D /var/lib/postgresql/data -E "UTF-8" --lc-collate="C.UTF-8" --lc-ctype="C.UTF-8" --username=postgres' postgres | ||
|
||
# Add a user with our UID and GID so that files get created on the host owned | ||
# by us, not root. | ||
ARG UID | ||
ARG GID | ||
RUN groupadd --gid $GID user | ||
RUN useradd --uid $UID --gid $GID --groups sudo --no-create-home user | ||
|
||
# Ensure we can start postgres by sudo-ing as the postgres user. | ||
RUN apt-get update && apt-get -qq install -y sudo | ||
RUN echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers | ||
|
||
ADD run_pg_tests.sh /run_pg_tests.sh | ||
# Use the "exec form" of ENTRYPOINT (https://docs.docker.com/engine/reference/builder/#entrypoint) | ||
# so that we can `docker run` this container and pass arguments to pg_tests.sh | ||
ENTRYPOINT ["/run_pg_tests.sh"] | ||
|
||
USER user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script builds the Docker image to run the PostgreSQL tests, and then runs | ||
# the tests. It uses a dedicated tox environment so that we don't have to | ||
# rebuild it each time. | ||
|
||
# Command line arguments to this script are forwarded to "tox" and then to "trial". | ||
|
||
set -e | ||
|
||
# Build, and tag | ||
docker build docker/ \ | ||
--build-arg "UID=$(id -u)" \ | ||
--build-arg "GID=$(id -g)" \ | ||
-f docker/Dockerfile-pgtests \ | ||
-t synapsepgtests | ||
|
||
# Run, mounting the current directory into /src | ||
docker run --rm -it -v "$(pwd):/src" -v synapse-pg-test-tox:/tox synapsepgtests "$@" |
This file was deleted.
Oops, something went wrong.