From 9315382353967ba3c255bb2ab364dacbb484b7d5 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 30 Mar 2022 13:46:29 +0100 Subject: [PATCH 1/2] Remove `dockerfile-pgtests` AFAICS these aren't used any more. They're going to break when I do poetry work (#11537), because tox won't (easily) recreate the locked poetry environment. I think it's less effort to throw it away than to fix it. --- docker/Dockerfile-pgtests | 30 -------------------------- docker/run_pg_tests.sh | 19 ---------------- docs/development/contributing_guide.md | 21 ------------------ scripts-dev/test_postgresql.sh | 19 ---------------- 4 files changed, 89 deletions(-) delete mode 100644 docker/Dockerfile-pgtests delete mode 100755 docker/run_pg_tests.sh delete mode 100755 scripts-dev/test_postgresql.sh diff --git a/docker/Dockerfile-pgtests b/docker/Dockerfile-pgtests deleted file mode 100644 index b94484ea7fd6..000000000000 --- a/docker/Dockerfile-pgtests +++ /dev/null @@ -1,30 +0,0 @@ -# Use the Sytest image that comes with a lot of the build dependencies -# pre-installed -FROM matrixdotorg/sytest:focal - -# 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 - -# 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 diff --git a/docker/run_pg_tests.sh b/docker/run_pg_tests.sh deleted file mode 100755 index b22b6ef16b7e..000000000000 --- a/docker/run_pg_tests.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -# This script runs the PostgreSQL tests inside a Docker container. It expects -# the relevant source files to be mounted into /src (done automatically by the -# caller script). It will set up the database, run it, and then use the tox -# configuration to run the tests. - -set -e - -# Set PGUSER so Synapse's tests know what user to connect to the database with -export PGUSER=postgres - -# Start the database -sudo -u postgres /usr/lib/postgresql/10/bin/pg_ctl -w -D /var/lib/postgresql/data start - -# Run the tests -cd /src -export TRIAL_FLAGS="-j 4" -tox --workdir=./.tox-pg-container -e py37-postgres "$@" diff --git a/docs/development/contributing_guide.md b/docs/development/contributing_guide.md index 071202e1965f..1116eecbcd23 100644 --- a/docs/development/contributing_guide.md +++ b/docs/development/contributing_guide.md @@ -220,27 +220,6 @@ export SYNAPSE_POSTGRES_PASSWORD=mydevenvpassword trial ``` -#### Prebuilt container - -Since configuring PostgreSQL can be fiddly, we can make use of a pre-made -Docker container to set up PostgreSQL and run our tests for us. To do so, run - -```shell -scripts-dev/test_postgresql.sh -``` - -Any extra arguments to the script will be passed to `tox` and then to `trial`, -so we can run a specific test in this container with e.g. - -```shell -scripts-dev/test_postgresql.sh tests.replication.test_sharded_event_persister.EventPersisterShardTestCase -``` - -The container creates a folder in your Synapse checkout called -`.tox-pg-container` and uses this as a tox environment. The output of any -`trial` runs goes into `_trial_temp` in your synapse source directory — the same -as running `trial` directly on your host machine. - ## Run the integration tests ([Sytest](https://github.com/matrix-org/sytest)). The integration tests are a more comprehensive suite of tests. They diff --git a/scripts-dev/test_postgresql.sh b/scripts-dev/test_postgresql.sh deleted file mode 100755 index 43cfa256e4da..000000000000 --- a/scripts-dev/test_postgresql.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/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 "$@" From 62208b5d53fb57a0d870fcb21997cf2d65f11975 Mon Sep 17 00:00:00 2001 From: David Robertson Date: Wed, 30 Mar 2022 17:44:10 +0100 Subject: [PATCH 2/2] Changelog --- changelog.d/12336.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/12336.misc diff --git a/changelog.d/12336.misc b/changelog.d/12336.misc new file mode 100644 index 000000000000..0aecd543f920 --- /dev/null +++ b/changelog.d/12336.misc @@ -0,0 +1 @@ +Remove the (broadly unused, dev-only) dockerfile for pg tests.