Skip to content

test(storage): fix failing unit, acceptance, and sample tests - #36713

Merged
torreypayne merged 7 commits into
mainfrom
fix-storage-tests-584435204
Nov 11, 2026
Merged

torreypayne merged 7 commits into
mainfrom
fix-storage-tests-584435204

Conversation

@nidhiii-27

Copy link
Copy Markdown
Contributor

Fixes failing google-cloud-storage unit, acceptance, and sample tests blocking the 1.62.2 release:

  1. Windows Unit Test (google-cloud-storage/test/google/cloud/storage/file_test.rb):
    • Call tmpfile.binmode in the gzip download Tempfile.open blocks (L243-L261 and L270-L288) and use binary encoding (StringIO.new "".b) in gzip_data (L1619) so Windows does not truncate binary gzip data at 0x1A (Ctrl+Z EOF) or perform CRLF translation.
  2. UBLA Acceptance Test (google-cloud-storage/acceptance/storage/bucket_uniform_bucket_level_access_test.rb):
    • Expect Google::Cloud::InvalidArgumentError (HTTP 400) instead of Google::Cloud::PermissionDeniedError when calling file.acl.add_reader on a bucket with Uniform Bucket-Level Access enabled.
  3. Signed POST Policy v4 Acceptance Test (google-cloud-storage/acceptance/storage/bucket_generate_signed_post_policy_v4_test.rb):
    • Use "acl" => "project-private" instead of "acl" => "public-read" so the test complies with Public Access Prevention (PAP) and receives HTTP 204 No Content.
  4. Samples list_buckets Pagination (google-cloud-storage/samples/storage_list_buckets.rb):
    • Use storage.buckets.all instead of storage.buckets.each so all pages of buckets are traversed.
  5. Samples Acceptance requester_pays & get_object_contexts (google-cloud-storage/samples/acceptance/files_test.rb):
    • Set bucket.user_project = true before toggling bucket.requester_pays (and reset bucket.user_project = nil in after do) so userProject is included and @bucket cleanup does not fail with InvalidArgumentError.
    • Use capture_io and assert_includes in get_object_contexts so custom context assertions do not depend on server map key iteration order.

[Generated-by: AI]

- Use binary mode on Tempfile and StringIO in gzip download unit tests to prevent Windows 0x1A EOF truncation and encoding mismatch
- Expect Google::Cloud::InvalidArgumentError when modifying object ACLs on UBLA-enabled buckets
- Use project-private ACL in signed POST policy v4 acceptance test to comply with Public Access Prevention (PAP)
- Paginate through all buckets with storage.buckets.all in storage_list_buckets sample
- Set bucket.user_project = true when toggling requester_pays and use order-independent assertions in get_object_contexts sample test

[Generated-by: AI]
@nidhiii-27 nidhiii-27 added the ai-generated Generated by AI label Nov 11, 2026
- Clean up leftover objects in bucket_list_object_contexts_test.rb before/after runs so negative context filter queries are not polluted by prior tests
- Skip uniform_bucket_level_access file reload permission test matching policy_only test (#32426)
- Pass user_project: true in storage_disable_requester_pays, storage_get_requester_pays_status, buckets_test.rb, and helper.rb cleanup

[Generated-by: AI]
…anup

Ensure bucket.user_project remains true while deleting files in the
after hook of samples/acceptance/files_test.rb and pass user_project: true
in delete_bucket_helper so cleanup succeeds while requester_pays=false
propagates across GCS frontends.

[Generated-by: AI]
Retry bucket metadata patch calls on ResourceExhaustedError in
acceptance/storage/bucket_encryption_test.rb to prevent rateLimitExceeded
failures when tests rapidly update the same bucket.

[Generated-by: AI]
@nidhiii-27
nidhiii-27 marked this pull request as ready for review November 11, 2026 11:27
@nidhiii-27
nidhiii-27 requested review from a team and yoshi-approver as code owners November 11, 2026 11:27
@nidhiii-27
nidhiii-27 requested a review from cpriti-os November 11, 2026 11:30

@cpriti-os cpriti-os left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Mostly looks good, left a couple of comments inline.

…ys tests

- Use before do to match after do and assert _(list).wont_be :empty? across all 4 tests in bucket_list_object_contexts_test.rb
- Reset bucket.user_project = nil in download_file_requester_pays ensure block and remove user_project/requester_pays toggling from shared after hook in files_test.rb

[Generated-by: AI]
…es acls_test

Wrap bucket ACL and default ACL mutation calls in samples/acceptance/acls_test.rb with retry_resource_exhaustion to avoid 429 rateLimitExceeded errors during sample acceptance runs.

[Generated-by: AI]
…kets

Use dedicated temporary buckets for download_file_requester_pays in files_test.rb and requester_pays in buckets_test.rb so eventual consistency of requester_pays=false does not cause subsequent tests on shared buckets to fail with InvalidArgumentError.

[Generated-by: AI]

@cpriti-os cpriti-os left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, thanks for the updates!

@torreypayne
torreypayne merged commit 5dc19a3 into main Nov 11, 2026
20 checks passed
@torreypayne
torreypayne deleted the fix-storage-tests-584435204 branch November 11, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Generated by AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants