Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix case in wait_for_background_updates where self.store does not…
Browse files Browse the repository at this point in the history
… exist (#11331)

Pull the DataStore from the HomeServer instance, which
always exists.
  • Loading branch information
anoadragon453 authored Dec 7, 2021
1 parent 26b5d23 commit d6fb96e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelog.d/11331.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A test helper (`wait_for_background_updates`) no longer depends on classes defining a `store` property.
11 changes: 4 additions & 7 deletions tests/unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,13 @@ def wait_on_thread(self, deferred, timeout=10):
time.sleep(0.01)

def wait_for_background_updates(self) -> None:
"""Block until all background database updates have completed.
Note that callers must ensure there's a store property created on the
testcase.
"""
"""Block until all background database updates have completed."""
store = self.hs.get_datastore()
while not self.get_success(
self.store.db_pool.updates.has_completed_background_updates()
store.db_pool.updates.has_completed_background_updates()
):
self.get_success(
self.store.db_pool.updates.do_next_background_update(False), by=0.1
store.db_pool.updates.do_next_background_update(False), by=0.1
)

def make_homeserver(self, reactor, clock):
Expand Down

0 comments on commit d6fb96e

Please sign in to comment.