summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2021-12-03 11:35:24 +0000
committerOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2021-12-03 11:35:24 +0000
commitf7ec6e7d9e0dc360d9fb41f3a1afd7bdba1475c7 (patch)
treef4ed3cee8a9bc0062ac00a223e35d263d417ef0c /tests
parentDisambiguate queries on `state_key` (#11497) (diff)
downloadsynapse-f7ec6e7d9e0dc360d9fb41f3a1afd7bdba1475c7.tar.xz
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/server.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/tests/server.py b/tests/server.py
index 40cf5b12c3..41eb3995bd 100644
--- a/tests/server.py
+++ b/tests/server.py
@@ -57,7 +57,6 @@ from synapse.http.site import SynapseRequest
 from synapse.types import JsonDict
 from synapse.util import Clock
 
-from tests.utils import setup_test_homeserver as _sth
 
 logger = logging.getLogger(__name__)
 
@@ -450,14 +449,11 @@ class ThreadPool:
         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
-    the homeserver.
+    Make the given test homeserver's database interactions synchronous.
     """
-    server = _sth(cleanup_func, *args, **kwargs)
 
-    # Make the thread pool synchronous.
     clock = server.get_clock()
 
     for database in server.get_datastores().databases:
@@ -485,6 +481,7 @@ def setup_test_homeserver(cleanup_func, *args, **kwargs):
 
         pool.runWithConnection = runWithConnection
         pool.runInteraction = runInteraction
+        # Replace the thread pool with a threadless 'thread' pool
         pool.threadpool = ThreadPool(clock._reactor)
         pool.running = True
 
@@ -492,8 +489,6 @@ def setup_test_homeserver(cleanup_func, *args, **kwargs):
     # thread, so we need to disable the dedicated thread behaviour.
     server.get_datastores().main.USE_DEDICATED_DB_THREADS_FOR_EVENT_FETCHING = False
 
-    return server
-
 
 def get_clock() -> Tuple[ThreadedMemoryReactorClock, Clock]:
     clock = ThreadedMemoryReactorClock()