Skip to content

Commit 46c6e0a

Browse files
Unify Complement developer docs (#19518)
Instead of having info spread across a few places, consolidate and link to one spot.
1 parent c2c0587 commit 46c6e0a

File tree

4 files changed

+49
-58
lines changed

4 files changed

+49
-58
lines changed

changelog.d/19518.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Unify Complement developer docs.

complement/README.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ ensure everything works at a holistic level.
88
## Setup
99

1010
Nothing beyond a [normal Complement
11-
setup](https://github.com/matrix-org/complement?tab=readme-ov-file#running) (just Go and
12-
Docker).
11+
setup](https://github.com/matrix-org/complement#running) (just Go and Docker).
1312

1413

1514
## Running tests
@@ -28,14 +27,39 @@ scripts-dev/complement.sh ./tests/csapi/... -run TestRoomCreate/Parallel/POST_/c
2827
scripts-dev/complement.sh ./tests/... -run 'TestRoomCreate/Parallel/POST_/createRoom_makes_a_(.*)'
2928
```
3029

31-
Typically, if you're developing the Synapse and Complement tests side-by-side, you will
32-
run something like this:
30+
It's often nice to develop on Synapse and write Complement tests at the same time.
31+
Here is how to run your local Synapse checkout against your local Complement checkout.
3332

3433
```shell
3534
# To run a specific test
3635
COMPLEMENT_DIR=../complement ./scripts-dev/complement.sh ./tests/csapi/... -run TestRoomCreate
3736
```
3837

38+
The above will run a monolithic (single-process) Synapse with SQLite as the database.
39+
For other configurations, try:
40+
41+
- Passing `POSTGRES=1` as an environment variable to use the Postgres database instead.
42+
- Passing `WORKERS=1` as an environment variable to use a workerised setup instead. This
43+
option implies the use of Postgres.
44+
- If setting `WORKERS=1`, optionally set `WORKER_TYPES=` to declare which worker types
45+
you wish to test. A simple comma-delimited string containing the worker types
46+
defined from the `WORKERS_CONFIG` template in
47+
[here](https://github.com/element-hq/synapse/blob/develop/docker/configure_workers_and_start.py#L54).
48+
A safe example would be `WORKER_TYPES="federation_inbound, federation_sender,
49+
synchrotron"`. See the [worker documentation](../workers.md) for additional
50+
information on workers.
51+
- Passing `ASYNCIO_REACTOR=1` as an environment variable to use the asyncio-backed
52+
reactor with Twisted instead of the default one.
53+
- Passing `PODMAN=1` will use the [podman](https://podman.io/) container runtime,
54+
instead of docker.
55+
- Passing `UNIX_SOCKETS=1` will utilise Unix socket functionality for Synapse, Redis,
56+
and Postgres(when applicable).
57+
58+
To increase the log level for the tests, set `SYNAPSE_TEST_LOG_LEVEL`, e.g:
59+
```sh
60+
SYNAPSE_TEST_LOG_LEVEL=DEBUG COMPLEMENT_DIR=../complement ./scripts-dev/complement.sh -run TestRoomCreate
61+
```
62+
3963

4064
### Running in-repo tests
4165

@@ -52,3 +76,20 @@ To run the in-repo Complement tests, use the `--in-repo` command line argument.
5276
# Similarly, you can also use `-run` to specify all or part of a specific test path to run
5377
scripts-dev/complement.sh --in-repo ./tests/... -run TestIntraShardFederation
5478
```
79+
80+
### Access database for homeserver after Complement test runs.
81+
82+
If you're curious what the database looks like after you run some tests, here are some
83+
steps to get you going in Synapse:
84+
85+
1. In your Complement test comment out `defer deployment.Destroy(t)` and replace with
86+
`defer time.Sleep(2 * time.Hour)` to keep the homeserver running after the tests
87+
complete
88+
1. Start the Complement tests
89+
1. Find the name of the container, `docker ps -f name=complement_` (this will filter for
90+
just the Complement related Docker containers)
91+
1. Access the container replacing the name with what you found in the previous step:
92+
`docker exec -it complement_1_hs_with_application_service.hs1_2 /bin/bash`
93+
1. Install sqlite (database driver), `apt-get update && apt-get install -y sqlite3`
94+
1. Then run `sqlite3` and open the database `.open /conf/homeserver.db` (this db path
95+
comes from the Synapse homeserver.yaml)

docker/README-testing.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ Note that running Synapse's unit tests from within the docker image is not suppo
1212

1313
`scripts-dev/complement.sh` is a script that will automatically build
1414
and run Synapse against Complement.
15-
Consult the [contributing guide][guideComplementSh] for instructions on how to use it.
15+
Consult our [Complement docs][https://github.com/element-hq/synapse/tree/develop/complement] for instructions on how to use it.
1616

1717

18-
[guideComplementSh]: https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-integration-tests-complement
19-
2018
## Building and running the images manually
2119

2220
Under some circumstances, you may wish to build the images manually.

docs/development/contributing_guide.md

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -334,46 +334,9 @@ For more details about other configurations, see the [Docker-specific documentat
334334
335335
## Run the integration tests ([Complement](https://github.com/matrix-org/complement)).
336336
337-
[Complement](https://github.com/matrix-org/complement) is a suite of black box tests that can be run on any homeserver implementation. It can also be thought of as end-to-end (e2e) tests.
337+
See our [Complement docs](https://github.com/element-hq/synapse/tree/develop/complement)
338+
for how to use the `./scripts-dev/complement.sh` test runner script.
338339
339-
It's often nice to develop on Synapse and write Complement tests at the same time.
340-
Here is how to run your local Synapse checkout against your local Complement checkout.
341-
342-
(checkout [`complement`](https://github.com/matrix-org/complement) alongside your `synapse` checkout)
343-
```sh
344-
COMPLEMENT_DIR=../complement ./scripts-dev/complement.sh
345-
```
346-
347-
To run a specific test file, you can pass the test name at the end of the command. The name passed comes from the naming structure in your Complement tests. If you're unsure of the name, you can do a full run and copy it from the test output:
348-
349-
```sh
350-
COMPLEMENT_DIR=../complement ./scripts-dev/complement.sh -run TestImportHistoricalMessages
351-
```
352-
353-
To run a specific test, you can specify the whole name structure:
354-
355-
```sh
356-
COMPLEMENT_DIR=../complement ./scripts-dev/complement.sh -run TestImportHistoricalMessages/parallel/Historical_events_resolve_in_the_correct_order
357-
```
358-
359-
The above will run a monolithic (single-process) Synapse with SQLite as the database. For other configurations, try:
360-
361-
- Passing `POSTGRES=1` as an environment variable to use the Postgres database instead.
362-
- Passing `WORKERS=1` as an environment variable to use a workerised setup instead. This option implies the use of Postgres.
363-
- If setting `WORKERS=1`, optionally set `WORKER_TYPES=` to declare which worker
364-
types you wish to test. A simple comma-delimited string containing the worker types
365-
defined from the `WORKERS_CONFIG` template in
366-
[here](https://github.com/element-hq/synapse/blob/develop/docker/configure_workers_and_start.py#L54).
367-
A safe example would be `WORKER_TYPES="federation_inbound, federation_sender, synchrotron"`.
368-
See the [worker documentation](../workers.md) for additional information on workers.
369-
- Passing `ASYNCIO_REACTOR=1` as an environment variable to use the Twisted asyncio reactor instead of the default one.
370-
- Passing `PODMAN=1` will use the [podman](https://podman.io/) container runtime, instead of docker.
371-
- Passing `UNIX_SOCKETS=1` will utilise Unix socket functionality for Synapse, Redis, and Postgres(when applicable).
372-
373-
To increase the log level for the tests, set `SYNAPSE_TEST_LOG_LEVEL`, e.g:
374-
```sh
375-
SYNAPSE_TEST_LOG_LEVEL=DEBUG COMPLEMENT_DIR=../complement ./scripts-dev/complement.sh -run TestImportHistoricalMessages
376-
```
377340
378341
### Prettier formatting with `gotestfmt`
379342
@@ -389,18 +352,6 @@ COMPLEMENT_DIR=../complement ./scripts-dev/complement.sh -json | gotestfmt -hide
389352
(Remove `-hide successful-tests` if you don't want to hide successful tests.)
390353

391354

392-
### Access database for homeserver after Complement test runs.
393-
394-
If you're curious what the database looks like after you run some tests, here are some steps to get you going in Synapse:
395-
396-
1. In your Complement test comment out `defer deployment.Destroy(t)` and replace with `defer time.Sleep(2 * time.Hour)` to keep the homeserver running after the tests complete
397-
1. Start the Complement tests
398-
1. Find the name of the container, `docker ps -f name=complement_` (this will filter for just the Compelement related Docker containers)
399-
1. Access the container replacing the name with what you found in the previous step: `docker exec -it complement_1_hs_with_application_service.hs1_2 /bin/bash`
400-
1. Install sqlite (database driver), `apt-get update && apt-get install -y sqlite3`
401-
1. Then run `sqlite3` and open the database `.open /conf/homeserver.db` (this db path comes from the Synapse homeserver.yaml)
402-
403-
404355
# 9. Submit your patch.
405356

406357
Once you're happy with your patch, it's time to prepare a Pull Request.

0 commit comments

Comments
 (0)