Hook up more IStorageServer tests that can now pass with HTTP.

This commit is contained in:
Itamar Turner-Trauring 2022-02-01 10:25:13 -05:00
parent c72e7b0585
commit 48a9bf7457
2 changed files with 31 additions and 4 deletions

View File

@ -1042,7 +1042,7 @@ class _FakeRemoteReference(object):
@attr.s @attr.s
class _HTTPBucketWriter(object): class _HTTPBucketWriter(object):
""" """
Emulate a ``RIBucketWriter``. Emulate a ``RIBucketWriter``, but use HTTP protocol underneath.
""" """
client = attr.ib(type=StorageClientImmutables) client = attr.ib(type=StorageClientImmutables)
storage_index = attr.ib(type=bytes) storage_index = attr.ib(type=bytes)
@ -1069,6 +1069,25 @@ class _HTTPBucketWriter(object):
return defer.succeed(None) return defer.succeed(None)
@attr.s
class _HTTPBucketReader(object):
"""
Emulate a ``RIBucketReader``.
"""
client = attr.ib(type=StorageClientImmutables)
storage_index = attr.ib(type=bytes)
share_number = attr.ib(type=int)
def read(self, offset, length):
return self.client.read_share_chunk(
self.storage_index, self.share_number, offset, length
)
def advise_corrupt_share(self, reason):
pass # TODO in later ticket
# WORK IN PROGRESS, for now it doesn't actually implement whole thing. # WORK IN PROGRESS, for now it doesn't actually implement whole thing.
@implementer(IStorageServer) # type: ignore @implementer(IStorageServer) # type: ignore
@attr.s @attr.s
@ -1117,8 +1136,18 @@ class _HTTPStorageServer(object):
}) })
) )
@defer.inlineCallbacks
def get_buckets( def get_buckets(
self, self,
storage_index, storage_index,
): ):
pass immutable_client = StorageClientImmutables(self._http_client)
share_numbers = yield immutable_client.list_shares(
storage_index
)
defer.returnValue({
share_num: _FakeRemoteReference(_HTTPBucketReader(
immutable_client, storage_index, share_num
))
for share_num in share_numbers
})

View File

@ -1149,8 +1149,6 @@ class HTTPImmutableAPIsTests(
"test_get_buckets_skips_unfinished_buckets", "test_get_buckets_skips_unfinished_buckets",
"test_matching_overlapping_writes", "test_matching_overlapping_writes",
"test_non_matching_overlapping_writes", "test_non_matching_overlapping_writes",
"test_read_bucket_at_offset",
"test_written_shares_are_readable",
"test_written_shares_are_allocated", "test_written_shares_are_allocated",
} }