Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 0d17357

Browse files
David Robertsonsquahtx
andauthored
Suggest using docker when testing against postgres (#12765)
Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
1 parent 182ca78 commit 0d17357

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

changelog.d/12765.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Recommend using docker to run tests against postgres.

docs/development/contributing_guide.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,32 @@ This means that we need to run our unit tests against PostgreSQL too. Our CI doe
206206
this automatically for pull requests and release candidates, but it's sometimes
207207
useful to reproduce this locally.
208208

209-
To do so, [configure Postgres](../postgres.md) and run `trial` with the
209+
#### Using Docker
210+
211+
The easiest way to do so is to run Postgres via a docker container. In one
212+
terminal:
213+
214+
```shell
215+
docker run --rm -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_USER=postgres -e POSTGRES_DB=postgress -p 5432:5432 postgres:14
216+
```
217+
218+
If you see an error like
219+
220+
```
221+
docker: Error response from daemon: driver failed programming external connectivity on endpoint nice_ride (b57bbe2e251b70015518d00c9981e8cb8346b5c785250341a6c53e3c899875f1): Error starting userland proxy: listen tcp4 0.0.0.0:5432: bind: address already in use.
222+
```
223+
224+
then something is already bound to port 5432. You're probably already running postgres locally.
225+
226+
Once you have a postgres server running, invoke `trial` in a second terminal:
227+
228+
```shell
229+
SYNAPSE_POSTGRES=1 SYNAPSE_POSTGRES_HOST=127.0.0.1 SYNAPSE_POSTGRES_USER=postgres SYNAPSE_POSTGRES_PASSWORD=mysecretpassword poetry run trial tests
230+
````
231+
232+
#### Using an existing Postgres installation
233+
234+
If you have postgres already installed on your system, you can run `trial` with the
210235
following environment variables matching your configuration:
211236

212237
- `SYNAPSE_POSTGRES` to anything nonempty
@@ -229,8 +254,8 @@ You don't need to specify the host, user, port or password if your Postgres
229254
server is set to authenticate you over the UNIX socket (i.e. if the `psql` command
230255
works without further arguments).
231256
232-
Your Postgres account needs to be able to create databases.
233-
257+
Your Postgres account needs to be able to create databases; see the postgres
258+
docs for [`ALTER ROLE`](https://www.postgresql.org/docs/current/sql-alterrole.html).
234259
235260
## Run the integration tests ([Sytest](https://github.com/matrix-org/sytest)).
236261

0 commit comments

Comments
 (0)