Skip to content

Commit 18a0edf

Browse files
authored
chore: add system test for cloud path (#1666)
chore: add system test for cloud path
1 parent e072133 commit 18a0edf

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

tests/system/test_zonal.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,40 @@
2424
# TODO: replace this with a fixture once zonal bucket creation / deletion
2525
# is supported in grpc client or json client client.
2626
_ZONAL_BUCKET = os.getenv("ZONAL_BUCKET")
27+
_BYTES_TO_UPLOAD = b"dummy_bytes_to_write_read_and_delete_appendable_object"
2728

2829

2930
@pytest.mark.asyncio
30-
async def test_basic_wrd(storage_client, blobs_to_delete):
31-
bytes_to_upload = b"dummy_bytes_to_write_read_and_delete_appendable_object"
31+
@pytest.mark.parametrize(
32+
"attempt_direct_path",
33+
[True, False],
34+
)
35+
async def test_basic_wrd(storage_client, blobs_to_delete, attempt_direct_path):
3236
object_name = f"test_basic_wrd-{str(uuid.uuid4())}"
3337

3438
# Client instantiation; it cannot be part of fixture because.
3539
# grpc_client's event loop and event loop of coroutine running it
3640
# (i.e. this test) must be same.
3741
# Note:
38-
# 1. @pytest.mark.asyncio ensures new event for each test.
42+
# 1. @pytest.mark.asyncio ensures new event loop for each test.
3943
# 2. we can keep the same event loop for entire module but that may
4044
# create issues if tests are run in parallel and one test hogs the event
4145
# loop slowing down other tests.
42-
grpc_client = AsyncGrpcClient().grpc_client
46+
grpc_client = AsyncGrpcClient(attempt_direct_path=attempt_direct_path).grpc_client
4347

4448
writer = AsyncAppendableObjectWriter(grpc_client, _ZONAL_BUCKET, object_name)
4549
await writer.open()
46-
await writer.append(bytes_to_upload)
50+
await writer.append(_BYTES_TO_UPLOAD)
4751
object_metadata = await writer.close(finalize_on_close=True)
48-
assert object_metadata.size == len(bytes_to_upload)
52+
assert object_metadata.size == len(_BYTES_TO_UPLOAD)
4953

5054
mrd = AsyncMultiRangeDownloader(grpc_client, _ZONAL_BUCKET, object_name)
5155
buffer = BytesIO()
5256
await mrd.open()
5357
# (0, 0) means read the whole object
5458
await mrd.download_ranges([(0, 0, buffer)])
5559
await mrd.close()
56-
assert buffer.getvalue() == bytes_to_upload
60+
assert buffer.getvalue() == _BYTES_TO_UPLOAD
5761

5862
# Clean up; use json client (i.e. `storage_client` fixture) to delete.
5963
blobs_to_delete.append(storage_client.bucket(_ZONAL_BUCKET).blob(object_name))

0 commit comments

Comments
 (0)