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

Commit 9904b73

Browse files
committed
Document Complement dev usage
Also includes info on how to acces the databae for the homeserver after running Complement, see matrix-org/complement#165
1 parent b7186c6 commit 9904b73

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

CONTRIBUTING.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ source ./env/bin/activate
155155
./scripts-dev/lint.sh path/to/file1.py path/to/file2.py path/to/folder
156156
```
157157

158-
## Run the unit tests.
158+
## Run the unit tests (Twisted trial).
159159

160160
The unit tests run parts of Synapse, including your changes, to see if anything
161161
was broken. They are slower than the linters but will typically catch more errors.
@@ -186,7 +186,7 @@ SYNAPSE_TEST_LOG_LEVEL=DEBUG trial tests
186186
```
187187

188188

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

191191
The integration tests are a more comprehensive suite of tests. They
192192
run a full version of Synapse, including your changes, to check if
@@ -203,6 +203,45 @@ $ docker run --rm -it -v /path/where/you/have/cloned/the/repository\:/src:ro -v
203203
This configuration should generally cover your needs. For more details about other configurations, see [documentation in the SyTest repo](https://github.com/matrix-org/sytest/blob/develop/docker/README.md).
204204

205205

206+
## Run the integration tests ([Complement](https://github.com/matrix-org/complement)).
207+
208+
[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.
209+
210+
It's often nice to develop on Synapse and write Complement tests at the same time.
211+
Here is how to run your local Synapse checkout against your local Complement checkout.
212+
213+
(checkout [`complement`](https://github.com/matrix-org/complement) alongside your `synapse` checkout)
214+
```sh
215+
COMPLEMENT_DIR=../complement ./scripts-dev/complement.sh
216+
```
217+
218+
To run a specific test file, you can adjust [`scripts-dev/complement.sh`](https://github.com/matrix-org/synapse/blob/develop/scripts-dev/complement.sh) to use the `-run MyTest` syntax. The name comes from the name 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:
219+
220+
```sh
221+
go test -v -tags synapse_blacklist,msc2946,msc2716,msc3083,msc2403 -count=1 $EXTRA_COMPLEMENT_ARGS ./tests -run TestBackfillingHistory
222+
```
223+
224+
To run a specific test, you can specify the whole name structure:
225+
226+
```sh
227+
go test -v -tags synapse_blacklist,msc2946,msc2716,msc3083,msc2403 -count=1 $EXTRA_COMPLEMENT_ARGS ./tests -run TestBackfillingHistory/parallel/Backfilled_historical_events_resolve_with_proper_state_in_correct_order
228+
```
229+
230+
231+
### Access database for homeserver after Complement test runs.
232+
233+
If you're curious what the database looks like after you run some tests, here are some steps to get you going in Synapse:
234+
235+
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
236+
1. Start the Complement tests
237+
1. Find the name of the container, `docker ps -f name=complement_` (this will filter for just the Compelement related Docker containers)
238+
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`
239+
1. Install sqlite (database driver), `apt-get update && apt-get install -y sqlite3`
240+
1. Then run `sqlite3` and open the database `.open /conf/homeserver.db` (this db path comes from the Synapse homeserver.yaml)
241+
242+
243+
244+
206245
# 9. Submit your patch.
207246

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

0 commit comments

Comments
 (0)