2022-06-10 17:52:12 -06:00
|
|
|
# Testing
|
|
|
|
|
|
|
|
## Setup
|
|
|
|
|
|
|
|
If you haven't setup `matrix-public-archive` yet, see the [_Setup_ section in the root `README.md`](../README.md#setup)
|
|
|
|
|
2023-04-26 23:22:41 -06:00
|
|
|
Then we need to setup the federation cluster of homeservers that we will test with.
|
2022-06-10 17:52:12 -06:00
|
|
|
Sorry, this isn't automated yet when you run the tests 🙇
|
|
|
|
|
2022-06-09 19:44:57 -06:00
|
|
|
```sh
|
2023-04-26 23:22:41 -06:00
|
|
|
# Build the test homeserver image that are pre-configured to federate with each other
|
2022-02-23 20:25:05 -07:00
|
|
|
$ docker pull matrixdotorg/synapse:latest
|
|
|
|
$ docker build -t matrix-public-archive-test-homeserver -f test/dockerfiles/Synapse.Dockerfile test/dockerfiles/
|
2022-06-10 17:52:12 -06:00
|
|
|
|
2023-04-26 23:22:41 -06:00
|
|
|
# Start the test homeservers
|
2022-06-10 17:52:12 -06:00
|
|
|
$ docker-compose --project-name matrix_public_archive_test -f test/docker-compose.yml up -d --no-recreate
|
2022-02-22 19:25:24 -07:00
|
|
|
```
|
|
|
|
|
2022-06-10 17:52:12 -06:00
|
|
|
## Running the tests
|
|
|
|
|
2022-06-09 19:44:57 -06:00
|
|
|
```sh
|
2022-06-10 17:52:12 -06:00
|
|
|
$ npm run test
|
|
|
|
```
|
|
|
|
|
2023-04-26 23:22:41 -06:00
|
|
|
Or if you want to keep the Matrix Public Archive server running after the tests run and
|
|
|
|
explore the UI from the interactive URL's printed on the screen to better debug, use:
|
2022-06-10 17:52:12 -06:00
|
|
|
|
|
|
|
```sh
|
|
|
|
$ npm run test-interactive
|
2022-02-22 19:25:24 -07:00
|
|
|
```
|
2022-02-23 20:25:05 -07:00
|
|
|
|
2023-04-26 23:22:41 -06:00
|
|
|
Caveat: You might not see the same result that a test is seeing when visiting the
|
|
|
|
interactive URL. Some tests set config like the `archiveMessageLimit` which is reset
|
|
|
|
after each test case unless you are using `npm run test-interactive` and visiting the
|
|
|
|
interactive URL for a failed test. Otherwise, we reset config between each test case so
|
|
|
|
they don't leak and contaminate each other.
|
|
|
|
|
2022-06-10 17:52:12 -06:00
|
|
|
### Developer utility
|
|
|
|
|
2023-04-26 23:22:41 -06:00
|
|
|
Some copy-pasta to help you manage the Docker containers for the test homeservers:
|
|
|
|
|
2022-06-09 19:44:57 -06:00
|
|
|
```sh
|
2022-02-23 20:25:05 -07:00
|
|
|
$ docker ps --all | grep test_hs
|
2022-06-09 19:44:57 -06:00
|
|
|
$ docker logs -f --tail 10 matrix_public_archive_test_hs1_1
|
|
|
|
$ docker logs -f --tail 10 matrix_public_archive_test_hs2_1
|
2022-02-23 20:25:05 -07:00
|
|
|
|
2022-06-09 19:44:57 -06:00
|
|
|
$ docker stop matrix_public_archive_test_hs1_1 matrix_public_archive_test_hs2_1
|
|
|
|
$ docker rm matrix_public_archive_test_hs1_1 matrix_public_archive_test_hs2_1
|
2022-02-23 20:25:05 -07:00
|
|
|
```
|