From fedbfcab6ea769296a60e058fa477a7d249c2886 Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Tue, 16 Dec 2025 14:42:43 +0000 Subject: [PATCH 1/2] chore: add system test for cloud path --- tests/system/test_zonal.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/tests/system/test_zonal.py b/tests/system/test_zonal.py index 909b9ddf1..64f1ff3f0 100644 --- a/tests/system/test_zonal.py +++ b/tests/system/test_zonal.py @@ -24,18 +24,18 @@ # TODO: replace this with a fixture once zonal bucket creation / deletion # is supported in grpc client or json client client. _ZONAL_BUCKET = os.getenv("ZONAL_BUCKET") +_BYTES_TO_UPLOAD = b"dummy_bytes_to_write_read_and_delete_appendable_object" @pytest.mark.asyncio async def test_basic_wrd(storage_client, blobs_to_delete): - bytes_to_upload = b"dummy_bytes_to_write_read_and_delete_appendable_object" object_name = f"test_basic_wrd-{str(uuid.uuid4())}" # Client instantiation; it cannot be part of fixture because. # grpc_client's event loop and event loop of coroutine running it # (i.e. this test) must be same. # Note: - # 1. @pytest.mark.asyncio ensures new event for each test. + # 1. @pytest.mark.asyncio ensures new event loop for each test. # 2. we can keep the same event loop for entire module but that may # create issues if tests are run in parallel and one test hogs the event # loop slowing down other tests. @@ -43,9 +43,9 @@ async def test_basic_wrd(storage_client, blobs_to_delete): writer = AsyncAppendableObjectWriter(grpc_client, _ZONAL_BUCKET, object_name) await writer.open() - await writer.append(bytes_to_upload) + await writer.append(_BYTES_TO_UPLOAD) object_metadata = await writer.close(finalize_on_close=True) - assert object_metadata.size == len(bytes_to_upload) + assert object_metadata.size == len(_BYTES_TO_UPLOAD) mrd = AsyncMultiRangeDownloader(grpc_client, _ZONAL_BUCKET, object_name) buffer = BytesIO() @@ -53,7 +53,31 @@ async def test_basic_wrd(storage_client, blobs_to_delete): # (0, 0) means read the whole object await mrd.download_ranges([(0, 0, buffer)]) await mrd.close() - assert buffer.getvalue() == bytes_to_upload + assert buffer.getvalue() == _BYTES_TO_UPLOAD + + # Clean up; use json client (i.e. `storage_client` fixture) to delete. + blobs_to_delete.append(storage_client.bucket(_ZONAL_BUCKET).blob(object_name)) + + +@pytest.mark.asyncio +async def test_basic_wrd_cloud_path(storage_client, blobs_to_delete): + object_name = f"test_basic_wrd-{str(uuid.uuid4())}" + + grpc_client = AsyncGrpcClient(attempt_direct_path=False).grpc_client + + writer = AsyncAppendableObjectWriter(grpc_client, _ZONAL_BUCKET, object_name) + await writer.open() + await writer.append(_BYTES_TO_UPLOAD) + object_metadata = await writer.close(finalize_on_close=True) + assert object_metadata.size == len(_BYTES_TO_UPLOAD) + + mrd = AsyncMultiRangeDownloader(grpc_client, _ZONAL_BUCKET, object_name) + buffer = BytesIO() + await mrd.open() + # (0, 0) means read the whole object + await mrd.download_ranges([(0, 0, buffer)]) + await mrd.close() + assert buffer.getvalue() == _BYTES_TO_UPLOAD # Clean up; use json client (i.e. `storage_client` fixture) to delete. blobs_to_delete.append(storage_client.bucket(_ZONAL_BUCKET).blob(object_name)) From 57cfe30627d99dd3d30aafa5bb008abadf3fec12 Mon Sep 17 00:00:00 2001 From: Chandra Sirimala Date: Tue, 16 Dec 2025 15:12:14 +0000 Subject: [PATCH 2/2] parametrize "attempt_direct_path" --- tests/system/test_zonal.py | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/tests/system/test_zonal.py b/tests/system/test_zonal.py index 64f1ff3f0..ffdab8744 100644 --- a/tests/system/test_zonal.py +++ b/tests/system/test_zonal.py @@ -28,7 +28,11 @@ @pytest.mark.asyncio -async def test_basic_wrd(storage_client, blobs_to_delete): +@pytest.mark.parametrize( + "attempt_direct_path", + [True, False], +) +async def test_basic_wrd(storage_client, blobs_to_delete, attempt_direct_path): object_name = f"test_basic_wrd-{str(uuid.uuid4())}" # Client instantiation; it cannot be part of fixture because. @@ -39,31 +43,7 @@ async def test_basic_wrd(storage_client, blobs_to_delete): # 2. we can keep the same event loop for entire module but that may # create issues if tests are run in parallel and one test hogs the event # loop slowing down other tests. - grpc_client = AsyncGrpcClient().grpc_client - - writer = AsyncAppendableObjectWriter(grpc_client, _ZONAL_BUCKET, object_name) - await writer.open() - await writer.append(_BYTES_TO_UPLOAD) - object_metadata = await writer.close(finalize_on_close=True) - assert object_metadata.size == len(_BYTES_TO_UPLOAD) - - mrd = AsyncMultiRangeDownloader(grpc_client, _ZONAL_BUCKET, object_name) - buffer = BytesIO() - await mrd.open() - # (0, 0) means read the whole object - await mrd.download_ranges([(0, 0, buffer)]) - await mrd.close() - assert buffer.getvalue() == _BYTES_TO_UPLOAD - - # Clean up; use json client (i.e. `storage_client` fixture) to delete. - blobs_to_delete.append(storage_client.bucket(_ZONAL_BUCKET).blob(object_name)) - - -@pytest.mark.asyncio -async def test_basic_wrd_cloud_path(storage_client, blobs_to_delete): - object_name = f"test_basic_wrd-{str(uuid.uuid4())}" - - grpc_client = AsyncGrpcClient(attempt_direct_path=False).grpc_client + grpc_client = AsyncGrpcClient(attempt_direct_path=attempt_direct_path).grpc_client writer = AsyncAppendableObjectWriter(grpc_client, _ZONAL_BUCKET, object_name) await writer.open()