From 51d24eba96e91824e13f35a5c3b3adbe4aa4b6dc Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 8 Oct 2020 12:18:46 +0100 Subject: [PATCH 1/4] Run multiple event persisters when using Redis --- lib/SyTest/Homeserver/Synapse.pm | 86 ++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/lib/SyTest/Homeserver/Synapse.pm b/lib/SyTest/Homeserver/Synapse.pm index a60489404..1bf1ba094 100644 --- a/lib/SyTest/Homeserver/Synapse.pm +++ b/lib/SyTest/Homeserver/Synapse.pm @@ -81,6 +81,14 @@ sub _init frontend_proxy_metrics => main::alloc_port( "frontend_proxy[$idx].metrics" ), frontend_proxy_manhole => main::alloc_port( "frontend_proxy[$idx].manhole" ), + event_persister1 => main::alloc_port( "event_persister1[$idx]" ), + event_persister1_metrics => main::alloc_port( "event_persister1[$idx].metrics" ), + event_persister1_manhole => main::alloc_port( "event_persister1[$idx].manhole" ), + + event_persister2 => main::alloc_port( "event_persister2[$idx]" ), + event_persister2_metrics => main::alloc_port( "event_persister2[$idx].metrics" ), + event_persister2_manhole => main::alloc_port( "event_persister2[$idx].manhole" ), + haproxy => main::alloc_port( "haproxy[$idx]" ), }; } @@ -290,14 +298,18 @@ sub start ) : (), instance_map => { - "frontend_proxy1" => { + "event_persister1" => { + host => "$bind_host", + port => $self->{ports}{event_persister1}, + }, + "event_persister2" => { host => "$bind_host", - port => $self->{ports}{frontend_proxy}, + port => $self->{ports}{event_persister2}, }, }, stream_writers => { - events => $self->{redis_host} ne '' ? "frontend_proxy1" : "master", + events => $self->{redis_host} ne '' ? [ "event_persister1", "event_persister2" ] : "master", }, # We use a high limit so the limit is never reached, but enabling the @@ -970,6 +982,74 @@ sub _start_synapse push @worker_configs, $background_worker_config; } + { + my $event_persister1_config = { + "worker_app" => "synapse.app.generic_worker", + "worker_name" => "event_persister1", + "worker_pid_file" => "$hsdir/event_persister1.pid", + "worker_log_config" => $self->configure_logger("event_persister1"), + "worker_replication_host" => "$bind_host", + "worker_replication_port" => $self->{ports}{synapse_replication_tcp}, + "worker_replication_http_port" => $self->{ports}{synapse_unsecure}, + "worker_main_http_uri" => "http://$bind_host:$self->{ports}{synapse_unsecure}", + "worker_listeners" => [ + { + type => "http", + resources => [{ names => ["client", "replication"] }], + port => $self->{ports}{event_persister1}, + bind_address => $bind_host, + }, + { + type => "manhole", + port => $self->{ports}{event_persister1_manhole}, + bind_address => $bind_host, + }, + { + type => "http", + resources => [{ names => ["metrics"] }], + port => $self->{ports}{event_persister1_metrics}, + bind_address => $bind_host, + }, + ], + }; + + push @worker_configs, $event_persister1_config; + } + + { + my $event_persister2_config = { + "worker_app" => "synapse.app.generic_worker", + "worker_name" => "event_persister2", + "worker_pid_file" => "$hsdir/event_persister2.pid", + "worker_log_config" => $self->configure_logger("event_persister2"), + "worker_replication_host" => "$bind_host", + "worker_replication_port" => $self->{ports}{synapse_replication_tcp}, + "worker_replication_http_port" => $self->{ports}{synapse_unsecure}, + "worker_main_http_uri" => "http://$bind_host:$self->{ports}{synapse_unsecure}", + "worker_listeners" => [ + { + type => "http", + resources => [{ names => ["client", "replication"] }], + port => $self->{ports}{event_persister2}, + bind_address => $bind_host, + }, + { + type => "manhole", + port => $self->{ports}{event_persister2_manhole}, + bind_address => $bind_host, + }, + { + type => "http", + resources => [{ names => ["metrics"] }], + port => $self->{ports}{event_persister2_metrics}, + bind_address => $bind_host, + }, + ], + }; + + push @worker_configs, $event_persister2_config; + } + my @base_synapse_command = $self->_generate_base_synapse_command(); my $idx = $self->{hs_index}; From 935782b28d648f5a93e28b4fff1e37d289560e9b Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 9 Oct 2020 15:44:13 +0100 Subject: [PATCH 2/4] Fix flakey test --- tests/30rooms/60version_upgrade.pl | 67 ++++++++++++++++-------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/tests/30rooms/60version_upgrade.pl b/tests/30rooms/60version_upgrade.pl index 0c42c6e1e..a81454d91 100644 --- a/tests/30rooms/60version_upgrade.pl +++ b/tests/30rooms/60version_upgrade.pl @@ -1070,46 +1070,51 @@ sub upgrade_room_synced { $remote_joiner, $new_room_id, ( server_name => $creator->server_name, ) ); })->then(sub { - do_request_json_for( $creator, - method => "GET", - uri => "/r0/publicRooms", - ); - })->then( sub { - # Check public rooms list for local user - my ( $body ) = @_; + retry_until_success { + do_request_json_for( $creator, + method => "GET", + uri => "/r0/publicRooms", + )->then( sub { + # Check public rooms list for local user + my ( $body ) = @_; - log_if_fail "Public rooms list for local user", $body; + log_if_fail "Public rooms list for local user", $body; - assert_json_keys( $body, qw( chunk ) ); + assert_json_keys( $body, qw( chunk ) ); - # Check that the room list contains new room id - any { $new_room_id eq $_->{room_id} } @{ $body->{chunk} } - or die "Local room list did not include expected room id $new_room_id"; + # Check that the room list contains new room id + any { $new_room_id eq $_->{room_id} } @{ $body->{chunk} } + or die "Local room list did not include expected room id $new_room_id"; - # Check that the room list doesn't contain old room id - none { $room_id eq $_->{room_id} } @{ $body->{chunk} } - or die "Local room list included unexpected room id $room_id"; + # Check that the room list doesn't contain old room id + none { $room_id eq $_->{room_id} } @{ $body->{chunk} } + or die "Local room list included unexpected room id $room_id"; - do_request_json_for( $remote_joiner, - method => "GET", - uri => "/r0/publicRooms", - ); - })->then( sub { - # Check public rooms list for remote user - my ( $body ) = @_; + }) + } + })->then(sub { + retry_until_success { + do_request_json_for( $remote_joiner, + method => "GET", + uri => "/r0/publicRooms", + )->then( sub { + # Check public rooms list for remote user + my ( $body ) = @_; - log_if_fail "Public rooms list for remote user", $body; + log_if_fail "Public rooms list for remote user", $body; - assert_json_keys( $body, qw( chunk ) ); + assert_json_keys( $body, qw( chunk ) ); - # Check that the room list contains new room id - any { $new_room_id eq $_->{room_id} } @{ $body->{chunk} } - or die "Remote room list did not include expected room id $new_room_id"; + # Check that the room list contains new room id + any { $new_room_id eq $_->{room_id} } @{ $body->{chunk} } + or die "Remote room list did not include expected room id $new_room_id"; - # Check that the room list doesn't contain old room id - none { $room_id eq $_->{room_id} } @{ $body->{chunk} } - or die "Remote room list included unexpected room id $room_id"; + # Check that the room list doesn't contain old room id + none { $room_id eq $_->{room_id} } @{ $body->{chunk} } + or die "Remote room list included unexpected room id $room_id"; - Future->done( 1 ); + Future->done( 1 ); + }) + } }); } From 2fab331ef5a6c4773dcc9482d95f28aa6f47cd6c Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 13 Oct 2020 10:48:02 +0100 Subject: [PATCH 3/4] Add comment --- tests/30rooms/60version_upgrade.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/30rooms/60version_upgrade.pl b/tests/30rooms/60version_upgrade.pl index a81454d91..7cf650380 100644 --- a/tests/30rooms/60version_upgrade.pl +++ b/tests/30rooms/60version_upgrade.pl @@ -1070,6 +1070,8 @@ sub upgrade_room_synced { $remote_joiner, $new_room_id, ( server_name => $creator->server_name, ) ); })->then(sub { + # The room list can be updated asynchrounously, so we retry if it + # doesn't match what we expect. retry_until_success { do_request_json_for( $creator, method => "GET", @@ -1093,6 +1095,8 @@ sub upgrade_room_synced { }) } })->then(sub { + # The room list can be updated asynchrounously, so we retry if it + # doesn't match what we expect. retry_until_success { do_request_json_for( $remote_joiner, method => "GET", From 8d4d21d46dd7221043b6fc691dafa4ca807557ad Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 13 Oct 2020 11:00:13 +0100 Subject: [PATCH 4/4] Damn typos Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- tests/30rooms/60version_upgrade.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/30rooms/60version_upgrade.pl b/tests/30rooms/60version_upgrade.pl index 7cf650380..dc601c81e 100644 --- a/tests/30rooms/60version_upgrade.pl +++ b/tests/30rooms/60version_upgrade.pl @@ -1070,7 +1070,7 @@ sub upgrade_room_synced { $remote_joiner, $new_room_id, ( server_name => $creator->server_name, ) ); })->then(sub { - # The room list can be updated asynchrounously, so we retry if it + # The room list can be updated asynchronously, so we retry if it # doesn't match what we expect. retry_until_success { do_request_json_for( $creator, @@ -1095,7 +1095,7 @@ sub upgrade_room_synced { }) } })->then(sub { - # The room list can be updated asynchrounously, so we retry if it + # The room list can be updated asynchronously, so we retry if it # doesn't match what we expect. retry_until_success { do_request_json_for( $remote_joiner,