chore: Add Sys test large obj by chandra-siri · Pull Request #1676 · googleapis/python-storage · GitHub
Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

chore: Add Sys test large obj#1676

Merged
chandra-siri merged 11 commits into
mainfrom
sys_test_large_obj
Dec 19, 2025
Merged

chore: Add Sys test large obj#1676
chandra-siri merged 11 commits into
mainfrom
sys_test_large_obj

Conversation

@chandra-siri

Copy link
Copy Markdown
Collaborator

chore: Add Sys test large obj

@product-auto-label product-auto-label Bot added size: m Pull request size is medium. api: storage Issues related to the googleapis/python-storage API. labels Dec 18, 2025
@gemini-code-assist

Copy link
Copy Markdown
Contributor

@chandra-siri chandra-siri changed the base branch from main to bidi_writes_checksum December 18, 2025 14:16
@chandra-siri

Copy link
Copy Markdown
Collaborator Author

/gcbrun(2b1d6ce)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a check for the C-accelerated google-crc32c implementation to prevent silent performance degradation, refactoring this check into a shared utility function. It also adds CRC32C checksum validation for data chunks in AsyncAppendableObjectWriter. To support these changes, extensive system tests for large object uploads (both single and multi-part) have been added, along with corresponding unit tests. My feedback includes a minor correction to a docstring and a suggestion to reduce code duplication in the new system tests for better maintainability.

I am having trouble creating individual review comments. Click here to see my feedback.

google/cloud/storage/_experimental/asyncio/_utils.py (20-28)

medium

The docstring for raise_if_no_fast_crc32c incorrectly states that the function returns a boolean value. This function either raises an exception or returns None. The docstring should be updated to remove the returns and rtype sections. I've also taken the liberty to format the raises section to follow common style guides.

    """Check if the C-accelerated version of google-crc32c is available.

    If not, raise an error to prevent silent performance degradation.

    Raises:
        google.api_core.exceptions.FailedPrecondition: If the C extension is not available.
    """

tests/system/test_zonal.py (131-168)

medium

There is significant code duplication between test_basic_wrd and test_basic_wrd_in_slices. The logic for client instantiation, data generation, download, verification, and cleanup is identical in both tests.

To improve maintainability, you could refactor this common code into a helper function. The helper could accept a callback to perform the specific writing logic for each test case.

Here's an example of how you could structure it:

async def _perform_wrd_test(storage_client, blobs_to_delete, attempt_direct_path, object_size, write_callable):
    # ... common setup code ...
    object_name = f"test_basic_wrd-{str(uuid.uuid4())}"
    object_data = os.urandom(object_size)
    object_checksum = google_crc32c.value(object_data)
    grpc_client = AsyncGrpcClient(attempt_direct_path=attempt_direct_path).grpc_client

    writer = AsyncAppendableObjectWriter(grpc_client, _ZONAL_BUCKET, object_name)
    await writer.open()

    # Call the specific write logic
    await write_callable(writer, object_data)

    object_metadata = await writer.close(finalize_on_close=True)
    assert object_metadata.size == object_size
    # ... common verification and cleanup ...

# In test_basic_wrd:
await _perform_wrd_test(..., write_callable=lambda writer, data: writer.append(data))

# In test_basic_wrd_in_slices:
async def sliced_write(writer, data):
    mark1, mark2 = _get_equal_dist(0, len(data))
    await writer.append(data[0:mark1])
    await writer.append(data[mark1:mark2])
    await writer.append(data[mark2:])

await _perform_wrd_test(..., write_callable=sliced_write)

This approach would reduce code duplication and make the tests easier to read and maintain.

@chandra-siri chandra-siri marked this pull request as ready for review December 18, 2025 14:27
@chandra-siri chandra-siri requested review from a team December 18, 2025 14:27
@chandra-siri chandra-siri requested a review from a team as a code owner December 18, 2025 14:27
Base automatically changed from bidi_writes_checksum to main December 19, 2025 10:51
@chandra-siri chandra-siri added kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Dec 19, 2025
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Dec 19, 2025
@chandra-siri

Copy link
Copy Markdown
Collaborator Author

Comment thread tests/system/test_zonal.py Outdated
@chandra-siri chandra-siri requested a review from suni72 December 19, 2025 13:36
@chandra-siri chandra-siri merged commit a0668ec into main Dec 19, 2025
16 of 17 checks passed
@chandra-siri chandra-siri deleted the sys_test_large_obj branch December 19, 2025 14:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: storage Issues related to the googleapis/python-storage API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants