Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-v1.15.2' into dinsic
Browse files Browse the repository at this point in the history
* origin/release-v1.15.2:
  Unbreak dendrite build; use json true
  Switch to YAML::XS for YAML serialisation (#888)
  Add DENDRITE_TRACE_INTERNAL
  • Loading branch information
anoadragon453 committed Aug 4, 2020
2 parents aa50989 + a8321fe commit 1710aa3
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.git/
server-0/
server-1/
2 changes: 1 addition & 1 deletion cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ requires 'Net::SSLeay', '>= 1.59';
requires 'Protocol::Matrix', '>= 0.02';
requires 'Struct::Dumb', '>= 0.04';
requires 'URI::Escape';
requires 'YAML';
requires 'YAML::XS';
21 changes: 13 additions & 8 deletions lib/SyTest/Homeserver.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use base qw( IO::Async::Notifier );

use Future::Utils qw( repeat );

use YAML ();
use YAML::XS ();
use JSON ();
use File::Path qw( make_path );
use File::Slurper qw( write_binary );
Expand Down Expand Up @@ -215,7 +215,12 @@ sub write_yaml_file

my $hs_dir = $self->{hs_dir};

YAML::DumpFile( my $abspath = "$hs_dir/$relpath", $content );
# the docs on this aren't great, but empirically this is needed to make
# YAML::XS::DumpFile understand that JSON::true values should be dumped as
# `true`.
local $YAML::XS::Boolean = "JSON::PP";

YAML::XS::DumpFile( my $abspath = "$hs_dir/$relpath", $content );

return $abspath;
}
Expand All @@ -236,7 +241,7 @@ sub configure_logger
my $hs_dir = $self->{hs_dir};

my $log_config_file = $self->write_yaml_file("log.config.$log_type" => {
version => "1",
version => 1,

formatters => {
precise => {
Expand Down Expand Up @@ -311,7 +316,7 @@ sub _get_dbconfig

my ( %db_config );
if( -f $db_config_abs_path ) {
%db_config = %{ YAML::LoadFile( $db_config_abs_path ) };
%db_config = %{ YAML::XS::LoadFile( $db_config_abs_path ) };

# backwards-compatibility hacks
my $db_name = delete $db_config{name};
Expand All @@ -328,7 +333,7 @@ sub _get_dbconfig
}
}
else {
YAML::DumpFile( $db_config_abs_path, \%defaults );
$self->write_yaml_file( $db_config_path, \%defaults );
%db_config = %defaults;
}

Expand Down Expand Up @@ -375,19 +380,19 @@ sub _get_dbconfigs
if ( -f "$hs_dir/databases.yaml") {
$self->{output}->diag( "Using DB config from $hs_dir/databases.yaml" );

%db_configs = %{ YAML::LoadFile( "$hs_dir/databases.yaml" ) };
%db_configs = %{ YAML::XS::LoadFile( "$hs_dir/databases.yaml" ) };
}
elsif( -f "$hs_dir/database.yaml" ) {
$self->{output}->diag( "Using DB config from $hs_dir/database.yaml" );

my %db_config = %{ YAML::LoadFile( "$hs_dir/database.yaml" ) };
my %db_config = %{ YAML::XS::LoadFile( "$hs_dir/database.yaml" ) };

$db_configs{"main"} = \%db_config;
}
else {
$self->{output}->diag( "Using default DB config and writing to $hs_dir/database.yaml" );

YAML::DumpFile( "$hs_dir/database.yaml", \%defaults );
$self->write_yaml_file( "database.yaml", \%defaults );
$db_configs{"main"} = \%defaults;
}

Expand Down
3 changes: 2 additions & 1 deletion lib/SyTest/Homeserver/Dendrite.pm
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ sub _get_config
my $self = shift;
my %config = $self->SUPER::_get_config();

$config{kafka}{use_naffka} = 'true';
$config{kafka}{use_naffka} = JSON::true;

return %config;
}
Expand Down Expand Up @@ -291,6 +291,7 @@ sub _start_monolith
LOG_DIR => $self->{hs_dir},
DENDRITE_TRACE_SQL => $ENV{'DENDRITE_TRACE_SQL'},
DENDRITE_TRACE_HTTP => $ENV{'DENDRITE_TRACE_HTTP'},
DENDRITE_TRACE_INTERNAL => $ENV{'DENDRITE_TRACE_INTERNAL'},
},
],
command => [ @command ],
Expand Down
11 changes: 4 additions & 7 deletions lib/SyTest/Homeserver/Synapse.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use File::Path qw( remove_tree );
use List::Util qw( any );
use POSIX qw( strftime WIFEXITED WEXITSTATUS );

use YAML ();
use JSON;

use SyTest::SSL qw( ensure_ssl_key create_ssl_cert );

Expand Down Expand Up @@ -419,9 +419,8 @@ sub generate_listeners
type => "http",
port => $unsecure_port,
bind_address => $bind_host,
tls => 0,
resources => [{
names => [ "client", "federation", "replication", "metrics" ], compress => 0
names => [ "client", "federation", "replication", "metrics" ]
}]
}
}
Expand All @@ -431,7 +430,6 @@ sub generate_listeners
type => "replication",
port => $replication_tcp_port,
bind_address => $bind_host,
tls => 0,
}
}

Expand All @@ -440,7 +438,6 @@ sub generate_listeners
type => "metrics",
port => $self->{ports}{synapse_metrics},
bind_address => $bind_host,
tls => 0,
};
}

Expand Down Expand Up @@ -652,9 +649,9 @@ sub generate_listeners
type => "http",
port => $self->{ports}{synapse},
bind_address => $self->{bind_host},
tls => 1,
tls => JSON::true,
resources => [{
names => [ "client", "federation", "replication", "metrics" ], compress => 0
names => [ "client", "federation", "replication", "metrics" ]
}]
},
$self->SUPER::generate_listeners;
Expand Down
4 changes: 3 additions & 1 deletion tests/04mail-server.pl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ =head2 MAIL_SERVER_INFO
$OUTPUT->diag( "Started test SMTP Server at $sockname" );
Future->done({
host => $BIND_HOST,
port => $sockport,
# +0 because otherwise this comes back as a string, and perl is
# awful
port => $sockport + 0,
});
});
},
Expand Down
6 changes: 3 additions & 3 deletions tests/05homeserver.pl
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@
sender_localpart => $as_info->localpart,
namespaces => {
users => [
{ regex => '@_.*:' . $info->server_name, exclusive => "false" },
map { { regex => $_, exclusive => "true" } } @{ $as_info->user_regexes },
{ regex => '@_.*:' . $info->server_name, exclusive => JSON::false },
map { { regex => $_, exclusive => JSON::true } } @{ $as_info->user_regexes },
],
aliases => [
map { { regex => $_, exclusive => "true" } } @{ $as_info->alias_regexes },
map { { regex => $_, exclusive => JSON::true } } @{ $as_info->alias_regexes },
],
rooms => [],
},
Expand Down

0 comments on commit 1710aa3

Please sign in to comment.