Skip to content
Snippets Groups Projects
Commit f7ec6e7d authored by Olivier Wilkinson (reivilibre)'s avatar Olivier Wilkinson (reivilibre)
Browse files

Convert one of the `setup_test_homeserver`s to `make_test_homeserver_synchronous`

and pass in the homeserver rather than calling a same-named function to ask for one.

Later commits will jiggle things around to make this sensible.
parent 5640992d
No related branches found
No related tags found
No related merge requests found
...@@ -57,7 +57,6 @@ from synapse.http.site import SynapseRequest ...@@ -57,7 +57,6 @@ from synapse.http.site import SynapseRequest
from synapse.types import JsonDict from synapse.types import JsonDict
from synapse.util import Clock from synapse.util import Clock
from tests.utils import setup_test_homeserver as _sth
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -450,14 +449,11 @@ class ThreadPool: ...@@ -450,14 +449,11 @@ class ThreadPool:
return d return d
def setup_test_homeserver(cleanup_func, *args, **kwargs): def make_test_homeserver_synchronous(server: HomeServer) -> None:
""" """
Set up a synchronous test server, driven by the reactor used by Make the given test homeserver's database interactions synchronous.
the homeserver.
""" """
server = _sth(cleanup_func, *args, **kwargs)
# Make the thread pool synchronous.
clock = server.get_clock() clock = server.get_clock()
for database in server.get_datastores().databases: for database in server.get_datastores().databases:
...@@ -485,6 +481,7 @@ def setup_test_homeserver(cleanup_func, *args, **kwargs): ...@@ -485,6 +481,7 @@ def setup_test_homeserver(cleanup_func, *args, **kwargs):
pool.runWithConnection = runWithConnection pool.runWithConnection = runWithConnection
pool.runInteraction = runInteraction pool.runInteraction = runInteraction
# Replace the thread pool with a threadless 'thread' pool
pool.threadpool = ThreadPool(clock._reactor) pool.threadpool = ThreadPool(clock._reactor)
pool.running = True pool.running = True
...@@ -492,8 +489,6 @@ def setup_test_homeserver(cleanup_func, *args, **kwargs): ...@@ -492,8 +489,6 @@ def setup_test_homeserver(cleanup_func, *args, **kwargs):
# thread, so we need to disable the dedicated thread behaviour. # thread, so we need to disable the dedicated thread behaviour.
server.get_datastores().main.USE_DEDICATED_DB_THREADS_FOR_EVENT_FETCHING = False server.get_datastores().main.USE_DEDICATED_DB_THREADS_FOR_EVENT_FETCHING = False
return server
def get_clock() -> Tuple[ThreadedMemoryReactorClock, Clock]: def get_clock() -> Tuple[ThreadedMemoryReactorClock, Clock]:
clock = ThreadedMemoryReactorClock() clock = ThreadedMemoryReactorClock()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment