Skip to content

fix(test): resolve flag duplication in emulator tests, update GetObject count, and rename proxy log prefix#4728

Open
alleaditya wants to merge 1 commit into
GoogleCloudPlatform:masterfrom
alleaditya:fix-emulator-tests-flags
Open

fix(test): resolve flag duplication in emulator tests, update GetObject count, and rename proxy log prefix#4728
alleaditya wants to merge 1 commit into
GoogleCloudPlatform:masterfrom
alleaditya:fix-emulator-tests-flags

Conversation

@alleaditya
Copy link
Copy Markdown
Contributor

@alleaditya alleaditya commented May 25, 2026

Description

This PR resolves a test isolation issue in the gcsfuse emulator integration tests:

  1. Flag Accumulation Bug: In grpc_header_validation_test.go and writes_stall_on_sync_test.go, flags were being appended in-place to a suite-level or loop-level slice. Since the test instances are reused across multiple sub-tests, this caused flags (specifically --custom-endpoint and --anonymous-access) to accumulate, leading to mounting errors (connecting to dead ports of previous test runs). This PR fixes it by copying the base flags before appending local test-specific flags.
  2. Emulator GetObject Count: Updated the expected GetObject call count in TestGRPCHeadersInMultipleOperations from 3 to 4. This is because the test runs with gRPC enabled, which triggers a DirectPath verification call (gcsfuse-dp-object Stat) during mount that was previously not accounted for in the strict count assertion.
  3. Kokoro Proxy Logs Collection: Renamed the proxy server log file prefix from proxy-server-failed- to gcsfuse-failed-integration-test-logs-proxy-server- to match the Kokoro artifact collection pattern in presubmit.cfg, ensuring proxy logs are successfully uploaded to GCS on failures.

Link to the issue in case of a bug fix.

NA

Testing details

  1. Manual - NA
  2. Unit tests - NA
  3. Integration tests - Verified that emulator tests pass locally and checks are passing on Kokoro.

Any backward incompatible change? If so, please explain.

No.

@alleaditya alleaditya requested review from a team and meet2mky as code owners May 25, 2026 08:55
@gemini-code-assist
Copy link
Copy Markdown
Contributor

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 improves the reliability and consistency of integration tests by addressing flag duplication issues and standardizing log file naming. It also updates specific test expectations to reflect current behavior, ensuring that validation logic remains accurate as test scenarios evolve.

Highlights

  • Flag Management: Implemented base flag preservation in emulator tests to prevent duplicate flag accumulation during test execution.
  • Test Assertions: Updated the expected GetObject call count in GRPC header validation tests to account for additional verification steps.
  • Logging: Renamed the proxy server log file prefix to improve consistency with existing GCSFuse log naming conventions.
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 the 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 counterproductive. 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
Contributor

@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 improves test isolation and reliability by ensuring that flag slices are correctly copied and reset between tests, preventing side effects from shared state. It also updates the proxy server log file prefix for better consistency. The reviewer suggested using GreaterOrEqual instead of an exact Equal assertion for RPC counts in TestGRPCHeadersInMultipleOperations to avoid test flakiness caused by asynchronous background operations.

assert.Contains(g.T(), logStr, "force_direct_connectivity=ENFORCED")
assert.Contains(g.T(), logStr, "direct_connectivity_diagnostic=no_auth")
assert.Equal(g.T(), 3, strings.Count(logStr, "/google.storage.v2.Storage/GetObject"), "Expected 3 GetObject calls (1 for each operation)")
assert.Equal(g.T(), 4, strings.Count(logStr, "/google.storage.v2.Storage/GetObject"), "Expected 4 GetObject calls (1 verification + 3 operations)")
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

Following the general rules for this repository, assertions on RPC counts should use GreaterOrEqual instead of Equal when asynchronous background tasks (like metadata prefetch) might trigger additional calls. This helps prevent test flakiness due to non-deterministic timing of these async operations.

Suggested change
assert.Equal(g.T(), 4, strings.Count(logStr, "/google.storage.v2.Storage/GetObject"), "Expected 4 GetObject calls (1 verification + 3 operations)")
assert.GreaterOrEqual(g.T(), strings.Count(logStr, "/google.storage.v2.Storage/GetObject"), 4, "Expected at least 4 GetObject calls (1 verification + 3 operations)")
References
  1. When asserting the count of operations in tests where asynchronous background tasks (such as metadata prefetch) might trigger additional calls, use 'GreaterOrEqual' instead of exact 'Equal' assertions if the precise count is already verified in other dedicated test cases. This approach helps prevent test flakiness due to non-deterministic timing of async operations.

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