Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3914ed6

Browse files
authoredNov 17, 2020
Implementation-specific tests (#981)
* Mark admin tests as Synapse-specific * Match just the first part of the implementation name * Let's try that again * Declare tokens * Scalar vs list etc * Invert the check * Fat-fingered * Less magic * Define implementation_name for all * whois is actually in the spec * Add commented stub, try without implementation_name in ViaHaproxy/Monolith
1 parent 73fa9af commit 3914ed6

File tree

8 files changed

+41
-0
lines changed

8 files changed

+41
-0
lines changed
 

‎DEVELOP.rst

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ is described in more detail in the following sections.
5555
deprecated in the spec. These tests will be ignored automatically if
5656
the ``--exclude-deprecated`` flag is provided to Sytest.
5757

58+
``implementation_specific``
59+
A string to specify that the test should only be run for certain homeserver
60+
implementations, e.g. `"Synapse"`, `"Dendrite"` etc.
61+
5862
A call to ``test`` is a simplified version of ``multi_test`` which produces
5963
only a single line of test output indicating success or failure automatically.
6064
A call to ``multi_test`` can make use of additional functions within the body

‎lib/SyTest/HomeserverFactory.pm

+8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ sub new
3838

3939
sub _init {}
4040

41+
# Returns the generic simple name of the implementation, e.g. "synapse",
42+
# "dendrite" etc. This is used when determining whether to run any
43+
# implementation-specific tests.
44+
sub implementation_name
45+
{
46+
return "";
47+
}
48+
4149
# returns a list of (name => action) pairs suitable for
4250
# inclusion in the GetOptions argument list
4351
sub get_options

‎lib/SyTest/HomeserverFactory/Dendrite.pm

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ sub _init
3131
$self->SUPER::_init( @_ );
3232
}
3333

34+
sub implementation_name
35+
{
36+
return "dendrite";
37+
}
38+
3439
sub get_options
3540
{
3641
my $self = shift;

‎lib/SyTest/HomeserverFactory/Manual.pm

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ sub _init
3131
$self->SUPER::_init( @_ );
3232
}
3333

34+
sub implementation_name
35+
{
36+
return "manual";
37+
}
38+
3439
sub get_options
3540
{
3641
my $self = shift;

‎lib/SyTest/HomeserverFactory/Synapse.pm

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ sub _init
3838
$self->SUPER::_init( @_ );
3939
}
4040

41+
sub implementation_name
42+
{
43+
return "synapse";
44+
}
45+
4146
sub get_options
4247
{
4348
my $self = shift;

‎run-tests.pl

+6
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,12 @@ sub _push_test
622622
}
623623
}
624624

625+
if( exists $params{implementation_specific} ) {
626+
if ( $HS_FACTORY->implementation_name() ne $params{implementation_specific} ) {
627+
return;
628+
}
629+
}
630+
625631
push @TESTS, Test( $filename, $name, $multi,
626632
@params{qw( expect_fail proves requires check do timeout )} );
627633
}

‎tests/10apidoc/01register.pl

+4
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ sub shared_secret_tests {
318318

319319
test "POST $ep_name with shared secret",
320320
requires => [ $main::API_CLIENTS[0], localpart_fixture() ],
321+
implementation_specific => "synapse",
321322

322323
proves => [qw( can_register_with_secret )],
323324

@@ -334,6 +335,7 @@ sub shared_secret_tests {
334335

335336
test "POST $ep_name admin with shared secret",
336337
requires => [ $main::API_CLIENTS[0], localpart_fixture() ],
338+
implementation_specific => "synapse",
337339

338340
do => sub {
339341
my ( $http, $uid ) = @_;
@@ -349,6 +351,7 @@ sub shared_secret_tests {
349351

350352
test "POST $ep_name with shared secret downcases capitals",
351353
requires => [ $main::API_CLIENTS[0], localpart_fixture() ],
354+
implementation_specific => "synapse",
352355

353356
proves => [qw( can_register_with_secret )],
354357

@@ -365,6 +368,7 @@ sub shared_secret_tests {
365368

366369
test "POST $ep_name with shared secret disallows symbols",
367370
requires => [ $main::API_CLIENTS[0] ],
371+
implementation_specific => "synapse",
368372

369373
proves => [qw( can_register_with_secret )],
370374

‎tests/48admin.pl

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ sub await_purge_complete {
6969

7070
test "/purge_history",
7171
requires => [ local_admin_fixture(), local_user_and_room_fixtures() ],
72+
implementation_specific => "synapse",
7273

7374
do => sub {
7475
my ( $admin, $user, $room_id ) = @_;
@@ -149,6 +150,7 @@ sub await_purge_complete {
149150

150151
test "/purge_history by ts",
151152
requires => [ local_admin_fixture(), local_user_and_room_fixtures() ],
153+
implementation_specific => "synapse",
152154

153155
do => sub {
154156
my ( $admin, $user, $room_id ) = @_;
@@ -222,6 +224,7 @@ sub await_purge_complete {
222224
test "Can backfill purged history",
223225
requires => [ local_admin_fixture(), local_user_and_room_fixtures(),
224226
remote_user_fixture(), qw( can_paginate_room_remotely ) ],
227+
implementation_specific => "synapse",
225228

226229
# this test is a bit slow.
227230
timeout => 50,
@@ -358,6 +361,7 @@ sub await_purge_complete {
358361
multi_test "Shutdown room",
359362
requires => [ local_admin_fixture(), local_user_fixtures( 2 ), remote_user_fixture(),
360363
room_alias_name_fixture() ],
364+
implementation_specific => "synapse",
361365

362366
do => sub {
363367
my ( $admin, $user, $dummy_user, $remote_user, $room_alias_name ) = @_;

0 commit comments

Comments
 (0)
Please sign in to comment.