Skip to content
Snippets Groups Projects
Commit 91ed7e7b authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

Switch to newly added get_leases method on the storage server

parent 6e4b280e
No related branches found
No related tags found
1 merge request!22Separate mutable writes from lease updates
...@@ -270,7 +270,7 @@ class ShareTests(TestCase): ...@@ -270,7 +270,7 @@ class ShareTests(TestCase):
cancel_secret, cancel_secret,
), ),
) )
[(_, leases)] = get_leases(self.server, storage_index).items() leases = list(self.anonymous_storage_server.get_leases(storage_index))
self.assertThat(leases, HasLength(2)) self.assertThat(leases, HasLength(2))
@given( @given(
...@@ -315,7 +315,7 @@ class ShareTests(TestCase): ...@@ -315,7 +315,7 @@ class ShareTests(TestCase):
# Based on Tahoe-LAFS' hard-coded renew time. # Based on Tahoe-LAFS' hard-coded renew time.
RENEW_INTERVAL = 60 * 60 * 24 * 31 RENEW_INTERVAL = 60 * 60 * 24 * 31
[(_, [lease])] = get_leases(self.server, storage_index).items() [lease] = self.anonymous_storage_server.get_leases(storage_index)
self.assertThat( self.assertThat(
lease.get_expiration_time(), lease.get_expiration_time(),
Equals(int(now + RENEW_INTERVAL)), Equals(int(now + RENEW_INTERVAL)),
...@@ -522,28 +522,6 @@ def write_toy_shares( ...@@ -522,28 +522,6 @@ def write_toy_shares(
writer.remote_close() writer.remote_close()
def get_leases(storage_server, storage_index):
"""
Get all leases for all shares of the given storage index on the given
server.
:param StorageServer storage_server: The storage server on which to find
the information.
:param bytes storage_index: The storage index for which to look up shares.
:return dict[int, list[LeaseInfo]]: The lease information for each share.
"""
# It's hard to assert much about the lease without knowing about *some*
# implementation details of the storage server. I prefer to know Python
# API details rather than on-disk format details.
return {
sharenum: list(reader._share_file.get_leases())
for (sharenum, reader)
in storage_server.remote_get_buckets(storage_index).items()
}
def cleanup_storage_server(storage_server): def cleanup_storage_server(storage_server):
""" """
Delete all of the shares held by the given storage server. Delete all of the shares held by the given storage server.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment