Skip to content

Commit bae3a00

Browse files
committed
test: refactor test_mrd_concurrent_download_out_of_bounds in test_zonal.py
1 parent a381c05 commit bae3a00

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

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

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -759,34 +759,24 @@ async def _run():
759759
async with AsyncMultiRangeDownloader(
760760
grpc_client_direct, _ZONAL_BUCKET, object_name
761761
) as mrd:
762-
b_valid = BytesIO()
763-
t_valid = asyncio.create_task(mrd.download_ranges([(0, 100, b_valid)]))
764-
765-
b_oob1 = BytesIO()
766-
t_oob1 = asyncio.create_task(
767-
mrd.download_ranges([(object_size + 1000, 100, b_oob1)])
762+
valid_buffer = BytesIO()
763+
valid_task = asyncio.create_task(
764+
mrd.download_ranges([(0, 100, valid_buffer)])
768765
)
769766

770-
# EOF ask for 100 bytes
771-
b_oob2 = BytesIO()
772-
t_oob2 = asyncio.create_task(
773-
mrd.download_ranges([(object_size, 100, b_oob2)])
767+
oob_buffer = BytesIO()
768+
oob_task = asyncio.create_task(
769+
mrd.download_ranges([(object_size + 1000, 100, oob_buffer)])
774770
)
775771

776-
results = await asyncio.gather(
777-
t_valid, t_oob1, t_oob2, return_exceptions=True
778-
)
772+
results = await asyncio.gather(valid_task, oob_task, return_exceptions=True)
779773

780774
# Verify valid one processed correctly
781-
assert b_valid.getvalue() == object_data[:100]
775+
assert valid_buffer.getvalue() == object_data[:100]
782776

783777
# Verify fully OOB request returned Exception
784778
assert isinstance(results[1], OutOfRange)
785779

786-
# Verify request exactly at EOF successfully completed with 0 bytes
787-
assert not isinstance(results[2], Exception)
788-
assert b_oob2.getvalue() == b""
789-
790780
del writer
791781
gc.collect()
792782
blobs_to_delete.append(storage_client.bucket(_ZONAL_BUCKET).blob(object_name))

0 commit comments

Comments
 (0)