Skip to content

Commit 8460dac

Browse files
committed
Merge tag 'v1.44.0' into 2021-05
Synapse 1.44.0 (2021-10-05) =========================== No significant changes since 1.44.0rc3. Synapse 1.44.0rc3 (2021-10-04) ============================== Bugfixes -------- - Fix a bug introduced in Synapse v1.40.0 where changing a user's display name or avatar in a restricted room would cause an authentication error. ([\matrix-org#10933](matrix-org#10933)) - Fix `/admin/whois/{user_id}` endpoint, which was broken in v1.44.0rc1. ([\matrix-org#10968](matrix-org#10968)) Synapse 1.44.0rc2 (2021-09-30) ============================== Bugfixes -------- - Fix a bug introduced in v1.44.0rc1 which caused the experimental [MSC2716](matrix-org/matrix-spec-proposals#2716) `/batch_send` endpoint to return a 500 error. ([\matrix-org#10938](matrix-org#10938)) - Fix a bug introduced in v1.44.0rc1 which prevented sending presence events to application services. ([\matrix-org#10944](matrix-org#10944)) Improved Documentation ---------------------- - Minor updates to the installation instructions. ([\matrix-org#10919](matrix-org#10919)) Synapse 1.44.0rc1 (2021-09-29) ============================== Features -------- - Only allow the [MSC2716](matrix-org/matrix-spec-proposals#2716) `/batch_send?chunk_id=xxx` endpoint to connect to an already existing insertion event. ([\matrix-org#10776](matrix-org#10776)) - Improve oEmbed URL previews by processing the author name, photo, and video information. ([\matrix-org#10814](matrix-org#10814), [\matrix-org#10819](matrix-org#10819)) - Speed up responding with large JSON objects to requests. ([\matrix-org#10868](matrix-org#10868), [\matrix-org#10905](matrix-org#10905)) - Add a `user_may_create_room_with_invites` spam checker callback to allow modules to allow or deny a room creation request based on the invites and/or 3PID invites it includes. ([\matrix-org#10898](matrix-org#10898)) Bugfixes -------- - Fix a long-standing bug that caused an `AssertionError` when purging history in certain rooms. Contributed by @Kokokokoka. ([\matrix-org#10690](matrix-org#10690)) - Fix a long-standing bug which caused deactivated users that were later reactivated to be missing from the user directory. ([\matrix-org#10782](matrix-org#10782)) - Fix a long-standing bug that caused unbanning a user by sending a membership event to fail. Contributed by @aaronraimist. ([\matrix-org#10807](matrix-org#10807)) - Fix a long-standing bug where logging contexts would go missing when federation requests time out. ([\matrix-org#10810](matrix-org#10810)) - Fix a long-standing bug causing an error in the deprecated `/initialSync` endpoint when using the undocumented `from` and `to` parameters. ([\matrix-org#10827](matrix-org#10827)) - Fix a bug causing the `remove_stale_pushers` background job to repeatedly fail and log errors. This bug affected Synapse servers that had been upgraded from version 1.28 or older and are using SQLite. ([\matrix-org#10843](matrix-org#10843)) - Fix a long-standing bug in Unicode support of the room search admin API breaking search for rooms with non-ASCII characters. ([\matrix-org#10859](matrix-org#10859)) - Fix a bug introduced in Synapse 1.37.0 which caused `knock` membership events which we sent to remote servers to be incorrectly stored in the local database. ([\matrix-org#10873](matrix-org#10873)) - Fix invalidating one-time key count cache after claiming keys. The bug was introduced in Synapse v1.41.0. Contributed by Tulir at Beeper. ([\matrix-org#10875](matrix-org#10875)) - Fix a long-standing bug causing application service users to be subject to MAU blocking if the MAU limit had been reached, even if configured not to be blocked. ([\matrix-org#10881](matrix-org#10881)) - Fix a long-standing bug which could cause events pulled over federation to be incorrectly rejected. ([\matrix-org#10907](matrix-org#10907)) - Fix a long-standing bug causing URL cache files to be stored in storage providers. Server admins may safely delete the `url_cache/` and `url_cache_thumbnails/` directories from any configured storage providers to reclaim space. ([\matrix-org#10911](matrix-org#10911)) - Fix a long-standing bug leading to race conditions when creating media store and config directories. ([\matrix-org#10913](matrix-org#10913)) Improved Documentation ---------------------- - Fix some crashes in the Module API example code, by adding JSON encoding/decoding. ([\matrix-org#10845](matrix-org#10845)) - Add developer documentation about experimental configuration flags. ([\matrix-org#10865](matrix-org#10865)) - Properly remove deleted files from GitHub pages when generating the documentation. ([\matrix-org#10869](matrix-org#10869)) Internal Changes ---------------- - Fix GitHub Actions config so we can run sytest on synapse from parallel branches. ([\matrix-org#10659](matrix-org#10659)) - Split out [MSC2716](matrix-org/matrix-spec-proposals#2716) meta events to their own fields in the `/batch_send` response. ([\matrix-org#10777](matrix-org#10777)) - Add missing type hints to REST servlets. ([\matrix-org#10785](matrix-org#10785), [\matrix-org#10817](matrix-org#10817)) - Simplify the internal logic which maintains the user directory database tables. ([\matrix-org#10796](matrix-org#10796)) - Use direct references to config flags. ([\matrix-org#10812](matrix-org#10812), [\matrix-org#10885](matrix-org#10885), [\matrix-org#10893](matrix-org#10893), [\matrix-org#10897](matrix-org#10897)) - Specify the type of token in generic "Invalid token" error messages. ([\matrix-org#10815](matrix-org#10815)) - Make `StateFilter` frozen so it is hashable. ([\matrix-org#10816](matrix-org#10816)) - Fix a long-standing bug where an `m.room.message` event containing a null byte would cause an internal server error. ([\matrix-org#10820](matrix-org#10820)) - Add type hints to the state database. ([\matrix-org#10823](matrix-org#10823)) - Opt out of cache expiry for `get_users_who_share_room_with_user`, to hopefully improve `/sync` performance when you haven't synced recently. ([\matrix-org#10826](matrix-org#10826)) - Track cache eviction rates more finely in Prometheus's monitoring. ([\matrix-org#10829](matrix-org#10829)) - Add missing type hints to `synapse.handlers`. ([\matrix-org#10831](matrix-org#10831), [\matrix-org#10856](matrix-org#10856)) - Extend the Module API to let plug-ins check whether an ID is local and to access IP + User Agent data. ([\matrix-org#10833](matrix-org#10833)) - Factor out PNG image data to a constant to be used in several tests. ([\matrix-org#10834](matrix-org#10834)) - Add a test to ensure state events sent by modules get persisted correctly. ([\matrix-org#10835](matrix-org#10835)) - Rename [MSC2716](matrix-org/matrix-spec-proposals#2716) fields and event types from `chunk` to `batch` to match the `/batch_send` endpoint. ([\matrix-org#10838](matrix-org#10838)) - Rename [MSC2716](matrix-org/matrix-spec-proposals#2716) `/batch_send` query parameter from `?prev_event` to more obvious usage with `?prev_event_id`. ([\matrix-org#10839](matrix-org#10839)) - Add type hints to `synapse.http.site`. ([\matrix-org#10867](matrix-org#10867)) - Include outlier status when we log V2 or V3 events. ([\matrix-org#10879](matrix-org#10879)) - Break down Grafana's cache expiry time series based on reason for eviction, c.f. [\matrix-org#10829](matrix-org#10829). ([\matrix-org#10880](matrix-org#10880)) - Clean up some of the federation event authentication code for clarity. ([\matrix-org#10883](matrix-org#10883), [\matrix-org#10884](matrix-org#10884), [\matrix-org#10896](matrix-org#10896), [\matrix-org#10901](matrix-org#10901)) - Allow the `.` and `~` characters when creating registration tokens as per the change to [MSC3231](matrix-org/matrix-spec-proposals#3231). ([\matrix-org#10887](matrix-org#10887)) - Clean up some unnecessary parentheses in places around the codebase. ([\matrix-org#10889](matrix-org#10889)) - Improve type hinting in the user directory code. ([\matrix-org#10891](matrix-org#10891)) - Update development testing script `test_postgresql.sh` to use a supported Python version and make re-runs quicker. ([\matrix-org#10906](matrix-org#10906)) - Document and summarize changes in schema version `61` – `64`. ([\matrix-org#10917](matrix-org#10917)) - Update release script to sign the newly created git tags. ([\matrix-org#10925](matrix-org#10925)) - Fix Debian builds due to `dh-virtualenv` no longer being able to build their docs. ([\matrix-org#10931](matrix-org#10931))
2 parents bd72ab3 + b2c5e79 commit 8460dac

File tree

246 files changed

+4043
-2225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+4043
-2225
lines changed

.github/workflows/docs.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,5 @@ jobs:
6161
uses: peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 # v3.8.0
6262
with:
6363
github_token: ${{ secrets.GITHUB_TOKEN }}
64-
keep_files: true
6564
publish_dir: ./book
6665
destination_dir: ./${{ steps.vars.outputs.branch-version }}

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ jobs:
192192
volumes:
193193
- ${{ github.workspace }}:/src
194194
env:
195+
SYTEST_BRANCH: ${{ github.head_ref }}
195196
POSTGRES: ${{ matrix.postgres && 1}}
196197
MULTI_POSTGRES: ${{ (matrix.postgres == 'multi-postgres') && 1}}
197198
WORKERS: ${{ matrix.workers && 1 }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ __pycache__/
4040
/.coverage*
4141
/.mypy_cache/
4242
/.tox
43+
/.tox-pg-container
4344
/build/
4445
/coverage.*
4546
/dist/

CHANGES.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,107 @@
1+
Synapse 1.44.0 (2021-10-05)
2+
===========================
3+
4+
No significant changes since 1.44.0rc3.
5+
6+
7+
Synapse 1.44.0rc3 (2021-10-04)
8+
==============================
9+
10+
Bugfixes
11+
--------
12+
13+
- Fix a bug introduced in Synapse v1.40.0 where changing a user's display name or avatar in a restricted room would cause an authentication error. ([\#10933](https://github.com/matrix-org/synapse/issues/10933))
14+
- Fix `/admin/whois/{user_id}` endpoint, which was broken in v1.44.0rc1. ([\#10968](https://github.com/matrix-org/synapse/issues/10968))
15+
16+
17+
Synapse 1.44.0rc2 (2021-09-30)
18+
==============================
19+
20+
Bugfixes
21+
--------
22+
23+
- Fix a bug introduced in v1.44.0rc1 which caused the experimental [MSC2716](https://github.com/matrix-org/matrix-doc/pull/2716) `/batch_send` endpoint to return a 500 error. ([\#10938](https://github.com/matrix-org/synapse/issues/10938))
24+
- Fix a bug introduced in v1.44.0rc1 which prevented sending presence events to application services. ([\#10944](https://github.com/matrix-org/synapse/issues/10944))
25+
26+
27+
Improved Documentation
28+
----------------------
29+
30+
- Minor updates to the installation instructions. ([\#10919](https://github.com/matrix-org/synapse/issues/10919))
31+
32+
33+
Synapse 1.44.0rc1 (2021-09-29)
34+
==============================
35+
36+
Features
37+
--------
38+
39+
- Only allow the [MSC2716](https://github.com/matrix-org/matrix-doc/pull/2716) `/batch_send?chunk_id=xxx` endpoint to connect to an already existing insertion event. ([\#10776](https://github.com/matrix-org/synapse/issues/10776))
40+
- Improve oEmbed URL previews by processing the author name, photo, and video information. ([\#10814](https://github.com/matrix-org/synapse/issues/10814), [\#10819](https://github.com/matrix-org/synapse/issues/10819))
41+
- Speed up responding with large JSON objects to requests. ([\#10868](https://github.com/matrix-org/synapse/issues/10868), [\#10905](https://github.com/matrix-org/synapse/issues/10905))
42+
- Add a `user_may_create_room_with_invites` spam checker callback to allow modules to allow or deny a room creation request based on the invites and/or 3PID invites it includes. ([\#10898](https://github.com/matrix-org/synapse/issues/10898))
43+
44+
45+
Bugfixes
46+
--------
47+
48+
- Fix a long-standing bug that caused an `AssertionError` when purging history in certain rooms. Contributed by @Kokokokoka. ([\#10690](https://github.com/matrix-org/synapse/issues/10690))
49+
- Fix a long-standing bug which caused deactivated users that were later reactivated to be missing from the user directory. ([\#10782](https://github.com/matrix-org/synapse/issues/10782))
50+
- Fix a long-standing bug that caused unbanning a user by sending a membership event to fail. Contributed by @aaronraimist. ([\#10807](https://github.com/matrix-org/synapse/issues/10807))
51+
- Fix a long-standing bug where logging contexts would go missing when federation requests time out. ([\#10810](https://github.com/matrix-org/synapse/issues/10810))
52+
- Fix a long-standing bug causing an error in the deprecated `/initialSync` endpoint when using the undocumented `from` and `to` parameters. ([\#10827](https://github.com/matrix-org/synapse/issues/10827))
53+
- Fix a bug causing the `remove_stale_pushers` background job to repeatedly fail and log errors. This bug affected Synapse servers that had been upgraded from version 1.28 or older and are using SQLite. ([\#10843](https://github.com/matrix-org/synapse/issues/10843))
54+
- Fix a long-standing bug in Unicode support of the room search admin API breaking search for rooms with non-ASCII characters. ([\#10859](https://github.com/matrix-org/synapse/issues/10859))
55+
- Fix a bug introduced in Synapse 1.37.0 which caused `knock` membership events which we sent to remote servers to be incorrectly stored in the local database. ([\#10873](https://github.com/matrix-org/synapse/issues/10873))
56+
- Fix invalidating one-time key count cache after claiming keys. The bug was introduced in Synapse v1.41.0. Contributed by Tulir at Beeper. ([\#10875](https://github.com/matrix-org/synapse/issues/10875))
57+
- Fix a long-standing bug causing application service users to be subject to MAU blocking if the MAU limit had been reached, even if configured not to be blocked. ([\#10881](https://github.com/matrix-org/synapse/issues/10881))
58+
- Fix a long-standing bug which could cause events pulled over federation to be incorrectly rejected. ([\#10907](https://github.com/matrix-org/synapse/issues/10907))
59+
- Fix a long-standing bug causing URL cache files to be stored in storage providers. Server admins may safely delete the `url_cache/` and `url_cache_thumbnails/` directories from any configured storage providers to reclaim space. ([\#10911](https://github.com/matrix-org/synapse/issues/10911))
60+
- Fix a long-standing bug leading to race conditions when creating media store and config directories. ([\#10913](https://github.com/matrix-org/synapse/issues/10913))
61+
62+
63+
Improved Documentation
64+
----------------------
65+
66+
- Fix some crashes in the Module API example code, by adding JSON encoding/decoding. ([\#10845](https://github.com/matrix-org/synapse/issues/10845))
67+
- Add developer documentation about experimental configuration flags. ([\#10865](https://github.com/matrix-org/synapse/issues/10865))
68+
- Properly remove deleted files from GitHub pages when generating the documentation. ([\#10869](https://github.com/matrix-org/synapse/issues/10869))
69+
70+
71+
Internal Changes
72+
----------------
73+
74+
- Fix GitHub Actions config so we can run sytest on synapse from parallel branches. ([\#10659](https://github.com/matrix-org/synapse/issues/10659))
75+
- Split out [MSC2716](https://github.com/matrix-org/matrix-doc/pull/2716) meta events to their own fields in the `/batch_send` response. ([\#10777](https://github.com/matrix-org/synapse/issues/10777))
76+
- Add missing type hints to REST servlets. ([\#10785](https://github.com/matrix-org/synapse/issues/10785), [\#10817](https://github.com/matrix-org/synapse/issues/10817))
77+
- Simplify the internal logic which maintains the user directory database tables. ([\#10796](https://github.com/matrix-org/synapse/issues/10796))
78+
- Use direct references to config flags. ([\#10812](https://github.com/matrix-org/synapse/issues/10812), [\#10885](https://github.com/matrix-org/synapse/issues/10885), [\#10893](https://github.com/matrix-org/synapse/issues/10893), [\#10897](https://github.com/matrix-org/synapse/issues/10897))
79+
- Specify the type of token in generic "Invalid token" error messages. ([\#10815](https://github.com/matrix-org/synapse/issues/10815))
80+
- Make `StateFilter` frozen so it is hashable. ([\#10816](https://github.com/matrix-org/synapse/issues/10816))
81+
- Fix a long-standing bug where an `m.room.message` event containing a null byte would cause an internal server error. ([\#10820](https://github.com/matrix-org/synapse/issues/10820))
82+
- Add type hints to the state database. ([\#10823](https://github.com/matrix-org/synapse/issues/10823))
83+
- Opt out of cache expiry for `get_users_who_share_room_with_user`, to hopefully improve `/sync` performance when you
84+
haven't synced recently. ([\#10826](https://github.com/matrix-org/synapse/issues/10826))
85+
- Track cache eviction rates more finely in Prometheus's monitoring. ([\#10829](https://github.com/matrix-org/synapse/issues/10829))
86+
- Add missing type hints to `synapse.handlers`. ([\#10831](https://github.com/matrix-org/synapse/issues/10831), [\#10856](https://github.com/matrix-org/synapse/issues/10856))
87+
- Extend the Module API to let plug-ins check whether an ID is local and to access IP + User Agent data. ([\#10833](https://github.com/matrix-org/synapse/issues/10833))
88+
- Factor out PNG image data to a constant to be used in several tests. ([\#10834](https://github.com/matrix-org/synapse/issues/10834))
89+
- Add a test to ensure state events sent by modules get persisted correctly. ([\#10835](https://github.com/matrix-org/synapse/issues/10835))
90+
- Rename [MSC2716](https://github.com/matrix-org/matrix-doc/pull/2716) fields and event types from `chunk` to `batch` to match the `/batch_send` endpoint. ([\#10838](https://github.com/matrix-org/synapse/issues/10838))
91+
- Rename [MSC2716](https://github.com/matrix-org/matrix-doc/pull/2716) `/batch_send` query parameter from `?prev_event` to more obvious usage with `?prev_event_id`. ([\#10839](https://github.com/matrix-org/synapse/issues/10839))
92+
- Add type hints to `synapse.http.site`. ([\#10867](https://github.com/matrix-org/synapse/issues/10867))
93+
- Include outlier status when we log V2 or V3 events. ([\#10879](https://github.com/matrix-org/synapse/issues/10879))
94+
- Break down Grafana's cache expiry time series based on reason for eviction, c.f. [\#10829](https://github.com/matrix-org/synapse/issues/10829). ([\#10880](https://github.com/matrix-org/synapse/issues/10880))
95+
- Clean up some of the federation event authentication code for clarity. ([\#10883](https://github.com/matrix-org/synapse/issues/10883), [\#10884](https://github.com/matrix-org/synapse/issues/10884), [\#10896](https://github.com/matrix-org/synapse/issues/10896), [\#10901](https://github.com/matrix-org/synapse/issues/10901))
96+
- Allow the `.` and `~` characters when creating registration tokens as per the change to [MSC3231](https://github.com/matrix-org/matrix-doc/pull/3231). ([\#10887](https://github.com/matrix-org/synapse/issues/10887))
97+
- Clean up some unnecessary parentheses in places around the codebase. ([\#10889](https://github.com/matrix-org/synapse/issues/10889))
98+
- Improve type hinting in the user directory code. ([\#10891](https://github.com/matrix-org/synapse/issues/10891))
99+
- Update development testing script `test_postgresql.sh` to use a supported Python version and make re-runs quicker. ([\#10906](https://github.com/matrix-org/synapse/issues/10906))
100+
- Document and summarize changes in schema version `61` – `64`. ([\#10917](https://github.com/matrix-org/synapse/issues/10917))
101+
- Update release script to sign the newly created git tags. ([\#10925](https://github.com/matrix-org/synapse/issues/10925))
102+
- Fix Debian builds due to `dh-virtualenv` no longer being able to build their docs. ([\#10931](https://github.com/matrix-org/synapse/issues/10931))
103+
104+
1105
Synapse 1.43.0 (2021-09-21)
2106
===========================
3107

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ Quick start
288288

289289
Before setting up a development environment for synapse, make sure you have the
290290
system dependencies (such as the python header files) installed - see
291-
`Installing from source <https://matrix-org.github.io/synapse/latest/setup/installation.html#installing-from-source>`_.
291+
`Platform-specific prerequisites <https://matrix-org.github.io/synapse/latest/setup/installation.html#platform-specific-prerequisites>`_.
292292

293293
To check out a synapse for development, clone the git repo into a working
294294
directory of your choice::

contrib/grafana/synapse.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6785,7 +6785,7 @@
67856785
"expr": "rate(synapse_util_caches_cache:evicted_size{instance=\"$instance\",job=~\"$job\",index=~\"$index\"}[$bucket_size])",
67866786
"format": "time_series",
67876787
"intervalFactor": 1,
6788-
"legendFormat": "{{name}} {{job}}-{{index}}",
6788+
"legendFormat": "{{name}} ({{reason}}) {{job}}-{{index}}",
67896789
"refId": "A"
67906790
}
67916791
],
@@ -10888,5 +10888,5 @@
1088810888
"timezone": "",
1088910889
"title": "Synapse",
1089010890
"uid": "000000012",
10891-
"version": 99
10891+
"version": 100
1089210892
}

debian/changelog

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
matrix-synapse-py3 (1.44.0) stable; urgency=medium
2+
3+
* New synapse release 1.44.0.
4+
5+
-- Synapse Packaging team <[email protected]> Tue, 05 Oct 2021 13:43:57 +0100
6+
7+
matrix-synapse-py3 (1.44.0~rc3) stable; urgency=medium
8+
9+
* New synapse release 1.44.0~rc3.
10+
11+
-- Synapse Packaging team <[email protected]> Mon, 04 Oct 2021 14:57:22 +0100
12+
13+
matrix-synapse-py3 (1.44.0~rc2) stable; urgency=medium
14+
15+
* New synapse release 1.44.0~rc2.
16+
17+
-- Synapse Packaging team <[email protected]> Thu, 30 Sep 2021 12:39:10 +0100
18+
19+
matrix-synapse-py3 (1.44.0~rc1) stable; urgency=medium
20+
21+
* New synapse release 1.44.0~rc1.
22+
23+
-- Synapse Packaging team <[email protected]> Tue, 28 Sep 2021 13:41:28 +0100
24+
125
matrix-synapse-py3 (1.43.0) stable; urgency=medium
226

327
* New synapse release 1.43.0.

docker/Dockerfile-dhvirtualenv

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ RUN apt-get update -qq -o Acquire::Languages=none \
4747
&& cd /dh-virtualenv \
4848
&& env DEBIAN_FRONTEND=noninteractive mk-build-deps -ri -t "apt-get -y --no-install-recommends"
4949

50-
# build it
51-
RUN cd /dh-virtualenv && dpkg-buildpackage -us -uc -b
50+
# Build it. Note that building the docs doesn't work due to differences in
51+
# Sphinx APIs across versions/distros.
52+
RUN cd /dh-virtualenv && DEB_BUILD_OPTIONS=nodoc dpkg-buildpackage -us -uc -b
5253

5354
###
5455
### Stage 1

docker/Dockerfile-pgtests

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
# Use the Sytest image that comes with a lot of the build dependencies
22
# pre-installed
3-
FROM matrixdotorg/sytest:latest
3+
FROM matrixdotorg/sytest:bionic
44

55
# The Sytest image doesn't come with python, so install that
66
RUN apt-get update && apt-get -qq install -y python3 python3-dev python3-pip
77

88
# We need tox to run the tests in run_pg_tests.sh
99
RUN python3 -m pip install tox
1010

11-
ADD run_pg_tests.sh /pg_tests.sh
12-
ENTRYPOINT /pg_tests.sh
11+
# Initialise the db
12+
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
13+
14+
# Add a user with our UID and GID so that files get created on the host owned
15+
# by us, not root.
16+
ARG UID
17+
ARG GID
18+
RUN groupadd --gid $GID user
19+
RUN useradd --uid $UID --gid $GID --groups sudo --no-create-home user
20+
21+
# Ensure we can start postgres by sudo-ing as the postgres user.
22+
RUN apt-get update && apt-get -qq install -y sudo
23+
RUN echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
24+
25+
ADD run_pg_tests.sh /run_pg_tests.sh
26+
# Use the "exec form" of ENTRYPOINT (https://docs.docker.com/engine/reference/builder/#entrypoint)
27+
# so that we can `docker run` this container and pass arguments to pg_tests.sh
28+
ENTRYPOINT ["/run_pg_tests.sh"]
29+
30+
USER user

docker/run_pg_tests.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ set -e
1010
# Set PGUSER so Synapse's tests know what user to connect to the database with
1111
export PGUSER=postgres
1212

13-
# Initialise & start the database
14-
su -c '/usr/lib/postgresql/9.6/bin/initdb -D /var/lib/postgresql/data -E "UTF-8" --lc-collate="en_US.UTF-8" --lc-ctype="en_US.UTF-8" --username=postgres' postgres
15-
su -c '/usr/lib/postgresql/9.6/bin/pg_ctl -w -D /var/lib/postgresql/data start' postgres
13+
# Start the database
14+
sudo -u postgres /usr/lib/postgresql/10/bin/pg_ctl -w -D /var/lib/postgresql/data start
1615

1716
# Run the tests
1817
cd /src
1918
export TRIAL_FLAGS="-j 4"
20-
tox --workdir=/tmp -e py35-postgres
19+
tox --workdir=./.tox-pg-container -e py36-postgres "$@"

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
- [Testing]()
7575
- [OpenTracing](opentracing.md)
7676
- [Database Schemas](development/database_schema.md)
77+
- [Experimental features](development/experimental_features.md)
7778
- [Synapse Architecture]()
7879
- [Log Contexts](log_contexts.md)
7980
- [Replication](replication.md)

docs/development/contributing_guide.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,53 @@ To increase the log level for the tests, set `SYNAPSE_TEST_LOG_LEVEL`:
170170
SYNAPSE_TEST_LOG_LEVEL=DEBUG trial tests
171171
```
172172

173+
### Running tests under PostgreSQL
174+
175+
Invoking `trial` as above will use an in-memory SQLite database. This is great for
176+
quick development and testing. However, we recommend using a PostgreSQL database
177+
in production (and indeed, we have some code paths specific to each database).
178+
This means that we need to run our unit tests against PostgreSQL too. Our CI does
179+
this automatically for pull requests and release candidates, but it's sometimes
180+
useful to reproduce this locally.
181+
182+
To do so, [configure Postgres](../postgres.md) and run `trial` with the
183+
following environment variables matching your configuration:
184+
185+
- `SYNAPSE_POSTGRES` to anything nonempty
186+
- `SYNAPSE_POSTGRES_HOST`
187+
- `SYNAPSE_POSTGRES_USER`
188+
- `SYNAPSE_POSTGRES_PASSWORD`
189+
190+
For example:
191+
192+
```shell
193+
export SYNAPSE_POSTGRES=1
194+
export SYNAPSE_POSTGRES_HOST=localhost
195+
export SYNAPSE_POSTGRES_USER=postgres
196+
export SYNAPSE_POSTGRES_PASSWORD=mydevenvpassword
197+
trial
198+
```
199+
200+
#### Prebuilt container
201+
202+
Since configuring PostgreSQL can be fiddly, we can make use of a pre-made
203+
Docker container to set up PostgreSQL and run our tests for us. To do so, run
204+
205+
```shell
206+
scripts-dev/test_postgresql.sh
207+
```
208+
209+
Any extra arguments to the script will be passed to `tox` and then to `trial`,
210+
so we can run a specific test in this container with e.g.
211+
212+
```shell
213+
scripts-dev/test_postgresql.sh tests.replication.test_sharded_event_persister.EventPersisterShardTestCase
214+
```
215+
216+
The container creates a folder in your Synapse checkout called
217+
`.tox-pg-container` and uses this as a tox environment. The output of any
218+
`trial` runs goes into `_trial_temp` in your synapse source directory — the same
219+
as running `trial` directly on your host machine.
173220

174221
## Run the integration tests ([Sytest](https://github.com/matrix-org/sytest)).
175222

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Implementing experimental features in Synapse
2+
3+
It can be desirable to implement "experimental" features which are disabled by
4+
default and must be explicitly enabled via the Synapse configuration. This is
5+
applicable for features which:
6+
7+
* Are unstable in the Matrix spec (e.g. those defined by an MSC that has not yet been merged).
8+
* Developers are not confident in their use by general Synapse administrators/users
9+
(e.g. a feature is incomplete, buggy, performs poorly, or needs further testing).
10+
11+
Note that this only really applies to features which are expected to be desirable
12+
to a broad audience. The [module infrastructure](../modules/index.md) should
13+
instead be investigated for non-standard features.
14+
15+
Guarding experimental features behind configuration flags should help with some
16+
of the following scenarios:
17+
18+
* Ensure that clients do not assume that unstable features exist (failing
19+
gracefully if they do not).
20+
* Unstable features do not become de-facto standards and can be removed
21+
aggressively (since only those who have opted-in will be affected).
22+
* Ease finding the implementation of unstable features in Synapse (for future
23+
removal or stabilization).
24+
* Ease testing a feature (or removal of feature) due to enabling/disabling without
25+
code changes. It also becomes possible to ask for wider testing, if desired.
26+
27+
Experimental configuration flags should be disabled by default (requiring Synapse
28+
administrators to explicitly opt-in), although there are situations where it makes
29+
sense (from a product point-of-view) to enable features by default. This is
30+
expected and not an issue.
31+
32+
It is not a requirement for experimental features to be behind a configuration flag,
33+
but one should be used if unsure.
34+
35+
New experimental configuration flags should be added under the `experimental`
36+
configuration key (see the `synapse.config.experimental` file) and either explain
37+
(briefly) what is being enabled, or include the MSC number.

0 commit comments

Comments
 (0)