Remove database config parsing from apps.
parent
0f3614f0f6
commit
bc5cb8bfe8
|
@ -45,7 +45,6 @@ from synapse.replication.slave.storage.registration import SlavedRegistrationSto
|
||||||
from synapse.replication.slave.storage.room import RoomStore
|
from synapse.replication.slave.storage.room import RoomStore
|
||||||
from synapse.replication.tcp.client import ReplicationClientHandler
|
from synapse.replication.tcp.client import ReplicationClientHandler
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.storage.engines import create_engine
|
|
||||||
from synapse.util.logcontext import LoggingContext
|
from synapse.util.logcontext import LoggingContext
|
||||||
from synapse.util.versionstring import get_version_string
|
from synapse.util.versionstring import get_version_string
|
||||||
|
|
||||||
|
@ -229,14 +228,10 @@ def start(config_options):
|
||||||
|
|
||||||
synapse.events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
synapse.events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
||||||
|
|
||||||
database_engine = create_engine(config.database_config)
|
|
||||||
|
|
||||||
ss = AdminCmdServer(
|
ss = AdminCmdServer(
|
||||||
config.server_name,
|
config.server_name,
|
||||||
db_config=config.database_config,
|
|
||||||
config=config,
|
config=config,
|
||||||
version_string="Synapse/" + get_version_string(synapse),
|
version_string="Synapse/" + get_version_string(synapse),
|
||||||
database_engine=database_engine,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
setup_logging(ss, config, use_worker_options=True)
|
setup_logging(ss, config, use_worker_options=True)
|
||||||
|
|
|
@ -34,7 +34,6 @@ from synapse.replication.slave.storage.events import SlavedEventStore
|
||||||
from synapse.replication.slave.storage.registration import SlavedRegistrationStore
|
from synapse.replication.slave.storage.registration import SlavedRegistrationStore
|
||||||
from synapse.replication.tcp.client import ReplicationClientHandler
|
from synapse.replication.tcp.client import ReplicationClientHandler
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.storage.engines import create_engine
|
|
||||||
from synapse.util.httpresourcetree import create_resource_tree
|
from synapse.util.httpresourcetree import create_resource_tree
|
||||||
from synapse.util.manhole import manhole
|
from synapse.util.manhole import manhole
|
||||||
from synapse.util.versionstring import get_version_string
|
from synapse.util.versionstring import get_version_string
|
||||||
|
@ -143,8 +142,6 @@ def start(config_options):
|
||||||
|
|
||||||
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
||||||
|
|
||||||
database_engine = create_engine(config.database_config)
|
|
||||||
|
|
||||||
if config.notify_appservices:
|
if config.notify_appservices:
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
"\nThe appservices must be disabled in the main synapse process"
|
"\nThe appservices must be disabled in the main synapse process"
|
||||||
|
@ -159,10 +156,8 @@ def start(config_options):
|
||||||
|
|
||||||
ps = AppserviceServer(
|
ps = AppserviceServer(
|
||||||
config.server_name,
|
config.server_name,
|
||||||
db_config=config.database_config,
|
|
||||||
config=config,
|
config=config,
|
||||||
version_string="Synapse/" + get_version_string(synapse),
|
version_string="Synapse/" + get_version_string(synapse),
|
||||||
database_engine=database_engine,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
setup_logging(ps, config, use_worker_options=True)
|
setup_logging(ps, config, use_worker_options=True)
|
||||||
|
|
|
@ -62,7 +62,6 @@ from synapse.rest.client.v2_alpha.keys import KeyChangesServlet, KeyQueryServlet
|
||||||
from synapse.rest.client.v2_alpha.register import RegisterRestServlet
|
from synapse.rest.client.v2_alpha.register import RegisterRestServlet
|
||||||
from synapse.rest.client.versions import VersionsRestServlet
|
from synapse.rest.client.versions import VersionsRestServlet
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.storage.engines import create_engine
|
|
||||||
from synapse.util.httpresourcetree import create_resource_tree
|
from synapse.util.httpresourcetree import create_resource_tree
|
||||||
from synapse.util.manhole import manhole
|
from synapse.util.manhole import manhole
|
||||||
from synapse.util.versionstring import get_version_string
|
from synapse.util.versionstring import get_version_string
|
||||||
|
@ -181,14 +180,10 @@ def start(config_options):
|
||||||
|
|
||||||
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
||||||
|
|
||||||
database_engine = create_engine(config.database_config)
|
|
||||||
|
|
||||||
ss = ClientReaderServer(
|
ss = ClientReaderServer(
|
||||||
config.server_name,
|
config.server_name,
|
||||||
db_config=config.database_config,
|
|
||||||
config=config,
|
config=config,
|
||||||
version_string="Synapse/" + get_version_string(synapse),
|
version_string="Synapse/" + get_version_string(synapse),
|
||||||
database_engine=database_engine,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
setup_logging(ss, config, use_worker_options=True)
|
setup_logging(ss, config, use_worker_options=True)
|
||||||
|
|
|
@ -57,7 +57,6 @@ from synapse.rest.client.v1.room import (
|
||||||
)
|
)
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.storage.data_stores.main.user_directory import UserDirectoryStore
|
from synapse.storage.data_stores.main.user_directory import UserDirectoryStore
|
||||||
from synapse.storage.engines import create_engine
|
|
||||||
from synapse.util.httpresourcetree import create_resource_tree
|
from synapse.util.httpresourcetree import create_resource_tree
|
||||||
from synapse.util.manhole import manhole
|
from synapse.util.manhole import manhole
|
||||||
from synapse.util.versionstring import get_version_string
|
from synapse.util.versionstring import get_version_string
|
||||||
|
@ -180,14 +179,10 @@ def start(config_options):
|
||||||
|
|
||||||
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
||||||
|
|
||||||
database_engine = create_engine(config.database_config)
|
|
||||||
|
|
||||||
ss = EventCreatorServer(
|
ss = EventCreatorServer(
|
||||||
config.server_name,
|
config.server_name,
|
||||||
db_config=config.database_config,
|
|
||||||
config=config,
|
config=config,
|
||||||
version_string="Synapse/" + get_version_string(synapse),
|
version_string="Synapse/" + get_version_string(synapse),
|
||||||
database_engine=database_engine,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
setup_logging(ss, config, use_worker_options=True)
|
setup_logging(ss, config, use_worker_options=True)
|
||||||
|
|
|
@ -46,7 +46,6 @@ from synapse.replication.slave.storage.transactions import SlavedTransactionStor
|
||||||
from synapse.replication.tcp.client import ReplicationClientHandler
|
from synapse.replication.tcp.client import ReplicationClientHandler
|
||||||
from synapse.rest.key.v2 import KeyApiV2Resource
|
from synapse.rest.key.v2 import KeyApiV2Resource
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.storage.engines import create_engine
|
|
||||||
from synapse.util.httpresourcetree import create_resource_tree
|
from synapse.util.httpresourcetree import create_resource_tree
|
||||||
from synapse.util.manhole import manhole
|
from synapse.util.manhole import manhole
|
||||||
from synapse.util.versionstring import get_version_string
|
from synapse.util.versionstring import get_version_string
|
||||||
|
@ -162,14 +161,10 @@ def start(config_options):
|
||||||
|
|
||||||
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
||||||
|
|
||||||
database_engine = create_engine(config.database_config)
|
|
||||||
|
|
||||||
ss = FederationReaderServer(
|
ss = FederationReaderServer(
|
||||||
config.server_name,
|
config.server_name,
|
||||||
db_config=config.database_config,
|
|
||||||
config=config,
|
config=config,
|
||||||
version_string="Synapse/" + get_version_string(synapse),
|
version_string="Synapse/" + get_version_string(synapse),
|
||||||
database_engine=database_engine,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
setup_logging(ss, config, use_worker_options=True)
|
setup_logging(ss, config, use_worker_options=True)
|
||||||
|
|
|
@ -41,7 +41,6 @@ from synapse.replication.tcp.client import ReplicationClientHandler
|
||||||
from synapse.replication.tcp.streams._base import ReceiptsStream
|
from synapse.replication.tcp.streams._base import ReceiptsStream
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.storage.database import Database
|
from synapse.storage.database import Database
|
||||||
from synapse.storage.engines import create_engine
|
|
||||||
from synapse.types import ReadReceipt
|
from synapse.types import ReadReceipt
|
||||||
from synapse.util.async_helpers import Linearizer
|
from synapse.util.async_helpers import Linearizer
|
||||||
from synapse.util.httpresourcetree import create_resource_tree
|
from synapse.util.httpresourcetree import create_resource_tree
|
||||||
|
@ -174,8 +173,6 @@ def start(config_options):
|
||||||
|
|
||||||
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
||||||
|
|
||||||
database_engine = create_engine(config.database_config)
|
|
||||||
|
|
||||||
if config.send_federation:
|
if config.send_federation:
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
"\nThe send_federation must be disabled in the main synapse process"
|
"\nThe send_federation must be disabled in the main synapse process"
|
||||||
|
@ -190,10 +187,8 @@ def start(config_options):
|
||||||
|
|
||||||
ss = FederationSenderServer(
|
ss = FederationSenderServer(
|
||||||
config.server_name,
|
config.server_name,
|
||||||
db_config=config.database_config,
|
|
||||||
config=config,
|
config=config,
|
||||||
version_string="Synapse/" + get_version_string(synapse),
|
version_string="Synapse/" + get_version_string(synapse),
|
||||||
database_engine=database_engine,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
setup_logging(ss, config, use_worker_options=True)
|
setup_logging(ss, config, use_worker_options=True)
|
||||||
|
|
|
@ -39,7 +39,6 @@ from synapse.replication.slave.storage.registration import SlavedRegistrationSto
|
||||||
from synapse.replication.tcp.client import ReplicationClientHandler
|
from synapse.replication.tcp.client import ReplicationClientHandler
|
||||||
from synapse.rest.client.v2_alpha._base import client_patterns
|
from synapse.rest.client.v2_alpha._base import client_patterns
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.storage.engines import create_engine
|
|
||||||
from synapse.util.httpresourcetree import create_resource_tree
|
from synapse.util.httpresourcetree import create_resource_tree
|
||||||
from synapse.util.manhole import manhole
|
from synapse.util.manhole import manhole
|
||||||
from synapse.util.versionstring import get_version_string
|
from synapse.util.versionstring import get_version_string
|
||||||
|
@ -234,14 +233,10 @@ def start(config_options):
|
||||||
|
|
||||||
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
||||||
|
|
||||||
database_engine = create_engine(config.database_config)
|
|
||||||
|
|
||||||
ss = FrontendProxyServer(
|
ss = FrontendProxyServer(
|
||||||
config.server_name,
|
config.server_name,
|
||||||
db_config=config.database_config,
|
|
||||||
config=config,
|
config=config,
|
||||||
version_string="Synapse/" + get_version_string(synapse),
|
version_string="Synapse/" + get_version_string(synapse),
|
||||||
database_engine=database_engine,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
setup_logging(ss, config, use_worker_options=True)
|
setup_logging(ss, config, use_worker_options=True)
|
||||||
|
|
|
@ -69,7 +69,7 @@ from synapse.rest.media.v0.content_repository import ContentRepoResource
|
||||||
from synapse.rest.well_known import WellKnownResource
|
from synapse.rest.well_known import WellKnownResource
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.storage import DataStore
|
from synapse.storage import DataStore
|
||||||
from synapse.storage.engines import IncorrectDatabaseSetup, create_engine
|
from synapse.storage.engines import IncorrectDatabaseSetup
|
||||||
from synapse.storage.prepare_database import UpgradeDatabaseException
|
from synapse.storage.prepare_database import UpgradeDatabaseException
|
||||||
from synapse.util.caches import CACHE_SIZE_FACTOR
|
from synapse.util.caches import CACHE_SIZE_FACTOR
|
||||||
from synapse.util.httpresourcetree import create_resource_tree
|
from synapse.util.httpresourcetree import create_resource_tree
|
||||||
|
@ -328,15 +328,10 @@ def setup(config_options):
|
||||||
|
|
||||||
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
||||||
|
|
||||||
database_engine = create_engine(config.database_config)
|
|
||||||
config.database_config["args"]["cp_openfun"] = database_engine.on_new_connection
|
|
||||||
|
|
||||||
hs = SynapseHomeServer(
|
hs = SynapseHomeServer(
|
||||||
config.server_name,
|
config.server_name,
|
||||||
db_config=config.database_config,
|
|
||||||
config=config,
|
config=config,
|
||||||
version_string="Synapse/" + get_version_string(synapse),
|
version_string="Synapse/" + get_version_string(synapse),
|
||||||
database_engine=database_engine,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
synapse.config.logger.setup_logging(hs, config, use_worker_options=False)
|
synapse.config.logger.setup_logging(hs, config, use_worker_options=False)
|
||||||
|
|
|
@ -40,7 +40,6 @@ from synapse.rest.admin import register_servlets_for_media_repo
|
||||||
from synapse.rest.media.v0.content_repository import ContentRepoResource
|
from synapse.rest.media.v0.content_repository import ContentRepoResource
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.storage.data_stores.main.media_repository import MediaRepositoryStore
|
from synapse.storage.data_stores.main.media_repository import MediaRepositoryStore
|
||||||
from synapse.storage.engines import create_engine
|
|
||||||
from synapse.util.httpresourcetree import create_resource_tree
|
from synapse.util.httpresourcetree import create_resource_tree
|
||||||
from synapse.util.manhole import manhole
|
from synapse.util.manhole import manhole
|
||||||
from synapse.util.versionstring import get_version_string
|
from synapse.util.versionstring import get_version_string
|
||||||
|
@ -157,14 +156,10 @@ def start(config_options):
|
||||||
|
|
||||||
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
||||||
|
|
||||||
database_engine = create_engine(config.database_config)
|
|
||||||
|
|
||||||
ss = MediaRepositoryServer(
|
ss = MediaRepositoryServer(
|
||||||
config.server_name,
|
config.server_name,
|
||||||
db_config=config.database_config,
|
|
||||||
config=config,
|
config=config,
|
||||||
version_string="Synapse/" + get_version_string(synapse),
|
version_string="Synapse/" + get_version_string(synapse),
|
||||||
database_engine=database_engine,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
setup_logging(ss, config, use_worker_options=True)
|
setup_logging(ss, config, use_worker_options=True)
|
||||||
|
|
|
@ -36,7 +36,6 @@ from synapse.replication.slave.storage.receipts import SlavedReceiptsStore
|
||||||
from synapse.replication.tcp.client import ReplicationClientHandler
|
from synapse.replication.tcp.client import ReplicationClientHandler
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.storage import DataStore
|
from synapse.storage import DataStore
|
||||||
from synapse.storage.engines import create_engine
|
|
||||||
from synapse.util.httpresourcetree import create_resource_tree
|
from synapse.util.httpresourcetree import create_resource_tree
|
||||||
from synapse.util.manhole import manhole
|
from synapse.util.manhole import manhole
|
||||||
from synapse.util.versionstring import get_version_string
|
from synapse.util.versionstring import get_version_string
|
||||||
|
@ -198,14 +197,10 @@ def start(config_options):
|
||||||
# Force the pushers to start since they will be disabled in the main config
|
# Force the pushers to start since they will be disabled in the main config
|
||||||
config.start_pushers = True
|
config.start_pushers = True
|
||||||
|
|
||||||
database_engine = create_engine(config.database_config)
|
|
||||||
|
|
||||||
ps = PusherServer(
|
ps = PusherServer(
|
||||||
config.server_name,
|
config.server_name,
|
||||||
db_config=config.database_config,
|
|
||||||
config=config,
|
config=config,
|
||||||
version_string="Synapse/" + get_version_string(synapse),
|
version_string="Synapse/" + get_version_string(synapse),
|
||||||
database_engine=database_engine,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
setup_logging(ps, config, use_worker_options=True)
|
setup_logging(ps, config, use_worker_options=True)
|
||||||
|
|
|
@ -55,7 +55,6 @@ from synapse.rest.client.v1.room import RoomInitialSyncRestServlet
|
||||||
from synapse.rest.client.v2_alpha import sync
|
from synapse.rest.client.v2_alpha import sync
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.storage.data_stores.main.presence import UserPresenceState
|
from synapse.storage.data_stores.main.presence import UserPresenceState
|
||||||
from synapse.storage.engines import create_engine
|
|
||||||
from synapse.util.httpresourcetree import create_resource_tree
|
from synapse.util.httpresourcetree import create_resource_tree
|
||||||
from synapse.util.manhole import manhole
|
from synapse.util.manhole import manhole
|
||||||
from synapse.util.stringutils import random_string
|
from synapse.util.stringutils import random_string
|
||||||
|
@ -437,14 +436,10 @@ def start(config_options):
|
||||||
|
|
||||||
synapse.events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
synapse.events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
||||||
|
|
||||||
database_engine = create_engine(config.database_config)
|
|
||||||
|
|
||||||
ss = SynchrotronServer(
|
ss = SynchrotronServer(
|
||||||
config.server_name,
|
config.server_name,
|
||||||
db_config=config.database_config,
|
|
||||||
config=config,
|
config=config,
|
||||||
version_string="Synapse/" + get_version_string(synapse),
|
version_string="Synapse/" + get_version_string(synapse),
|
||||||
database_engine=database_engine,
|
|
||||||
application_service_handler=SynchrotronApplicationService(),
|
application_service_handler=SynchrotronApplicationService(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ from synapse.rest.client.v2_alpha import user_directory
|
||||||
from synapse.server import HomeServer
|
from synapse.server import HomeServer
|
||||||
from synapse.storage.data_stores.main.user_directory import UserDirectoryStore
|
from synapse.storage.data_stores.main.user_directory import UserDirectoryStore
|
||||||
from synapse.storage.database import Database
|
from synapse.storage.database import Database
|
||||||
from synapse.storage.engines import create_engine
|
|
||||||
from synapse.util.caches.stream_change_cache import StreamChangeCache
|
from synapse.util.caches.stream_change_cache import StreamChangeCache
|
||||||
from synapse.util.httpresourcetree import create_resource_tree
|
from synapse.util.httpresourcetree import create_resource_tree
|
||||||
from synapse.util.manhole import manhole
|
from synapse.util.manhole import manhole
|
||||||
|
@ -200,8 +199,6 @@ def start(config_options):
|
||||||
|
|
||||||
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
||||||
|
|
||||||
database_engine = create_engine(config.database_config)
|
|
||||||
|
|
||||||
if config.update_user_directory:
|
if config.update_user_directory:
|
||||||
sys.stderr.write(
|
sys.stderr.write(
|
||||||
"\nThe update_user_directory must be disabled in the main synapse process"
|
"\nThe update_user_directory must be disabled in the main synapse process"
|
||||||
|
@ -216,10 +213,8 @@ def start(config_options):
|
||||||
|
|
||||||
ss = UserDirectoryServer(
|
ss = UserDirectoryServer(
|
||||||
config.server_name,
|
config.server_name,
|
||||||
db_config=config.database_config,
|
|
||||||
config=config,
|
config=config,
|
||||||
version_string="Synapse/" + get_version_string(synapse),
|
version_string="Synapse/" + get_version_string(synapse),
|
||||||
database_engine=database_engine,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
setup_logging(ss, config, use_worker_options=True)
|
setup_logging(ss, config, use_worker_options=True)
|
||||||
|
|
|
@ -97,6 +97,7 @@ from synapse.server_notices.worker_server_notices_sender import (
|
||||||
)
|
)
|
||||||
from synapse.state import StateHandler, StateResolutionHandler
|
from synapse.state import StateHandler, StateResolutionHandler
|
||||||
from synapse.storage import DataStores, Storage
|
from synapse.storage import DataStores, Storage
|
||||||
|
from synapse.storage.engines import create_engine
|
||||||
from synapse.streams.events import EventSources
|
from synapse.streams.events import EventSources
|
||||||
from synapse.util import Clock
|
from synapse.util import Clock
|
||||||
from synapse.util.distributor import Distributor
|
from synapse.util.distributor import Distributor
|
||||||
|
@ -209,7 +210,7 @@ class HomeServer(object):
|
||||||
# instantiated during setup() for future return by get_datastore()
|
# instantiated during setup() for future return by get_datastore()
|
||||||
DATASTORE_CLASS = abc.abstractproperty()
|
DATASTORE_CLASS = abc.abstractproperty()
|
||||||
|
|
||||||
def __init__(self, hostname, reactor=None, **kwargs):
|
def __init__(self, hostname, config, reactor=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
hostname : The hostname for the server.
|
hostname : The hostname for the server.
|
||||||
|
@ -219,6 +220,7 @@ class HomeServer(object):
|
||||||
|
|
||||||
self._reactor = reactor
|
self._reactor = reactor
|
||||||
self.hostname = hostname
|
self.hostname = hostname
|
||||||
|
self.config = config
|
||||||
self._building = {}
|
self._building = {}
|
||||||
self._listening_services = []
|
self._listening_services = []
|
||||||
self.start_time = None
|
self.start_time = None
|
||||||
|
@ -229,6 +231,12 @@ class HomeServer(object):
|
||||||
self.admin_redaction_ratelimiter = Ratelimiter()
|
self.admin_redaction_ratelimiter = Ratelimiter()
|
||||||
self.registration_ratelimiter = Ratelimiter()
|
self.registration_ratelimiter = Ratelimiter()
|
||||||
|
|
||||||
|
self.database_engine = create_engine(config.database_config)
|
||||||
|
config.database_config.setdefault("args", {})[
|
||||||
|
"cp_openfun"
|
||||||
|
] = self.database_engine.on_new_connection
|
||||||
|
self.db_config = config.database_config
|
||||||
|
|
||||||
self.datastores = None
|
self.datastores = None
|
||||||
|
|
||||||
# Other kwargs are explicit dependencies
|
# Other kwargs are explicit dependencies
|
||||||
|
|
|
@ -17,18 +17,15 @@ from synapse.api.errors import SynapseError
|
||||||
from synapse.types import GroupID, RoomAlias, UserID, map_username_to_mxid_localpart
|
from synapse.types import GroupID, RoomAlias, UserID, map_username_to_mxid_localpart
|
||||||
|
|
||||||
from tests import unittest
|
from tests import unittest
|
||||||
from tests.utils import TestHomeServer
|
|
||||||
|
|
||||||
mock_homeserver = TestHomeServer(hostname="my.domain")
|
|
||||||
|
|
||||||
|
|
||||||
class UserIDTestCase(unittest.TestCase):
|
class UserIDTestCase(unittest.HomeserverTestCase):
|
||||||
def test_parse(self):
|
def test_parse(self):
|
||||||
user = UserID.from_string("@1234abcd:my.domain")
|
user = UserID.from_string("@1234abcd:test")
|
||||||
|
|
||||||
self.assertEquals("1234abcd", user.localpart)
|
self.assertEquals("1234abcd", user.localpart)
|
||||||
self.assertEquals("my.domain", user.domain)
|
self.assertEquals("test", user.domain)
|
||||||
self.assertEquals(True, mock_homeserver.is_mine(user))
|
self.assertEquals(True, self.hs.is_mine(user))
|
||||||
|
|
||||||
def test_pase_empty(self):
|
def test_pase_empty(self):
|
||||||
with self.assertRaises(SynapseError):
|
with self.assertRaises(SynapseError):
|
||||||
|
@ -48,13 +45,13 @@ class UserIDTestCase(unittest.TestCase):
|
||||||
self.assertTrue(userA != userB)
|
self.assertTrue(userA != userB)
|
||||||
|
|
||||||
|
|
||||||
class RoomAliasTestCase(unittest.TestCase):
|
class RoomAliasTestCase(unittest.HomeserverTestCase):
|
||||||
def test_parse(self):
|
def test_parse(self):
|
||||||
room = RoomAlias.from_string("#channel:my.domain")
|
room = RoomAlias.from_string("#channel:test")
|
||||||
|
|
||||||
self.assertEquals("channel", room.localpart)
|
self.assertEquals("channel", room.localpart)
|
||||||
self.assertEquals("my.domain", room.domain)
|
self.assertEquals("test", room.domain)
|
||||||
self.assertEquals(True, mock_homeserver.is_mine(room))
|
self.assertEquals(True, self.hs.is_mine(room))
|
||||||
|
|
||||||
def test_build(self):
|
def test_build(self):
|
||||||
room = RoomAlias("channel", "my.domain")
|
room = RoomAlias("channel", "my.domain")
|
||||||
|
|
|
@ -260,9 +260,7 @@ def setup_test_homeserver(
|
||||||
hs = homeserverToUse(
|
hs = homeserverToUse(
|
||||||
name,
|
name,
|
||||||
config=config,
|
config=config,
|
||||||
db_config=config.database_config,
|
|
||||||
version_string="Synapse/tests",
|
version_string="Synapse/tests",
|
||||||
database_engine=db_engine,
|
|
||||||
tls_server_context_factory=Mock(),
|
tls_server_context_factory=Mock(),
|
||||||
tls_client_options_factory=Mock(),
|
tls_client_options_factory=Mock(),
|
||||||
reactor=reactor,
|
reactor=reactor,
|
||||||
|
|
Loading…
Reference in New Issue