Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds comprehensive async testing support for database interceptors and mock server tests, including new async integration tests for aborted transactions, operation metrics, pool binding, and request ID headers. The feedback suggests avoiding fragile post-creation channel hacking of private grpc.aio.Channel details by flattening multi-interface interceptors and passing them directly to standard gRPC channel creation APIs. Additionally, it is recommended to add an optional tz parameter to the mocked now() method in _FakeDatetime to ensure compatibility with standard datetime.now() usage.
16be826 to
f5b80f5
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces comprehensive asynchronous testing support and refactoring across the Google Cloud Spanner Python client, including async interceptor support, refactored mock server test bases, and new async integration tests for aborted transactions, operation metrics, pool binding, and request ID headers. The review feedback suggests using getattr when appending to private interceptor lists on gRPC channels to prevent AttributeErrors on mocked channels, and inheriting the test _FakeDatetime class from datetime to avoid errors with other standard datetime methods.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces comprehensive async support for testing utilities, mock server tests, and interceptors in the Google Cloud Spanner Python client. Key changes include adding async interceptor attachment, extending interceptors to support unary-stream calls, refactoring mock server test bases to cleanly manage async databases, and implementing extensive async test suites for aborted transactions, basic operations, operation metrics, pool binding, and request ID headers. The review feedback suggests three main improvements: defensively resolving the underlying gRPC channel before accessing private interceptor lists to prevent fragility with wrapped channels, adding a safety check for _transaction in MethodAbortAsyncInterceptor to avoid potential AttributeErrors, and subclassing datetime in the mock metrics tracer to make the fake datetime class more robust.
f5b80f5 to
61feb4c
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request significantly expands async test coverage for the Google Cloud Spanner client by introducing async mock server tests, including tests for aborted transactions, basic operations, operation metrics, and pool bindings. It also updates async interceptors to support both unary-unary and unary-stream calls. The review feedback suggests improving robustness by using getattr to safely access private attributes of grpc.aio.Channel and self._connection. Additionally, it recommends enhancing the fake datetime class to handle timezones and utcnow(), and refining the _count_leading_session_requests helper to break on any non-session creation request.
Only modifies test suites and internal test-only helpers; no production runtime code is changed. Summary of changes: - Extend the async mock server test base class with client/database setup and automatic database/transport cleanup so async tests do not leak background tasks or channels across test cases. - Update the test-only async database and test interceptors to support multi-interface gRPC async interceptors, bytes header metadata, and async transaction abort/rollback simulation. - Add async mock server integration tests covering basic queries/streaming, aborted transaction retries, session pool binding, x-goog-spanner-request-id headers, and operation metrics, reusing shared assertion helpers across sync and async suites. - Replace wall-clock sleeps in the operation metrics tests with a deterministic fake clock.
61feb4c to
3489306
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request significantly enhances the asynchronous testing infrastructure for Google Cloud Spanner by refactoring test interceptors to support both unary-unary and unary-stream async gRPC calls, and introducing a robust set of async mock server tests covering aborted transactions, pool binding, operation metrics, and request ID headers. Feedback on the changes suggests adding a guard clause and duplicate checks in _attach_async_interceptors to prevent duplicate interceptor registrations on the gRPC channel.
Only modifies test suites and internal test-only helpers; no production runtime code is changed.
Summary of changes: