Skip to content

Conversation

@thiyaguk09
Copy link
Owner

Description

This change addresses flakiness in the resumable-upload integration tests, specifically regarding CRC32C validation and cleanup hooks.

Key changes include:

  • Status Code Validation: Updated the success criteria to accept any 2xx status code. Previously, the test strictly looked for 200, which caused failures when the server returned 201 Created.
  • Resource Leak Prevention: Removed a rogue upload() call in the beforeEach hook. This call was initiating a network request without data or cleanup, leading to orphaned streams and resource contention during the afterEach deletion phase.
  • Consistent Naming: Standardized the use of path.basename(filePath) for remote object names to ensure the afterEach cleanup hook correctly identifies and deletes the test files in the bucket.
  • Assertion Safety: Wrapped event-driven assertions in try/catch blocks within the finish listener to ensure Mocha reports assertion failures correctly instead of timing out.

Impact

This change reduces CI flakiness in the nodejs-storage repository. It ensures that the integrity checks (CRC32C) are validated against actual server behavior and that test environments are cleaned up reliably between runs.

Testing

  • Integration Tests: Ran the system-test/kitchen.ts test suite locally against a live GCS bucket.
  • Stress Testing: Verified the should upload successfully when crc32c calculation is enabled test by running it in a loop (20 iterations) to ensure the previous "flaky" behavior is resolved.
  • Cleanup Verification: Confirmed that the afterEach hook successfully removes objects from the test bucket, preventing "dirty" test environments.

Additional Information

The failures were originally reported by the flaky-bot in issues googleapis#2708 and googleapis#2714. The root cause was a combination of strict HTTP status checks and orphaned stream handles.

Checklist

  • 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
  • Appropriate docs were updated
  • Appropriate comments were added, particularly in complex areas or places that require background
  • No new warnings or issues will be generated from this change

Fixes #issue_number_goes_here 🦕

@gemini-code-assist
Copy link

Summary of Changes

Hello @thiyaguk09, 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 improves the stability and reliability of the resumable-upload integration tests. It addresses intermittent failures related to CRC32C validation and test environment cleanup by making success criteria more flexible, preventing resource leaks, and ensuring proper file identification for deletion. These changes aim to reduce CI flakiness and provide more consistent test results.

Highlights

  • Status Code Validation: Updated success criteria for uploads to accept any 2xx HTTP status code, resolving issues where 201 Created caused test failures.
  • Resource Leak Prevention: Removed an unnecessary upload() call from the beforeEach hook to prevent orphaned streams and resource contention during test cleanup.
  • Consistent Naming for Cleanup: Standardized the use of path.basename(filePath) for remote object names, ensuring the afterEach hook correctly identifies and deletes test files.
  • Robust Assertion Handling: Wrapped event-driven assertions in try/catch blocks within the finish listener to ensure Mocha reports assertion failures accurately instead of timing out.

🧠 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.

Changelog
  • system-test/kitchen.ts
    • Removed a beforeEach hook that initiated an upload() call without proper data or cleanup.
    • Modified the afterEach hook to use path.basename(filePath) for deleting remote files, ensuring correct file identification.
    • Added a check fs.existsSync(filePath) before attempting to remove the local temporary file in the after hook.
    • Updated the upload function calls to use path.basename(filePath) for the remote file name.
    • Changed the upload success condition from resp.status === 200 to resp.status >= 200 && resp.status < 300 to accommodate 201 Created responses.
    • Wrapped the assert.strictEqual call within the finish event listener in a try/catch block to ensure Mocha correctly reports assertion failures.
    • Removed a console.log(err) statement from an error handler.
Activity
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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

@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 does an excellent job of stabilizing the resumable-upload integration tests. Key improvements include accepting any 2xx status code for success, removing a resource-leaking upload() call in the beforeEach hook, standardizing remote object naming for reliable cleanup, and wrapping event-driven assertions in try/catch blocks to prevent test timeouts on failure. These changes effectively address the reported flakiness. I have one minor suggestion to simplify the file cleanup logic.

@thiyaguk09 thiyaguk09 force-pushed the fix/issue-2708-2714-crc32c-flake branch from c3951b6 to 709bd9e Compare February 12, 2026 10:19
- Update success status check to handle all 2xx codes (including 201)
- Remove orphaned upload in beforeEach causing stream leaks
- Normalize remote file naming using path.basename
- Fixes googleapis#2708, Fixes googleapis#2714
@thiyaguk09 thiyaguk09 force-pushed the fix/issue-2708-2714-crc32c-flake branch from 709bd9e to e717f13 Compare February 12, 2026 10:26
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.

1 participant