fix(test): resolve flag duplication in emulator tests, update GetObject count, and rename proxy log prefix#4728
Conversation
…ct count, and rename proxy log prefix
Summary of ChangesHello, 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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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)") |
There was a problem hiding this comment.
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.
| 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
- 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.
Description
This PR resolves a test isolation issue in the gcsfuse emulator integration tests:
grpc_header_validation_test.goandwrites_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-endpointand--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.GetObjectcall count inTestGRPCHeadersInMultipleOperationsfrom 3 to 4. This is because the test runs with gRPC enabled, which triggers a DirectPath verification call (gcsfuse-dp-objectStat) during mount that was previously not accounted for in the strict count assertion.proxy-server-failed-togcsfuse-failed-integration-test-logs-proxy-server-to match the Kokoro artifact collection pattern inpresubmit.cfg, ensuring proxy logs are successfully uploaded to GCS on failures.Link to the issue in case of a bug fix.
NA
Testing details
Any backward incompatible change? If so, please explain.
No.