Skip to content

refactor(storage): Migrate conformance and system tests to StorageTransport with enhanced retry logic#7

Open
thiyaguk09 wants to merge 1295 commits into
storage-node-18from
node18/conformance-test
Open

refactor(storage): Migrate conformance and system tests to StorageTransport with enhanced retry logic#7
thiyaguk09 wants to merge 1295 commits into
storage-node-18from
node18/conformance-test

Conversation

@thiyaguk09
Copy link
Copy Markdown
Owner

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

d-goog and others added 30 commits September 22, 2022 17:07
…oogleapis#2074)

* test: Add system-tests for resumable multi-chunk uploads

* test: streamline multi-chunk upload system tests

* chore: verify `Content-Range`: `bytes ${this.offset}-*/*` behavior

* style: typo

* style: typo

* fix: determine content-length before attempting multi-chunk upload

* test: Use bigger file for multi-chunk test since chunks need to be large

* feat: dynamically determine Content-Length when unspecified

* feat: dynamically determine Content-Length when unspecified

* docs: clarifications, make it easier for the future team

* docs: Another clarification
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* refactor(deps): remove arrify

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
…pis#1314) (googleapis#2070)

* fix: correct STORAGE_EMULATOR_HOST handling (googleapis#2069, googleapis#1314)

credit to @jpambrun for identifying the fix

* fix: normalize baseUrl

Co-authored-by: Daniel Bankhead <dan@danielbankhead.com>

* fix: adjust URL normalization & tests for consistency

Co-authored-by: Daniel Bankhead <dan@danielbankhead.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* feat(crc32c): Convenient Method For Reading Files

* fix: `fs/promises` for Node 12

* fix: Use `unlink`, `rm` isn't available on Node 12

* fix: Use `unlink`, `rm` isn't available on Node 12
googleapis#2094)

* fix: remove async from final function which causes double invocation of callback

* add catch clause
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* feat: support autoclass

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* added documentation

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* fixed documentation

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* removed log statements

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
…will be rotated (googleapis#2112)

* build: have Kokoro grab service account credentials from secret that will be rotated

Source-Link: https://togithub.com/googleapis/synthtool/commit/4a0230eb8dc497f36fd3839e6144982131f30a9d
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:f59941869d508c6825deeffce180579545fd528f359f549a80a18ec0458d7094
* feat: implement parallel operations (googleapis#2067)

* feat: implement parallel operations

* add more parallel operations

* add header to test file

* update import of fs/promises

* fix pathing on windows, fix mocking of fs promises

* add jsdoc headers to class and uploadMulti

* add jsdoc comments to remaining functions

* update comment wording

* add experimental jsdoc tags

* feat: add directory generator to performance test framework

* clarify variable names and comments

* capitalization

* wip: transfer manager performance tests

* feat: merged in application performance tests (googleapis#2100)

* fix: fixed many bugs (googleapis#2102)

* fix: cleaning up bugs

* fix: fixed many bugs

* fix: more work on transfer manager perf metrics (googleapis#2103)

* fix: more work on transfer manager perf metrics

* fix unit tests for tm

* fix: performance test refactoring, comments (googleapis#2104)

* refactor: refactor constants (googleapis#2105)

* refactor: refactor constants

* bug fixes

* bug fixes

* bug fixes

* linter fixes, download to disk for performance test

* rename transfer manager functions

* remove callbacks from transfer manager

* add more experimental tags, update comments

* change signature of downloadManyFiles to accept array of strings or a folder name

* linter fix

* add transfer manager samples and samples tests

Co-authored-by: Sameena Shaffeeullah <shaffeeullah@google.com>

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat: add crc32c validation option to chunked download, cleanup naming (googleapis#2110)

* feat: add crc32c validation option to chunked download, cleanup naming in perf tests

* close file in finally block

Co-authored-by: Sameena Shaffeeullah <shaffeeullah@google.com>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
…will be rotated for system tests (googleapis#2121)

Source-Link: https://togithub.com/googleapis/synthtool/commit/abbc97db69a57dcb991ba97ef503305b701ffb3a
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest@sha256:fe04ae044dadf5ad88d979dbcc85e0e99372fb5d6316790341e6aca5e4e3fbc8
…oogleapis#2124)

This is a follow-up to PR googleapis/nodejs-storage#2123 in hope to address both README.md elaborate documentation updates as well as in-code documentation
googleapis#2118)

* feat: add ability to upload entire directory, add samples for upload directory / download folder

* linter fix

* update phrasing of comments

* update comment in downloadFolderWithTransferManager sample

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
googleapis#2130)

* samples: fix wording for preconditions to use correct operation instead of upload

* correct file.setmetadata related samples to reference ifMetagenerationMatch instead of ifGenerationMatch

* fix samples tests
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
* test: add output format for SSB to performance tests

* rename SSB to cloud monitoring

* reword comments for additional clarity

* adjust threshold for chunked downloads in order to support workload 2

* fix a few typos, consume async generator correctly
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the internal conformance tests by migrating them to use the StorageTransport class. This change standardizes how HTTP requests are made and how retries are handled, moving away from direct client methods to a more unified transport layer. The update also introduces more robust retry logic, ensuring that requests are only retried when safe and appropriate, based on HTTP methods and preconditions. This improves the reliability and maintainability of the test suite and the underlying client library.

Highlights

  • Conformance Test Migration: Refactored conformance tests to directly utilize the StorageTransport class, centralizing HTTP request handling and retry logic for consistency.
  • Enhanced Retry Logic: Updated the default retryable error function to intelligently consider HTTP methods and the presence of preconditions (e.g., ifGenerationMatch) when determining if a request should be retried.
  • CI/CD Streamlining: Removed the 'docs' job and its corresponding status check from the CI/CD configuration, simplifying the build process.
  • Test Bench Update: Upgraded the Storage Testbench Docker image version to v0.60.0 for improved testing capabilities.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

Code Review

The pull request refactors Google Cloud Storage conformance tests to directly use StorageTransport.makeRequest for API calls, bypassing higher-level client methods, and updates the testbench Docker image. It also removes the docs CI job and related settings. Review comments highlight a bug in the create function's bucketExists check, where a 404 error was not handled, causing premature exit, and suggest an optimization to reuse the Gaxios instance in the authClient.request mock for efficiency.

Comment thread handwritten/storage/conformance-test/libraryMethods.ts Outdated
Comment on lines +81 to +82
const gaxios = new Gaxios();
return gaxios.request(opts);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Creating a new Gaxios instance for every authClient.request call within this mock can be inefficient, especially if this mock is called frequently. While this is a test utility, reusing a single Gaxios instance might offer a slight performance improvement and better reflect how Gaxios is typically used in production code.

Consider initializing gaxios once outside the request function and reusing it.

authClient.request = async opts => {
  const gaxios = new Gaxios();
  return gaxios.request(opts);
};

@thiyaguk09 thiyaguk09 force-pushed the node18/conformance-test branch from 111ddca to 5ff1473 Compare April 25, 2026 10:20
@thiyaguk09
Copy link
Copy Markdown
Owner Author

/gemini review

Copy link
Copy Markdown

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

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 refactors the storage library to improve conformance testing, ensure Node 18 compatibility, and enhance retry logic with granular idempotency checks. Key updates include transitioning to full REST API paths and refactoring conformance tests to use raw API calls. Reviewers identified a bug in a setTimeout callback and a potential crash in File.isPublic due to unnormalized callbacks. Additionally, feedback suggests refining the decompress option handling in StorageTransport, avoiding response data pollution when attaching metadata, and optimizing performance by reducing unnecessary JSON parsing during retry evaluations.

Comment thread handwritten/storage/system-test/kitchen.ts Outdated
Comment thread handwritten/storage/src/file.ts Outdated
Comment on lines +172 to +173
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...({decompress: false} as any),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Hardcoding decompress: false here overrides any decompress option passed in reqOpts. While this might be intended to avoid Gaxios's automatic decompression in favor of manual handling, it prevents users from explicitly requesting decompression for non-stream requests or when they want Gaxios to handle it. Consider only setting it to false if not explicitly provided in reqOpts.

Suggested change
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...({decompress: false} as any),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
decompress: (reqOpts as any).decompress ?? false,

Comment on lines +189 to +192
if (data && typeof data === 'object') {
data.headers = resp.headers;
data.status = resp.status;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Attaching headers and status directly to the data object can have unexpected side effects, especially if data is an Array, a Buffer, or a frozen object. It also pollutes the response data with metadata that might conflict with actual data fields. A cleaner approach would be to return a structured object or ensure data is a plain object before modification.

// Optimized Precondition Check
let bodyEtag = false;
try {
const parsedBody = typeof data === 'string' ? JSON.parse(data) : data;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Attempting to JSON.parse(data) on every retryable error where data is a string can be a significant performance bottleneck if the request body is a large non-JSON string (e.g., a large file upload). Consider checking if the request was intended to be JSON or limiting the size of the string being parsed.

@thiyaguk09 thiyaguk09 force-pushed the node18/conformance-test branch from 5ff1473 to 585bbb5 Compare April 25, 2026 11:00
@thiyaguk09 thiyaguk09 changed the title Refactor: Migrate conformance tests to StorageTransport and enhance retry logic refactor(storage): Migrate conformance and system tests to StorageTransport with enhanced retry logic Apr 27, 2026
@thiyaguk09 thiyaguk09 force-pushed the storage-node-18 branch 4 times, most recently from b4ee48b to b2e12e7 Compare May 7, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.