feat: Add system test for cross-region buckets by chandra-siri · Pull Request #1760 · googleapis/python-storage · GitHub
Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.

feat: Add system test for cross-region buckets#1760

Closed
chandra-siri wants to merge 3 commits into
lint_changesfrom
rapid_bucket_cross_region_sys_tests
Closed

feat: Add system test for cross-region buckets#1760
chandra-siri wants to merge 3 commits into
lint_changesfrom
rapid_bucket_cross_region_sys_tests

Conversation

@chandra-siri

Copy link
Copy Markdown
Collaborator

feat: Add system test for cross-region buckets

  • Adds a new system test, test_basic_wrd_x_region, to verify functionality with cross-region GCS buckets.

  • Also updates the Cloud Build configuration to pass the necessary _CROSS_REGION_BUCKET environment variable to the test environment

Adds a new system test, test_basic_wrd_x_region, to verify functionality with cross-region GCS buckets.

Also updates the Cloud Build configuration to pass the necessary _CROSS_REGION_BUCKET environment variable to the test environment.
@product-auto-label product-auto-label Bot added size: l Pull request size is large. api: storage Issues related to the googleapis/python-storage API. labels Feb 21, 2026
@chandra-siri chandra-siri changed the base branch from main to lint_changes February 21, 2026 09:17
@gemini-code-assist

Copy link
Copy Markdown
Contributor

@chandra-siri

Copy link
Copy Markdown
Collaborator Author

/gcbrun(4f6bd14)

@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 adds a new system test for cross-region buckets, which is a valuable addition for verifying functionality across different bucket locations. The changes in the Cloud Build configuration and the new test in test_zonal.py are mostly correct. However, there is a critical issue with how the environment variable for the cross-region bucket is handled that will likely cause the new test to fail. Additionally, there is an opportunity to improve maintainability by refactoring the new test to reduce code duplication. Please see the detailed comments for suggestions.

# 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")
_CROSS_REGION_BUCKET = os.getenv("CROSS_REGION_BUCKET")

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.

critical

This will likely evaluate to None as the CROSS_REGION_BUCKET environment variable is not exported in the test execution environment. The cloudbuild.yaml configuration passes _CROSS_REGION_BUCKET, but the run_zonal_tests.sh script does not export it as CROSS_REGION_BUCKET for the pytest command (unlike ZONAL_BUCKET).

To fix this, you should add export CROSS_REGION_BUCKET=${_CROSS_REGION_BUCKET} to cloudbuild/run_zonal_tests.sh. This change is necessary for the new test to pass.

Comment on lines +94 to +100
def test_basic_wrd_x_region(
storage_client,
blobs_to_delete,
object_size,
event_loop,
grpc_client,
):

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.

medium

This new test test_basic_wrd_x_region is nearly identical to the existing test_basic_wrd function. This significant code duplication can make the test suite harder to maintain.

To improve maintainability, consider refactoring this to avoid duplication. One approach would be to parameterize a single test function to handle both zonal and cross-region bucket cases, as well as the direct path option. For example, you could parameterize on a tuple containing (bucket_name, attempt_direct_path).

event_loop,
grpc_client,
):
object_name = f"test_basic_wrd-{str(uuid.uuid4())}"

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.

medium

For easier debugging and to avoid potential conflicts, it's good practice to make test object names specific to the test case. This helps identify which test created an object if cleanup fails.

Suggested change
object_name = f"test_basic_wrd-{str(uuid.uuid4())}"
object_name = f"test_basic_wrd_x_region-{str(uuid.uuid4())}"

@product-auto-label product-auto-label Bot added size: s Pull request size is small. and removed size: l Pull request size is large. labels Feb 21, 2026
@chandra-siri

Copy link
Copy Markdown
Collaborator Author

/gcbrun(ad3387c)

@chandra-siri chandra-siri marked this pull request as ready for review February 21, 2026 11:08
@chandra-siri chandra-siri requested review from a team February 21, 2026 11:08
@chandra-siri chandra-siri requested a review from a team as a code owner February 21, 2026 11:08
Renames open_retries to _open_retries in AsyncMultiRangeDownloader to encapsulate the retry counter. Updates test_zonal.py to verify the private attribute.
@product-auto-label product-auto-label Bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Feb 21, 2026
@chalmerlowe

Copy link
Copy Markdown
Contributor

@chalmerlowe chalmerlowe closed this Mar 2, 2026
@chandra-siri chandra-siri reopened this Mar 2, 2026
@chandra-siri chandra-siri changed the base branch from lint_changes to main March 3, 2026 16:06
@chandra-siri chandra-siri requested review from a team as code owners March 3, 2026 16:06
@chandra-siri chandra-siri changed the base branch from main to lint_changes March 3, 2026 16:07
chandra-siri added a commit that referenced this pull request Mar 3, 2026
feat: Add system test for cross-region buckets
    
- Adds a new system test, test_basic_wrd_x_region, to verify
functionality with cross-region GCS buckets.
    
- Also updates the Cloud Build configuration to pass the necessary
_CROSS_REGION_BUCKET environment variable to the test environment



This PR is a cherry-picked from
#1760 because that PR
is blocked by b/489420625
parthea pushed a commit to googleapis/google-cloud-python that referenced this pull request Mar 9, 2026
feat: Add system test for cross-region buckets
    
- Adds a new system test, test_basic_wrd_x_region, to verify
functionality with cross-region GCS buckets.
    
- Also updates the Cloud Build configuration to pass the necessary
_CROSS_REGION_BUCKET environment variable to the test environment



This PR is a cherry-picked from
googleapis/python-storage#1760 because that PR
is blocked by b/489420625
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