Skip to content

tests(Spanner): More MUX explicit tests#15442

Merged
amanda-tarafa merged 3 commits intogoogleapis:mainfrom
amanda-tarafa:mux-direct-tests
Feb 11, 2026
Merged

tests(Spanner): More MUX explicit tests#15442
amanda-tarafa merged 3 commits intogoogleapis:mainfrom
amanda-tarafa:mux-direct-tests

Conversation

@amanda-tarafa
Copy link
Copy Markdown
Contributor

No description provided.

@amanda-tarafa amanda-tarafa requested a review from a team February 10, 2026 07:11
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Feb 10, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @amanda-tarafa, 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 expands the test suite for the Spanner client library's session and transaction management components. It introduces new tests to validate the lifecycle of managed sessions, ensuring correct handling of session freshness, expiry, and concurrent access. Additionally, it adds detailed tests for managed transactions, covering different transaction types and their disposal behavior. These additions enhance the reliability and maintainability of the Spanner client by providing more explicit and thorough validation of its core session and transaction mechanisms.

Highlights

  • Enhanced ManagedSession Test Coverage: Expanded the test suite for ManagedSession to include scenarios for initial session creation, handling of soft and hard expiry, concurrent session refresh attempts, and the graceful swallowing or propagation of refresh failures.
  • Comprehensive ManagedTransaction Tests: Introduced new tests for ManagedTransaction to validate behavior across different transaction options (no options, single-use, explicit, and inlined transactions), including fallback mechanisms and correct disposal logic for various transaction states (read-only, partitioned DML, committed, rolled-back, and uncommitted read-write).
  • Improved Test Utility for SpannerClient: Modified SpannerClientHelpers.CreateMockClient to accept an optional FakeClock, providing more precise control over time-sensitive operations within tests and enhancing test predictability.
  • Robust CancellationToken Access: Updated ManagedSession.BatchWriteAsync to use a null-conditional operator when accessing CancellationToken from callSettings, preventing potential NullReferenceException.
Changelog
  • apis/Google.Cloud.Spanner.Data/Google.Cloud.Spanner.Data.Tests/V1/ManagedSessionOptionsTests.cs
    • Renamed file from apis/Google.Cloud.Spanner.V1/Google.Cloud.Spanner.V1.Tests/ManagedSessionOptionsTests.cs.
    • Updated using directives to include Google.Cloud.Spanner.V1 and Google.Cloud.Spanner.V1.Internal.Logging.
    • Modified _mockClient initialization to use SpannerClientHelpers.CreateMockClient.
  • apis/Google.Cloud.Spanner.Data/Google.Cloud.Spanner.Data.Tests/V1/ManagedSessionTests.cs
    • Added new test cases for ManagedSession covering initial creation, no expiry, soft expiry with background refresh, concurrent calls, soft expiry refresh failure, hard expiry with blocking refresh, hard expiry refresh propagation, concurrent BeginTransactionAsync calls, and BatchWriteAsync session handling.
  • apis/Google.Cloud.Spanner.Data/Google.Cloud.Spanner.Data.Tests/V1/ManagedTransactionTests.cs
    • Added new test cases for ManagedTransaction covering no transaction options, single-use transaction options, explicit transactions, inlined transactions, inlined transaction fallback to explicit, DisposeAsync invalidating further RPCs, and DisposeAsync behavior for read-only, partitioned DML, committed, rolled-back, and uncommitted read-write transactions.
  • apis/Google.Cloud.Spanner.Data/Google.Cloud.Spanner.Data.Tests/V1/SpannerClientHelpers.cs
    • Added Google.Api.Gax using directive.
    • Modified CreateMockClient method signature to accept an optional FakeClock parameter.
    • Updated CreateMockClient implementation to use the provided FakeClock or create a new one.
  • apis/Google.Cloud.Spanner.V1/Google.Cloud.Spanner.V1/ManagedSession.cs
    • Updated BatchWriteAsync to use a null-conditional operator when accessing callSettings.CancellationToken.
Activity
  • No specific activity (comments, reviews, progress updates) has been recorded for this pull request yet.
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
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 introduces valuable new tests for ManagedSession and ManagedTransaction, significantly improving test coverage for multiplexed session handling. The refactoring of test file locations and the mock client helper are also positive changes. My review has identified a couple of minor issues in the new test code: one regarding the use of Task.Delay which could lead to test flakiness, and another concerning a redundant and incorrect mock setup. Addressing these points will enhance the robustness and clarity of the new tests.

@amanda-tarafa
Copy link
Copy Markdown
Contributor Author

/gemini review

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 adds a comprehensive set of tests for ManagedSession and ManagedTransaction, which is a great addition for ensuring the stability of the multiplexed sessions feature. The tests cover various scenarios including session lifecycle, expiry, and transaction management. I've found a few areas for improvement related to namespace consistency and the use of Task.Delay in tests which could lead to flakiness. Please see my detailed comments. Overall, this is a valuable contribution.

@amanda-tarafa amanda-tarafa merged commit 583d3b9 into googleapis:main Feb 11, 2026
13 checks passed
@amanda-tarafa amanda-tarafa deleted the mux-direct-tests branch February 11, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants