Skip to content
Snippets Groups Projects
Commit 51f4d52c authored by Richard van der Hoff's avatar Richard van der Hoff
Browse files

Set a logging context while running the bg updates

This mostly just reduces the amount of "running from sentinel context" spam
during unittest setup.
parent 26d17b9b
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,7 @@ from synapse.http.server import JsonResource ...@@ -40,6 +40,7 @@ from synapse.http.server import JsonResource
from synapse.http.site import SynapseRequest, SynapseSite from synapse.http.site import SynapseRequest, SynapseSite
from synapse.logging.context import ( from synapse.logging.context import (
SENTINEL_CONTEXT, SENTINEL_CONTEXT,
LoggingContext,
current_context, current_context,
set_current_context, set_current_context,
) )
...@@ -419,15 +420,17 @@ class HomeserverTestCase(TestCase): ...@@ -419,15 +420,17 @@ class HomeserverTestCase(TestCase):
config_obj.parse_config_dict(config, "", "") config_obj.parse_config_dict(config, "", "")
kwargs["config"] = config_obj kwargs["config"] = config_obj
async def run_bg_updates():
with LoggingContext("run_bg_updates", request="run_bg_updates-1"):
while not await stor.db.updates.has_completed_background_updates():
await stor.db.updates.do_next_background_update(1)
hs = setup_test_homeserver(self.addCleanup, *args, **kwargs) hs = setup_test_homeserver(self.addCleanup, *args, **kwargs)
stor = hs.get_datastore() stor = hs.get_datastore()
# Run the database background updates, when running against "master". # Run the database background updates, when running against "master".
if hs.__class__.__name__ == "TestHomeServer": if hs.__class__.__name__ == "TestHomeServer":
while not self.get_success( self.get_success(run_bg_updates())
stor.db.updates.has_completed_background_updates()
):
self.get_success(stor.db.updates.do_next_background_update(1))
return hs return hs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment