From aa17cf83ac9ed08e9e557c90afce3a51f7cc9cce Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Sat, 3 Jun 2017 12:04:25 +0200 Subject: [PATCH 1/2] syncapi: Add configuration for the account database --- .../matrix-org/dendrite/cmd/dendrite-sync-api-server/main.go | 3 +-- src/github.com/matrix-org/dendrite/syncapi/config/config.go | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/cmd/dendrite-sync-api-server/main.go b/src/github.com/matrix-org/dendrite/cmd/dendrite-sync-api-server/main.go index 638eba3cd..3fe5baeb6 100644 --- a/src/github.com/matrix-org/dendrite/cmd/dendrite-sync-api-server/main.go +++ b/src/github.com/matrix-org/dendrite/cmd/dendrite-sync-api-server/main.go @@ -76,8 +76,7 @@ func main() { log.Panicf("startup: failed to create sync server database with data source %s : %s", cfg.DataSource, err) } - // TODO: DO NOT USE THIS DATA SOURCE (it's the sync one, not devices!) - deviceDB, err := devices.NewDatabase(cfg.DataSource, cfg.ServerName) + deviceDB, err := devices.NewDatabase(cfg.AccountDataSource, cfg.ServerName) if err != nil { log.Panicf("startup: failed to create device database with data source %s : %s", cfg.DataSource, err) } diff --git a/src/github.com/matrix-org/dendrite/syncapi/config/config.go b/src/github.com/matrix-org/dendrite/syncapi/config/config.go index 433a7a2b6..18d067b65 100644 --- a/src/github.com/matrix-org/dendrite/syncapi/config/config.go +++ b/src/github.com/matrix-org/dendrite/syncapi/config/config.go @@ -26,6 +26,8 @@ type Sync struct { KafkaConsumerURIs []string `yaml:"consumer_uris"` // The postgres connection config for connecting to the database e.g a postgres:// URI DataSource string `yaml:"database"` + // The postgres connection config for connecting to the account database e.g a postgres:// URI + AccountDataSource string `yaml:"account_database"` // The server_name of the running process e.g "localhost" ServerName gomatrixserverlib.ServerName `yaml:"server_name"` } From 72154fd4745d140ea63d7edb99a52ae18d1ac92c Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Sat, 3 Jun 2017 12:19:27 +0200 Subject: [PATCH 2/2] syncserver-integration-tests: WIP db improvements --- .../dendrite/cmd/syncserver-integration-tests/main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/github.com/matrix-org/dendrite/cmd/syncserver-integration-tests/main.go b/src/github.com/matrix-org/dendrite/cmd/syncserver-integration-tests/main.go index f8f6ff91a..9ad825651 100644 --- a/src/github.com/matrix-org/dendrite/cmd/syncserver-integration-tests/main.go +++ b/src/github.com/matrix-org/dendrite/cmd/syncserver-integration-tests/main.go @@ -50,6 +50,10 @@ var ( testDatabaseName = defaulting(os.Getenv("DATABASE_NAME"), "syncserver_test") // The postgres connection config for connecting to the test database. testDatabase = defaulting(os.Getenv("DATABASE"), fmt.Sprintf("dbname=%s sslmode=disable binary_parameters=yes", testDatabaseName)) + // The name of the test account database to create. + testAccountDatabaseName = defaulting(os.Getenv("ACCOUNT_DATABASE_NAME"), "account_test") + // The postgres connection config for connecting to the test account database. + testAccountDatabase = defaulting(os.Getenv("ACCOUNT_DATABASE"), fmt.Sprintf("dbname=%s sslmode=disable binary_parameters=yes", testDatabaseName)) ) const inputTopic = "syncserverInput" @@ -83,6 +87,7 @@ func getLastRequestError() error { var syncServerConfigFileContents = (`consumer_uris: ["` + kafkaURI + `"] roomserver_topic: "` + inputTopic + `" database: "` + testDatabase + `" +account_database: "` + testAccountDatabase + `" server_name: "localhost" `) @@ -231,6 +236,9 @@ func startSyncServer() (*exec.Cmd, chan error) { if err := createDatabase(testDatabaseName); err != nil { panic(err) } + if err := createDatabase(testAccountDatabaseName); err != nil { + panic(err) + } if err := createTestUser(testDatabase, "alice", "@alice:localhost"); err != nil { panic(err)