Skip to content

Commit b24e0aa

Browse files
committed
Merge branch 'develop' of github.com:matrix-org/sytest into anoa/dendrite_whitelist_annotation
* 'develop' of github.com:matrix-org/sytest: (42 commits) Fix OFFLINE support for the sytest-synapse docker image (#858) Add support for running worker mode against redis (#857) route GET account_data requests to client_reader (#855) Test that users receive updates for their own devices (#854) Add tests for SSO + user interactive authentication. (#845) Modify login tests to be spec compliant Make message history pagination test less flaky (#851) Small comment fixes for consistency (#808) Change room_fixture to run matrix_create_room_synced by default (#848) Update dendrite docs with new whitelist/blacklist info (#849) Add test for querying remote public rooms list with local server_name (#847) Add more logging to "Guest user can set display names" (#846) Add test for updating room aliases on upgraded room join (#844) Add tests to ensure that the operation cannot be modified during interactive auth. (#830) fix the CAS login test (#829) Update NOT_FOUND error to BAD_ALIAS error to be spec compliant. (#837) Missing bits Use r0 instead of 'unstable' for joined_members|rooms Add test to optionally keep other sessions when modifying a user's password. (#832) Remove tests that call query_auth endpoint. (#827) ...
2 parents 2130d18 + 8e8a0fb commit b24e0aa

37 files changed

+1194
-571
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
/var
1212
\#*
1313
.vscode
14-
.coverage*
14+
.coverage*
15+
.idea

docker/base.Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,3 @@ ENV PGHOST=/var/run/postgresql
6060
ENV PGDATA=$PGHOST/data
6161
ENV PGUSER=postgres
6262
RUN for ver in `ls /usr/lib/postgresql | head -n 1`; do su -c '/usr/lib/postgresql/'$ver'/bin/initdb -E "UTF-8" --lc-collate="C" --lc-ctype="C" --username=postgres' postgres; done
63-
64-
# Turn off all the fsync stuff for postgres
65-
RUN for ver in /etc/postgresql/*/main; do mkdir -p $ver/conf.d/; echo -e "fsync=off\nfull_page_writes=off" >> $ver/conf.d/fsync.conf; done

docs/dendrite-setup.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,18 @@ SyTest will expect Dendrite to be at `../dendrite` relative to Sytest's root dir
4141
Simply run the following to execute tests:
4242

4343
```
44-
./run-tests.pl -I Dendrite::Monolith -W ../dendrite/testfile
44+
./run-tests.pl -I Dendrite::Monolith -W ../dendrite/sytest-whitelist -B ../dendrite/sytest-blacklist
4545
```
4646

4747
## Useful flags
4848

4949
* `-W` applies a test whitelist file, one of which is currently kept up to date
5050
with what sytests Dendrite passes
51-
[here](https://github.com/matrix-org/dendrite/blob/master/testfile)
51+
[here](https://github.com/matrix-org/dendrite/blob/master/sytest-whitelist)
52+
53+
* `-B` applies a test blacklist file, one of which is currently kept up to date
54+
with what sytests are currently flaky (fail *sometimes*) with Dendrite
55+
[here](https://github.com/matrix-org/dendrite/blob/master/sytest-blacklist)
5256

5357
* `-d` lets you set the path to Dendrite's `bin/` directory, in case it's
5458
somewhere other than `../dendrite/bin`

lib/SyTest/HTTPClient.pm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ sub do_request
8383
my $self = shift;
8484
my %params = @_;
8585

86+
croak "must give a method" unless $params{method};
87+
8688
my $uri = $self->full_uri_for( %params );
8789

8890
# Also set verify_mode = 0 to not complain about self-signed SSL certs

lib/SyTest/Homeserver/Dendrite.pm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ sub _get_config
136136
},
137137

138138
database => {
139-
map { $_ => $db_uri } qw(
139+
# POSTGRES not set or is 0, use sqlite, which has separate .db files for each server
140+
map { ( ! defined $ENV{'POSTGRES'} || $ENV{'POSTGRES'} == '0') ?
141+
($_ => "file:$self->{hs_dir}/" . $_ . ".db") :
142+
($_ => $db_uri) } qw(
140143
account device media_api sync_api room_server server_key
141144
federation_sender public_rooms_api naffka appservice
142145
),

lib/SyTest/Homeserver/Synapse.pm

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ sub _init
3333

3434
$self->{paths} = {};
3535
$self->{dendron} = '';
36+
$self->{redis_host} = '';
3637

3738
$self->SUPER::_init( $args );
3839

@@ -282,6 +283,11 @@ sub start
282283
limit_usage_by_mau => "true",
283284
max_mau_value => 50000000,
284285

286+
redis => {
287+
enabled => $self->{redis_host} ne '',
288+
host => $self->{redis_host},
289+
},
290+
285291
map {
286292
defined $self->{$_} ? ( $_ => $self->{$_} ) : ()
287293
} qw(
@@ -653,6 +659,7 @@ sub _init
653659
$self->SUPER::_init( @_ );
654660

655661
$self->{dendron} = delete $args->{dendron_binary};
662+
$self->{redis_host} = delete $args->{redis_host};
656663

657664
if( my $level = delete $args->{torture_replication} ) {
658665
# torture the replication protocol a bit, to replicate bugs.
@@ -703,6 +710,7 @@ sub wrap_synapse_command
703710
"worker_log_config" => $self->configure_logger("pusher"),
704711
"worker_replication_host" => "$bind_host",
705712
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
713+
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
706714
"worker_listeners" => [
707715
{
708716
type => "http",
@@ -728,6 +736,7 @@ sub wrap_synapse_command
728736
"worker_log_config" => $self->configure_logger("appservice"),
729737
"worker_replication_host" => "$bind_host",
730738
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
739+
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
731740
"worker_listeners" => [
732741
{
733742
type => "manhole",
@@ -753,6 +762,7 @@ sub wrap_synapse_command
753762
"worker_log_config" => $self->configure_logger("federation_sender"),
754763
"worker_replication_host" => "$bind_host",
755764
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
765+
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
756766
"worker_listeners" => [
757767
{
758768
type => "manhole",
@@ -778,6 +788,7 @@ sub wrap_synapse_command
778788
"worker_log_config" => $self->configure_logger("synchrotron"),
779789
"worker_replication_host" => "$bind_host",
780790
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
791+
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
781792
"worker_listeners" => [
782793
{
783794
type => "http",
@@ -845,6 +856,7 @@ sub wrap_synapse_command
845856
"worker_log_config" => $self->configure_logger("media_repository"),
846857
"worker_replication_host" => "$bind_host",
847858
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
859+
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
848860
"worker_listeners" => [
849861
{
850862
type => "http",
@@ -912,6 +924,7 @@ sub wrap_synapse_command
912924
"worker_log_config" => $self->configure_logger("user_dir"),
913925
"worker_replication_host" => "$bind_host",
914926
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
927+
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
915928
"worker_listeners" => [
916929
{
917930
type => "http",
@@ -990,7 +1003,7 @@ sub wrap_synapse_command
9901003
},
9911004
{
9921005
type => "manhole",
993-
port => $self->{ports}{frontend_proxy},
1006+
port => $self->{ports}{frontend_proxy_manhole},
9941007
bind_address => $bind_host,
9951008
},
9961009
{
@@ -1183,6 +1196,7 @@ sub generate_haproxy_map
11831196
^/_matrix/federation/v1/exchange_third_party_invite/ federation_reader
11841197
^/_matrix/federation/v1/send/ federation_reader
11851198
^/_matrix/federation/v1/get_groups_publicised federation_reader
1199+
^/_matrix/federation/v1/user/devices/ federation_reader
11861200
^/_matrix/key/v2/query federation_reader
11871201
11881202
^/_matrix/client/(api/v1|r0|unstable)/publicRooms$ client_reader
@@ -1197,9 +1211,12 @@ sub generate_haproxy_map
11971211
^/_matrix/client/versions$ client_reader
11981212
^/_matrix/client/(api/v1|r0|unstable)/voip/turnServer$ client_reader
11991213
^/_matrix/client/(r0|unstable)/register$ client_reader
1214+
^/_matrix/client/(r0|unstable)/auth/.*/fallback/web$ client_reader
12001215
^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/messages$ client_reader
12011216
^/_matrix/client/(api/v1|r0|unstable)/get_groups_publicised$ client_reader
12021217
^/_matrix/client/(api/v1|r0|unstable)/joined_groups$ client_reader
1218+
^/_matrix/client/(api/v1|r0|unstable)/publicised_groups$ client_reader
1219+
^/_matrix/client/(api/v1|r0|unstable)/publicised_groups/ client_reader
12031220
12041221
^/_matrix/client/(api/v1|r0|unstable)/keys/upload frontend_proxy
12051222
@@ -1216,10 +1233,13 @@ EOCONFIG
12161233
sub generate_haproxy_get_map
12171234
{
12181235
return <<'EOCONFIG';
1219-
^/_matrix/federation/v1/groups/ federation_reader
1220-
1221-
^/_matrix/client/(api/v1|r0|unstable)/groups/ client_reader
1236+
# pushrules should be here, but the tests seem to be racy.
1237+
# ^/_matrix/client/(api/v1|r0|unstable)/pushrules/ client_reader
1238+
^/_matrix/client/(api/v1|r0|unstable)/groups/ client_reader
1239+
^/_matrix/client/r0/user/[^/]*/account_data/ client_reader
1240+
^/_matrix/client/r0/user/[^/]*/rooms/[^/]*/account_data/ client_reader
12221241
1242+
^/_matrix/federation/v1/groups/ federation_reader
12231243
EOCONFIG
12241244
}
12251245

lib/SyTest/HomeserverFactory/Synapse.pm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,17 @@ sub _init
101101
$self->{impl} = "SyTest::Homeserver::Synapse::ViaDendron";
102102
$self->{args}{dendron_binary} = "";
103103
$self->{args}{torture_replication} = 0;
104+
$self->{args}{redis_host} = "";
104105
}
105106

