Skip to content

Commit 9ba049a

Browse files
authored
fix(storage): fix test_mrd_concurrent_download_cancellation (#17151)
The test test_mrd_concurrent_download_cancellation is failing specifically because the download was successful before the test could cancel it. - Increased object_size from 5MB to 20MB and adjusted num_chunks to 40 (resulting in 500KB per chunk). Error: ``` for i in range(num_chunks): Step #3 - "run-tests-and-delete-vm": if i % 2 == 0: Step #3 - "run-tests-and-delete-vm": > assert isinstance(results[i], asyncio.CancelledError) Step #3 - "run-tests-and-delete-vm": E AssertionError: assert False Step #3 - "run-tests-and-delete-vm": E + where False = isinstance(None, <class 'asyncio.exceptions.CancelledError'>) Step #3 - "run-tests-and-delete-vm": E + where <class 'asyncio.exceptions.CancelledError'> = asyncio.CancelledError Step #3 - "run-tests-and-delete-vm": Step #3 - "run-tests-and-delete-vm": tests/system/test_zonal.py:904: AssertionError ```
1 parent 07dd331 commit 9ba049a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

packages/google-cloud-storage/tests/system/test_zonal.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ def test_mrd_concurrent_download_cancellation(
827827
Tests that downloading gracefully manages memory and internal references
828828
when tasks are canceled during active multiplexing, without breaking remaining downloads.
829829
"""
830-
object_size = 5 * 1024 * 1024 # 5MB
830+
object_size = 20 * 1024 * 1024 # 20MB
831831
object_name = f"test_mrd_cancel-{uuid.uuid4()}"
832832

833833
async def _run():
@@ -844,7 +844,7 @@ async def _run():
844844
grpc_client_direct, _ZONAL_BUCKET, object_name
845845
) as mrd:
846846
tasks = []
847-
num_chunks = 100
847+
num_chunks = 40
848848
chunk_size = object_size // num_chunks
849849
buffers = [BytesIO() for _ in range(num_chunks)]
850850

@@ -856,8 +856,8 @@ async def _run():
856856
)
857857
)
858858

859-
# Let the loop start sending Bidi requests
860-
await asyncio.sleep(0.01)
859+
# Yield control to event loop so tasks send Bidi requests, but do not wait for server responses
860+
await asyncio.sleep(0)
861861

862862
# Cancel a subset of evenly distributed tasks
863863
for i in range(0, num_chunks, 2):

0 commit comments

Comments
 (0)