From 2c3061badf8e19626c06e5abc90a64612a7592f7 Mon Sep 17 00:00:00 2001 From: DMRobertson Date: Fri, 24 Sep 2021 14:27:34 +0000 Subject: deploy: ea01d4c2de65f29cf23e2d28786bfc10bd5fd881 --- develop/development/contributing_guide.html | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'develop/development/contributing_guide.html') diff --git a/develop/development/contributing_guide.html b/develop/development/contributing_guide.html index 7c0613b12a..7fcd7baa8f 100644 --- a/develop/development/contributing_guide.html +++ b/develop/development/contributing_guide.html @@ -291,6 +291,41 @@ trial tests.rest.admin.test_room tests.handlers.test_admin.ExfiltrateData.test_i

To increase the log level for the tests, set SYNAPSE_TEST_LOG_LEVEL:

SYNAPSE_TEST_LOG_LEVEL=DEBUG trial tests
 
+

Running tests under PostgreSQL

+

Invoking trial as above will use an in-memory SQLite database. This is great for +quick development and testing. However, we recommend using a PostgreSQL database +in production (and indeed, we have some code paths specific to each database). +This means that we need to run our unit tests against PostgreSQL too. Our CI does +this automatically for pull requests and release candidates, but it's sometimes +useful to reproduce this locally.

+

To do so, configure Postgres and run trial with the +following environment variables matching your configuration:

+ +

For example:

+
export SYNAPSE_POSTGRES=1
+export SYNAPSE_POSTGRES_HOST=localhost
+export SYNAPSE_POSTGRES_USER=postgres
+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

+
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.

+
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).

The integration tests are a more comprehensive suite of tests. They run a full version of Synapse, including your changes, to check if -- cgit 1.5.1