Browse Source

Set a logging context while running the bg updates

This mostly just reduces the amount of "running from sentinel context" spam
during unittest setup.
tags/v1.13.0rc1
Richard van der Hoff 4 years ago
parent
commit
51f4d52cb4
1 changed files with 7 additions and 4 deletions
  1. +7
    -4
      tests/unittest.py

+ 7
- 4
tests/unittest.py View File

@@ -40,6 +40,7 @@ from synapse.http.server import JsonResource
from synapse.http.site import SynapseRequest, SynapseSite
from synapse.logging.context import (
SENTINEL_CONTEXT,
LoggingContext,
current_context,
set_current_context,
)
@@ -419,15 +420,17 @@ class HomeserverTestCase(TestCase):
config_obj.parse_config_dict(config, "", "")
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)
stor = hs.get_datastore()

# Run the database background updates, when running against "master".
if hs.__class__.__name__ == "TestHomeServer":
while not self.get_success(
stor.db.updates.has_completed_background_updates()
):
self.get_success(stor.db.updates.do_next_background_update(1))
self.get_success(run_bg_updates())

return hs



Loading…
Cancel
Save