106107
sub get_options
107108
{
108109
my $self = shift;
109110

110111
return (
111-
'dendron-binary=s' => \$self->{args}{dendron_binary},
112+
'dendron-binary=s' => \$self->{args}{dendron_binary},
112113
'torture-replication:50' => \$self->{args}{torture_replication},
114+
'redis-host=s' => \$self->{args}{redis_host},
113115
$self->SUPER::get_options(),
114116
);
115117
}
@@ -125,6 +127,8 @@ sub print_usage
125127
--dendron-binary PATH - path to the 'dendron' binary
126128
127129
--torture-replication[=LEVEL] - enable torturing of the replication protocol
130+
131+
--redis-host HOST - if set then use redis for replication
128132
EOF
129133
}
130134

scripts/synapse_sytest.sh

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,26 @@ cd "$(dirname $0)/.."
1616
mkdir /work
1717

1818
# PostgreSQL setup
19-
if [ -n "$MULTI_POSTGRES" ]; then
20-
# In this mode we want to run synapse against multiple split out databases.
21-
19+
if [ -n "$MULTI_POSTGRES" ] || [ -n "$POSTGRES" ]; then
2220
# We increase the max connections as we have more databases.
23-
echo -e "max_connections=1000" >> /var/run/postgresql/data/postgresql.conf
21+
sed -i -r "s/^max_connections.*$/max_connections = 500/" /var/run/postgresql/data/postgresql.conf
22+
23+
echo -e "fsync = off" >> /var/run/postgresql/data/postgresql.conf
24+
echo -e "full_page_writes = off" >> /var/run/postgresql/data/postgresql.conf
2425

2526
# Start the database
2627
su -c 'eatmydata /usr/lib/postgresql/*/bin/pg_ctl -w -D $PGDATA start' postgres
2728

29+
su -c psql postgres <<< "show config_file"
30+
su -c psql postgres <<< "show max_connections"
31+
su -c psql postgres <<< "show full_page_writes"
32+
su -c psql postgres <<< "show fsync"
33+
fi
34+
35+
# Now create the databases
36+
if [ -n "$MULTI_POSTGRES" ]; then
37+
# In this mode we want to run synapse against multiple split out databases.
38+
2839
# Make the test databases for the two Synapse servers that will be spun up
2940
su -c psql postgres <<EOF
3041
CREATE DATABASE pg1_main;
@@ -85,13 +96,11 @@ state_db:
8596
EOF
8697

8798
elif [ -n "$POSTGRES" ]; then
99+
# Env vars used by prep_sytest_for_postgres script.
88100
export PGUSER=postgres
89101
export POSTGRES_DB_1=pg1
90102
export POSTGRES_DB_2=pg2
91103

92-
# Start the database
93-
su -c 'eatmydata /usr/lib/postgresql/*/bin/pg_ctl -w -D $PGDATA start' postgres
94-
95104
# Write out the configuration for a PostgreSQL using Synapse
96105
./scripts/prep_sytest_for_postgres.sh
97106

