Skip to content

Commit 14ba2c5

Browse files
authored
Fix SQLite Synapse runs (#1392)
Broke in #1390
1 parent 4ad9b13 commit 14ba2c5

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

.github/workflows/pipeline.yml

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
include:
24+
- label: Py 3.10, SQLite, Monolith
25+
sytest-tag: bookworm-python3.10
26+
2427
- label: Py 3.10, PG 14, Monolith
2528
sytest-tag: bookworm-python3.10
2629
postgres: postgres

lib/SyTest/Homeserver.pm

+3-5
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,9 @@ sub _get_dbconfigs
374374
foreach my $db ( keys %db_configs ) {
375375
my $db_config = $db_configs{$db};
376376

377-
# Extract the name of the module that is used to access the database. This
378-
# does add a new item to the database config block, 'type'. It appears to
379-
# be harmless and is used later on to determine which method to use to
380-
# clear the database
381-
my $db_name = $db_config->{name};
377+
# Backwards compatibility: the `type` field in the sytest database config
378+
# used to be called `name` and have different values. We fix that up here.
379+
my $db_name = delete $db_config->{name};
382380
if( defined $db_name ) {
383381
if( $db_name eq 'psycopg2' ) {
384382
$db_config->{type} = 'pg';

lib/SyTest/Homeserver/Synapse.pm

+16
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,22 @@ sub start
125125
},
126126
);
127127

128+
# convert sytest db args onto synapse db args
129+
for my $db ( keys %db_configs ) {
130+
my %db_config = %{ $db_configs{$db} };
131+
132+
my $db_type = $db_config{type};
133+
134+
if( $db_type eq "pg" ) {
135+
$db_configs{$db}{name} = 'psycopg2';
136+
} elsif ($db_type eq "sqlite" ) {
137+
$db_configs{$db}{name} = 'sqlite3';
138+
} else {
139+
# We should have already validated the database type here.
140+
die "Unrecognized database type: '$db_type'";
141+
}
142+
}
143+
128144
# Clean up the media_store directory each time, or else it fills up with
129145
# thousands of automatically-generated avatar images
130146
if( -d "$hs_dir/media_store" ) {

0 commit comments

Comments
 (0)