googleapis / googleapis/storage-testbench
Add support for unfinalized appendable objects
- Dominant language
- Python
- Stars
- 24
- Forks
- 38
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 1
Description
To support unfinalized appendable objects in the testbench, the blob (metadata size, media, etc) needs to be updated in the database within `Upload.process_bidi_write_object_grpc`, which mainly handles the bidi write business logic.
Below is an example of how `blob.media` and `blob.metadata.size` could be updated to the database. This would support test cases where size or data needs to read back for unfinalized appendable objects.
Testbench implementaton details should be decided based on the internal design doc and needed test cases.
```
upload.media += content
# ...
# Update appendable blob size and media here, as an example.
# TODO: (1) Update_time, size and crc are updated in object metadata.
# TODO: (2) Whether the testbench checks for flush or/and performs a background force-close.
if is_appendable:
def update_appendable_blob(blob, unused_generation):
blob.media = upload.media
blob.metadata.size = len(upload.media)
return blob
blob = db.do_update_object(
upload.bucket.name,
upload.metadata.name,
update_fn=update_appendable_blob,
context=context,
generation=upload.metadata.generation,
)
```
https://github.com/googleapis/storage-testbench/blob/9a8ca669c6083f75c20e648e0a85392dd8be8e2b/gcs/upload.py#L504-L507
Contributor guide
Assessment
This issue has not been assessed yet.