@@ -105,14 +114,15 @@ if [ -n "$OFFLINE" ]; then
105114
# if we're in offline mode, just put synapse into the virtualenv, and
106115
# hope that the deps are up-to-date.
107116
#
108-
# (`pip install -e` likes to reinstall setuptools even if it's already installed,
109-
# so we just run setup.py explicitly.)
110-
#
111-
(cd /src && /venv/bin/python setup.py -q develop)
117+
# --no-use-pep517 works around what appears to be a pip issue
118+
# (https://github.com/pypa/pip/issues/5402 possibly) where pip wants
119+
# to reinstall any requirements for the build system, even if they are
120+
# already installed.
121+
/venv/bin/pip install --no-index --no-use-pep517 /src
112122
else
113123
# We've already created the virtualenv, but lets double check we have all
114124
# deps.
115-
/venv/bin/pip install -q --upgrade --no-cache-dir /src
125+
/venv/bin/pip install -q --upgrade --no-cache-dir /src[redis]
116126
/venv/bin/pip install -q --upgrade --no-cache-dir \
117127
lxml psycopg2 coverage codecov tap.py coverage_enable_subprocess
118128

tests/10apidoc/00prepare.pl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ sub do_request_json_for
1313
my ( $user, %args ) = @_;
1414
is_User( $user ) or croak "Expected a User";
1515

16+
croak "must give a method" unless $args{method};
17+
1618
my $user_id = $user->user_id;
1719
( my $uri = delete $args{uri} ) =~ s/:user_id/$user_id/g;
1820

tests/10apidoc/02login.pl

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
my ( $http ) = @_;
3838

3939
$http->do_request_json(
40+
method => "GET",
4041
uri => "/r0/login",
4142
)->then( sub {
4243
my ( $body ) = @_;
@@ -81,7 +82,10 @@
8182

8283
content => {
8384
type => "m.login.password",
84-
user => $user_id,
85+
identifier => {
86+
type => "m.id.user",
87+
user => $user_id,
88+
},
8589
password => $password,
8690
},
8791
)->then( sub {
@@ -113,7 +117,10 @@
113117

114118
content => {
115119
type => "m.login.password",
116-
user => $user_id,
120+
identifier => {
121+
type => "m.id.user",
122+
user => $user_id,
123+
},
117124
password => $password,
118125
device_id => $device_id,
119126
},
@@ -145,7 +152,10 @@
145152

146153
content => {
147154
type => "m.login.password",
148-
user => $user_localpart,
155+
identifier => {
156+
type => "m.id.user",
157+
user => $user_localpart,
158+
},
149159
password => $password,
150160
},
151161
)->then( sub {
@@ -173,7 +183,10 @@
173183

174184
content => {
175185
type => "m.login.password",
176-
user => "i-ought-not-to-exist",
186+
identifier => {
187+
type => "m.id.user",
188+
user => "i-ought-not-to-exist",
189+
},
177190
password => "XXX",
178191
},
179192
)->main::expect_http_403;
@@ -192,7 +205,10 @@
192205

193206
content => {
194207
type => "m.login.password",
195-
user => $user_id,
208+
identifier => {
209+
type => "m.id.user",
210+
user => $user_id,
211+
},
196212
password => "${password}wrong",
197213
},
198214
)->main::expect_http_403->then( sub {
@@ -224,7 +240,10 @@ sub matrix_login_again_with_user
224240
uri => "/r0/login",
225241
content => {
226242
type => "m.login.password",
227-
user => $user->user_id,
243+
identifier => {
244+
type => "m.id.user",
245+
user => $user->user_id,
246+
},
228247
password => $user->password,
229248
%args,
230249
},

0 commit comments

Comments
 (0)