Skip to content

Commit ba77d0e

Browse files
authored
Merge pull request #1710 from matthiasn/test/toxiproxy_docker
test: use toxiproxy and dendrite cli in docker
2 parents cc0b198 + e406e52 commit ba77d0e

12 files changed

+61
-41
lines changed

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,5 @@ whisper.cpp/whisper.cpp-*/
7979
# FVM Version Cache
8080
.fvm/
8181

82-
integration_test/dendrite/config/jetstream/
83-
integration_test/dendrite/config/logs/
82+
integration_test/docker/config/jetstream/
83+
integration_test/docker/config/logs/

integration_test/README.md

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
# Integration test for Matrix sync
22

3-
Clone [dendrite](https://github.com/matrix-org/dendrite) into a sibling directory,
4-
e.g. `~/github/dendrite`. Build it, we need the executable in order to create users for the test.
3+
For the Matrix integration tests, there's a [Docker Compose](https://docs.docker.com/compose/) setup
4+
that starts the following services:
55

6-
Run dendrite in a separate shell:
6+
- [dendrite](https://github.com/matrix-org/dendrite): the Matrix homeserver we use in the test
7+
- [postgres](https://hub.docker.com/_/postgres/): a PostgreSQL server used by dendrite
8+
- [toxiproxy](https://github.com/Shopify/toxiproxy): a TCP proxy for simulating bad networks
9+
10+
Run the docker containers in a separate shell:
711

812
```shell
9-
$ cd integration_test/dendrite/
13+
$ cd docker
1014
$ docker-compose up
1115
```
1216

1317
Run the test script:
1418

1519
````shell
16-
$ ./integration_test/run_matrix_tests.sh
20+
$ ./run_matrix_tests.sh
1721
````
1822

1923
The test script will create two users and then run a Flutter integration test that instantiates two
@@ -23,22 +27,19 @@ successfully. Also see [PR #1695](https://github.com/matthiasn/lotti/pull/1695)
2327

2428
## Testing with simulated bad network
2529

26-
Install [toxiproxy](https://github.com/Shopify/toxiproxy) and run server:
27-
28-
````shell
29-
$ toxiproxy-server
30-
````
31-
32-
In separate shell:
30+
Set up the toxiproxy server running in the docker compose environment:
3331

3432
````shell
35-
$ toxiproxy-cli create -l localhost:18008 -u localhost:8008 dendrite-proxy
36-
$ toxiproxy-cli toxic add -t latency -a latency=1000 dendrite-proxy
37-
$ toxiproxy-cli toxic add -t bandwidth -a rate=100 dendrite-proxy
33+
$ ./setup_toxiproxy_docker.sh
3834
````
3935

4036
Run the test script against `toxiproxy`;
4137

4238
````shell
43-
$ SLOW_NETWORK=true ./integration_test/run_matrix_tests.sh
39+
$ SLOW_NETWORK=true ./run_matrix_tests.sh
4440
````
41+
42+
With the simulated bad network (with added 1000 ms latency and throttled to 100 KB/s), the tests
43+
should still complete successfully, it'll just take a bit longer. For example on an M1 Max, it
44+
typically takes around 1m 25s with the bad network simulation, and around 50s with non-degraded
45+
network.

integration_test/dendrite/docker-compose.yml integration_test/docker/docker-compose.yml

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.4"
2-
31
services:
42
postgres:
53
hostname: postgres
@@ -21,8 +19,8 @@ services:
2119
networks:
2220
- internal
2321

24-
monolith:
25-
hostname: monolith
22+
dendrite:
23+
hostname: dendrite
2624
image: matrixdotorg/dendrite-monolith:latest
2725
command: -really-enable-open-registration
2826
ports:
@@ -42,6 +40,17 @@ services:
4240
- internal
4341
restart: unless-stopped
4442

43+
toxiproxy:
44+
hostname: toxiproxy
45+
image: ghcr.io/shopify/toxiproxy:2.9.0
46+
depends_on:
47+
- dendrite
48+
ports:
49+
- 18008:18008
50+
- 8474:8474
51+
networks:
52+
- internal
53+
4554
networks:
4655
internal:
4756
attachable: true

integration_test/matrix_service_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void main() {
4949
: 'http://localhost:8008';
5050
const testPassword = bool.hasEnvironment(testPasswordEnv)
5151
? String.fromEnvironment(testPasswordEnv)
52-
: '?Secret123@!';
52+
: '?Secret123@';
5353

5454
const config1 = MatrixConfig(
5555
homeServer: testHomeServer,

integration_test/run_matrix_tests.sh

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
#!/bin/bash
2+
# Go to directory of script
3+
cd "$(dirname "$0")" || exit
24

35
# Create user name
46
uuid1=$(uuidgen)
57
uuid2=$(uuidgen)
68
TEST_USER1="$(tr '[:upper:]' '[:lower:]' <<< "$uuid1")"
79
TEST_USER2="$(tr '[:upper:]' '[:lower:]' <<< "$uuid2")"
810

9-
# Go to dendrite docker directory that contains config and keys
10-
cd ../dendrite/build/docker/config || exit
11-
12-
# Create user using the create-account binary in dendrite build
13-
../../../bin/create-account -config dendrite.yaml -username "$TEST_USER1" -admin -password "?Secret123@!"
14-
../../../bin/create-account -config dendrite.yaml -username "$TEST_USER2" -admin -password "?Secret123@!"
11+
cd docker || exit
12+
docker compose exec dendrite create-account -config dendrite.yaml -username "$TEST_USER1" -admin -password "?Secret123@"
13+
docker compose exec dendrite create-account -config dendrite.yaml -username "$TEST_USER2" -admin -password "?Secret123@"
1514
cd - > /dev/null || exit
15+
cd ..
1616

1717
fvm flutter test integration_test/matrix_service_test.dart \
1818
--dart-define=TEST_USER1="@$TEST_USER1:localhost" \
1919
--dart-define=TEST_USER2="@$TEST_USER2:localhost" \
2020
--dart-define=SLOW_NETWORK="$SLOW_NETWORK"
2121

22+
cd - || exit
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
# Go to directory of script
3+
cd "$(dirname "$0")" || exit
4+
5+
cd docker || exit
6+
docker compose exec toxiproxy /toxiproxy-cli create -l toxiproxy:18008 -u dendrite:8008 dendrite-proxy
7+
docker compose exec toxiproxy /toxiproxy-cli toxic add -t latency -a latency=1000 dendrite-proxy
8+
docker compose exec toxiproxy /toxiproxy-cli toxic add -t bandwidth -a rate=100 dendrite-proxy
9+
cd ..

pubspec.lock

+11-11
Original file line numberDiff line numberDiff line change
@@ -1088,10 +1088,10 @@ packages:
10881088
dependency: "direct dev"
10891089
description:
10901090
name: freezed
1091-
sha256: "57247f692f35f068cae297549a46a9a097100685c6780fe67177503eea5ed4e5"
1091+
sha256: "24f77b50776d4285cc4b3a1665bb79852714c09b878363efbe64788c179c4284"
10921092
url: "https://pub.dev"
10931093
source: hosted
1094-
version: "2.4.7"
1094+
version: "2.5.0"
10951095
freezed_annotation:
10961096
dependency: "direct main"
10971097
description:
@@ -1149,10 +1149,10 @@ packages:
11491149
dependency: "direct main"
11501150
description:
11511151
name: google_fonts
1152-
sha256: b1ac0fe2832c9cc95e5e88b57d627c5e68c223b9657f4b96e1487aa9098c7b82
1152+
sha256: "5b1726fee554d1cc9db1baef8061b126567ff0a1140a03ed7de936e62f2ab98b"
11531153
url: "https://pub.dev"
11541154
source: hosted
1155-
version: "6.2.1"
1155+
version: "6.2.0"
11561156
graphs:
11571157
dependency: transitive
11581158
description:
@@ -1651,10 +1651,10 @@ packages:
16511651
dependency: "direct main"
16521652
description:
16531653
name: meta
1654-
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
1654+
sha256: "25dfcaf170a0190f47ca6355bdd4552cb8924b430512ff0cafb8db9bd41fe33b"
16551655
url: "https://pub.dev"
16561656
source: hosted
1657-
version: "1.12.0"
1657+
version: "1.14.0"
16581658
mgrs_dart:
16591659
dependency: transitive
16601660
description:
@@ -1955,10 +1955,10 @@ packages:
19551955
dependency: transitive
19561956
description:
19571957
name: pointycastle
1958-
sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29"
1958+
sha256: "70fe966348fe08c34bf929582f1d8247d9d9408130723206472b4687227e4333"
19591959
url: "https://pub.dev"
19601960
source: hosted
1961-
version: "3.7.4"
1961+
version: "3.8.0"
19621962
polylabel:
19631963
dependency: transitive
19641964
description:
@@ -2728,10 +2728,10 @@ packages:
27282728
dependency: transitive
27292729
description:
27302730
name: video_player
2731-
sha256: "822e68b62403bebea846b012988ee1e77262e7b786345594a444c59338096ddf"
2731+
sha256: efa2e24042166906ddf836dd131258d0371d0009cdf0476f6a83fd992a17f5d0
27322732
url: "https://pub.dev"
27332733
source: hosted
2734-
version: "2.8.4"
2734+
version: "2.8.5"
27352735
video_player_android:
27362736
dependency: transitive
27372737
description:
@@ -2918,4 +2918,4 @@ packages:
29182918
version: "3.1.2"
29192919
sdks:
29202920
dart: ">=3.3.0 <4.0.0"
2921-
flutter: ">=3.19.2"
2921+
flutter: ">=3.19.0"

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: lotti
22
description: Achieve your goals and keep your data private with Lotti.
33
publish_to: 'none'
4-
version: 0.9.445+2432
4+
version: 0.9.445+2433
55

66
msix_config:
77
display_name: LottiApp

0 commit comments

Comments
 (0)