From 43d957e1e2910fb6b16d551bf5182917f3676131 Mon Sep 17 00:00:00 2001 From: Scott Hart Date: Wed, 4 Feb 2026 14:42:06 -0500 Subject: [PATCH 1/5] deprecation warnings suppressed --- .../backup_extra_integration_test.cc | 2 + .../backup_integration_test.cc | 2 + .../benchmarks/multiple_rows_cpu_benchmark.cc | 2 + .../single_row_throughput_benchmark.cc | 2 + google/cloud/spanner/client.cc | 2 + google/cloud/spanner/client_test.cc | 2 + google/cloud/spanner/commit_options.cc | 4 + google/cloud/spanner/connection.cc | 2 + .../client_integration_test.cc | 2 + .../integration_tests/client_stress_test.cc | 2 + .../data_types_integration_test.cc | 2 + .../session_pool_integration_test.cc | 2 + .../cloud/spanner/internal/connection_impl.cc | 2 + .../spanner/internal/connection_impl_test.cc | 1296 +++++++++-------- google/cloud/spanner/internal/defaults.cc | 4 + .../cloud/spanner/internal/defaults_test.cc | 2 + .../partial_result_set_resume_test.cc | 2 + .../internal/partial_result_set_source.cc | 2 + .../partial_result_set_source_test.cc | 2 + .../cloud/spanner/internal/route_to_leader.cc | 4 + .../spanner/internal/route_to_leader_test.cc | 2 + google/cloud/spanner/internal/session_pool.cc | 2 + .../spanner/internal/session_pool_test.cc | 168 ++- google/cloud/spanner/options.h | 30 +- google/cloud/spanner/partition_options.cc | 2 + google/cloud/spanner/query_options.cc | 2 + google/cloud/spanner/query_options_test.cc | 3 + google/cloud/spanner/query_partition.cc | 2 + google/cloud/spanner/query_partition_test.cc | 3 + google/cloud/spanner/quickstart/quickstart.cc | 2 + google/cloud/spanner/read_options.cc | 2 + google/cloud/spanner/read_partition.cc | 2 + google/cloud/spanner/read_partition_test.cc | 2 + google/cloud/spanner/results_test.cc | 2 + .../cloud/spanner/samples/client_samples.cc | 2 + google/cloud/spanner/samples/graph_samples.cc | 2 + .../spanner/samples/mock_execute_query.cc | 2 + .../spanner/samples/postgresql_samples.cc | 2 + google/cloud/spanner/samples/samples.cc | 2 + .../spanner/session_pool_options_test.cc | 2 + google/cloud/spanner/transaction.cc | 4 + 41 files changed, 871 insertions(+), 709 deletions(-) diff --git a/google/cloud/spanner/admin/integration_tests/backup_extra_integration_test.cc b/google/cloud/spanner/admin/integration_tests/backup_extra_integration_test.cc index 557b6674848bc..deee6e2ea5e07 100644 --- a/google/cloud/spanner/admin/integration_tests/backup_extra_integration_test.cc +++ b/google/cloud/spanner/admin/integration_tests/backup_extra_integration_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/admin/database_admin_options.h" @@ -541,3 +542,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/admin/integration_tests/backup_integration_test.cc b/google/cloud/spanner/admin/integration_tests/backup_integration_test.cc index 127fa61186e4b..1b6f736ab8639 100644 --- a/google/cloud/spanner/admin/integration_tests/backup_integration_test.cc +++ b/google/cloud/spanner/admin/integration_tests/backup_integration_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/admin/database_admin_options.h" @@ -275,3 +276,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/benchmarks/multiple_rows_cpu_benchmark.cc b/google/cloud/spanner/benchmarks/multiple_rows_cpu_benchmark.cc index 5179c7eb81f38..3b0dad3851a30 100644 --- a/google/cloud/spanner/benchmarks/multiple_rows_cpu_benchmark.cc +++ b/google/cloud/spanner/benchmarks/multiple_rows_cpu_benchmark.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/benchmarks/benchmarks_config.h" @@ -1434,3 +1435,4 @@ int main(int argc, char* argv[]) { : "database dropped\n"); return exit_status; } +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/benchmarks/single_row_throughput_benchmark.cc b/google/cloud/spanner/benchmarks/single_row_throughput_benchmark.cc index 396b042b9b2f8..0c14907412c93 100644 --- a/google/cloud/spanner/benchmarks/single_row_throughput_benchmark.cc +++ b/google/cloud/spanner/benchmarks/single_row_throughput_benchmark.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/benchmarks/benchmarks_config.h" @@ -511,3 +512,4 @@ int main(int argc, char* argv[]) { : "database dropped\n"); return 0; } +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/client.cc b/google/cloud/spanner/client.cc index 03a04dd965fed..7477132c3d79f 100644 --- a/google/cloud/spanner/client.cc +++ b/google/cloud/spanner/client.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/client.h" #include "google/cloud/spanner/internal/connection_impl.h" @@ -432,3 +433,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/client_test.cc b/google/cloud/spanner/client_test.cc index 626b6e207479f..735032ea4b7eb 100644 --- a/google/cloud/spanner/client_test.cc +++ b/google/cloud/spanner/client_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/client.h" #include "google/cloud/mocks/mock_stream_range.h" @@ -1339,3 +1340,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/commit_options.cc b/google/cloud/spanner/commit_options.cc index 804b40908f0bf..385823bb1106d 100644 --- a/google/cloud/spanner/commit_options.cc +++ b/google/cloud/spanner/commit_options.cc @@ -13,6 +13,9 @@ // limitations under the License. #include "google/cloud/spanner/commit_options.h" + +// do no reorder +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/options.h" namespace google { @@ -48,3 +51,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/connection.cc b/google/cloud/spanner/connection.cc index 9a3352f68901a..0b5e2fde19ed0 100644 --- a/google/cloud/spanner/connection.cc +++ b/google/cloud/spanner/connection.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/connection.h" #include "google/cloud/spanner/query_partition.h" @@ -115,3 +116,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/integration_tests/client_integration_test.cc b/google/cloud/spanner/integration_tests/client_integration_test.cc index eaa1a258860ee..1b5757949ce8d 100644 --- a/google/cloud/spanner/integration_tests/client_integration_test.cc +++ b/google/cloud/spanner/integration_tests/client_integration_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/client.h" @@ -1769,3 +1770,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/integration_tests/client_stress_test.cc b/google/cloud/spanner/integration_tests/client_stress_test.cc index 472b71ec3432d..1e8d451438ce1 100644 --- a/google/cloud/spanner/integration_tests/client_stress_test.cc +++ b/google/cloud/spanner/integration_tests/client_stress_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/client.h" #include "google/cloud/spanner/database.h" @@ -302,3 +303,4 @@ int main(int argc, char* argv[]) { return RUN_ALL_TESTS(); } +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/integration_tests/data_types_integration_test.cc b/google/cloud/spanner/integration_tests/data_types_integration_test.cc index 0245dfa1a9e69..6e171b3284eb5 100644 --- a/google/cloud/spanner/integration_tests/data_types_integration_test.cc +++ b/google/cloud/spanner/integration_tests/data_types_integration_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/client.h" @@ -1003,3 +1004,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/integration_tests/session_pool_integration_test.cc b/google/cloud/spanner/integration_tests/session_pool_integration_test.cc index 08e6ba6274d2f..c102054f8500e 100644 --- a/google/cloud/spanner/integration_tests/session_pool_integration_test.cc +++ b/google/cloud/spanner/integration_tests/session_pool_integration_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/internal/defaults.h" #include "google/cloud/spanner/internal/session_pool.h" @@ -124,3 +125,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/internal/connection_impl.cc b/google/cloud/spanner/internal/connection_impl.cc index f137fcd2ca1ef..52e738e2e7c8c 100644 --- a/google/cloud/spanner/internal/connection_impl.cc +++ b/google/cloud/spanner/internal/connection_impl.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/internal/connection_impl.h" #include "google/cloud/spanner/internal/defaults.h" @@ -1446,3 +1447,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/internal/connection_impl_test.cc b/google/cloud/spanner/internal/connection_impl_test.cc index e01ae824baea3..ac4be4a20a381 100644 --- a/google/cloud/spanner/internal/connection_impl_test.cc +++ b/google/cloud/spanner/internal/connection_impl_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/internal/connection_impl.h" #include "google/cloud/spanner/client.h" @@ -286,7 +287,7 @@ google::spanner::v1::Transaction MakeTestTransaction( *txn.mutable_precommit_token() = token; return txn; } - +#if 0 // Create a `BatchCreateSessionsResponse` with the given `sessions`. google::spanner::v1::BatchCreateSessionsResponse MakeSessionsResponse( std::vector sessions) { @@ -296,7 +297,7 @@ google::spanner::v1::BatchCreateSessionsResponse MakeSessionsResponse( } return response; } - +#endif // Create a `CommitResponse` with the given `commit_timestamp` and // `commit_stats`. google::spanner::v1::CommitResponse MakeCommitResponse( @@ -409,14 +410,18 @@ TEST(ConnectionImplTest, ReadCreateSessionFailure) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .Times(AtLeast(2)) - .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - "uh-oh in BatchCreateSessions"))); - EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); + + // EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) + // .WillRepeatedly(Return( + // Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); + // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) + // .Times(AtLeast(2)) + // .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, + // "uh-oh in BatchCreateSessions"))); + // EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -427,7 +432,7 @@ TEST(ConnectionImplTest, ReadCreateSessionFailure) { {"column1"}}); for (auto& row : rows) { EXPECT_THAT(row, StatusIs(StatusCode::kPermissionDenied, - HasSubstr("uh-oh in BatchCreateSessions"))); + HasSubstr("uh-oh in CreateSession"))); } } @@ -435,16 +440,16 @@ TEST(ConnectionImplTest, ReadStreamingReadFailure) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto finish_status = internal::PermissionDeniedError("uh-oh in GrpcReader::Finish"); EXPECT_CALL(*mock, StreamingRead) .WillOnce( Return(ByMove(MakeReader({}, finish_status)))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -463,8 +468,8 @@ TEST(ConnectionImplTest, ReadSuccess) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto retry_status = internal::UnavailableError("try-again"); std::vector responses = { R"pb( @@ -527,9 +532,9 @@ TEST(ConnectionImplTest, ReadSuccess) { EXPECT_THAT(request.resume_token(), Eq("restart-row-2")); return MakeReader({responses[1], responses[2]}); }); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -553,13 +558,13 @@ TEST(ConnectionImplTest, ReadDirectedRead) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction).Times(0); EXPECT_CALL(*mock, StreamingRead) .WillOnce([](std::shared_ptr const&, Options const&, google::spanner::v1::ReadRequest const& request) { - EXPECT_EQ("test-session-name", request.session()); + EXPECT_EQ("multiplexed", request.session()); EXPECT_TRUE(request.has_directed_read_options()); auto const& directed_read_options = request.directed_read_options(); EXPECT_TRUE(directed_read_options.has_include_replicas()); @@ -572,9 +577,9 @@ TEST(ConnectionImplTest, ReadDirectedRead) { return MakeReader( {R"pb(metadata: { transaction: { id: "ABCDEF00" } })pb"}); }); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -593,22 +598,22 @@ TEST(ConnectionImplTest, ReadDirectedRead) { spanner::ReplicaSelection(spanner::ReplicaType::kReadOnly)}, true)}); EXPECT_TRUE(ContainsNoRows(rows)); - EXPECT_THAT(txn, HasSessionAndTransaction("test-session-name", "ABCDEF00", - false, "")); + EXPECT_THAT(txn, + HasSessionAndTransaction("multiplexed", "ABCDEF00", false, "")); } TEST(ConnectionImplTest, ReadPermanentFailure) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, StreamingRead) .WillOnce(Return(ByMove(MakeReader( {}, internal::PermissionDeniedError("uh-oh"))))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -627,8 +632,8 @@ TEST(ConnectionImplTest, ReadTooManyTransientFailures) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, StreamingRead) .Times(AtLeast(2)) // This won't compile without `Unused` despite what the gMock docs say. @@ -636,9 +641,9 @@ TEST(ConnectionImplTest, ReadTooManyTransientFailures) { return MakeReader( {}, internal::UnavailableError("try-again")); }); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -658,17 +663,19 @@ TEST(ConnectionImplTest, ReadImplicitBeginTransaction) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); + // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) + // .WillOnce(Return(MakeSessionsResponse({"multiplexed"}))); EXPECT_CALL(*mock, BeginTransaction).Times(0); auto constexpr kText = R"pb( metadata: { transaction: { id: "ABCDEF00" } } )pb"; EXPECT_CALL(*mock, StreamingRead) .WillOnce(Return(ByMove(MakeReader({kText})))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -677,8 +684,8 @@ TEST(ConnectionImplTest, ReadImplicitBeginTransaction) { auto rows = conn->Read( {txn, "table", spanner::KeySet::All(), {"UserId", "UserName"}}); EXPECT_TRUE(ContainsNoRows(rows)); - EXPECT_THAT(txn, HasSessionAndTransaction("test-session-name", "ABCDEF00", - false, "")); + EXPECT_THAT(txn, + HasSessionAndTransaction("multiplexed", "ABCDEF00", false, "")); } TEST(ConnectionImplTest, ReadImplicitBeginTransactionOneTransientFailure) { @@ -711,23 +718,23 @@ TEST(ConnectionImplTest, ReadImplicitBeginTransactionOneTransientFailure) { // n.b. these calls are explicitly sequenced because using the scoped // `InSequence` object causes gMock to get confused by the reader calls. Sequence s; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .InSequence(s) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); - EXPECT_CALL(*mock, StreamingRead(_, _, - AllOf(HasSession("test-session-name"), - HasBeginTransaction()))) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); + EXPECT_CALL( + *mock, StreamingRead( + _, _, AllOf(HasSession("multiplexed"), HasBeginTransaction()))) .InSequence(s) .WillOnce(Return(ByMove(std::move(failing_reader)))); - EXPECT_CALL(*mock, StreamingRead(_, _, - AllOf(HasSession("test-session-name"), - HasBeginTransaction()))) + EXPECT_CALL( + *mock, StreamingRead( + _, _, AllOf(HasSession("multiplexed"), HasBeginTransaction()))) .InSequence(s) .WillOnce(Return(ByMove(std::move(ok_reader)))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .InSequence(s) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .InSequence(s) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -741,8 +748,8 @@ TEST(ConnectionImplTest, ReadImplicitBeginTransactionOneTransientFailure) { auto actual = std::vector>{stream.begin(), stream.end()}; EXPECT_THAT(actual, ElementsAre(IsOkAndHolds(RowType(12, "Steve")), IsOkAndHolds(RowType(42, "Ann")))); - EXPECT_THAT(txn, HasSessionAndTransaction("test-session-name", "ABCDEF00", - false, "")); + EXPECT_THAT(txn, + HasSessionAndTransaction("multiplexed", "ABCDEF00", false, "")); } TEST(ConnectionImplTest, ReadImplicitBeginTransactionOnePermanentFailure) { @@ -774,26 +781,26 @@ TEST(ConnectionImplTest, ReadImplicitBeginTransactionOnePermanentFailure) { // n.b. these calls are explicitly sequenced because using the scoped // `InSequence` object causes gMock to get confused by the reader calls. Sequence s; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .InSequence(s) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); - EXPECT_CALL(*mock, StreamingRead(_, _, - AllOf(HasSession("test-session-name"), - HasBeginTransaction()))) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); + EXPECT_CALL( + *mock, StreamingRead( + _, _, AllOf(HasSession("multiplexed"), HasBeginTransaction()))) .InSequence(s) .WillOnce(Return(ByMove(std::move(failing_reader)))); EXPECT_CALL(*mock, BeginTransaction) .InSequence(s) .WillOnce(Return(MakeTestTransaction("FEDCBA98"))); EXPECT_CALL(*mock, StreamingRead(_, _, - AllOf(HasSession("test-session-name"), + AllOf(HasSession("multiplexed"), HasTransactionId("FEDCBA98")))) .InSequence(s) .WillOnce(Return(ByMove(std::move(ok_reader)))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .InSequence(s) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .InSequence(s) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -807,8 +814,8 @@ TEST(ConnectionImplTest, ReadImplicitBeginTransactionOnePermanentFailure) { auto actual = std::vector>{stream.begin(), stream.end()}; EXPECT_THAT(actual, ElementsAre(IsOkAndHolds(RowType(12, "Steve")), IsOkAndHolds(RowType(42, "Ann")))); - EXPECT_THAT(txn, HasSessionAndTransaction("test-session-name", "FEDCBA98", - false, "")); + EXPECT_THAT(txn, + HasSessionAndTransaction("multiplexed", "FEDCBA98", false, "")); } TEST(ConnectionImplTest, ReadImplicitBeginTransactionPermanentFailure) { @@ -822,26 +829,26 @@ TEST(ConnectionImplTest, ReadImplicitBeginTransactionPermanentFailure) { // n.b. these calls are explicitly sequenced because using the scoped // `InSequence` object causes gMock to get confused by the reader calls. Sequence s; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .InSequence(s) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); - EXPECT_CALL(*mock, StreamingRead(_, _, - AllOf(HasSession("test-session-name"), - HasBeginTransaction()))) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); + EXPECT_CALL( + *mock, StreamingRead( + _, _, AllOf(HasSession("multiplexed"), HasBeginTransaction()))) .InSequence(s) .WillOnce(Return(ByMove(std::move(reader1)))); EXPECT_CALL(*mock, BeginTransaction) .InSequence(s) .WillOnce(Return(MakeTestTransaction("FEDCBA98"))); EXPECT_CALL(*mock, StreamingRead(_, _, - AllOf(HasSession("test-session-name"), + AllOf(HasSession("multiplexed"), HasTransactionId("FEDCBA98")))) .InSequence(s) .WillOnce(Return(ByMove(std::move(reader2)))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .InSequence(s) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .InSequence(s) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -859,13 +866,10 @@ TEST(ConnectionImplTest, ExecuteQueryCreateSessionFailure) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .Times(AtLeast(2)) - .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - "uh-oh in BatchCreateSessions"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillRepeatedly(Return( + Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -874,7 +878,7 @@ TEST(ConnectionImplTest, ExecuteQueryCreateSessionFailure) { spanner::SqlStatement("SELECT * FROM Table")}); for (auto& row : rows) { EXPECT_THAT(row, StatusIs(StatusCode::kPermissionDenied, - HasSubstr("uh-oh in BatchCreateSessions"))); + HasSubstr("uh-oh in CreateSession"))); } } @@ -882,15 +886,15 @@ TEST(ConnectionImplTest, ExecuteQueryStreamingReadFailure) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce(Return(ByMove(MakeReader( {}, internal::PermissionDeniedError("uh-oh in GrpcReader::Finish"))))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -907,8 +911,8 @@ TEST(ConnectionImplTest, ExecuteQueryReadSuccess) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto constexpr kText = R"pb( metadata: { row_type: { @@ -935,9 +939,9 @@ TEST(ConnectionImplTest, ExecuteQueryReadSuccess) { )pb"; EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce(Return(ByMove(MakeReader({kText})))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -960,13 +964,13 @@ TEST(ConnectionImplTest, ExecuteQueryDirectedRead) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction).Times(0); EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce([](std::shared_ptr const&, Options const&, google::spanner::v1::ExecuteSqlRequest const& request) { - EXPECT_EQ("test-session-name", request.session()); + EXPECT_EQ("multiplexed", request.session()); EXPECT_TRUE(request.has_directed_read_options()); auto const& directed_read_options = request.directed_read_options(); EXPECT_TRUE(directed_read_options.has_exclude_replicas()); @@ -979,9 +983,9 @@ TEST(ConnectionImplTest, ExecuteQueryDirectedRead) { return MakeReader( {R"pb(metadata: { transaction: { id: "00FEDCBA" } })pb"}); }); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -996,16 +1000,16 @@ TEST(ConnectionImplTest, ExecuteQueryDirectedRead) { {spanner::ReplicaSelection(spanner::ReplicaType::kReadWrite), spanner::ReplicaSelection("us-east4")})}); EXPECT_TRUE(ContainsNoRows(rows)); - EXPECT_THAT(txn, HasSessionAndTransaction("test-session-name", "00FEDCBA", - false, "")); + EXPECT_THAT(txn, + HasSessionAndTransaction("multiplexed", "00FEDCBA", false, "")); } TEST(ConnectionImplTest, ExecuteQueryPgNumericResult) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto constexpr kText = R"pb( metadata: { row_type: { @@ -1026,9 +1030,9 @@ TEST(ConnectionImplTest, ExecuteQueryPgNumericResult) { )pb"; EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce(Return(ByMove(MakeReader({kText})))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1053,8 +1057,8 @@ TEST(ConnectionImplTest, ExecuteQueryJsonBResult) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto constexpr kText = R"pb( metadata: { row_type: { @@ -1075,9 +1079,9 @@ TEST(ConnectionImplTest, ExecuteQueryJsonBResult) { )pb"; EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce(Return(ByMove(MakeReader({kText})))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1100,8 +1104,8 @@ TEST(ConnectionImplTest, ExecuteQueryNumericParameter) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto constexpr kResponseNumeric = R"pb( metadata: { row_type: { @@ -1153,9 +1157,9 @@ TEST(ConnectionImplTest, ExecuteQueryNumericParameter) { google::spanner::v1::TypeAnnotationCode::PG_NUMERIC); return MakeReader({kResponsePgNumeric}); }); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1186,8 +1190,8 @@ TEST(ConnectionImplTest, ExecuteQueryPgOidResult) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto constexpr kText = R"pb( metadata: { row_type: { @@ -1208,9 +1212,9 @@ TEST(ConnectionImplTest, ExecuteQueryPgOidResult) { )pb"; EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce(Return(ByMove(MakeReader({kText})))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1233,17 +1237,17 @@ TEST(ConnectionImplTest, ExecuteQueryImplicitBeginTransaction) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction).Times(0); auto constexpr kText = R"pb( metadata: { transaction: { id: "00FEDCBA" } } )pb"; EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce(Return(ByMove(MakeReader({kText})))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1252,8 +1256,8 @@ TEST(ConnectionImplTest, ExecuteQueryImplicitBeginTransaction) { auto rows = conn->ExecuteQuery({txn, spanner::SqlStatement("SELECT * FROM Table")}); EXPECT_TRUE(ContainsNoRows(rows)); - EXPECT_THAT(txn, HasSessionAndTransaction("test-session-name", "00FEDCBA", - false, "")); + EXPECT_THAT(txn, + HasSessionAndTransaction("multiplexed", "00FEDCBA", false, "")); } /** @@ -1261,6 +1265,9 @@ TEST(ConnectionImplTest, ExecuteQueryImplicitBeginTransaction) { * by QueryOptions contain the expected fields. */ TEST(ConnectionImplTest, QueryOptions) { + // TODO(#15927): Update the instrumentation of this test for multiplexed + // sessions. + GTEST_SKIP(); struct { // Given these QueryOptions ... spanner::QueryOptions options; @@ -1452,8 +1459,8 @@ TEST(ConnectionImplTest, QueryOptions) { .Build())); // ExecuteQuery(). - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))) + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))) .RetiresOnSaturation(); EXPECT_CALL(*mock, ExecuteStreamingSql(_, _, execute_sql_request_matcher)) .WillOnce(Return(ByMove(std::move(stream)))) @@ -1467,8 +1474,8 @@ TEST(ConnectionImplTest, QueryOptions) { .RetiresOnSaturation(); // ExecutePartitionedDml(). - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))) + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))) .RetiresOnSaturation(); EXPECT_CALL(*mock, BeginTransaction(_, _, begin_transaction_request_matcher)) @@ -1504,10 +1511,11 @@ TEST(ConnectionImplTest, QueryOptions) { .Times(1) .RetiresOnSaturation(); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))) - .RetiresOnSaturation(); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))) + // .RetiresOnSaturation(); } auto conn = MakeConnectionImpl(db, mock); @@ -1531,11 +1539,11 @@ TEST(ConnectionImplTest, ExecuteDmlCreateSessionFailure) { EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .Times(AtLeast(2)) - .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - "uh-oh in BatchCreateSessions"))); - EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); + // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) + // .Times(AtLeast(2)) + // .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, + // "uh-oh in BatchCreateSessions"))); + // EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1545,15 +1553,15 @@ TEST(ConnectionImplTest, ExecuteDmlCreateSessionFailure) { conn->ExecuteDml({txn, spanner::SqlStatement("DELETE * FROM Table")}); EXPECT_THAT(result, StatusIs(StatusCode::kPermissionDenied, - HasSubstr("uh-oh in BatchCreateSessions"))); + HasSubstr("uh-oh in CreateSession"))); } TEST(ConnectionImplTest, ExecuteDmlDeleteSuccess) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto constexpr kText = R"pb( metadata: { transaction: { id: "1234567890" } } stats: { row_count_exact: 42 } @@ -1563,9 +1571,9 @@ TEST(ConnectionImplTest, ExecuteDmlDeleteSuccess) { EXPECT_CALL(*mock, ExecuteSql) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(response)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1584,16 +1592,16 @@ TEST(ConnectionImplTest, ExecuteDmlDeletePermanentFailure) { "placeholder_database_id"); { InSequence seq; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); Status status(StatusCode::kPermissionDenied, "uh-oh in ExecuteDml"); EXPECT_CALL(*mock, ExecuteSql).WillOnce(Return(status)); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction())); EXPECT_CALL(*mock, ExecuteSql).WillOnce(Return(status)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); } auto conn = MakeConnectionImpl(db, mock); @@ -1612,8 +1620,8 @@ TEST(ConnectionImplTest, ExecuteDmlDeleteTooManyTransientFailures) { "placeholder_database_id"); { InSequence seq; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); Status status(StatusCode::kUnavailable, "try-again in ExecuteDml"); EXPECT_CALL(*mock, ExecuteSql) .Times(AtLeast(2)) @@ -1623,9 +1631,9 @@ TEST(ConnectionImplTest, ExecuteDmlDeleteTooManyTransientFailures) { EXPECT_CALL(*mock, ExecuteSql) .Times(AtLeast(2)) .WillRepeatedly(Return(status)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); } auto conn = MakeConnectionImpl(db, mock); @@ -1648,8 +1656,8 @@ TEST(ConnectionImplTest, ExecuteDmlTransactionAtomicity) { Status begin_status(StatusCode::kInvalidArgument, "BeginTransaction status"); { InSequence seq; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); // The first `ExecuteDml` call tries to implicitly begin the transaction // via `ExecuteSql`, and then explicitly via `BeginTransaction`. Both fail, @@ -1658,9 +1666,9 @@ TEST(ConnectionImplTest, ExecuteDmlTransactionAtomicity) { EXPECT_CALL(*mock, ExecuteSql).WillOnce(Return(op_status)); EXPECT_CALL(*mock, BeginTransaction).WillOnce(Return(begin_status)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); } auto conn = MakeConnectionImpl(db, mock); @@ -1683,17 +1691,17 @@ TEST(ConnectionImplTest, ExecuteDmlTransactionMissing) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); // Return an otherwise valid response that does not contain a transaction. google::spanner::v1::ResultSet response; ASSERT_TRUE(TextFormat::ParseFromString("metadata: {}", &response)); EXPECT_CALL(*mock, ExecuteSql).WillOnce(Return(response)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1710,8 +1718,8 @@ TEST(ConnectionImplTest, ProfileQuerySuccess) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto constexpr kText = R"pb( metadata: { row_type: { @@ -1741,9 +1749,9 @@ TEST(ConnectionImplTest, ProfileQuerySuccess) { )pb"; EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce(Return(ByMove(MakeReader({kText})))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1780,10 +1788,10 @@ TEST(ConnectionImplTest, ProfileQueryCreateSessionFailure) { EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .Times(AtLeast(2)) - .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - "uh-oh in BatchCreateSessions"))); + // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) + // .Times(AtLeast(2)) + // .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, + // "uh-oh in BatchCreateSessions"))); EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); auto conn = MakeConnectionImpl(db, mock); @@ -1793,7 +1801,7 @@ TEST(ConnectionImplTest, ProfileQueryCreateSessionFailure) { spanner::SqlStatement("SELECT * FROM Table")}); for (auto& row : result) { EXPECT_THAT(row, StatusIs(StatusCode::kPermissionDenied, - HasSubstr("uh-oh in BatchCreateSessions"))); + HasSubstr("uh-oh in CreateSession"))); } } @@ -1801,16 +1809,16 @@ TEST(ConnectionImplTest, ProfileQueryStreamingReadFailure) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto finish_status = internal::PermissionDeniedError("uh-oh in GrpcReader::Finish"); EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce( Return(ByMove(MakeReader({}, finish_status)))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1830,10 +1838,10 @@ TEST(ConnectionImplTest, ProfileDmlCreateSessionFailure) { EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .Times(AtLeast(2)) - .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - "uh-oh in BatchCreateSessions"))); + // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) + // .Times(AtLeast(2)) + // .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, + // "uh-oh in BatchCreateSessions"))); EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); auto conn = MakeConnectionImpl(db, mock); @@ -1843,15 +1851,15 @@ TEST(ConnectionImplTest, ProfileDmlCreateSessionFailure) { auto result = conn->ProfileDml({txn, spanner::SqlStatement("DELETE * FROM Table")}); EXPECT_THAT(result, StatusIs(StatusCode::kPermissionDenied, - HasSubstr("uh-oh in BatchCreateSessions"))); + HasSubstr("uh-oh in CreateSession"))); } TEST(ConnectionImplTest, ProfileDmlDeleteSuccess) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto constexpr kText = R"pb( metadata: { transaction: { id: "1234567890" } } stats: { @@ -1870,9 +1878,9 @@ TEST(ConnectionImplTest, ProfileDmlDeleteSuccess) { EXPECT_CALL(*mock, ExecuteSql) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(response)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1906,16 +1914,16 @@ TEST(ConnectionImplTest, ProfileDmlDeletePermanentFailure) { "placeholder_database_id"); { InSequence seq; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); Status status(StatusCode::kPermissionDenied, "uh-oh in ExecuteDml"); EXPECT_CALL(*mock, ExecuteSql).WillOnce(Return(status)); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction())); EXPECT_CALL(*mock, ExecuteSql).WillOnce(Return(status)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); } auto conn = MakeConnectionImpl(db, mock); @@ -1934,8 +1942,8 @@ TEST(ConnectionImplTest, ProfileDmlDeleteTooManyTransientFailures) { "placeholder_database_id"); { InSequence seq; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); Status status(StatusCode::kUnavailable, "try-again in ExecuteDml"); EXPECT_CALL(*mock, ExecuteSql) .Times(AtLeast(2)) @@ -1945,9 +1953,9 @@ TEST(ConnectionImplTest, ProfileDmlDeleteTooManyTransientFailures) { EXPECT_CALL(*mock, ExecuteSql) .Times(AtLeast(2)) .WillRepeatedly(Return(status)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); } auto conn = MakeConnectionImpl(db, mock); @@ -1965,8 +1973,8 @@ TEST(ConnectionImplTest, AnalyzeSqlSuccess) { auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto constexpr kText = R"pb( metadata: {} stats: { query_plan { plan_nodes: { index: 42 } } } @@ -1976,9 +1984,9 @@ TEST(ConnectionImplTest, AnalyzeSqlSuccess) { EXPECT_CALL(*mock, ExecuteSql) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(ByMove(std::move(response)))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2002,11 +2010,11 @@ TEST(ConnectionImplTest, AnalyzeSqlCreateSessionFailure) { EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .Times(AtLeast(2)) - .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - "uh-oh in BatchCreateSessions"))); - EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); + // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) + // .Times(AtLeast(2)) + // .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, + // "uh-oh in BatchCreateSessions"))); + // EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2015,7 +2023,7 @@ TEST(ConnectionImplTest, AnalyzeSqlCreateSessionFailure) { auto result = conn->AnalyzeSql({txn, spanner::SqlStatement("DELETE * FROM Table")}); EXPECT_THAT(result, StatusIs(StatusCode::kPermissionDenied, - HasSubstr("uh-oh in BatchCreateSessions"))); + HasSubstr("uh-oh in CreateSession"))); } TEST(ConnectionImplTest, AnalyzeSqlDeletePermanentFailure) { @@ -2024,16 +2032,16 @@ TEST(ConnectionImplTest, AnalyzeSqlDeletePermanentFailure) { "placeholder_database_id"); { InSequence seq; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); Status status(StatusCode::kPermissionDenied, "uh-oh in ExecuteDml"); EXPECT_CALL(*mock, ExecuteSql).WillOnce(Return(status)); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction())); EXPECT_CALL(*mock, ExecuteSql).WillOnce(Return(status)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); } auto conn = MakeConnectionImpl(db, mock); @@ -2052,8 +2060,8 @@ TEST(ConnectionImplTest, AnalyzeSqlDeleteTooManyTransientFailures) { "placeholder_database_id"); { InSequence seq; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); Status status(StatusCode::kUnavailable, "try-again in ExecuteDml"); EXPECT_CALL(*mock, ExecuteSql) .Times(AtLeast(2)) @@ -2063,9 +2071,9 @@ TEST(ConnectionImplTest, AnalyzeSqlDeleteTooManyTransientFailures) { EXPECT_CALL(*mock, ExecuteSql) .Times(AtLeast(2)) .WillRepeatedly(Return(status)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); } auto conn = MakeConnectionImpl(db, mock); @@ -2082,8 +2090,8 @@ TEST(ConnectionImplTest, ExecuteBatchDmlSuccess) { auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); auto mock = std::make_shared(); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto constexpr kText = R"pb( result_sets: { metadata: { transaction: { id: "1234567890" } } @@ -2101,9 +2109,6 @@ TEST(ConnectionImplTest, ExecuteBatchDmlSuccess) { HasPriority(google::spanner::v1::RequestOptions::PRIORITY_MEDIUM))) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(response)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); auto request = { spanner::SqlStatement("UPDATE ..."), @@ -2127,7 +2132,7 @@ TEST(ConnectionImplTest, ExecuteBatchDmlSuccess) { EXPECT_EQ(result->stats[1].row_count, 1); EXPECT_EQ(result->stats[2].row_count, 2); EXPECT_THAT( - txn, HasSessionAndTransaction("session-name", "1234567890", true, "tag")); + txn, HasSessionAndTransaction("multiplexed", "1234567890", true, "tag")); } TEST(ConnectionImplTest, MultiplexedExecuteBatchDmlSuccess) { @@ -2173,7 +2178,8 @@ TEST(ConnectionImplTest, MultiplexedExecuteBatchDmlSuccess) { spanner::SqlStatement("UPDATE ..."), }; - auto options = Options{}.set({}); + auto options = Options{}; + // .set({}); auto conn = MakeConnectionImpl(db, mock, options); internal::OptionsSpan span(MakeLimitedTimeOptions()); auto txn = spanner::MakeReadWriteTransaction( @@ -2199,8 +2205,8 @@ TEST(ConnectionImplTest, ExecuteBatchDmlPartialFailure) { auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); auto mock = std::make_shared(); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto constexpr kText = R"pb( result_sets: { metadata: { transaction: { id: "1234567890" } } @@ -2212,9 +2218,9 @@ TEST(ConnectionImplTest, ExecuteBatchDmlPartialFailure) { google::spanner::v1::ExecuteBatchDmlResponse response; ASSERT_TRUE(TextFormat::ParseFromString(kText, &response)); EXPECT_CALL(*mock, ExecuteBatchDml).WillOnce(Return(response)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto request = { spanner::SqlStatement("UPDATE ..."), @@ -2234,7 +2240,7 @@ TEST(ConnectionImplTest, ExecuteBatchDmlPartialFailure) { EXPECT_EQ(result->stats[0].row_count, 42); EXPECT_EQ(result->stats[1].row_count, 43); EXPECT_THAT( - txn, HasSessionAndTransaction("session-name", "1234567890", true, "tag")); + txn, HasSessionAndTransaction("multiplexed", "1234567890", true, "tag")); } TEST(ConnectionImplTest, ExecuteBatchDmlPermanentFailure) { @@ -2243,17 +2249,17 @@ TEST(ConnectionImplTest, ExecuteBatchDmlPermanentFailure) { auto mock = std::make_shared(); { InSequence seq; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); Status status(StatusCode::kPermissionDenied, "uh-oh in ExecuteBatchDml"); EXPECT_CALL(*mock, ExecuteBatchDml).WillOnce(Return(status)); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction())); EXPECT_CALL(*mock, ExecuteBatchDml).WillOnce(Return(status)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); } auto request = { @@ -2276,8 +2282,8 @@ TEST(ConnectionImplTest, ExecuteBatchDmlTooManyTransientFailures) { auto mock = std::make_shared(); { InSequence seq; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); Status status(StatusCode::kUnavailable, "try-again in ExecuteBatchDml"); EXPECT_CALL(*mock, ExecuteBatchDml) @@ -2289,9 +2295,9 @@ TEST(ConnectionImplTest, ExecuteBatchDmlTooManyTransientFailures) { .Times(AtLeast(2)) .WillRepeatedly(Return(status)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); } auto request = { @@ -2314,8 +2320,8 @@ TEST(ConnectionImplTest, ExecuteBatchDmlNoResultSets) { auto mock = std::make_shared(); { InSequence seq; - EXPECT_CALL(*mock, BatchCreateSessions) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); // The `ExecuteBatchDml` call can succeed, but with no `ResultSet`s and an // error status in the response. auto constexpr kText = R"pb( @@ -2324,18 +2330,18 @@ TEST(ConnectionImplTest, ExecuteBatchDmlNoResultSets) { google::spanner::v1::ExecuteBatchDmlResponse response; ASSERT_TRUE(TextFormat::ParseFromString(kText, &response)); EXPECT_CALL(*mock, ExecuteBatchDml(_, _, - AllOf(HasSession("session-name"), + AllOf(HasSession("multiplexed"), HasBeginTransaction()))) .WillOnce(Return(response)); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction("BD000001"))); EXPECT_CALL(*mock, ExecuteBatchDml(_, _, - AllOf(HasSession("session-name"), + AllOf(HasSession("multiplexed"), HasTransactionId("BD000001")))) .WillOnce(Return(response)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); } auto request = {spanner::SqlStatement("UPDATE ...")}; @@ -2353,8 +2359,8 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlDeleteSuccess) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce( @@ -2375,9 +2381,9 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlDeleteSuccess) { {}, internal::UnavailableError("try-again in ExecutePartitionedDml"))))) .WillOnce(Return(ByMove(MakeReader({kTextResponse})))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2392,8 +2398,8 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlExcludeFromChangeStreams) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction) .WillOnce( [](grpc::ClientContext&, Options const&, @@ -2410,9 +2416,9 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlExcludeFromChangeStreams) { ExecuteStreamingSql( _, _, AllOf(HasRequestTag("tag"), HasTransactionTag("")))) .WillOnce(Return(ByMove(MakeReader({kTextResponse})))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span( @@ -2432,26 +2438,26 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlCreateSessionFailure) { EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .Times(AtLeast(2)) - .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - "uh-oh in BatchCreateSessions"))); - EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); + // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) + // .Times(AtLeast(2)) + // .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, + // "uh-oh in BatchCreateSessions"))); + // EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); auto result = conn->ExecutePartitionedDml( {spanner::SqlStatement("DELETE * FROM Table")}); EXPECT_THAT(result, StatusIs(StatusCode::kPermissionDenied, - HasSubstr("uh-oh in BatchCreateSessions"))); + HasSubstr("uh-oh in CreateSession"))); } TEST(ConnectionImplTest, ExecutePartitionedDmlDeletePermanentFailure) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(MakeTestTransaction())); @@ -2462,9 +2468,9 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlDeletePermanentFailure) { .WillOnce(Return(ByMove(MakeReader( {}, internal::InternalError("permanent failure"))))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2478,8 +2484,8 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlDeleteTooManyTransientFailures) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(MakeTestTransaction())); @@ -2491,9 +2497,9 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlDeleteTooManyTransientFailures) { {}, internal::UnavailableError("try-again in ExecutePartitionedDml")); }); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2508,8 +2514,8 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlRetryableInternalErrors) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction("2345678901"))); @@ -2529,9 +2535,9 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlRetryableInternalErrors) { "HTTP/2 error code: INTERNAL_ERROR\nReceived Rst Stream"))))) .WillOnce(Return(ByMove(MakeReader({kTextResponse})))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2546,14 +2552,14 @@ TEST(ConnectionImplTest, auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh in ExecutePartitionedDml"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2568,15 +2574,15 @@ TEST(ConnectionImplTest, auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction) .Times(AtLeast(2)) .WillRepeatedly(Return(Status(StatusCode::kUnavailable, "try-again in ExecutePartitionedDml"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2594,56 +2600,56 @@ TEST(ConnectionImplTest, CommitCreateSessionPermanentFailure) { EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .Times(AtLeast(2)) - .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - "uh-oh in BatchCreateSessions"))); EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); auto commit = conn->Commit({spanner::MakeReadWriteTransaction()}); EXPECT_THAT(commit, StatusIs(StatusCode::kPermissionDenied, - HasSubstr("uh-oh in BatchCreateSessions"))); + HasSubstr("uh-oh in CreateSession"))); } TEST(ConnectionImplTest, CommitCreateSessionTooManyTransientFailures) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .Times(AtLeast(2)) - .WillRepeatedly(Return(Status(StatusCode::kUnavailable, - "try-again in BatchCreateSessions"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + .WillRepeatedly(Return( + Status(StatusCode::kUnavailable, "try-again in CreateSession"))); + + // + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); auto commit = conn->Commit({spanner::MakeReadWriteTransaction()}); EXPECT_THAT(commit, StatusIs(StatusCode::kUnavailable, - HasSubstr("try-again in BatchCreateSessions"))); + HasSubstr("try-again in CreateSession"))); } TEST(ConnectionImplTest, CommitCreateSessionRetry) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .WillOnce(Return( - Status(StatusCode::kUnavailable, "try-again in BatchCreateSessions"))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + Status(StatusCode::kUnavailable, "try-again in CreateSession"))) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); + google::spanner::v1::Transaction txn = MakeTestTransaction(); EXPECT_CALL(*mock, BeginTransaction).WillOnce(Return(txn)); EXPECT_CALL(*mock, Commit(_, _, - AllOf(HasSession("test-session-name"), + AllOf(HasSession("multiplexed"), HasNakedTransactionId(txn.id())))) .WillOnce( Return(Status(StatusCode::kPermissionDenied, "uh-oh in Commit"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2656,8 +2662,8 @@ TEST(ConnectionImplTest, CommitBeginTransactionRetry) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); google::spanner::v1::Transaction txn = MakeTestTransaction(); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) @@ -2666,12 +2672,12 @@ TEST(ConnectionImplTest, CommitBeginTransactionRetry) { spanner::MakeTimestamp(std::chrono::system_clock::from_time_t(123)) .value(); EXPECT_CALL(*mock, Commit(_, _, - AllOf(HasSession("test-session-name"), + AllOf(HasSession("multiplexed"), HasNakedTransactionId(txn.id())))) .WillOnce(Return(MakeCommitResponse(commit_timestamp))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2684,13 +2690,14 @@ TEST(ConnectionImplTest, CommitBeginTransactionSessionNotFound) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction) - .WillOnce(Return(SessionNotFoundError("test-session-name"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + .WillOnce(Return(SessionNotFoundError("multiplexed"))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2706,14 +2713,14 @@ TEST(ConnectionImplTest, CommitBeginTransactionPermanentFailure) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return( Status(StatusCode::kInvalidArgument, "BeginTransaction failed"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2733,18 +2740,18 @@ TEST(ConnectionImplTest, CommitCommitPermanentFailure) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); google::spanner::v1::Transaction txn = MakeTestTransaction(); EXPECT_CALL(*mock, BeginTransaction).WillOnce(Return(txn)); EXPECT_CALL(*mock, Commit(_, _, - AllOf(HasSession("test-session-name"), + AllOf(HasSession("multiplexed"), HasNakedTransactionId(txn.id())))) .WillOnce( Return(Status(StatusCode::kPermissionDenied, "uh-oh in Commit"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2757,18 +2764,18 @@ TEST(ConnectionImplTest, CommitCommitTooManyTransientFailures) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); google::spanner::v1::Transaction txn = MakeTestTransaction(); EXPECT_CALL(*mock, BeginTransaction).WillOnce(Return(txn)); EXPECT_CALL(*mock, Commit(_, _, - AllOf(HasSession("test-session-name"), + AllOf(HasSession("multiplexed"), HasNakedTransactionId(txn.id())))) .WillOnce( Return(Status(StatusCode::kPermissionDenied, "uh-oh in Commit"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2781,13 +2788,13 @@ TEST(ConnectionImplTest, CommitCommitInvalidatedTransaction) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction).Times(0); EXPECT_CALL(*mock, Commit).Times(0); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2806,19 +2813,19 @@ TEST(ConnectionImplTest, CommitCommitIdempotentTransientSuccess) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto const commit_timestamp = spanner::MakeTimestamp(std::chrono::system_clock::from_time_t(123)) .value(); EXPECT_CALL(*mock, Commit(_, _, - AllOf(HasSession("test-session-name"), + AllOf(HasSession("multiplexed"), HasNakedTransactionId("test-txn-id")))) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(MakeCommitResponse(commit_timestamp))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2836,21 +2843,21 @@ TEST(ConnectionImplTest, CommitSuccessWithTransactionId) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL( *mock, - Commit(_, _, - AllOf(HasSession("test-session-name"), - HasNakedTransactionId("test-txn-id"), - HasPriority( - google::spanner::v1::RequestOptions::PRIORITY_HIGH)))) + Commit( + _, _, + AllOf( + HasSession("multiplexed"), HasNakedTransactionId("test-txn-id"), + HasPriority(google::spanner::v1::RequestOptions::PRIORITY_HIGH)))) .WillOnce(Return(MakeCommitResponse( spanner::MakeTimestamp(std::chrono::system_clock::from_time_t(123)) .value()))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2870,8 +2877,8 @@ TEST(ConnectionImplTest, CommitSuccessWithStats) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction) .WillOnce( [](grpc::ClientContext&, Options const&, @@ -2881,16 +2888,16 @@ TEST(ConnectionImplTest, CommitSuccessWithStats) { EXPECT_FALSE(request.has_mutation_key()); return MakeTestTransaction(); }); - EXPECT_CALL(*mock, Commit(_, _, - AllOf(HasSession("test-session-name"), - HasReturnStats(true)))) + EXPECT_CALL( + *mock, + Commit(_, _, AllOf(HasSession("multiplexed"), HasReturnStats(true)))) .WillOnce(Return(MakeCommitResponse( spanner::MakeTimestamp(std::chrono::system_clock::from_time_t(123)) .value(), spanner::CommitStats{42}))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2948,7 +2955,8 @@ TEST(ConnectionImplTest, MutationCommitSuccess) { commit_timestamp, spanner::CommitStats{request.mutations_size()}); }); - auto options = Options{}.set({}); + auto options = Options{}; + // .set({}); auto conn = MakeConnectionImpl(db, mock, options); internal::OptionsSpan span(MakeLimitedTimeOptions()); auto commit = conn->Commit({spanner::MakeReadWriteTransaction(), mutations, @@ -3019,7 +3027,8 @@ TEST(ConnectionImplTest, MutationCommitRetryOnceSuccess) { commit_timestamp, spanner::CommitStats{original_mutations_size}); }); - auto options = Options{}.set({}); + auto options = Options{}; + // .set({}); auto conn = MakeConnectionImpl(db, mock, options); internal::OptionsSpan span(MakeLimitedTimeOptions()); auto commit = conn->Commit({spanner::MakeReadWriteTransaction(), mutations, @@ -3104,7 +3113,8 @@ TEST(ConnectionImplTest, MutationCommitRetryMoreThanOnceSuccess) { commit_timestamp, spanner::CommitStats{original_mutations_size}); }); - auto options = Options{}.set({}); + auto options = Options{}; + // .set({}); auto conn = MakeConnectionImpl(db, mock, options); internal::OptionsSpan span(MakeLimitedTimeOptions()); auto commit = conn->Commit({spanner::MakeReadWriteTransaction(), mutations, @@ -3188,7 +3198,8 @@ TEST(ConnectionImplTest, MultiplexedPrecommitUpdated) { }); } - auto options = Options{}.set({}); + auto options = Options{}; + // .set({}); auto conn = MakeConnectionImpl(db, mock, options); internal::OptionsSpan span(MakeLimitedTimeOptions()); spanner::Transaction txn = @@ -3207,8 +3218,8 @@ TEST(ConnectionImplTest, CommitSuccessExcludeFromChangeStreams) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction) .WillOnce( [](grpc::ClientContext&, Options const&, @@ -3217,13 +3228,13 @@ TEST(ConnectionImplTest, CommitSuccessExcludeFromChangeStreams) { EXPECT_TRUE(request.options().exclude_txn_from_change_streams()); return MakeTestTransaction(); }); - EXPECT_CALL(*mock, Commit(_, _, HasSession("test-session-name"))) + EXPECT_CALL(*mock, Commit(_, _, HasSession("multiplexed"))) .WillOnce(Return(MakeCommitResponse( spanner::MakeTimestamp(std::chrono::system_clock::from_time_t(123)) .value()))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span( @@ -3241,20 +3252,20 @@ TEST(ConnectionImplTest, CommitSuccessWithMaxCommitDelay) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); google::spanner::v1::Transaction txn = MakeTestTransaction(); EXPECT_CALL(*mock, BeginTransaction).WillOnce(Return(txn)); EXPECT_CALL(*mock, Commit(_, _, - AllOf(HasSession("test-session-name"), + AllOf(HasSession("multiplexed"), HasMaxCommitDelay(std::chrono::milliseconds(100))))) .WillOnce(Return(MakeCommitResponse( spanner::MakeTimestamp(std::chrono::system_clock::from_time_t(123)) .value()))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3269,21 +3280,21 @@ TEST(ConnectionImplTest, CommitSuccessWithCompression) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); google::spanner::v1::Transaction txn = MakeTestTransaction(); EXPECT_CALL(*mock, BeginTransaction).WillOnce(Return(txn)); EXPECT_CALL(*mock, Commit(HasCompressionAlgorithm(GRPC_COMPRESS_GZIP), _, - HasSession("test-session-name"))) + HasSession("multiplexed"))) .WillOnce([](grpc::ClientContext&, Options const&, google::spanner::v1::CommitRequest const&) { return MakeCommitResponse( spanner::MakeTimestamp(std::chrono::system_clock::from_time_t(123)) .value()); }); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span( @@ -3301,8 +3312,8 @@ TEST(ConnectionImplTest, CommitAtLeastOnce) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction).Times(0); // The whole point! auto const commit_timestamp = spanner::MakeTimestamp(std::chrono::system_clock::from_time_t(123)) @@ -3311,7 +3322,7 @@ TEST(ConnectionImplTest, CommitAtLeastOnce) { .WillOnce([commit_timestamp]( grpc::ClientContext&, Options const&, google::spanner::v1::CommitRequest const& request) { - EXPECT_EQ("test-session-name", request.session()); + EXPECT_EQ("multiplexed", request.session()); EXPECT_TRUE(request.has_single_use_transaction()); EXPECT_EQ(0, request.mutations_size()); EXPECT_FALSE(request.return_commit_stats()); @@ -3321,9 +3332,9 @@ TEST(ConnectionImplTest, CommitAtLeastOnce) { EXPECT_THAT(request.request_options().transaction_tag(), IsEmpty()); return MakeCommitResponse(commit_timestamp); }); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3338,13 +3349,13 @@ TEST(ConnectionImplTest, CommitAtLeastOnceBatched) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); using BatchWriteRequest = google::spanner::v1::BatchWriteRequest; EXPECT_CALL(*mock, BatchWrite) .WillOnce([](std::shared_ptr const&, Options const&, BatchWriteRequest const& request) { - EXPECT_EQ("test-session-name", request.session()); + EXPECT_EQ("multiplexed", request.session()); EXPECT_EQ(google::spanner::v1::RequestOptions::PRIORITY_UNSPECIFIED, request.request_options().priority()); EXPECT_THAT(request.request_options().request_tag(), IsEmpty()); @@ -3359,7 +3370,7 @@ TEST(ConnectionImplTest, CommitAtLeastOnceBatched) { }) .WillOnce([&](std::shared_ptr const&, Options const&, BatchWriteRequest const& request) { - EXPECT_EQ("test-session-name", request.session()); + EXPECT_EQ("multiplexed", request.session()); EXPECT_EQ(google::spanner::v1::RequestOptions::PRIORITY_UNSPECIFIED, request.request_options().priority()); EXPECT_THAT(request.request_options().request_tag(), IsEmpty()); @@ -3378,9 +3389,9 @@ TEST(ConnectionImplTest, CommitAtLeastOnceBatched) { commit_timestamp { seconds: 123 } )pb"}); }); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3396,6 +3407,7 @@ TEST(ConnectionImplTest, CommitAtLeastOnceBatched) { EXPECT_EQ(++it, commit_results.end()); } +#if 0 // session pool test TEST(ConnectionImplTest, CommitAtLeastOnceBatchedSessionNotFound) { auto mock = std::make_shared>(); auto db = spanner::Database("placeholder_project", "placeholder_instance", @@ -3453,18 +3465,19 @@ TEST(ConnectionImplTest, CommitAtLeastOnceBatchedSessionNotFound) { EXPECT_EQ(++it, commit_results.end()); } } +#endif TEST(ConnectionImplTest, CommitAtLeastOnceBatchedExcludeFromChangeStreams) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); using BatchWriteRequest = google::spanner::v1::BatchWriteRequest; EXPECT_CALL(*mock, BatchWrite) .WillOnce([&](std::shared_ptr const&, Options const&, BatchWriteRequest const& request) { - EXPECT_EQ("test-session-name", request.session()); + EXPECT_EQ("multiplexed", request.session()); EXPECT_EQ(google::spanner::v1::RequestOptions::PRIORITY_UNSPECIFIED, request.request_options().priority()); EXPECT_THAT(request.request_options().request_tag(), IsEmpty()); @@ -3483,9 +3496,9 @@ TEST(ConnectionImplTest, CommitAtLeastOnceBatchedExcludeFromChangeStreams) { commit_timestamp { seconds: 123 } )pb"}); }); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span( @@ -3506,13 +3519,13 @@ TEST(ConnectionImplTest, CommitAtLeastOnceBatchedExcludeFromChangeStreams) { TEST(ConnectionImplTest, RollbackCreateSessionFailure) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .Times(AtLeast(2)) - .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - "uh-oh in BatchCreateSessions"))); + // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) + // .Times(AtLeast(2)) + // .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, + // "uh-oh in BatchCreateSessions"))); EXPECT_CALL(*mock, Rollback).Times(0); EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); @@ -3522,15 +3535,15 @@ TEST(ConnectionImplTest, RollbackCreateSessionFailure) { SetTransactionId(txn, "test-txn-id"); auto rollback = conn->Rollback({txn}); EXPECT_THAT(rollback, StatusIs(StatusCode::kPermissionDenied, - HasSubstr("uh-oh in BatchCreateSessions"))); + HasSubstr("uh-oh in CreateSession"))); } TEST(ConnectionImplTest, RollbackBeginTransaction) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - std::string const session_name = "test-session-name"; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({session_name}))); + std::string const session_name = "multiplexed"; + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); std::string const transaction_id = "RollbackBeginTransaction"; EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction(transaction_id))); @@ -3538,9 +3551,9 @@ TEST(ConnectionImplTest, RollbackBeginTransaction) { AllOf(HasSession(session_name), HasNakedTransactionId(transaction_id)))) .WillOnce(Return(Status())); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3552,12 +3565,12 @@ TEST(ConnectionImplTest, RollbackBeginTransaction) { TEST(ConnectionImplTest, RollbackSingleUseTransaction) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, Rollback).Times(0); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3572,18 +3585,18 @@ TEST(ConnectionImplTest, RollbackSingleUseTransaction) { TEST(ConnectionImplTest, RollbackPermanentFailure) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - std::string const session_name = "test-session-name"; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({session_name}))); + std::string const session_name = "multiplexed"; + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); std::string const transaction_id = "test-txn-id"; EXPECT_CALL(*mock, Rollback(_, _, - AllOf(HasSession(session_name), + AllOf(HasSession("multiplexed"), HasNakedTransactionId(transaction_id)))) .WillOnce( Return(Status(StatusCode::kPermissionDenied, "uh-oh in Rollback"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -3597,9 +3610,9 @@ TEST(ConnectionImplTest, RollbackPermanentFailure) { TEST(ConnectionImplTest, RollbackTooManyTransientFailures) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - std::string const session_name = "test-session-name"; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({session_name}))); + std::string const session_name = "multiplexed"; + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); std::string const transaction_id = "test-txn-id"; EXPECT_CALL(*mock, Rollback(_, _, AllOf(HasSession(session_name), @@ -3607,9 +3620,9 @@ TEST(ConnectionImplTest, RollbackTooManyTransientFailures) { .Times(AtLeast(2)) .WillRepeatedly( Return(Status(StatusCode::kUnavailable, "try-again in Rollback"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -3623,18 +3636,18 @@ TEST(ConnectionImplTest, RollbackTooManyTransientFailures) { TEST(ConnectionImplTest, RollbackSuccess) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - std::string const session_name = "test-session-name"; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({session_name}))); + std::string const session_name = "multiplexed"; + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); std::string const transaction_id = "test-txn-id"; EXPECT_CALL(*mock, Rollback(_, _, - AllOf(HasSession(session_name), + AllOf(HasSession("multiplexed"), HasNakedTransactionId(transaction_id)))) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(Status())); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3648,12 +3661,12 @@ TEST(ConnectionImplTest, RollbackInvalidatedTransaction) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, Rollback).Times(0); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3673,22 +3686,22 @@ TEST(ConnectionImplTest, ReadPartition) { auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction).Times(0); EXPECT_CALL(*mock, StreamingRead) .WillOnce([](std::shared_ptr const&, Options const&, google::spanner::v1::ReadRequest const& request) { - EXPECT_EQ("test-session-name", request.session()); + EXPECT_EQ("multiplexed", request.session()); EXPECT_EQ("Table", request.table()); EXPECT_EQ("DEADBEEF", request.partition_token()); EXPECT_TRUE(request.data_boost_enabled()); return MakeReader( {R"pb(metadata: { transaction: { id: "ABCDEF00" } })pb"}); }); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3706,8 +3719,8 @@ TEST(ConnectionImplTest, PartitionReadSuccess) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto constexpr kTextPartitionResponse = R"pb( partitions: { partition_token: "BADDECAF" } partitions: { partition_token: "DEADBEEF" } @@ -3718,7 +3731,7 @@ TEST(ConnectionImplTest, PartitionReadSuccess) { TextFormat::ParseFromString(kTextPartitionResponse, &partition_response)); auto constexpr kTextPartitionRequest = R"pb( - session: "test-session-name" + session: "multiplexed" transaction: { begin { read_only { strong: true return_read_timestamp: true } } } @@ -3737,9 +3750,10 @@ TEST(ConnectionImplTest, PartitionReadSuccess) { .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(partition_response)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3758,16 +3772,16 @@ TEST(ConnectionImplTest, PartitionReadSuccess) { read_options}, {absl::nullopt, absl::nullopt, data_boost}}); ASSERT_STATUS_OK(result); - EXPECT_THAT(txn, HasSessionAndTransaction("test-session-name", "CAFEDEAD", - false, "")); + EXPECT_THAT(txn, + HasSessionAndTransaction("multiplexed", "CAFEDEAD", false, "")); std::vector expected_read_partitions = { spanner_internal::MakeReadPartition( - "CAFEDEAD", false, "", "test-session-name", "BADDECAF", "table", + "CAFEDEAD", false, "", "multiplexed", "BADDECAF", "table", spanner::KeySet::All(), {"UserId", "UserName"}, data_boost, read_options), spanner_internal::MakeReadPartition( - "CAFEDEAD", false, "", "test-session-name", "DEADBEEF", "table", + "CAFEDEAD", false, "", "multiplexed", "DEADBEEF", "table", spanner::KeySet::All(), {"UserId", "UserName"}, data_boost, read_options)}; @@ -3780,16 +3794,17 @@ TEST(ConnectionImplTest, PartitionReadPermanentFailure) { "placeholder_database_id"); { InSequence seq; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); Status status(StatusCode::kPermissionDenied, "uh-oh"); EXPECT_CALL(*mock, PartitionRead).WillOnce(Return(status)); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction())); EXPECT_CALL(*mock, PartitionRead).WillOnce(Return(status)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); } auto conn = MakeConnectionImpl(db, mock); @@ -3809,8 +3824,8 @@ TEST(ConnectionImplTest, PartitionReadTooManyTransientFailures) { "placeholder_database_id"); { InSequence seq; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); Status status(StatusCode::kUnavailable, "try-again"); EXPECT_CALL(*mock, PartitionRead) .Times(AtLeast(2)) @@ -3820,9 +3835,10 @@ TEST(ConnectionImplTest, PartitionReadTooManyTransientFailures) { EXPECT_CALL(*mock, PartitionRead) .Times(AtLeast(2)) .WillRepeatedly(Return(status)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); } auto conn = MakeConnectionImpl(db, mock); @@ -3841,22 +3857,22 @@ TEST(ConnectionImplTest, QueryPartition) { auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction).Times(0); EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce([](std::shared_ptr const&, Options const&, google::spanner::v1::ExecuteSqlRequest const& request) { - EXPECT_EQ("test-session-name", request.session()); + EXPECT_EQ("multiplexed", request.session()); EXPECT_EQ("SELECT * FROM Table", request.sql()); EXPECT_EQ("DEADBEEF", request.partition_token()); EXPECT_TRUE(request.data_boost_enabled()); return MakeReader( {R"pb(metadata: { transaction: { id: "ABCDEF00" } })pb"}); }); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3872,8 +3888,8 @@ TEST(ConnectionImplTest, PartitionQuerySuccess) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); auto constexpr kTextPartitionResponse = R"pb( partitions: { partition_token: "BADDECAF" } partitions: { partition_token: "DEADBEEF" } @@ -3884,7 +3900,7 @@ TEST(ConnectionImplTest, PartitionQuerySuccess) { TextFormat::ParseFromString(kTextPartitionResponse, &partition_response)); auto constexpr kTextPartitionRequest = R"pb( - session: "test-session-name" + session: "multiplexed" transaction: { begin { read_only { strong: true return_read_timestamp: true } } } @@ -3899,9 +3915,10 @@ TEST(ConnectionImplTest, PartitionQuerySuccess) { .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(partition_response)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3914,12 +3931,12 @@ TEST(ConnectionImplTest, PartitionQuerySuccess) { ASSERT_STATUS_OK(result); std::vector expected_query_partitions = { - spanner_internal::MakeQueryPartition("CAFEDEAD", false, "", - "test-session-name", "BADDECAF", - data_boost, sql_statement), - spanner_internal::MakeQueryPartition("CAFEDEAD", false, "", - "test-session-name", "DEADBEEF", - data_boost, sql_statement)}; + spanner_internal::MakeQueryPartition("CAFEDEAD", false, "", "multiplexed", + "BADDECAF", data_boost, + sql_statement), + spanner_internal::MakeQueryPartition("CAFEDEAD", false, "", "multiplexed", + "DEADBEEF", data_boost, + sql_statement)}; EXPECT_THAT(*result, UnorderedPointwise(Eq(), expected_query_partitions)); } @@ -3931,15 +3948,16 @@ TEST(ConnectionImplTest, PartitionQueryPermanentFailure) { Status failed_status = Status(StatusCode::kPermissionDenied, "End of line."); { InSequence seq; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, PartitionQuery).WillOnce(Return(failed_status)); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction())); EXPECT_CALL(*mock, PartitionQuery).WillOnce(Return(failed_status)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); } auto conn = MakeConnectionImpl(db, mock); @@ -3960,8 +3978,8 @@ TEST(ConnectionImplTest, PartitionQueryTooManyTransientFailures) { Status(StatusCode::kUnavailable, "try-again in PartitionQuery"); { InSequence seq; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, PartitionQuery) .Times(AtLeast(2)) .WillRepeatedly(Return(failed_status)); @@ -3970,9 +3988,10 @@ TEST(ConnectionImplTest, PartitionQueryTooManyTransientFailures) { EXPECT_CALL(*mock, PartitionQuery) .Times(AtLeast(2)) .WillRepeatedly(Return(failed_status)); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); } auto conn = MakeConnectionImpl(db, mock); @@ -3991,35 +4010,15 @@ TEST(ConnectionImplTest, MultipleThreads) { std::string const session_prefix = "test-session-prefix-"; std::string const role = "TestRole"; std::atomic session_counter(0); - EXPECT_CALL(*mock, BatchCreateSessions( - _, _, AllOf(HasDatabase(db), HasCreatorRole(role)))) - .WillRepeatedly( - [&session_prefix, &session_counter]( - grpc::ClientContext&, Options const&, - google::spanner::v1::BatchCreateSessionsRequest const& request) { - google::spanner::v1::BatchCreateSessionsResponse response; - for (int i = 0; i < request.session_count(); ++i) { - response.add_session()->set_name( - session_prefix + std::to_string(++session_counter)); - } - return response; - }); + EXPECT_CALL(*mock, CreateSession(_, _, AllOf(IsMultiplexed()))) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, Rollback) .WillRepeatedly([session_prefix]( grpc::ClientContext&, Options const&, google::spanner::v1::RollbackRequest const& request) { - EXPECT_THAT(request.session(), StartsWith(session_prefix)); + EXPECT_THAT(request.session(), Eq("multiplexed")); return Status(); }); - EXPECT_CALL(*mock, AsyncDeleteSession) - .WillRepeatedly( - [session_prefix]( - CompletionQueue&, std::shared_ptr const&, - internal::ImmutableOptions const&, - google::spanner::v1::DeleteSessionRequest const& request) { - EXPECT_THAT(request.name(), StartsWith(session_prefix)); - return make_ready_future(Status{}); - }); int const per_thread_iterations = 1000; auto const thread_count = []() -> unsigned { @@ -4052,6 +4051,7 @@ TEST(ConnectionImplTest, MultipleThreads) { } } +#if 0 // session pool test /** * @test Verify Transactions remain bound to a single Session. * @@ -4163,7 +4163,7 @@ TEST(ConnectionImplTest, TransactionSessionBinding) { EXPECT_EQ(std::get<0>(*row), 3); } } - +#endif /** * @test Verify if a `Transaction` outlives the `ConnectionImpl` it was used * with, it does not call back into the deleted `ConnectionImpl` to release @@ -4173,8 +4173,8 @@ TEST(ConnectionImplTest, TransactionOutlivesConnection) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction).Times(0); auto constexpr kText = R"pb( @@ -4186,9 +4186,10 @@ TEST(ConnectionImplTest, TransactionOutlivesConnection) { // Because the transaction outlives the connection, the session is not in // the pool when the connection is destroyed, so the session is leaked. // Only the multiplexed session is deleted. - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -4197,8 +4198,8 @@ TEST(ConnectionImplTest, TransactionOutlivesConnection) { auto rows = conn->Read( {txn, "table", spanner::KeySet::All(), {"UserId", "UserName"}}); EXPECT_TRUE(ContainsNoRows(rows)); - EXPECT_THAT(txn, HasSessionAndTransaction("test-session-name", "ABCDEF00", - false, "")); + EXPECT_THAT(txn, + HasSessionAndTransaction("multiplexed", "ABCDEF00", false, "")); // `conn` is the only reference to the `ConnectionImpl`, so dropping it will // cause the `ConnectionImpl` object to be deleted, while `txn` and its @@ -4206,6 +4207,7 @@ TEST(ConnectionImplTest, TransactionOutlivesConnection) { conn.reset(); } +#if 0 // session pool test TEST(ConnectionImplTest, ReadSessionNotFound) { auto mock = std::make_shared>(); auto db = spanner::Database("project", "instance", "database"); @@ -4274,17 +4276,18 @@ TEST(ConnectionImplTest, ReadSessionNotFound) { EXPECT_THAT(actual, IsEmpty()); } } - +#endif TEST(ConnectionImplTest, PartitionReadSessionNotFound) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, PartitionRead) - .WillOnce(Return(SessionNotFoundError("test-session-name"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + .WillOnce(Return(SessionNotFoundError("multiplexed"))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4301,15 +4304,16 @@ TEST(ConnectionImplTest, PartitionReadSessionNotFound) { TEST(ConnectionImplTest, ExecuteQuerySessionNotFound) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); - auto finish_status = SessionNotFoundError("test-session-name"); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); + auto finish_status = SessionNotFoundError("multiplexed"); EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce( Return(ByMove(MakeReader({}, finish_status)))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4325,15 +4329,16 @@ TEST(ConnectionImplTest, ExecuteQuerySessionNotFound) { TEST(ConnectionImplTest, ProfileQuerySessionNotFound) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); - auto finish_status = SessionNotFoundError("test-session-name"); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); + auto finish_status = SessionNotFoundError("multiplexed"); EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce( Return(ByMove(MakeReader({}, finish_status)))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4349,13 +4354,14 @@ TEST(ConnectionImplTest, ProfileQuerySessionNotFound) { TEST(ConnectionImplTest, ExecuteDmlSessionNotFound) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, ExecuteSql) - .WillOnce(Return(SessionNotFoundError("test-session-name"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + .WillOnce(Return(SessionNotFoundError("multiplexed"))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4371,13 +4377,14 @@ TEST(ConnectionImplTest, ExecuteDmlSessionNotFound) { TEST(ConnectionImplTest, ProfileDmlSessionNotFound) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, ExecuteSql) - .WillOnce(Return(SessionNotFoundError("test-session-name"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + .WillOnce(Return(SessionNotFoundError("multiplexed"))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4393,13 +4400,14 @@ TEST(ConnectionImplTest, ProfileDmlSessionNotFound) { TEST(ConnectionImplTest, AnalyzeSqlSessionNotFound) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, ExecuteSql) - .WillOnce(Return(SessionNotFoundError("test-session-name"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + .WillOnce(Return(SessionNotFoundError("multiplexed"))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4415,13 +4423,14 @@ TEST(ConnectionImplTest, AnalyzeSqlSessionNotFound) { TEST(ConnectionImplTest, PartitionQuerySessionNotFound) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, PartitionQuery) - .WillOnce(Return(SessionNotFoundError("test-session-name"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + .WillOnce(Return(SessionNotFoundError("multiplexed"))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4437,13 +4446,14 @@ TEST(ConnectionImplTest, PartitionQuerySessionNotFound) { TEST(ConnectionImplTest, ExecuteBatchDmlSessionNotFound) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, ExecuteBatchDml) - .WillOnce(Return(SessionNotFoundError("test-session-name"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + .WillOnce(Return(SessionNotFoundError("multiplexed"))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4466,13 +4476,14 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlSessionNotFound) { TEST(ConnectionImplTest, CommitSessionNotFound) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, Commit) - .WillOnce(Return(SessionNotFoundError("test-session-name"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + .WillOnce(Return(SessionNotFoundError("multiplexed"))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4488,13 +4499,14 @@ TEST(ConnectionImplTest, CommitSessionNotFound) { TEST(ConnectionImplTest, RollbackSessionNotFound) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, Rollback) - .WillOnce(Return(SessionNotFoundError("test-session-name"))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, Not(HasSessionName("multiplexed")))) - .Times(0); + .WillOnce(Return(SessionNotFoundError("multiplexed"))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, + // Not(HasSessionName("multiplexed")))) + // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4508,17 +4520,17 @@ TEST(ConnectionImplTest, RollbackSessionNotFound) { TEST(ConnectionImplTest, ReadRequestOrderByParameterUnspecified) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); Sequence s; EXPECT_CALL( *mock, StreamingRead( _, _, - AllOf(HasSession("test-session-name"), + AllOf(HasSession("multiplexed"), HasOrderBy( google::spanner::v1::ReadRequest::ORDER_BY_UNSPECIFIED)))) .InSequence(s) @@ -4537,25 +4549,24 @@ TEST(ConnectionImplTest, ReadRequestOrderByParameterUnspecified) { for (auto const& row : rows1) { (void)row; } - EXPECT_THAT(txn1, - HasSessionAndTransaction("test-session-name", "txn1", false, "")); + EXPECT_THAT(txn1, HasSessionAndTransaction("multiplexed", "txn1", false, "")); } TEST(ConnectionImplTest, ReadRequestOrderByParameterNoOrder) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); Sequence s; EXPECT_CALL( *mock, StreamingRead( _, _, AllOf( - HasSession("test-session-name"), + HasSession("multiplexed"), HasOrderBy(google::spanner::v1::ReadRequest::ORDER_BY_NO_ORDER)))) .InSequence(s) .WillOnce(Return(ByMove(MakeReader( @@ -4580,24 +4591,23 @@ TEST(ConnectionImplTest, ReadRequestOrderByParameterNoOrder) { for (auto const& row : rows1) { (void)row; } - EXPECT_THAT(txn1, - HasSessionAndTransaction("test-session-name", "txn1", false, "")); + EXPECT_THAT(txn1, HasSessionAndTransaction("multiplexed", "txn1", false, "")); } TEST(ConnectionImplTest, ReadRequestLockHintParameterUnspecified) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); Sequence s; EXPECT_CALL( *mock, StreamingRead( _, _, - AllOf(HasSession("test-session-name"), + AllOf(HasSession("multiplexed"), HasLockHint( google::spanner::v1::ReadRequest::LOCK_HINT_UNSPECIFIED)))) .InSequence(s) @@ -4616,25 +4626,24 @@ TEST(ConnectionImplTest, ReadRequestLockHintParameterUnspecified) { for (auto const& row : rows1) { (void)row; } - EXPECT_THAT(txn1, - HasSessionAndTransaction("test-session-name", "txn1", false, "")); + EXPECT_THAT(txn1, HasSessionAndTransaction("multiplexed", "txn1", false, "")); } TEST(ConnectionImplTest, ReadRequestLockHintShared) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); Sequence s; EXPECT_CALL( *mock, StreamingRead( _, _, AllOf( - HasSession("test-session-name"), + HasSession("multiplexed"), HasLockHint(google::spanner::v1::ReadRequest::LOCK_HINT_SHARED)))) .InSequence(s) .WillOnce(Return(ByMove(MakeReader( @@ -4660,19 +4669,21 @@ TEST(ConnectionImplTest, ReadRequestLockHintShared) { for (auto const& row : rows1) { (void)row; } - EXPECT_THAT(txn1, - HasSessionAndTransaction("test-session-name", "txn1", false, "")); + EXPECT_THAT(txn1, HasSessionAndTransaction("multiplexed", "txn1", false, "")); } TEST(ConnectionImplTest, OperationsFailOnInvalidatedTransaction) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name"}))); - EXPECT_CALL(*mock, - AsyncDeleteSession(_, _, _, HasSessionName("test-session-name"))) - .WillOnce(Return(make_ready_future(Status{}))); + EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); + + // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) + // .WillOnce(Return(MakeSessionsResponse({"multiplexed"}))); + // EXPECT_CALL(*mock, + // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) + // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -4752,3 +4763,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/internal/defaults.cc b/google/cloud/spanner/internal/defaults.cc index 863dc944c7e7f..8e2951f5ce1cd 100644 --- a/google/cloud/spanner/internal/defaults.cc +++ b/google/cloud/spanner/internal/defaults.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/internal/defaults.h" #include "google/cloud/spanner/internal/session_pool.h" @@ -72,6 +73,8 @@ Options DefaultOptions(Options opts) { } } + opts.set({}); + // Sets Spanner-specific session-pool options. auto& num_channels = opts.lookup(); num_channels = (std::max)(num_channels, 1); @@ -164,3 +167,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/internal/defaults_test.cc b/google/cloud/spanner/internal/defaults_test.cc index f07d76d5d0a10..5e6ec8695b68b 100644 --- a/google/cloud/spanner/internal/defaults_test.cc +++ b/google/cloud/spanner/internal/defaults_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/internal/defaults.h" #include "google/cloud/spanner/internal/session_pool.h" @@ -304,3 +305,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/internal/partial_result_set_resume_test.cc b/google/cloud/spanner/internal/partial_result_set_resume_test.cc index 844e9ceb14442..382abfe53d576 100644 --- a/google/cloud/spanner/internal/partial_result_set_resume_test.cc +++ b/google/cloud/spanner/internal/partial_result_set_resume_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/internal/partial_result_set_resume.h" #include "google/cloud/spanner/internal/partial_result_set_source.h" @@ -610,3 +611,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/internal/partial_result_set_source.cc b/google/cloud/spanner/internal/partial_result_set_source.cc index 937aa714df83d..1c015bb474bfb 100644 --- a/google/cloud/spanner/internal/partial_result_set_source.cc +++ b/google/cloud/spanner/internal/partial_result_set_source.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/internal/partial_result_set_source.h" #include "google/cloud/spanner/internal/merge_chunk.h" @@ -299,3 +300,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/internal/partial_result_set_source_test.cc b/google/cloud/spanner/internal/partial_result_set_source_test.cc index 1238436be66a9..743d51920131a 100644 --- a/google/cloud/spanner/internal/partial_result_set_source_test.cc +++ b/google/cloud/spanner/internal/partial_result_set_source_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/internal/partial_result_set_source.h" #include "google/cloud/spanner/mocks/row.h" @@ -938,3 +939,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/internal/route_to_leader.cc b/google/cloud/spanner/internal/route_to_leader.cc index f53a3615bd668..3b7e98fb4928c 100644 --- a/google/cloud/spanner/internal/route_to_leader.cc +++ b/google/cloud/spanner/internal/route_to_leader.cc @@ -13,6 +13,9 @@ // limitations under the License. #include "google/cloud/spanner/internal/route_to_leader.h" +// do no reorder +#include "google/cloud/internal/disable_deprecation_warnings.inc" + #include "google/cloud/spanner/options.h" #include "google/cloud/options.h" @@ -33,3 +36,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/internal/route_to_leader_test.cc b/google/cloud/spanner/internal/route_to_leader_test.cc index df4bef1e6b1b9..c6dd34b494471 100644 --- a/google/cloud/spanner/internal/route_to_leader_test.cc +++ b/google/cloud/spanner/internal/route_to_leader_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/internal/route_to_leader.h" #include "google/cloud/spanner/options.h" @@ -82,3 +83,4 @@ TEST_F(RouteToLeader, OptionFalse) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/internal/session_pool.cc b/google/cloud/spanner/internal/session_pool.cc index e1a9d6f03342f..435a93752b237 100644 --- a/google/cloud/spanner/internal/session_pool.cc +++ b/google/cloud/spanner/internal/session_pool.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/internal/session_pool.h" #include "google/cloud/spanner/internal/route_to_leader.h" @@ -734,3 +735,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/internal/session_pool_test.cc b/google/cloud/spanner/internal/session_pool_test.cc index 8f95b27a556e4..2ffe2fbe4d42c 100644 --- a/google/cloud/spanner/internal/session_pool_test.cc +++ b/google/cloud/spanner/internal/session_pool_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/internal/session_pool.h" #include "google/cloud/spanner/internal/defaults.h" @@ -124,7 +125,7 @@ google::spanner::v1::Session MakeMultiplexedSession(std::string name, session.set_multiplexed(true); return session; } - +#if 0 // Create a response with the given `sessions`. google::spanner::v1::BatchCreateSessionsResponse MakeSessionsResponse( std::vector sessions, std::string role = "") { @@ -138,7 +139,7 @@ google::spanner::v1::BatchCreateSessionsResponse MakeSessionsResponse( } return response; } - +#endif std::shared_ptr MakeTestSessionPool( spanner::Database db, std::vector> stubs, CompletionQueue cq, Options opts = {}) { @@ -162,9 +163,8 @@ TEST_F(SessionPoolTest, Multiplexed) { .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - auto pool = MakeTestSessionPool( - db, {mock}, threads.cq(), - Options{}.set({})); + auto pool = MakeTestSessionPool(db, {mock}, threads.cq(), {}); + // Options{}.set({})); auto session = pool->Multiplexed(); ASSERT_STATUS_OK(session); EXPECT_EQ((*session)->session_name(), "multiplexed"); @@ -184,11 +184,10 @@ TEST_F(SessionPoolTest, MultiplexedAllocateRouteToLeader) { }); google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - auto pool = MakeTestSessionPool( - db, {mock}, threads.cq(), - Options{} - .set(true) - .set({})); + auto pool = + MakeTestSessionPool(db, {mock}, threads.cq(), + Options{}.set(true)); + // .set({})); auto session = pool->Multiplexed(); ASSERT_STATUS_OK(session); EXPECT_EQ((*session)->session_name(), "multiplexed"); @@ -198,17 +197,30 @@ TEST_F(SessionPoolTest, MultiplexedAllocateRouteToLeader) { TEST_F(SessionPoolTest, AllocateRouteToLeader) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, - BatchCreateSessions( - _, _, AllOf(DatabaseIs(db.FullName()), SessionCountIs(42)))) + + EXPECT_CALL( + *mock, + CreateSession(_, _, AllOf(DatabaseIs(db.FullName()), IsMultiplexed()))) .WillOnce([this](grpc::ClientContext& context, Options const&, - google::spanner::v1::BatchCreateSessionsRequest const&) { + google::spanner::v1::CreateSessionRequest const&) { EXPECT_THAT(GetMetadata(context), Contains(Pair(kRouteToLeader, "true"))); - return MakeSessionsResponse({"session1"}); + return MakeMultiplexedSession("multiplexed"); }); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session1"))) - .WillOnce(Return(make_ready_future(Status{}))); + + // EXPECT_CALL(*mock, + // BatchCreateSessions( + // _, _, AllOf(DatabaseIs(db.FullName()), + // SessionCountIs(42)))) + // .WillOnce([this](grpc::ClientContext& context, Options const&, + // google::spanner::v1::BatchCreateSessionsRequest + // const&) { + // EXPECT_THAT(GetMetadata(context), + // Contains(Pair(kRouteToLeader, "true"))); + // return MakeSessionsResponse({"session1"}); + // }); + // EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session1"))) + // .WillOnce(Return(make_ready_future(Status{}))); google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; auto pool = @@ -216,15 +228,16 @@ TEST_F(SessionPoolTest, AllocateRouteToLeader) { Options{} .set(true) .set(42)); - auto session = pool->Allocate(); + auto session = pool->Multiplexed(); ASSERT_STATUS_OK(session); - EXPECT_EQ((*session)->session_name(), "session1"); + EXPECT_EQ((*session)->session_name(), "multiplexed"); EXPECT_EQ(pool->GetStub(**session), mock); } TEST_F(SessionPoolTest, MultiplexedAllocateNoRouteToLeader) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); + EXPECT_CALL( *mock, CreateSession(_, _, AllOf(DatabaseIs(db.FullName()), IsMultiplexed()))) @@ -237,11 +250,10 @@ TEST_F(SessionPoolTest, MultiplexedAllocateNoRouteToLeader) { }); google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - auto pool = MakeTestSessionPool( - db, {mock}, threads.cq(), - Options{} - .set(false) - .set({})); + auto pool = + MakeTestSessionPool(db, {mock}, threads.cq(), + Options{}.set(false)); + // .set({})); auto session = pool->Multiplexed(); ASSERT_STATUS_OK(session); EXPECT_EQ((*session)->session_name(), "multiplexed"); @@ -251,18 +263,32 @@ TEST_F(SessionPoolTest, MultiplexedAllocateNoRouteToLeader) { TEST_F(SessionPoolTest, AllocateNoRouteToLeader) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, - BatchCreateSessions( - _, _, AllOf(DatabaseIs(db.FullName()), SessionCountIs(42)))) + + EXPECT_CALL( + *mock, + CreateSession(_, _, AllOf(DatabaseIs(db.FullName()), IsMultiplexed()))) .WillOnce([this](grpc::ClientContext& context, Options const&, - google::spanner::v1::BatchCreateSessionsRequest const&) { + google::spanner::v1::CreateSessionRequest const&) { EXPECT_THAT(GetMetadata(context), AnyOf(Contains(Pair(kRouteToLeader, "false")), Not(Contains(Pair(kRouteToLeader, _))))); - return MakeSessionsResponse({"session1"}); + return MakeMultiplexedSession("multiplexed"); }); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session1"))) - .WillOnce(Return(make_ready_future(Status{}))); + + // EXPECT_CALL(*mock, + // BatchCreateSessions( + // _, _, AllOf(DatabaseIs(db.FullName()), + // SessionCountIs(42)))) + // .WillOnce([this](grpc::ClientContext& context, Options const&, + // google::spanner::v1::BatchCreateSessionsRequest + // const&) { + // EXPECT_THAT(GetMetadata(context), + // AnyOf(Contains(Pair(kRouteToLeader, "false")), + // Not(Contains(Pair(kRouteToLeader, _))))); + // return MakeSessionsResponse({"session1"}); + // }); + // EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session1"))) + // .WillOnce(Return(make_ready_future(Status{}))); google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; auto pool = @@ -270,12 +296,13 @@ TEST_F(SessionPoolTest, AllocateNoRouteToLeader) { Options{} .set(false) .set(42)); - auto session = pool->Allocate(); + auto session = pool->Multiplexed(); ASSERT_STATUS_OK(session); - EXPECT_EQ((*session)->session_name(), "session1"); + EXPECT_EQ((*session)->session_name(), "multiplexed"); EXPECT_EQ(pool->GetStub(**session), mock); } +#if 0 TEST_F(SessionPoolTest, ReleaseBadSession) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); @@ -313,6 +340,7 @@ TEST_F(SessionPoolTest, ReleaseBadSession) { EXPECT_EQ((*session)->session_name(), "session2"); // Got a new session } } +#endif TEST_F(SessionPoolTest, MultiplexedCreateError) { auto mock = std::make_shared(); @@ -322,14 +350,14 @@ TEST_F(SessionPoolTest, MultiplexedCreateError) { Return(ByMove(Status(StatusCode::kInternal, "init failure")))); google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - auto pool = MakeTestSessionPool( - db, {mock}, threads.cq(), - Options{}.set({})); + auto pool = MakeTestSessionPool(db, {mock}, threads.cq(), {}); + // Options{}.set({})); auto session = pool->Multiplexed(); EXPECT_THAT(session, StatusIs(StatusCode::kInternal, HasSubstr("init failure"))); } +#if 0 TEST_F(SessionPoolTest, CreateError) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); @@ -344,27 +372,37 @@ TEST_F(SessionPoolTest, CreateError) { EXPECT_THAT(session, StatusIs(StatusCode::kInternal, HasSubstr("some failure"))); } +#endif TEST_F(SessionPoolTest, ReuseSession) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions) - .WillOnce(Return(ByMove(MakeSessionsResponse({"session1"})))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session1"))) - .WillOnce(Return(make_ready_future(Status{}))); + EXPECT_CALL( + *mock, + CreateSession(_, _, AllOf(DatabaseIs(db.FullName()), IsMultiplexed()))) + .WillOnce([this](grpc::ClientContext& context, Options const&, + google::spanner::v1::CreateSessionRequest const&) { + return MakeMultiplexedSession("multiplexed"); + }); + + // EXPECT_CALL(*mock, BatchCreateSessions) + // .WillOnce(Return(ByMove(MakeSessionsResponse({"session1"})))); + // EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session1"))) + // .WillOnce(Return(make_ready_future(Status{}))); google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; auto pool = MakeTestSessionPool(db, {mock}, threads.cq()); - auto session = pool->Allocate(); + auto session = pool->Multiplexed(); ASSERT_STATUS_OK(session); - EXPECT_EQ((*session)->session_name(), "session1"); + EXPECT_EQ((*session)->session_name(), "multiplexed"); session->reset(); - auto session2 = pool->Allocate(); + auto session2 = pool->Multiplexed(); ASSERT_STATUS_OK(session2); - EXPECT_EQ((*session2)->session_name(), "session1"); + EXPECT_EQ((*session2)->session_name(), "multiplexed"); } +#if 0 // session pool test TEST_F(SessionPoolTest, Lifo) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); @@ -399,7 +437,9 @@ TEST_F(SessionPoolTest, Lifo) { ASSERT_STATUS_OK(session4); EXPECT_EQ((*session4)->session_name(), "session1"); } +#endif +#if 0 // pool test TEST_F(SessionPoolTest, MinSessionsEagerAllocation) { int const min_sessions = 3; auto mock = std::make_shared(); @@ -419,7 +459,9 @@ TEST_F(SessionPoolTest, MinSessionsEagerAllocation) { Options{}.set(min_sessions)); auto session = pool->Allocate(); } +#endif +#if 0 // pool test TEST_F(SessionPoolTest, MinSessionsMultipleAllocations) { int const min_sessions = 3; auto mock = std::make_shared(); @@ -461,7 +503,9 @@ TEST_F(SessionPoolTest, MinSessionsMultipleAllocations) { EXPECT_THAT(session_names, UnorderedElementsAre("s1", "s2", "s3", "s4", "s5", "s6", "s7")); } +#endif +#if 0 // pool test TEST_F(SessionPoolTest, MaxSessionsFailOnExhaustion) { int const max_sessions_per_channel = 3; auto mock = std::make_shared(); @@ -498,7 +542,9 @@ TEST_F(SessionPoolTest, MaxSessionsFailOnExhaustion) { EXPECT_THAT(session, StatusIs(StatusCode::kResourceExhausted, "session pool exhausted")); } +#endif +#if 0 // pool test TEST_F(SessionPoolTest, MaxSessionsBlockUntilRelease) { int const max_sessions_per_channel = 1; auto mock = std::make_shared(); @@ -530,6 +576,7 @@ TEST_F(SessionPoolTest, MaxSessionsBlockUntilRelease) { session->reset(); t.join(); } +#endif TEST_F(SessionPoolTest, MultiplexedLabels) { auto mock = std::make_shared(); @@ -552,14 +599,14 @@ TEST_F(SessionPoolTest, MultiplexedLabels) { google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; auto pool = MakeTestSessionPool( db, {mock}, threads.cq(), - Options{} - .set(std::move(labels)) - .set({})); + Options{}.set(std::move(labels))); + // .set({})); auto session = pool->Multiplexed(); ASSERT_STATUS_OK(session); EXPECT_EQ((*session)->session_name(), "multiplexed"); } +#if 0 TEST_F(SessionPoolTest, Labels) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); @@ -578,6 +625,7 @@ TEST_F(SessionPoolTest, Labels) { ASSERT_STATUS_OK(session); EXPECT_EQ((*session)->session_name(), "session1"); } +#endif TEST_F(SessionPoolTest, MultiplexedCreatorRole) { auto mock = std::make_shared(); @@ -596,14 +644,14 @@ TEST_F(SessionPoolTest, MultiplexedCreatorRole) { google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; auto pool = MakeTestSessionPool( db, {mock}, threads.cq(), - Options{} - .set(role) - .set({})); + Options{}.set(role)); + // .set({})); auto session = pool->Multiplexed(); ASSERT_STATUS_OK(session); EXPECT_EQ((*session)->session_name(), "multiplexed"); } +#if 0 TEST_F(SessionPoolTest, CreatorRole) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); @@ -623,7 +671,9 @@ TEST_F(SessionPoolTest, CreatorRole) { ASSERT_STATUS_OK(session); EXPECT_EQ((*session)->session_name(), "session1"); } +#endif +#if 0 TEST_F(SessionPoolTest, MultipleChannels) { auto mock1 = std::make_shared(); auto mock2 = std::make_shared(); @@ -668,7 +718,9 @@ TEST_F(SessionPoolTest, MultipleChannels) { EXPECT_THAT(session_names, UnorderedElementsAre("c1s1", "c1s2", "c1s3", "c2s1", "c2s2", "c2s3")); } +#endif +#if 0 TEST_F(SessionPoolTest, MultipleChannelsPreAllocation) { auto mock1 = std::make_shared(); auto mock2 = std::make_shared(); @@ -732,6 +784,7 @@ TEST_F(SessionPoolTest, MultipleChannelsPreAllocation) { EXPECT_THAT(session, StatusIs(StatusCode::kResourceExhausted, "session pool exhausted")); } +#endif TEST_F(SessionPoolTest, GetStubForStublessSession) { auto mock = std::make_shared(); @@ -772,8 +825,8 @@ TEST_F(SessionPoolTest, MultilpexedSessionReplacementSuccess) { .set( background_interval) .set( - replacement_interval) - .set({})); + replacement_interval)); + // .set({})); auto s1 = pool->Multiplexed(); ASSERT_STATUS_OK(s1); @@ -814,8 +867,8 @@ TEST_F(SessionPoolTest, MultilpexedSessionReplacementRpcPermanentFailure) { .set( background_interval) .set( - replacement_interval) - .set({})); + replacement_interval)); + // .set({})); auto s1 = pool->Multiplexed(); ASSERT_STATUS_OK(s1); @@ -832,6 +885,7 @@ TEST_F(SessionPoolTest, MultilpexedSessionReplacementRpcPermanentFailure) { impl->SimulateCompletion(false); } +#if 0 TEST_F(SessionPoolTest, SessionRefresh) { auto mock = std::make_shared>(); EXPECT_CALL(*mock, BatchCreateSessions) @@ -905,6 +959,9 @@ TEST_F(SessionPoolTest, SessionRefresh) { impl->SimulateCompletion(false); } +#endif + +#if 0 TEST_F(SessionPoolTest, SessionRefreshNotFound) { auto mock = std::make_shared>(); EXPECT_CALL(*mock, BatchCreateSessions) @@ -977,9 +1034,10 @@ TEST_F(SessionPoolTest, SessionRefreshNotFound) { // automatically as part of its shutdown. impl->SimulateCompletion(false); } - +#endif } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/options.h b/google/cloud/spanner/options.h index 8111acfc5df15..377053724f9f4 100644 --- a/google/cloud/spanner/options.h +++ b/google/cloud/spanner/options.h @@ -75,8 +75,10 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN * more information. * * @ingroup google-cloud-spanner-options + * */ -struct EnableMultiplexedSessionOption { +struct GOOGLE_CLOUD_CPP_DEPRECATED("Multiplex Sessions are always enabled") + EnableMultiplexedSessionOption { using Type = absl::monostate; }; @@ -155,7 +157,8 @@ struct SessionCreatorRoleOption { * * @ingroup google-cloud-spanner-options */ -struct SessionPoolMinSessionsOption { +struct GOOGLE_CLOUD_CPP_DEPRECATED("Option not used with Multiplex Sessions") + SessionPoolMinSessionsOption { using Type = int; }; @@ -167,7 +170,8 @@ struct SessionPoolMinSessionsOption { * * @ingroup google-cloud-spanner-options */ -struct SessionPoolMaxSessionsPerChannelOption { +struct GOOGLE_CLOUD_CPP_DEPRECATED("Option not used with Multiplex Sessions") + SessionPoolMaxSessionsPerChannelOption { using Type = int; }; @@ -179,12 +183,14 @@ struct SessionPoolMaxSessionsPerChannelOption { * * @ingroup google-cloud-spanner-options */ -struct SessionPoolMaxIdleSessionsOption { +struct GOOGLE_CLOUD_CPP_DEPRECATED("Option not used with Multiplex Sessions") + SessionPoolMaxIdleSessionsOption { using Type = int; }; /// Action to take when the session pool is exhausted. -enum class ActionOnExhaustion { +enum class GOOGLE_CLOUD_CPP_DEPRECATED( + "Option not used with Multiplex Sessions") ActionOnExhaustion { /// Wait until a session is returned to the pool. kBlock, /// Fail the operation immediately. @@ -197,7 +203,8 @@ enum class ActionOnExhaustion { * * @ingroup google-cloud-spanner-options */ -struct SessionPoolActionOnExhaustionOption { +struct GOOGLE_CLOUD_CPP_DEPRECATED("Option not used with Multiplex Sessions") + SessionPoolActionOnExhaustionOption { using Type = spanner::ActionOnExhaustion; }; @@ -231,7 +238,8 @@ struct LockHintOption { * * @ingroup google-cloud-spanner-options */ -struct SessionPoolKeepAliveIntervalOption { +struct GOOGLE_CLOUD_CPP_DEPRECATED("Option not used with Multiplex Sessions") + SessionPoolKeepAliveIntervalOption { using Type = std::chrono::seconds; }; @@ -252,11 +260,9 @@ struct SessionPoolLabelsOption { /** * List of all SessionPool options. Pass to `spanner::MakeConnection()`. */ -using SessionPoolOptionList = OptionList< - RouteToLeaderOption, SessionCreatorRoleOption, SessionPoolMinSessionsOption, - SessionPoolMaxSessionsPerChannelOption, SessionPoolMaxIdleSessionsOption, - SessionPoolActionOnExhaustionOption, SessionPoolKeepAliveIntervalOption, - SessionPoolLabelsOption, EnableMultiplexedSessionOption>; +using SessionPoolOptionList = + OptionList; /** * Option for `google::cloud::Options` to set the optimizer version used in an diff --git a/google/cloud/spanner/partition_options.cc b/google/cloud/spanner/partition_options.cc index b96c3f0ad648c..15897336590cb 100644 --- a/google/cloud/spanner/partition_options.cc +++ b/google/cloud/spanner/partition_options.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/partition_options.h" #include "google/cloud/spanner/options.h" @@ -72,3 +73,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/query_options.cc b/google/cloud/spanner/query_options.cc index ce682dabfea1a..18292b06d064c 100644 --- a/google/cloud/spanner/query_options.cc +++ b/google/cloud/spanner/query_options.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/query_options.h" #include "google/cloud/spanner/options.h" @@ -54,3 +55,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/query_options_test.cc b/google/cloud/spanner/query_options_test.cc index d5389a76220b0..449921016bb17 100644 --- a/google/cloud/spanner/query_options_test.cc +++ b/google/cloud/spanner/query_options_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" + #include "google/cloud/spanner/query_options.h" #include "google/cloud/spanner/options.h" #include "google/cloud/spanner/version.h" @@ -132,3 +134,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/query_partition.cc b/google/cloud/spanner/query_partition.cc index 112b4ae7fa38b..d84e8a72b8a14 100644 --- a/google/cloud/spanner/query_partition.cc +++ b/google/cloud/spanner/query_partition.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/query_partition.h" #include "google/cloud/internal/make_status.h" @@ -133,3 +134,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/query_partition_test.cc b/google/cloud/spanner/query_partition_test.cc index 3e6cc8a87936b..12d97a0aeda0c 100644 --- a/google/cloud/spanner/query_partition_test.cc +++ b/google/cloud/spanner/query_partition_test.cc @@ -11,6 +11,8 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" + #include "google/cloud/spanner/query_partition.h" #include "google/cloud/spanner/connection.h" @@ -176,3 +178,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/quickstart/quickstart.cc b/google/cloud/spanner/quickstart/quickstart.cc index 20637df503486..b4c1ff155f90b 100644 --- a/google/cloud/spanner/quickstart/quickstart.cc +++ b/google/cloud/spanner/quickstart/quickstart.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" //! [all] #include "google/cloud/spanner/client.h" @@ -41,3 +42,4 @@ int main(int argc, char* argv[]) { return 0; } //! [all] +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/read_options.cc b/google/cloud/spanner/read_options.cc index 82ce337c63f4b..8f3adbeb83b07 100644 --- a/google/cloud/spanner/read_options.cc +++ b/google/cloud/spanner/read_options.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/read_options.h" #include "google/cloud/spanner/options.h" @@ -58,3 +59,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/read_partition.cc b/google/cloud/spanner/read_partition.cc index 594a6e3238682..67f03788b84c5 100644 --- a/google/cloud/spanner/read_partition.cc +++ b/google/cloud/spanner/read_partition.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/read_partition.h" #include "google/cloud/internal/make_status.h" @@ -148,3 +149,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/read_partition_test.cc b/google/cloud/spanner/read_partition_test.cc index 14866aa7e5f9f..17d58ebe5fee5 100644 --- a/google/cloud/spanner/read_partition_test.cc +++ b/google/cloud/spanner/read_partition_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/read_partition.h" #include "google/cloud/spanner/testing/matchers.h" @@ -234,3 +235,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/results_test.cc b/google/cloud/spanner/results_test.cc index f182c799f9e74..0baa6807e249d 100644 --- a/google/cloud/spanner/results_test.cc +++ b/google/cloud/spanner/results_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/results.h" #include "google/cloud/spanner/mocks/mock_spanner_connection.h" @@ -261,3 +262,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/samples/client_samples.cc b/google/cloud/spanner/samples/client_samples.cc index d38b404221777..6bc44174ec324 100644 --- a/google/cloud/spanner/samples/client_samples.cc +++ b/google/cloud/spanner/samples/client_samples.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/admin/instance_admin_client.h" @@ -140,3 +141,4 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) }); return example.Run(argc, argv); } +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/samples/graph_samples.cc b/google/cloud/spanner/samples/graph_samples.cc index 0388843a952a8..505588b945e09 100644 --- a/google/cloud/spanner/samples/graph_samples.cc +++ b/google/cloud/spanner/samples/graph_samples.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/admin/database_admin_options.h" @@ -607,3 +608,4 @@ int main(int ac, char* av[]) try { std::cerr << ex.what() << "\n"; return 1; } +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/samples/mock_execute_query.cc b/google/cloud/spanner/samples/mock_execute_query.cc index 3927168aaa68a..9d17c76a47877 100644 --- a/google/cloud/spanner/samples/mock_execute_query.cc +++ b/google/cloud/spanner/samples/mock_execute_query.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" //! [all] @@ -108,3 +109,4 @@ TEST(MockSpannerClient, SuccessfulExecuteQuery) { } // namespace //! [all] +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/samples/postgresql_samples.cc b/google/cloud/spanner/samples/postgresql_samples.cc index 6f8e8f83bcf8a..18a57e4808076 100644 --- a/google/cloud/spanner/samples/postgresql_samples.cc +++ b/google/cloud/spanner/samples/postgresql_samples.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/bytes.h" @@ -1321,3 +1322,4 @@ int main(int ac, char* av[]) try { std::cerr << "\n" << ex.what() << "\n"; return 1; } +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/samples/samples.cc b/google/cloud/spanner/samples/samples.cc index 61277749062b4..5a225a10cd53c 100644 --- a/google/cloud/spanner/samples/samples.cc +++ b/google/cloud/spanner/samples/samples.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" //! [START spanner_quickstart] #include "google/cloud/spanner/client.h" @@ -6202,3 +6203,4 @@ int main(int ac, char* av[]) try { std::cerr << ex.what() << "\n"; return 1; } +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/session_pool_options_test.cc b/google/cloud/spanner/session_pool_options_test.cc index 2fc944f4237ff..c106359b8a53b 100644 --- a/google/cloud/spanner/session_pool_options_test.cc +++ b/google/cloud/spanner/session_pool_options_test.cc @@ -11,6 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/session_pool_options.h" #include "google/cloud/spanner/version.h" @@ -82,3 +83,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file diff --git a/google/cloud/spanner/transaction.cc b/google/cloud/spanner/transaction.cc index c4284201916a3..1c166e1a911f8 100644 --- a/google/cloud/spanner/transaction.cc +++ b/google/cloud/spanner/transaction.cc @@ -15,7 +15,10 @@ #include "google/cloud/spanner/transaction.h" #include "google/cloud/spanner/internal/session.h" #include "google/cloud/spanner/internal/transaction_impl.h" +// do no reorder +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/options.h" + #include "google/protobuf/duration.pb.h" namespace google { @@ -191,3 +194,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google +#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file From 2f6e9b2eb841ad43ff23ea3ec82e01cf9b737976 Mon Sep 17 00:00:00 2001 From: Scott Hart Date: Wed, 4 Feb 2026 15:08:40 -0500 Subject: [PATCH 2/5] update tests and disable deprecation warnings --- google/cloud/spanner/README.md | 3 +++ .../admin/integration_tests/backup_extra_integration_test.cc | 3 +-- .../admin/integration_tests/backup_integration_test.cc | 3 +-- .../cloud/spanner/benchmarks/multiple_rows_cpu_benchmark.cc | 3 +-- .../spanner/benchmarks/single_row_throughput_benchmark.cc | 3 +-- google/cloud/spanner/client.cc | 3 +-- google/cloud/spanner/client_test.cc | 3 +-- google/cloud/spanner/commit_options.cc | 2 +- google/cloud/spanner/connection.cc | 3 +-- .../spanner/integration_tests/client_integration_test.cc | 3 +-- google/cloud/spanner/integration_tests/client_stress_test.cc | 3 +-- .../spanner/integration_tests/data_types_integration_test.cc | 3 +-- .../integration_tests/session_pool_integration_test.cc | 3 +-- google/cloud/spanner/internal/connection_impl.cc | 3 +-- google/cloud/spanner/internal/connection_impl_test.cc | 3 +-- google/cloud/spanner/internal/defaults.cc | 3 +-- google/cloud/spanner/internal/defaults_test.cc | 3 +-- .../cloud/spanner/internal/partial_result_set_resume_test.cc | 3 +-- google/cloud/spanner/internal/partial_result_set_source.cc | 3 +-- .../cloud/spanner/internal/partial_result_set_source_test.cc | 3 +-- google/cloud/spanner/internal/route_to_leader.cc | 3 +-- google/cloud/spanner/internal/route_to_leader_test.cc | 3 +-- google/cloud/spanner/internal/session_pool.cc | 3 +-- google/cloud/spanner/internal/session_pool_test.cc | 3 +-- google/cloud/spanner/partition_options.cc | 3 +-- google/cloud/spanner/query_options.cc | 3 +-- google/cloud/spanner/query_options_test.cc | 3 +-- google/cloud/spanner/query_partition.cc | 3 +-- google/cloud/spanner/query_partition_test.cc | 4 +--- google/cloud/spanner/quickstart/quickstart.cc | 2 +- google/cloud/spanner/read_options.cc | 3 +-- google/cloud/spanner/read_partition.cc | 3 +-- google/cloud/spanner/read_partition_test.cc | 3 +-- google/cloud/spanner/results_test.cc | 3 +-- google/cloud/spanner/samples/client_samples.cc | 3 +-- google/cloud/spanner/samples/graph_samples.cc | 3 +-- google/cloud/spanner/samples/mock_execute_query.cc | 2 +- google/cloud/spanner/samples/postgresql_samples.cc | 3 +-- google/cloud/spanner/samples/samples.cc | 2 +- google/cloud/spanner/session_pool_options_test.cc | 3 +-- google/cloud/spanner/transaction.cc | 3 +-- 41 files changed, 43 insertions(+), 77 deletions(-) diff --git a/google/cloud/spanner/README.md b/google/cloud/spanner/README.md index e02250f356a8a..01463c94475ca 100644 --- a/google/cloud/spanner/README.md +++ b/google/cloud/spanner/README.md @@ -18,6 +18,8 @@ this library. ```cc +#include "google/cloud/internal/disable_deprecation_warnings.inc" + #include "google/cloud/spanner/client.h" #include @@ -45,6 +47,7 @@ int main(int argc, char* argv[]) { return 0; } +#include "google/cloud/internal/diagnostics_pop.inc" ``` diff --git a/google/cloud/spanner/admin/integration_tests/backup_extra_integration_test.cc b/google/cloud/spanner/admin/integration_tests/backup_extra_integration_test.cc index deee6e2ea5e07..8e880f7fa88d7 100644 --- a/google/cloud/spanner/admin/integration_tests/backup_extra_integration_test.cc +++ b/google/cloud/spanner/admin/integration_tests/backup_extra_integration_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/admin/database_admin_options.h" #include "google/cloud/spanner/admin/instance_admin_client.h" @@ -542,4 +541,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/admin/integration_tests/backup_integration_test.cc b/google/cloud/spanner/admin/integration_tests/backup_integration_test.cc index 1b6f736ab8639..14085985883d5 100644 --- a/google/cloud/spanner/admin/integration_tests/backup_integration_test.cc +++ b/google/cloud/spanner/admin/integration_tests/backup_integration_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/admin/database_admin_options.h" #include "google/cloud/spanner/backoff_policy.h" @@ -276,4 +275,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/benchmarks/multiple_rows_cpu_benchmark.cc b/google/cloud/spanner/benchmarks/multiple_rows_cpu_benchmark.cc index 3b0dad3851a30..edfd09d82e1e6 100644 --- a/google/cloud/spanner/benchmarks/multiple_rows_cpu_benchmark.cc +++ b/google/cloud/spanner/benchmarks/multiple_rows_cpu_benchmark.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/benchmarks/benchmarks_config.h" #include "google/cloud/spanner/client.h" @@ -1435,4 +1434,4 @@ int main(int argc, char* argv[]) { : "database dropped\n"); return exit_status; } -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/benchmarks/single_row_throughput_benchmark.cc b/google/cloud/spanner/benchmarks/single_row_throughput_benchmark.cc index 0c14907412c93..115d324d601bc 100644 --- a/google/cloud/spanner/benchmarks/single_row_throughput_benchmark.cc +++ b/google/cloud/spanner/benchmarks/single_row_throughput_benchmark.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/benchmarks/benchmarks_config.h" #include "google/cloud/spanner/client.h" @@ -512,4 +511,4 @@ int main(int argc, char* argv[]) { : "database dropped\n"); return 0; } -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/client.cc b/google/cloud/spanner/client.cc index 7477132c3d79f..210e03858858c 100644 --- a/google/cloud/spanner/client.cc +++ b/google/cloud/spanner/client.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/client.h" #include "google/cloud/spanner/internal/connection_impl.h" #include "google/cloud/spanner/internal/spanner_stub_factory.h" @@ -433,4 +432,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/client_test.cc b/google/cloud/spanner/client_test.cc index 735032ea4b7eb..7d642c99dd7f8 100644 --- a/google/cloud/spanner/client_test.cc +++ b/google/cloud/spanner/client_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/client.h" #include "google/cloud/mocks/mock_stream_range.h" #include "google/cloud/spanner/connection.h" @@ -1340,4 +1339,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/commit_options.cc b/google/cloud/spanner/commit_options.cc index 385823bb1106d..40a627f890d3d 100644 --- a/google/cloud/spanner/commit_options.cc +++ b/google/cloud/spanner/commit_options.cc @@ -51,4 +51,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/connection.cc b/google/cloud/spanner/connection.cc index 0b5e2fde19ed0..8c7309423b4c3 100644 --- a/google/cloud/spanner/connection.cc +++ b/google/cloud/spanner/connection.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/connection.h" #include "google/cloud/spanner/query_partition.h" #include "google/cloud/spanner/read_partition.h" @@ -116,4 +115,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/integration_tests/client_integration_test.cc b/google/cloud/spanner/integration_tests/client_integration_test.cc index 1b5757949ce8d..f21bbec7a636a 100644 --- a/google/cloud/spanner/integration_tests/client_integration_test.cc +++ b/google/cloud/spanner/integration_tests/client_integration_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/client.h" #include "google/cloud/spanner/database.h" @@ -1770,4 +1769,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/integration_tests/client_stress_test.cc b/google/cloud/spanner/integration_tests/client_stress_test.cc index 1e8d451438ce1..f5f253ca57c09 100644 --- a/google/cloud/spanner/integration_tests/client_stress_test.cc +++ b/google/cloud/spanner/integration_tests/client_stress_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/client.h" #include "google/cloud/spanner/database.h" #include "google/cloud/spanner/testing/database_integration_test.h" @@ -303,4 +302,4 @@ int main(int argc, char* argv[]) { return RUN_ALL_TESTS(); } -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/integration_tests/data_types_integration_test.cc b/google/cloud/spanner/integration_tests/data_types_integration_test.cc index 6e171b3284eb5..1ea2f1e646f03 100644 --- a/google/cloud/spanner/integration_tests/data_types_integration_test.cc +++ b/google/cloud/spanner/integration_tests/data_types_integration_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/client.h" #include "google/cloud/spanner/database.h" @@ -1004,4 +1003,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/integration_tests/session_pool_integration_test.cc b/google/cloud/spanner/integration_tests/session_pool_integration_test.cc index c102054f8500e..ef3036e083e77 100644 --- a/google/cloud/spanner/integration_tests/session_pool_integration_test.cc +++ b/google/cloud/spanner/integration_tests/session_pool_integration_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/internal/defaults.h" #include "google/cloud/spanner/internal/session_pool.h" #include "google/cloud/spanner/internal/spanner_stub_factory.h" @@ -125,4 +124,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/internal/connection_impl.cc b/google/cloud/spanner/internal/connection_impl.cc index 52e738e2e7c8c..e7da01b3d48b2 100644 --- a/google/cloud/spanner/internal/connection_impl.cc +++ b/google/cloud/spanner/internal/connection_impl.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/internal/connection_impl.h" #include "google/cloud/spanner/internal/defaults.h" #include "google/cloud/spanner/internal/logging_result_set_reader.h" @@ -1447,4 +1446,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/internal/connection_impl_test.cc b/google/cloud/spanner/internal/connection_impl_test.cc index ac4be4a20a381..fb32f9f5c34b4 100644 --- a/google/cloud/spanner/internal/connection_impl_test.cc +++ b/google/cloud/spanner/internal/connection_impl_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/internal/connection_impl.h" #include "google/cloud/spanner/client.h" #include "google/cloud/spanner/internal/defaults.h" @@ -4763,4 +4762,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/internal/defaults.cc b/google/cloud/spanner/internal/defaults.cc index 8e2951f5ce1cd..fdfd785c366c8 100644 --- a/google/cloud/spanner/internal/defaults.cc +++ b/google/cloud/spanner/internal/defaults.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/internal/defaults.h" #include "google/cloud/spanner/internal/session_pool.h" #include "google/cloud/spanner/options.h" @@ -167,4 +166,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/internal/defaults_test.cc b/google/cloud/spanner/internal/defaults_test.cc index 5e6ec8695b68b..d3c2a498f65dd 100644 --- a/google/cloud/spanner/internal/defaults_test.cc +++ b/google/cloud/spanner/internal/defaults_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/internal/defaults.h" #include "google/cloud/spanner/internal/session_pool.h" #include "google/cloud/spanner/options.h" @@ -305,4 +304,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/internal/partial_result_set_resume_test.cc b/google/cloud/spanner/internal/partial_result_set_resume_test.cc index 382abfe53d576..7fef58f76f520 100644 --- a/google/cloud/spanner/internal/partial_result_set_resume_test.cc +++ b/google/cloud/spanner/internal/partial_result_set_resume_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/internal/partial_result_set_resume.h" #include "google/cloud/spanner/internal/partial_result_set_source.h" #include "google/cloud/spanner/mocks/row.h" @@ -611,4 +610,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/internal/partial_result_set_source.cc b/google/cloud/spanner/internal/partial_result_set_source.cc index 1c015bb474bfb..bf763ff48082a 100644 --- a/google/cloud/spanner/internal/partial_result_set_source.cc +++ b/google/cloud/spanner/internal/partial_result_set_source.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/internal/partial_result_set_source.h" #include "google/cloud/spanner/internal/merge_chunk.h" #include "google/cloud/spanner/options.h" @@ -300,4 +299,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/internal/partial_result_set_source_test.cc b/google/cloud/spanner/internal/partial_result_set_source_test.cc index 743d51920131a..bc3a408c41cff 100644 --- a/google/cloud/spanner/internal/partial_result_set_source_test.cc +++ b/google/cloud/spanner/internal/partial_result_set_source_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/internal/partial_result_set_source.h" #include "google/cloud/spanner/mocks/row.h" #include "google/cloud/spanner/options.h" @@ -939,4 +938,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/internal/route_to_leader.cc b/google/cloud/spanner/internal/route_to_leader.cc index 3b7e98fb4928c..0f219eba3071d 100644 --- a/google/cloud/spanner/internal/route_to_leader.cc +++ b/google/cloud/spanner/internal/route_to_leader.cc @@ -15,7 +15,6 @@ #include "google/cloud/spanner/internal/route_to_leader.h" // do no reorder #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/options.h" #include "google/cloud/options.h" @@ -36,4 +35,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/internal/route_to_leader_test.cc b/google/cloud/spanner/internal/route_to_leader_test.cc index c6dd34b494471..58785f7136f56 100644 --- a/google/cloud/spanner/internal/route_to_leader_test.cc +++ b/google/cloud/spanner/internal/route_to_leader_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/internal/route_to_leader.h" #include "google/cloud/spanner/options.h" #include "google/cloud/options.h" @@ -83,4 +82,4 @@ TEST_F(RouteToLeader, OptionFalse) { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/internal/session_pool.cc b/google/cloud/spanner/internal/session_pool.cc index 435a93752b237..ca064dad712c0 100644 --- a/google/cloud/spanner/internal/session_pool.cc +++ b/google/cloud/spanner/internal/session_pool.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/internal/session_pool.h" #include "google/cloud/spanner/internal/route_to_leader.h" #include "google/cloud/spanner/internal/session.h" @@ -735,4 +734,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/internal/session_pool_test.cc b/google/cloud/spanner/internal/session_pool_test.cc index 2ffe2fbe4d42c..16680772b5ca8 100644 --- a/google/cloud/spanner/internal/session_pool_test.cc +++ b/google/cloud/spanner/internal/session_pool_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/internal/session_pool.h" #include "google/cloud/spanner/internal/defaults.h" #include "google/cloud/spanner/internal/session.h" @@ -1040,4 +1039,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/partition_options.cc b/google/cloud/spanner/partition_options.cc index 15897336590cb..3e8195c51e699 100644 --- a/google/cloud/spanner/partition_options.cc +++ b/google/cloud/spanner/partition_options.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/partition_options.h" #include "google/cloud/spanner/options.h" @@ -73,4 +72,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/query_options.cc b/google/cloud/spanner/query_options.cc index 18292b06d064c..2d04751078508 100644 --- a/google/cloud/spanner/query_options.cc +++ b/google/cloud/spanner/query_options.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/query_options.h" #include "google/cloud/spanner/options.h" @@ -55,4 +54,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/query_options_test.cc b/google/cloud/spanner/query_options_test.cc index 449921016bb17..3a60d897656d6 100644 --- a/google/cloud/spanner/query_options_test.cc +++ b/google/cloud/spanner/query_options_test.cc @@ -13,7 +13,6 @@ // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/query_options.h" #include "google/cloud/spanner/options.h" #include "google/cloud/spanner/version.h" @@ -134,4 +133,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/query_partition.cc b/google/cloud/spanner/query_partition.cc index d84e8a72b8a14..289ba4c2fd0f0 100644 --- a/google/cloud/spanner/query_partition.cc +++ b/google/cloud/spanner/query_partition.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/query_partition.h" #include "google/cloud/internal/make_status.h" #include "google/spanner/v1/spanner.pb.h" @@ -134,4 +133,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/query_partition_test.cc b/google/cloud/spanner/query_partition_test.cc index 12d97a0aeda0c..cd34b2deda4a2 100644 --- a/google/cloud/spanner/query_partition_test.cc +++ b/google/cloud/spanner/query_partition_test.cc @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - - #include "google/cloud/spanner/query_partition.h" #include "google/cloud/spanner/connection.h" #include "google/cloud/spanner/testing/matchers.h" @@ -178,4 +176,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/quickstart/quickstart.cc b/google/cloud/spanner/quickstart/quickstart.cc index b4c1ff155f90b..e4b6a644a4924 100644 --- a/google/cloud/spanner/quickstart/quickstart.cc +++ b/google/cloud/spanner/quickstart/quickstart.cc @@ -42,4 +42,4 @@ int main(int argc, char* argv[]) { return 0; } //! [all] -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/read_options.cc b/google/cloud/spanner/read_options.cc index 8f3adbeb83b07..75cb195f4959e 100644 --- a/google/cloud/spanner/read_options.cc +++ b/google/cloud/spanner/read_options.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/read_options.h" #include "google/cloud/spanner/options.h" @@ -59,4 +58,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/read_partition.cc b/google/cloud/spanner/read_partition.cc index 67f03788b84c5..dab03a30d97f6 100644 --- a/google/cloud/spanner/read_partition.cc +++ b/google/cloud/spanner/read_partition.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/read_partition.h" #include "google/cloud/internal/make_status.h" #include "google/spanner/v1/spanner.pb.h" @@ -149,4 +148,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/read_partition_test.cc b/google/cloud/spanner/read_partition_test.cc index 17d58ebe5fee5..0e5481ae944b9 100644 --- a/google/cloud/spanner/read_partition_test.cc +++ b/google/cloud/spanner/read_partition_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/read_partition.h" #include "google/cloud/spanner/testing/matchers.h" #include "google/cloud/testing_util/is_proto_equal.h" @@ -235,4 +234,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/results_test.cc b/google/cloud/spanner/results_test.cc index 0baa6807e249d..a9d53bcb68c29 100644 --- a/google/cloud/spanner/results_test.cc +++ b/google/cloud/spanner/results_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/results.h" #include "google/cloud/spanner/mocks/mock_spanner_connection.h" #include "google/cloud/spanner/mocks/row.h" @@ -262,4 +261,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/samples/client_samples.cc b/google/cloud/spanner/samples/client_samples.cc index 6bc44174ec324..468bd1096fd32 100644 --- a/google/cloud/spanner/samples/client_samples.cc +++ b/google/cloud/spanner/samples/client_samples.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/admin/instance_admin_client.h" #include "google/cloud/spanner/client.h" @@ -141,4 +140,4 @@ int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) }); return example.Run(argc, argv); } -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/samples/graph_samples.cc b/google/cloud/spanner/samples/graph_samples.cc index 505588b945e09..547751b31df14 100644 --- a/google/cloud/spanner/samples/graph_samples.cc +++ b/google/cloud/spanner/samples/graph_samples.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/admin/database_admin_options.h" #include "google/cloud/spanner/client.h" @@ -608,4 +607,4 @@ int main(int ac, char* av[]) try { std::cerr << ex.what() << "\n"; return 1; } -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/samples/mock_execute_query.cc b/google/cloud/spanner/samples/mock_execute_query.cc index 9d17c76a47877..0086a05858645 100644 --- a/google/cloud/spanner/samples/mock_execute_query.cc +++ b/google/cloud/spanner/samples/mock_execute_query.cc @@ -109,4 +109,4 @@ TEST(MockSpannerClient, SuccessfulExecuteQuery) { } // namespace //! [all] -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/samples/postgresql_samples.cc b/google/cloud/spanner/samples/postgresql_samples.cc index 18a57e4808076..073fcbe11a9e7 100644 --- a/google/cloud/spanner/samples/postgresql_samples.cc +++ b/google/cloud/spanner/samples/postgresql_samples.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/admin/database_admin_client.h" #include "google/cloud/spanner/bytes.h" #include "google/cloud/spanner/client.h" @@ -1322,4 +1321,4 @@ int main(int ac, char* av[]) try { std::cerr << "\n" << ex.what() << "\n"; return 1; } -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/samples/samples.cc b/google/cloud/spanner/samples/samples.cc index 5a225a10cd53c..f543d663b4fdd 100644 --- a/google/cloud/spanner/samples/samples.cc +++ b/google/cloud/spanner/samples/samples.cc @@ -6203,4 +6203,4 @@ int main(int ac, char* av[]) try { std::cerr << ex.what() << "\n"; return 1; } -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/session_pool_options_test.cc b/google/cloud/spanner/session_pool_options_test.cc index c106359b8a53b..3ed25147a965f 100644 --- a/google/cloud/spanner/session_pool_options_test.cc +++ b/google/cloud/spanner/session_pool_options_test.cc @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. #include "google/cloud/internal/disable_deprecation_warnings.inc" - #include "google/cloud/spanner/session_pool_options.h" #include "google/cloud/spanner/version.h" #include @@ -83,4 +82,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" diff --git a/google/cloud/spanner/transaction.cc b/google/cloud/spanner/transaction.cc index 1c166e1a911f8..ea21d55462aab 100644 --- a/google/cloud/spanner/transaction.cc +++ b/google/cloud/spanner/transaction.cc @@ -18,7 +18,6 @@ // do no reorder #include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/options.h" - #include "google/protobuf/duration.pb.h" namespace google { @@ -194,4 +193,4 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal } // namespace cloud } // namespace google -#include "google/cloud/internal/diagnostics_pop.inc" \ No newline at end of file +#include "google/cloud/internal/diagnostics_pop.inc" From 19b8b09f8009d697c23a71b914624defaf6bf207 Mon Sep 17 00:00:00 2001 From: Scott Hart Date: Wed, 4 Feb 2026 15:29:23 -0500 Subject: [PATCH 3/5] cleanup --- google/cloud/spanner/commit_options.cc | 5 +- .../spanner/internal/connection_impl_test.cc | 596 +---------------- .../cloud/spanner/internal/route_to_leader.cc | 4 +- .../spanner/internal/session_pool_test.cc | 605 +----------------- google/cloud/spanner/transaction.cc | 4 +- 5 files changed, 12 insertions(+), 1202 deletions(-) diff --git a/google/cloud/spanner/commit_options.cc b/google/cloud/spanner/commit_options.cc index 40a627f890d3d..0291668647d2a 100644 --- a/google/cloud/spanner/commit_options.cc +++ b/google/cloud/spanner/commit_options.cc @@ -11,11 +11,8 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - -#include "google/cloud/spanner/commit_options.h" - -// do no reorder #include "google/cloud/internal/disable_deprecation_warnings.inc" +#include "google/cloud/spanner/commit_options.h" #include "google/cloud/spanner/options.h" namespace google { diff --git a/google/cloud/spanner/internal/connection_impl_test.cc b/google/cloud/spanner/internal/connection_impl_test.cc index fb32f9f5c34b4..20de839d7876b 100644 --- a/google/cloud/spanner/internal/connection_impl_test.cc +++ b/google/cloud/spanner/internal/connection_impl_test.cc @@ -286,17 +286,7 @@ google::spanner::v1::Transaction MakeTestTransaction( *txn.mutable_precommit_token() = token; return txn; } -#if 0 -// Create a `BatchCreateSessionsResponse` with the given `sessions`. -google::spanner::v1::BatchCreateSessionsResponse MakeSessionsResponse( - std::vector sessions) { - google::spanner::v1::BatchCreateSessionsResponse response; - for (auto& session : sessions) { - response.add_session()->set_name(std::move(session)); - } - return response; -} -#endif + // Create a `CommitResponse` with the given `commit_timestamp` and // `commit_stats`. google::spanner::v1::CommitResponse MakeCommitResponse( @@ -413,15 +403,6 @@ TEST(ConnectionImplTest, ReadCreateSessionFailure) { .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - // EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) - // .WillRepeatedly(Return( - // Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - // .Times(AtLeast(2)) - // .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - // "uh-oh in BatchCreateSessions"))); - // EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); - auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); auto rows = conn->Read( @@ -446,9 +427,6 @@ TEST(ConnectionImplTest, ReadStreamingReadFailure) { EXPECT_CALL(*mock, StreamingRead) .WillOnce( Return(ByMove(MakeReader({}, finish_status)))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -531,9 +509,6 @@ TEST(ConnectionImplTest, ReadSuccess) { EXPECT_THAT(request.resume_token(), Eq("restart-row-2")); return MakeReader({responses[1], responses[2]}); }); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -576,9 +551,6 @@ TEST(ConnectionImplTest, ReadDirectedRead) { return MakeReader( {R"pb(metadata: { transaction: { id: "ABCDEF00" } })pb"}); }); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -610,9 +582,6 @@ TEST(ConnectionImplTest, ReadPermanentFailure) { EXPECT_CALL(*mock, StreamingRead) .WillOnce(Return(ByMove(MakeReader( {}, internal::PermissionDeniedError("uh-oh"))))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -640,9 +609,6 @@ TEST(ConnectionImplTest, ReadTooManyTransientFailures) { return MakeReader( {}, internal::UnavailableError("try-again")); }); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -664,17 +630,12 @@ TEST(ConnectionImplTest, ReadImplicitBeginTransaction) { "placeholder_database_id"); EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); - // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - // .WillOnce(Return(MakeSessionsResponse({"multiplexed"}))); EXPECT_CALL(*mock, BeginTransaction).Times(0); auto constexpr kText = R"pb( metadata: { transaction: { id: "ABCDEF00" } } )pb"; EXPECT_CALL(*mock, StreamingRead) .WillOnce(Return(ByMove(MakeReader({kText})))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -730,10 +691,6 @@ TEST(ConnectionImplTest, ReadImplicitBeginTransactionOneTransientFailure) { _, _, AllOf(HasSession("multiplexed"), HasBeginTransaction()))) .InSequence(s) .WillOnce(Return(ByMove(std::move(ok_reader)))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .InSequence(s) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -796,10 +753,6 @@ TEST(ConnectionImplTest, ReadImplicitBeginTransactionOnePermanentFailure) { HasTransactionId("FEDCBA98")))) .InSequence(s) .WillOnce(Return(ByMove(std::move(ok_reader)))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .InSequence(s) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -844,10 +797,6 @@ TEST(ConnectionImplTest, ReadImplicitBeginTransactionPermanentFailure) { HasTransactionId("FEDCBA98")))) .InSequence(s) .WillOnce(Return(ByMove(std::move(reader2)))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .InSequence(s) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -891,9 +840,6 @@ TEST(ConnectionImplTest, ExecuteQueryStreamingReadFailure) { .WillOnce(Return(ByMove(MakeReader( {}, internal::PermissionDeniedError("uh-oh in GrpcReader::Finish"))))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -938,9 +884,6 @@ TEST(ConnectionImplTest, ExecuteQueryReadSuccess) { )pb"; EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce(Return(ByMove(MakeReader({kText})))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -982,9 +925,6 @@ TEST(ConnectionImplTest, ExecuteQueryDirectedRead) { return MakeReader( {R"pb(metadata: { transaction: { id: "00FEDCBA" } })pb"}); }); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1029,9 +969,6 @@ TEST(ConnectionImplTest, ExecuteQueryPgNumericResult) { )pb"; EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce(Return(ByMove(MakeReader({kText})))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1078,9 +1015,6 @@ TEST(ConnectionImplTest, ExecuteQueryJsonBResult) { )pb"; EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce(Return(ByMove(MakeReader({kText})))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1156,9 +1090,6 @@ TEST(ConnectionImplTest, ExecuteQueryNumericParameter) { google::spanner::v1::TypeAnnotationCode::PG_NUMERIC); return MakeReader({kResponsePgNumeric}); }); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1211,9 +1142,6 @@ TEST(ConnectionImplTest, ExecuteQueryPgOidResult) { )pb"; EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce(Return(ByMove(MakeReader({kText})))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1244,9 +1172,6 @@ TEST(ConnectionImplTest, ExecuteQueryImplicitBeginTransaction) { )pb"; EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce(Return(ByMove(MakeReader({kText})))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1538,11 +1463,6 @@ TEST(ConnectionImplTest, ExecuteDmlCreateSessionFailure) { EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - // .Times(AtLeast(2)) - // .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - // "uh-oh in BatchCreateSessions"))); - // EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1570,9 +1490,6 @@ TEST(ConnectionImplTest, ExecuteDmlDeleteSuccess) { EXPECT_CALL(*mock, ExecuteSql) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(response)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1598,9 +1515,6 @@ TEST(ConnectionImplTest, ExecuteDmlDeletePermanentFailure) { EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction())); EXPECT_CALL(*mock, ExecuteSql).WillOnce(Return(status)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); } auto conn = MakeConnectionImpl(db, mock); @@ -1630,9 +1544,6 @@ TEST(ConnectionImplTest, ExecuteDmlDeleteTooManyTransientFailures) { EXPECT_CALL(*mock, ExecuteSql) .Times(AtLeast(2)) .WillRepeatedly(Return(status)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); } auto conn = MakeConnectionImpl(db, mock); @@ -1664,10 +1575,6 @@ TEST(ConnectionImplTest, ExecuteDmlTransactionAtomicity) { // not valid the client fails any subsequent operations itself. EXPECT_CALL(*mock, ExecuteSql).WillOnce(Return(op_status)); EXPECT_CALL(*mock, BeginTransaction).WillOnce(Return(begin_status)); - - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); } auto conn = MakeConnectionImpl(db, mock); @@ -1698,10 +1605,6 @@ TEST(ConnectionImplTest, ExecuteDmlTransactionMissing) { ASSERT_TRUE(TextFormat::ParseFromString("metadata: {}", &response)); EXPECT_CALL(*mock, ExecuteSql).WillOnce(Return(response)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); - auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); spanner::Transaction txn = @@ -1748,9 +1651,6 @@ TEST(ConnectionImplTest, ProfileQuerySuccess) { )pb"; EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce(Return(ByMove(MakeReader({kText})))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1787,11 +1687,6 @@ TEST(ConnectionImplTest, ProfileQueryCreateSessionFailure) { EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - // .Times(AtLeast(2)) - // .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - // "uh-oh in BatchCreateSessions"))); - EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1815,9 +1710,6 @@ TEST(ConnectionImplTest, ProfileQueryStreamingReadFailure) { EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce( Return(ByMove(MakeReader({}, finish_status)))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1837,10 +1729,6 @@ TEST(ConnectionImplTest, ProfileDmlCreateSessionFailure) { EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - // .Times(AtLeast(2)) - // .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - // "uh-oh in BatchCreateSessions"))); EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); auto conn = MakeConnectionImpl(db, mock); @@ -1877,9 +1765,6 @@ TEST(ConnectionImplTest, ProfileDmlDeleteSuccess) { EXPECT_CALL(*mock, ExecuteSql) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(response)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -1920,9 +1805,6 @@ TEST(ConnectionImplTest, ProfileDmlDeletePermanentFailure) { EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction())); EXPECT_CALL(*mock, ExecuteSql).WillOnce(Return(status)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); } auto conn = MakeConnectionImpl(db, mock); @@ -1952,9 +1834,6 @@ TEST(ConnectionImplTest, ProfileDmlDeleteTooManyTransientFailures) { EXPECT_CALL(*mock, ExecuteSql) .Times(AtLeast(2)) .WillRepeatedly(Return(status)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); } auto conn = MakeConnectionImpl(db, mock); @@ -1983,9 +1862,6 @@ TEST(ConnectionImplTest, AnalyzeSqlSuccess) { EXPECT_CALL(*mock, ExecuteSql) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(ByMove(std::move(response)))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2009,11 +1885,6 @@ TEST(ConnectionImplTest, AnalyzeSqlCreateSessionFailure) { EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - // .Times(AtLeast(2)) - // .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - // "uh-oh in BatchCreateSessions"))); - // EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2038,9 +1909,6 @@ TEST(ConnectionImplTest, AnalyzeSqlDeletePermanentFailure) { EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction())); EXPECT_CALL(*mock, ExecuteSql).WillOnce(Return(status)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); } auto conn = MakeConnectionImpl(db, mock); @@ -2070,9 +1938,6 @@ TEST(ConnectionImplTest, AnalyzeSqlDeleteTooManyTransientFailures) { EXPECT_CALL(*mock, ExecuteSql) .Times(AtLeast(2)) .WillRepeatedly(Return(status)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); } auto conn = MakeConnectionImpl(db, mock); @@ -2217,9 +2082,6 @@ TEST(ConnectionImplTest, ExecuteBatchDmlPartialFailure) { google::spanner::v1::ExecuteBatchDmlResponse response; ASSERT_TRUE(TextFormat::ParseFromString(kText, &response)); EXPECT_CALL(*mock, ExecuteBatchDml).WillOnce(Return(response)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto request = { spanner::SqlStatement("UPDATE ..."), @@ -2256,9 +2118,6 @@ TEST(ConnectionImplTest, ExecuteBatchDmlPermanentFailure) { EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction())); EXPECT_CALL(*mock, ExecuteBatchDml).WillOnce(Return(status)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); } auto request = { @@ -2293,10 +2152,6 @@ TEST(ConnectionImplTest, ExecuteBatchDmlTooManyTransientFailures) { EXPECT_CALL(*mock, ExecuteBatchDml) .Times(AtLeast(2)) .WillRepeatedly(Return(status)); - - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); } auto request = { @@ -2338,9 +2193,6 @@ TEST(ConnectionImplTest, ExecuteBatchDmlNoResultSets) { AllOf(HasSession("multiplexed"), HasTransactionId("BD000001")))) .WillOnce(Return(response)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); } auto request = {spanner::SqlStatement("UPDATE ...")}; @@ -2380,9 +2232,6 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlDeleteSuccess) { {}, internal::UnavailableError("try-again in ExecutePartitionedDml"))))) .WillOnce(Return(ByMove(MakeReader({kTextResponse})))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2415,9 +2264,6 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlExcludeFromChangeStreams) { ExecuteStreamingSql( _, _, AllOf(HasRequestTag("tag"), HasTransactionTag("")))) .WillOnce(Return(ByMove(MakeReader({kTextResponse})))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span( @@ -2437,11 +2283,6 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlCreateSessionFailure) { EXPECT_CALL(*mock, CreateSession(_, _, HasDatabase(db))) .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - // .Times(AtLeast(2)) - // .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - // "uh-oh in BatchCreateSessions"))); - // EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2467,10 +2308,6 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlDeletePermanentFailure) { .WillOnce(Return(ByMove(MakeReader( {}, internal::InternalError("permanent failure"))))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); - auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); auto result = conn->ExecutePartitionedDml( @@ -2496,9 +2333,6 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlDeleteTooManyTransientFailures) { {}, internal::UnavailableError("try-again in ExecutePartitionedDml")); }); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2534,10 +2368,6 @@ TEST(ConnectionImplTest, ExecutePartitionedDmlRetryableInternalErrors) { "HTTP/2 error code: INTERNAL_ERROR\nReceived Rst Stream"))))) .WillOnce(Return(ByMove(MakeReader({kTextResponse})))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); - auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); auto result = conn->ExecutePartitionedDml( @@ -2556,9 +2386,6 @@ TEST(ConnectionImplTest, EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(Status(StatusCode::kPermissionDenied, "uh-oh in ExecutePartitionedDml"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2579,9 +2406,6 @@ TEST(ConnectionImplTest, .Times(AtLeast(2)) .WillRepeatedly(Return(Status(StatusCode::kUnavailable, "try-again in ExecutePartitionedDml"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("session-name"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2617,12 +2441,6 @@ TEST(ConnectionImplTest, CommitCreateSessionTooManyTransientFailures) { .WillRepeatedly(Return( Status(StatusCode::kUnavailable, "try-again in CreateSession"))); - // - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); - auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); auto commit = conn->Commit({spanner::MakeReadWriteTransaction()}); @@ -2646,9 +2464,6 @@ TEST(ConnectionImplTest, CommitCreateSessionRetry) { HasNakedTransactionId(txn.id())))) .WillOnce( Return(Status(StatusCode::kPermissionDenied, "uh-oh in Commit"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2674,9 +2489,6 @@ TEST(ConnectionImplTest, CommitBeginTransactionRetry) { AllOf(HasSession("multiplexed"), HasNakedTransactionId(txn.id())))) .WillOnce(Return(MakeCommitResponse(commit_timestamp))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2693,10 +2505,6 @@ TEST(ConnectionImplTest, CommitBeginTransactionSessionNotFound) { .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(SessionNotFoundError("multiplexed"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2717,9 +2525,6 @@ TEST(ConnectionImplTest, CommitBeginTransactionPermanentFailure) { EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return( Status(StatusCode::kInvalidArgument, "BeginTransaction failed"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2748,9 +2553,6 @@ TEST(ConnectionImplTest, CommitCommitPermanentFailure) { HasNakedTransactionId(txn.id())))) .WillOnce( Return(Status(StatusCode::kPermissionDenied, "uh-oh in Commit"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2772,9 +2574,6 @@ TEST(ConnectionImplTest, CommitCommitTooManyTransientFailures) { HasNakedTransactionId(txn.id())))) .WillOnce( Return(Status(StatusCode::kPermissionDenied, "uh-oh in Commit"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -2791,9 +2590,6 @@ TEST(ConnectionImplTest, CommitCommitInvalidatedTransaction) { .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, BeginTransaction).Times(0); EXPECT_CALL(*mock, Commit).Times(0); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2822,9 +2618,6 @@ TEST(ConnectionImplTest, CommitCommitIdempotentTransientSuccess) { HasNakedTransactionId("test-txn-id")))) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(MakeCommitResponse(commit_timestamp))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2854,9 +2647,6 @@ TEST(ConnectionImplTest, CommitSuccessWithTransactionId) { .WillOnce(Return(MakeCommitResponse( spanner::MakeTimestamp(std::chrono::system_clock::from_time_t(123)) .value()))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -2894,9 +2684,6 @@ TEST(ConnectionImplTest, CommitSuccessWithStats) { spanner::MakeTimestamp(std::chrono::system_clock::from_time_t(123)) .value(), spanner::CommitStats{42}))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3231,9 +3018,6 @@ TEST(ConnectionImplTest, CommitSuccessExcludeFromChangeStreams) { .WillOnce(Return(MakeCommitResponse( spanner::MakeTimestamp(std::chrono::system_clock::from_time_t(123)) .value()))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span( @@ -3262,9 +3046,6 @@ TEST(ConnectionImplTest, CommitSuccessWithMaxCommitDelay) { .WillOnce(Return(MakeCommitResponse( spanner::MakeTimestamp(std::chrono::system_clock::from_time_t(123)) .value()))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3291,9 +3072,6 @@ TEST(ConnectionImplTest, CommitSuccessWithCompression) { spanner::MakeTimestamp(std::chrono::system_clock::from_time_t(123)) .value()); }); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span( @@ -3331,9 +3109,6 @@ TEST(ConnectionImplTest, CommitAtLeastOnce) { EXPECT_THAT(request.request_options().transaction_tag(), IsEmpty()); return MakeCommitResponse(commit_timestamp); }); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3388,9 +3163,6 @@ TEST(ConnectionImplTest, CommitAtLeastOnceBatched) { commit_timestamp { seconds: 123 } )pb"}); }); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3406,66 +3178,6 @@ TEST(ConnectionImplTest, CommitAtLeastOnceBatched) { EXPECT_EQ(++it, commit_results.end()); } -#if 0 // session pool test -TEST(ConnectionImplTest, CommitAtLeastOnceBatchedSessionNotFound) { - auto mock = std::make_shared>(); - auto db = spanner::Database("placeholder_project", "placeholder_instance", - "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name-1"}))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name-2"}))); - using BatchWriteRequest = google::spanner::v1::BatchWriteRequest; - EXPECT_CALL(*mock, BatchWrite) - .WillOnce([](std::shared_ptr const&, Options const&, - BatchWriteRequest const& request) { - EXPECT_EQ("test-session-name-1", request.session()); - EXPECT_THAT(request.mutation_groups(), IsEmpty()); - EXPECT_FALSE(request.exclude_txn_from_change_streams()); - return MakeReader( - {}, SessionNotFoundError(request.session())); - }) - .WillOnce([&](std::shared_ptr const&, Options const&, - BatchWriteRequest const& request) { - EXPECT_EQ("test-session-name-2", request.session()); - EXPECT_THAT(request.mutation_groups(), IsEmpty()); - EXPECT_FALSE(request.exclude_txn_from_change_streams()); - return MakeReader( - {R"pb(status {} - commit_timestamp { seconds: 123 })pb"}); - }); - EXPECT_CALL( - *mock, AsyncDeleteSession(_, _, _, HasSessionName("test-session-name-2"))) - .WillOnce(Return(make_ready_future(Status{}))); - - auto conn = MakeConnectionImpl(db, mock); - internal::OptionsSpan span(MakeLimitedTimeOptions()); - { - auto commit_results = conn->BatchWrite({{}, Options{}}); - auto it = commit_results.begin(); - ASSERT_NE(it, commit_results.end()); - EXPECT_THAT(*it, Not(IsOk())); - EXPECT_TRUE(IsSessionNotFound(it->status())) << it->status(); - EXPECT_EQ(++it, commit_results.end()); - } - - // "test-session-name-1" should not have been returned to the pool. - // The best (only?) way to verify this is to make another write and - // check that another session was allocated (hence the strict mock). - { - auto commit_results = conn->BatchWrite({{}, Options{}}); - auto it = commit_results.begin(); - ASSERT_NE(it, commit_results.end()); - EXPECT_THAT( - *it, - IsOkAndHolds(AllOf( - Field(&spanner::BatchedCommitResult::indexes, IsEmpty()), - Field(&spanner::BatchedCommitResult::commit_timestamp, - Eq(spanner::MakeTimestamp(absl::FromUnixSeconds(123))))))); - EXPECT_EQ(++it, commit_results.end()); - } -} -#endif - TEST(ConnectionImplTest, CommitAtLeastOnceBatchedExcludeFromChangeStreams) { auto mock = std::make_shared(); auto db = spanner::Database("placeholder_project", "placeholder_instance", @@ -3495,9 +3207,6 @@ TEST(ConnectionImplTest, CommitAtLeastOnceBatchedExcludeFromChangeStreams) { commit_timestamp { seconds: 123 } )pb"}); }); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span( @@ -3521,10 +3230,6 @@ TEST(ConnectionImplTest, RollbackCreateSessionFailure) { EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .WillRepeatedly(Return( Status(StatusCode::kPermissionDenied, "uh-oh in CreateSession"))); - // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - // .Times(AtLeast(2)) - // .WillRepeatedly(Return(Status(StatusCode::kPermissionDenied, - // "uh-oh in BatchCreateSessions"))); EXPECT_CALL(*mock, Rollback).Times(0); EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); @@ -3550,9 +3255,6 @@ TEST(ConnectionImplTest, RollbackBeginTransaction) { AllOf(HasSession(session_name), HasNakedTransactionId(transaction_id)))) .WillOnce(Return(Status())); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3567,9 +3269,6 @@ TEST(ConnectionImplTest, RollbackSingleUseTransaction) { EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, Rollback).Times(0); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3593,9 +3292,6 @@ TEST(ConnectionImplTest, RollbackPermanentFailure) { HasNakedTransactionId(transaction_id)))) .WillOnce( Return(Status(StatusCode::kPermissionDenied, "uh-oh in Rollback"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -3619,9 +3315,6 @@ TEST(ConnectionImplTest, RollbackTooManyTransientFailures) { .Times(AtLeast(2)) .WillRepeatedly( Return(Status(StatusCode::kUnavailable, "try-again in Rollback"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -3644,9 +3337,6 @@ TEST(ConnectionImplTest, RollbackSuccess) { HasNakedTransactionId(transaction_id)))) .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(Status())); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3663,9 +3353,6 @@ TEST(ConnectionImplTest, RollbackInvalidatedTransaction) { EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, Rollback).Times(0); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3698,9 +3385,6 @@ TEST(ConnectionImplTest, ReadPartition) { return MakeReader( {R"pb(metadata: { transaction: { id: "ABCDEF00" } })pb"}); }); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3749,11 +3433,6 @@ TEST(ConnectionImplTest, PartitionReadSuccess) { .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(partition_response)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); - auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); spanner::Transaction txn = @@ -3800,10 +3479,6 @@ TEST(ConnectionImplTest, PartitionReadPermanentFailure) { EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction())); EXPECT_CALL(*mock, PartitionRead).WillOnce(Return(status)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); } auto conn = MakeConnectionImpl(db, mock); @@ -3834,10 +3509,6 @@ TEST(ConnectionImplTest, PartitionReadTooManyTransientFailures) { EXPECT_CALL(*mock, PartitionRead) .Times(AtLeast(2)) .WillRepeatedly(Return(status)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); } auto conn = MakeConnectionImpl(db, mock); @@ -3869,9 +3540,6 @@ TEST(ConnectionImplTest, QueryPartition) { return MakeReader( {R"pb(metadata: { transaction: { id: "ABCDEF00" } })pb"}); }); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); @@ -3914,11 +3582,6 @@ TEST(ConnectionImplTest, PartitionQuerySuccess) { .WillOnce(Return(Status(StatusCode::kUnavailable, "try-again"))) .WillOnce(Return(partition_response)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); - auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); spanner::SqlStatement sql_statement("SELECT * FROM Table"); @@ -3953,10 +3616,6 @@ TEST(ConnectionImplTest, PartitionQueryPermanentFailure) { EXPECT_CALL(*mock, BeginTransaction) .WillOnce(Return(MakeTestTransaction())); EXPECT_CALL(*mock, PartitionQuery).WillOnce(Return(failed_status)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); } auto conn = MakeConnectionImpl(db, mock); @@ -3987,10 +3646,6 @@ TEST(ConnectionImplTest, PartitionQueryTooManyTransientFailures) { EXPECT_CALL(*mock, PartitionQuery) .Times(AtLeast(2)) .WillRepeatedly(Return(failed_status)); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); } auto conn = MakeConnectionImpl(db, mock); @@ -4050,119 +3705,6 @@ TEST(ConnectionImplTest, MultipleThreads) { } } -#if 0 // session pool test -/** - * @test Verify Transactions remain bound to a single Session. - * - * This test makes interleaved Read() calls using two separate Transactions, - * and ensures each Transaction uses the same session consistently. - */ -TEST(ConnectionImplTest, TransactionSessionBinding) { - auto mock = std::make_shared(); - auto db = spanner::Database("placeholder_project", "placeholder_instance", - "placeholder_database_id"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"session-1"}))) - .WillOnce(Return(MakeSessionsResponse({"session-2"}))); - - constexpr int kNumResponses = 4; - std::array>, - kNumResponses> - readers; - for (int i = 0; i < kNumResponses; ++i) { - auto constexpr kText = R"pb( - metadata: { - row_type: { - fields: { - name: "Number", - type: { code: INT64 } - } - } - } - )pb"; - PartialResultSet response; - ASSERT_TRUE(TextFormat::ParseFromString(kText, &response)); - // The first two responses are reads from two different "begin" - // transactions. - if (i == 0) { - *response.mutable_metadata()->mutable_transaction() = - MakeTestTransaction("ABCDEF01"); - } else if (i == 1) { - *response.mutable_metadata()->mutable_transaction() = - MakeTestTransaction("ABCDEF02"); - } - response.add_values()->set_string_value(std::to_string(i)); - readers[i] = MakeReader({std::move(response)}); - } - - // Ensure the StreamingRead calls have the expected session and transaction - // IDs or "begin" set as appropriate. - { - InSequence s; - EXPECT_CALL( - *mock, StreamingRead( - _, _, AllOf(HasSession("session-1"), HasBeginTransaction()))) - .WillOnce(Return(ByMove(std::move(readers[0])))); - EXPECT_CALL( - *mock, StreamingRead( - _, _, AllOf(HasSession("session-2"), HasBeginTransaction()))) - .WillOnce(Return(ByMove(std::move(readers[1])))); - EXPECT_CALL(*mock, StreamingRead(_, _, - AllOf(HasSession("session-1"), - HasTransactionId("ABCDEF01")))) - .WillOnce(Return(ByMove(std::move(readers[2])))); - EXPECT_CALL(*mock, StreamingRead(_, _, - AllOf(HasSession("session-2"), - HasTransactionId("ABCDEF02")))) - .WillOnce(Return(ByMove(std::move(readers[3])))); - } - - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, HasSessionName("session-1"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, HasSessionName("session-2"))) - .WillOnce(Return(make_ready_future(Status{}))); - - // Now do the actual reads and verify the results. - auto conn = MakeConnectionImpl(db, mock); - internal::OptionsSpan span(MakeLimitedTimeOptions()); - - spanner::Transaction txn1 = - MakeReadOnlyTransaction(spanner::Transaction::ReadOnlyOptions()); - auto rows = conn->Read({txn1, "table", spanner::KeySet::All(), {"Number"}}); - EXPECT_THAT(txn1, - HasSessionAndTransaction("session-1", "ABCDEF01", false, "")); - for (auto& row : spanner::StreamOf>(rows)) { - ASSERT_STATUS_OK(row); - EXPECT_EQ(std::get<0>(*row), 0); - } - - spanner::Transaction txn2 = - MakeReadOnlyTransaction(spanner::Transaction::ReadOnlyOptions()); - rows = conn->Read({txn2, "table", spanner::KeySet::All(), {"Number"}}); - EXPECT_THAT(txn2, - HasSessionAndTransaction("session-2", "ABCDEF02", false, "")); - for (auto& row : spanner::StreamOf>(rows)) { - ASSERT_STATUS_OK(row); - EXPECT_EQ(std::get<0>(*row), 1); - } - - rows = conn->Read({txn1, "table", spanner::KeySet::All(), {"Number"}}); - EXPECT_THAT(txn1, - HasSessionAndTransaction("session-1", "ABCDEF01", false, "")); - for (auto& row : spanner::StreamOf>(rows)) { - ASSERT_STATUS_OK(row); - EXPECT_EQ(std::get<0>(*row), 2); - } - - rows = conn->Read({txn2, "table", spanner::KeySet::All(), {"Number"}}); - EXPECT_THAT(txn2, - HasSessionAndTransaction("session-2", "ABCDEF02", false, "")); - for (auto& row : spanner::StreamOf>(rows)) { - ASSERT_STATUS_OK(row); - EXPECT_EQ(std::get<0>(*row), 3); - } -} -#endif /** * @test Verify if a `Transaction` outlives the `ConnectionImpl` it was used * with, it does not call back into the deleted `ConnectionImpl` to release @@ -4182,14 +3724,6 @@ TEST(ConnectionImplTest, TransactionOutlivesConnection) { EXPECT_CALL(*mock, StreamingRead) .WillOnce(Return(ByMove(MakeReader({kText})))); - // Because the transaction outlives the connection, the session is not in - // the pool when the connection is destroyed, so the session is leaked. - // Only the multiplexed session is deleted. - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); - auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); spanner::Transaction txn = @@ -4206,76 +3740,6 @@ TEST(ConnectionImplTest, TransactionOutlivesConnection) { conn.reset(); } -#if 0 // session pool test -TEST(ConnectionImplTest, ReadSessionNotFound) { - auto mock = std::make_shared>(); - auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name-1"}))) - .WillOnce(Return(MakeSessionsResponse({"test-session-name-2"}))); - EXPECT_CALL(*mock, StreamingRead) - .WillOnce([](std::shared_ptr const&, Options const&, - google::spanner::v1::ReadRequest const& request) { - EXPECT_THAT(request.session(), Eq("test-session-name-1")); - EXPECT_THAT(request.transaction().id(), Eq("test-txn-id-1")); - return MakeReader( - {}, SessionNotFoundError(request.session())); - }) - .WillOnce([](std::shared_ptr const&, Options const&, - google::spanner::v1::ReadRequest const& request) { - EXPECT_THAT(request.session(), Eq("test-session-name-2")); - EXPECT_THAT(request.transaction().id(), Eq("test-txn-id-2")); - return MakeReader({ - R"pb( - metadata: { - row_type: { - fields: { - name: "UserId", - type: { code: INT64 } - } - fields: { - name: "UserName", - type: { code: STRING } - } - } - } - )pb"}); - }); - EXPECT_CALL( - *mock, AsyncDeleteSession(_, _, _, HasSessionName("test-session-name-1"))) - .Times(0); - EXPECT_CALL( - *mock, AsyncDeleteSession(_, _, _, HasSessionName("test-session-name-2"))) - .WillOnce(Return(make_ready_future(Status{}))); - - auto conn = MakeConnectionImpl(db, mock); - internal::OptionsSpan span(MakeLimitedRetryOptions()); - { - auto txn = spanner::MakeReadWriteTransaction(); - SetTransactionId(txn, "test-txn-id-1"); - auto params = spanner::Connection::ReadParams{txn}; - auto response = GetSingularRow(conn->Read(std::move(params))); - EXPECT_THAT(response, Not(IsOk())); - auto const& status = response.status(); - EXPECT_TRUE(IsSessionNotFound(status)) << status; - EXPECT_THAT(txn, HasBadSession()); - } - - // "test-session-name-1" should not have been returned to the pool. - // The best (only?) way to verify this is to make another read and - // check that another session was allocated (hence the strict mock). - { - auto txn = spanner::MakeReadWriteTransaction(); - SetTransactionId(txn, "test-txn-id-2"); - auto params = spanner::Connection::ReadParams{txn}; - auto rows = conn->Read(std::move(params)); - using RowType = std::tuple; - auto stream = spanner::StreamOf(rows); - auto actual = std::vector>{stream.begin(), stream.end()}; - EXPECT_THAT(actual, IsEmpty()); - } -} -#endif TEST(ConnectionImplTest, PartitionReadSessionNotFound) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); @@ -4283,10 +3747,6 @@ TEST(ConnectionImplTest, PartitionReadSessionNotFound) { .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, PartitionRead) .WillOnce(Return(SessionNotFoundError("multiplexed"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4309,10 +3769,6 @@ TEST(ConnectionImplTest, ExecuteQuerySessionNotFound) { EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce( Return(ByMove(MakeReader({}, finish_status)))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4334,10 +3790,6 @@ TEST(ConnectionImplTest, ProfileQuerySessionNotFound) { EXPECT_CALL(*mock, ExecuteStreamingSql) .WillOnce( Return(ByMove(MakeReader({}, finish_status)))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4357,10 +3809,6 @@ TEST(ConnectionImplTest, ExecuteDmlSessionNotFound) { .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, ExecuteSql) .WillOnce(Return(SessionNotFoundError("multiplexed"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4380,10 +3828,6 @@ TEST(ConnectionImplTest, ProfileDmlSessionNotFound) { .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, ExecuteSql) .WillOnce(Return(SessionNotFoundError("multiplexed"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4403,10 +3847,6 @@ TEST(ConnectionImplTest, AnalyzeSqlSessionNotFound) { .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, ExecuteSql) .WillOnce(Return(SessionNotFoundError("multiplexed"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4426,10 +3866,6 @@ TEST(ConnectionImplTest, PartitionQuerySessionNotFound) { .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, PartitionQuery) .WillOnce(Return(SessionNotFoundError("multiplexed"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4449,10 +3885,6 @@ TEST(ConnectionImplTest, ExecuteBatchDmlSessionNotFound) { .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, ExecuteBatchDml) .WillOnce(Return(SessionNotFoundError("multiplexed"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4479,10 +3911,6 @@ TEST(ConnectionImplTest, CommitSessionNotFound) { .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, Commit) .WillOnce(Return(SessionNotFoundError("multiplexed"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4502,10 +3930,6 @@ TEST(ConnectionImplTest, RollbackSessionNotFound) { .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, Rollback) .WillOnce(Return(SessionNotFoundError("multiplexed"))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, - // Not(HasSessionName("multiplexed")))) - // .Times(0); auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedRetryOptions()); @@ -4521,9 +3945,6 @@ TEST(ConnectionImplTest, ReadRequestOrderByParameterUnspecified) { auto db = spanner::Database("project", "instance", "database"); EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); Sequence s; EXPECT_CALL( *mock, @@ -4556,9 +3977,6 @@ TEST(ConnectionImplTest, ReadRequestOrderByParameterNoOrder) { auto db = spanner::Database("project", "instance", "database"); EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); Sequence s; EXPECT_CALL( *mock, @@ -4598,9 +4016,6 @@ TEST(ConnectionImplTest, ReadRequestLockHintParameterUnspecified) { auto db = spanner::Database("project", "instance", "database"); EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); Sequence s; EXPECT_CALL( *mock, @@ -4633,9 +4048,6 @@ TEST(ConnectionImplTest, ReadRequestLockHintShared) { auto db = spanner::Database("project", "instance", "database"); EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); Sequence s; EXPECT_CALL( *mock, @@ -4678,12 +4090,6 @@ TEST(ConnectionImplTest, OperationsFailOnInvalidatedTransaction) { EXPECT_CALL(*mock, CreateSession(_, _, IsMultiplexed())) .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); - // EXPECT_CALL(*mock, BatchCreateSessions(_, _, HasDatabase(db))) - // .WillOnce(Return(MakeSessionsResponse({"multiplexed"}))); - // EXPECT_CALL(*mock, - // AsyncDeleteSession(_, _, _, HasSessionName("multiplexed"))) - // .WillOnce(Return(make_ready_future(Status{}))); - auto conn = MakeConnectionImpl(db, mock); internal::OptionsSpan span(MakeLimitedTimeOptions()); diff --git a/google/cloud/spanner/internal/route_to_leader.cc b/google/cloud/spanner/internal/route_to_leader.cc index 0f219eba3071d..b404321fca9ec 100644 --- a/google/cloud/spanner/internal/route_to_leader.cc +++ b/google/cloud/spanner/internal/route_to_leader.cc @@ -11,10 +11,8 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - -#include "google/cloud/spanner/internal/route_to_leader.h" -// do no reorder #include "google/cloud/internal/disable_deprecation_warnings.inc" +#include "google/cloud/spanner/internal/route_to_leader.h" #include "google/cloud/spanner/options.h" #include "google/cloud/options.h" diff --git a/google/cloud/spanner/internal/session_pool_test.cc b/google/cloud/spanner/internal/session_pool_test.cc index 16680772b5ca8..39029b9af5c21 100644 --- a/google/cloud/spanner/internal/session_pool_test.cc +++ b/google/cloud/spanner/internal/session_pool_test.cc @@ -124,21 +124,7 @@ google::spanner::v1::Session MakeMultiplexedSession(std::string name, session.set_multiplexed(true); return session; } -#if 0 -// Create a response with the given `sessions`. -google::spanner::v1::BatchCreateSessionsResponse MakeSessionsResponse( - std::vector sessions, std::string role = "") { - google::spanner::v1::BatchCreateSessionsResponse response; - for (auto& session : sessions) { - auto* s = response.add_session(); - s->set_name(std::move(session)); - *s->mutable_create_time() = Now(); - *s->mutable_approximate_last_use_time() = Now(); - if (!role.empty()) s->set_creator_role(role); - } - return response; -} -#endif + std::shared_ptr MakeTestSessionPool( spanner::Database db, std::vector> stubs, CompletionQueue cq, Options opts = {}) { @@ -186,7 +172,7 @@ TEST_F(SessionPoolTest, MultiplexedAllocateRouteToLeader) { auto pool = MakeTestSessionPool(db, {mock}, threads.cq(), Options{}.set(true)); - // .set({})); + auto session = pool->Multiplexed(); ASSERT_STATUS_OK(session); EXPECT_EQ((*session)->session_name(), "multiplexed"); @@ -207,20 +193,6 @@ TEST_F(SessionPoolTest, AllocateRouteToLeader) { return MakeMultiplexedSession("multiplexed"); }); - // EXPECT_CALL(*mock, - // BatchCreateSessions( - // _, _, AllOf(DatabaseIs(db.FullName()), - // SessionCountIs(42)))) - // .WillOnce([this](grpc::ClientContext& context, Options const&, - // google::spanner::v1::BatchCreateSessionsRequest - // const&) { - // EXPECT_THAT(GetMetadata(context), - // Contains(Pair(kRouteToLeader, "true"))); - // return MakeSessionsResponse({"session1"}); - // }); - // EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session1"))) - // .WillOnce(Return(make_ready_future(Status{}))); - google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; auto pool = MakeTestSessionPool(db, {mock}, threads.cq(), @@ -252,7 +224,7 @@ TEST_F(SessionPoolTest, MultiplexedAllocateNoRouteToLeader) { auto pool = MakeTestSessionPool(db, {mock}, threads.cq(), Options{}.set(false)); - // .set({})); + auto session = pool->Multiplexed(); ASSERT_STATUS_OK(session); EXPECT_EQ((*session)->session_name(), "multiplexed"); @@ -274,21 +246,6 @@ TEST_F(SessionPoolTest, AllocateNoRouteToLeader) { return MakeMultiplexedSession("multiplexed"); }); - // EXPECT_CALL(*mock, - // BatchCreateSessions( - // _, _, AllOf(DatabaseIs(db.FullName()), - // SessionCountIs(42)))) - // .WillOnce([this](grpc::ClientContext& context, Options const&, - // google::spanner::v1::BatchCreateSessionsRequest - // const&) { - // EXPECT_THAT(GetMetadata(context), - // AnyOf(Contains(Pair(kRouteToLeader, "false")), - // Not(Contains(Pair(kRouteToLeader, _))))); - // return MakeSessionsResponse({"session1"}); - // }); - // EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session1"))) - // .WillOnce(Return(make_ready_future(Status{}))); - google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; auto pool = MakeTestSessionPool(db, {mock}, threads.cq(), @@ -301,46 +258,6 @@ TEST_F(SessionPoolTest, AllocateNoRouteToLeader) { EXPECT_EQ(pool->GetStub(**session), mock); } -#if 0 -TEST_F(SessionPoolTest, ReleaseBadSession) { - auto mock = std::make_shared(); - auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, - BatchCreateSessions( - _, _, AllOf(DatabaseIs(db.FullName()), SessionCountIs(1)))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"session1"})))); - EXPECT_CALL(*mock, - BatchCreateSessions( - _, _, AllOf(DatabaseIs(db.FullName()), SessionCountIs(2)))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"session2"})))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session1"))) - .Times(0); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session2"))) - .WillOnce(Return(make_ready_future(Status{}))); - - google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - auto pool = MakeTestSessionPool( - db, {mock}, threads.cq(), - Options{}.set(1)); - { - auto session = pool->Allocate(); - ASSERT_STATUS_OK(session); - EXPECT_EQ((*session)->session_name(), "session1"); - } - { - auto session = pool->Allocate(); - ASSERT_STATUS_OK(session); - EXPECT_EQ((*session)->session_name(), "session1"); - (*session)->set_bad(); // Marking session1 as bad - } - { - auto session = pool->Allocate(); - ASSERT_STATUS_OK(session); - EXPECT_EQ((*session)->session_name(), "session2"); // Got a new session - } -} -#endif - TEST_F(SessionPoolTest, MultiplexedCreateError) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); @@ -350,29 +267,12 @@ TEST_F(SessionPoolTest, MultiplexedCreateError) { google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; auto pool = MakeTestSessionPool(db, {mock}, threads.cq(), {}); - // Options{}.set({})); + auto session = pool->Multiplexed(); EXPECT_THAT(session, StatusIs(StatusCode::kInternal, HasSubstr("init failure"))); } -#if 0 -TEST_F(SessionPoolTest, CreateError) { - auto mock = std::make_shared(); - auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions) - .WillOnce(Return(ByMove(Status(StatusCode::kInternal, "init failure")))) - .WillOnce(Return(ByMove(Status(StatusCode::kInternal, "some failure")))); - EXPECT_CALL(*mock, AsyncDeleteSession).Times(0); - - google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - auto pool = MakeTestSessionPool(db, {mock}, threads.cq()); - auto session = pool->Allocate(); - EXPECT_THAT(session, - StatusIs(StatusCode::kInternal, HasSubstr("some failure"))); -} -#endif - TEST_F(SessionPoolTest, ReuseSession) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); @@ -384,11 +284,6 @@ TEST_F(SessionPoolTest, ReuseSession) { return MakeMultiplexedSession("multiplexed"); }); - // EXPECT_CALL(*mock, BatchCreateSessions) - // .WillOnce(Return(ByMove(MakeSessionsResponse({"session1"})))); - // EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session1"))) - // .WillOnce(Return(make_ready_future(Status{}))); - google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; auto pool = MakeTestSessionPool(db, {mock}, threads.cq()); auto session = pool->Multiplexed(); @@ -401,182 +296,6 @@ TEST_F(SessionPoolTest, ReuseSession) { EXPECT_EQ((*session2)->session_name(), "multiplexed"); } -#if 0 // session pool test -TEST_F(SessionPoolTest, Lifo) { - auto mock = std::make_shared(); - auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions) - .WillOnce(Return(ByMove(MakeSessionsResponse({"session1"})))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"session2"})))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session1"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session2"))) - .WillOnce(Return(make_ready_future(Status{}))); - - google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - auto pool = MakeTestSessionPool(db, {mock}, threads.cq()); - auto session = pool->Allocate(); - ASSERT_STATUS_OK(session); - EXPECT_EQ((*session)->session_name(), "session1"); - - auto session2 = pool->Allocate(); - ASSERT_STATUS_OK(session2); - EXPECT_EQ((*session2)->session_name(), "session2"); - - session->reset(); - session2->reset(); - - // The pool is Last-In-First-Out (LIFO), so we expect to get the sessions - // back in the reverse order they were released. - auto session3 = pool->Allocate(); - ASSERT_STATUS_OK(session3); - EXPECT_EQ((*session3)->session_name(), "session2"); - - auto session4 = pool->Allocate(); - ASSERT_STATUS_OK(session4); - EXPECT_EQ((*session4)->session_name(), "session1"); -} -#endif - -#if 0 // pool test -TEST_F(SessionPoolTest, MinSessionsEagerAllocation) { - int const min_sessions = 3; - auto mock = std::make_shared(); - auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions(_, _, SessionCountIs(min_sessions))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"s3", "s2", "s1"})))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s1"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s2"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s3"))) - .WillOnce(Return(make_ready_future(Status{}))); - - google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - auto pool = MakeTestSessionPool( - db, {mock}, threads.cq(), - Options{}.set(min_sessions)); - auto session = pool->Allocate(); -} -#endif - -#if 0 // pool test -TEST_F(SessionPoolTest, MinSessionsMultipleAllocations) { - int const min_sessions = 3; - auto mock = std::make_shared(); - auto db = spanner::Database("project", "instance", "database"); - // The constructor will make this call. - EXPECT_CALL(*mock, BatchCreateSessions(_, _, SessionCountIs(min_sessions))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"s3", "s2", "s1"})))); - // When we run out of sessions it will make this call. - EXPECT_CALL(*mock, - BatchCreateSessions(_, _, SessionCountIs(min_sessions + 1))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"s7", "s6", "s5", "s4"})))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s1"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s2"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s3"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s4"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s5"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s6"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s7"))) - .WillOnce(Return(make_ready_future(Status{}))); - - google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - auto pool = MakeTestSessionPool( - db, {mock}, threads.cq(), - Options{}.set(min_sessions)); - std::vector sessions; - std::vector session_names; - for (int i = 1; i <= 7; ++i) { - auto session = pool->Allocate(); - ASSERT_STATUS_OK(session); - session_names.push_back((*session)->session_name()); - sessions.push_back(*std::move(session)); - } - EXPECT_THAT(session_names, - UnorderedElementsAre("s1", "s2", "s3", "s4", "s5", "s6", "s7")); -} -#endif - -#if 0 // pool test -TEST_F(SessionPoolTest, MaxSessionsFailOnExhaustion) { - int const max_sessions_per_channel = 3; - auto mock = std::make_shared(); - auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions) - .WillOnce(Return(ByMove(MakeSessionsResponse({"s1"})))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"s2"})))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"s3"})))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s1"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s2"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s3"))) - .WillOnce(Return(make_ready_future(Status{}))); - - google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - auto pool = MakeTestSessionPool( - db, {mock}, threads.cq(), - Options{} - .set( - max_sessions_per_channel) - .set( - spanner::ActionOnExhaustion::kFail)); - std::vector sessions; - std::vector session_names; - for (int i = 1; i <= 3; ++i) { - auto session = pool->Allocate(); - ASSERT_STATUS_OK(session); - session_names.push_back((*session)->session_name()); - sessions.push_back(*std::move(session)); - } - EXPECT_THAT(session_names, UnorderedElementsAre("s1", "s2", "s3")); - auto session = pool->Allocate(); - EXPECT_THAT(session, StatusIs(StatusCode::kResourceExhausted, - "session pool exhausted")); -} -#endif - -#if 0 // pool test -TEST_F(SessionPoolTest, MaxSessionsBlockUntilRelease) { - int const max_sessions_per_channel = 1; - auto mock = std::make_shared(); - auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock, BatchCreateSessions) - .WillOnce(Return(ByMove(MakeSessionsResponse({"s1"})))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s1"))) - .WillOnce(Return(make_ready_future(Status{}))); - - google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - auto pool = MakeTestSessionPool( - db, {mock}, threads.cq(), - Options{} - .set( - max_sessions_per_channel) - .set( - spanner::ActionOnExhaustion::kBlock)); - auto session = pool->Allocate(); - ASSERT_STATUS_OK(session); - EXPECT_EQ((*session)->session_name(), "s1"); - - // This thread will block in Allocate() until the main thread releases s1. - std::thread t([&pool]() { - auto session = pool->Allocate(); - ASSERT_STATUS_OK(session); - EXPECT_EQ((*session)->session_name(), "s1"); - }); - - session->reset(); - t.join(); -} -#endif - TEST_F(SessionPoolTest, MultiplexedLabels) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); @@ -605,27 +324,6 @@ TEST_F(SessionPoolTest, MultiplexedLabels) { EXPECT_EQ((*session)->session_name(), "multiplexed"); } -#if 0 -TEST_F(SessionPoolTest, Labels) { - auto mock = std::make_shared(); - auto db = spanner::Database("project", "instance", "database"); - std::map labels = { - {"k1", "v1"}, {"k2", "v2"}, {"k3", "v3"}}; - EXPECT_CALL(*mock, BatchCreateSessions(_, _, LabelsAre(labels))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"session1"})))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session1"))) - .WillOnce(Return(make_ready_future(Status{}))); - - google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - auto pool = MakeTestSessionPool( - db, {mock}, threads.cq(), - Options{}.set(std::move(labels))); - auto session = pool->Allocate(); - ASSERT_STATUS_OK(session); - EXPECT_EQ((*session)->session_name(), "session1"); -} -#endif - TEST_F(SessionPoolTest, MultiplexedCreatorRole) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); @@ -644,147 +342,12 @@ TEST_F(SessionPoolTest, MultiplexedCreatorRole) { auto pool = MakeTestSessionPool( db, {mock}, threads.cq(), Options{}.set(role)); - // .set({})); + auto session = pool->Multiplexed(); ASSERT_STATUS_OK(session); EXPECT_EQ((*session)->session_name(), "multiplexed"); } -#if 0 -TEST_F(SessionPoolTest, CreatorRole) { - auto mock = std::make_shared(); - auto db = spanner::Database("project", "instance", "database"); - std::string const role = "public"; - EXPECT_CALL(*mock, - BatchCreateSessions( - _, _, AllOf(DatabaseIs(db.FullName()), CreatorRoleIs(role)))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"session1"}, role)))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("session1"))) - .WillOnce(Return(make_ready_future(Status{}))); - - google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - auto pool = MakeTestSessionPool( - db, {mock}, threads.cq(), - Options{}.set(role)); - auto session = pool->Allocate(); - ASSERT_STATUS_OK(session); - EXPECT_EQ((*session)->session_name(), "session1"); -} -#endif - -#if 0 -TEST_F(SessionPoolTest, MultipleChannels) { - auto mock1 = std::make_shared(); - auto mock2 = std::make_shared(); - auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock1, CreateSession) - .WillRepeatedly( - Return(ByMove(Status(StatusCode::kInternal, "init failure")))); - EXPECT_CALL(*mock1, BatchCreateSessions) - .WillOnce(Return(ByMove(MakeSessionsResponse({"c1s1"})))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"c1s2"})))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"c1s3"})))); - EXPECT_CALL(*mock1, AsyncDeleteSession(_, _, _, SessionNameIs("c1s1"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock1, AsyncDeleteSession(_, _, _, SessionNameIs("c1s2"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock1, AsyncDeleteSession(_, _, _, SessionNameIs("c1s3"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock2, CreateSession) - .WillRepeatedly( - Return(ByMove(Status(StatusCode::kInternal, "init failure")))); - EXPECT_CALL(*mock2, BatchCreateSessions) - .WillOnce(Return(ByMove(MakeSessionsResponse({"c2s1"})))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"c2s2"})))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"c2s3"})))); - EXPECT_CALL(*mock2, AsyncDeleteSession(_, _, _, SessionNameIs("c2s1"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock2, AsyncDeleteSession(_, _, _, SessionNameIs("c2s2"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock2, AsyncDeleteSession(_, _, _, SessionNameIs("c2s3"))) - .WillOnce(Return(make_ready_future(Status{}))); - - google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - auto pool = MakeTestSessionPool(db, {mock1, mock2}, threads.cq()); - std::vector sessions; - std::vector session_names; - for (int i = 1; i <= 6; ++i) { - auto session = pool->Allocate(); - ASSERT_STATUS_OK(session); - session_names.push_back((*session)->session_name()); - sessions.push_back(*std::move(session)); - } - EXPECT_THAT(session_names, UnorderedElementsAre("c1s1", "c1s2", "c1s3", - "c2s1", "c2s2", "c2s3")); -} -#endif - -#if 0 -TEST_F(SessionPoolTest, MultipleChannelsPreAllocation) { - auto mock1 = std::make_shared(); - auto mock2 = std::make_shared(); - auto mock3 = std::make_shared(); - auto db = spanner::Database("project", "instance", "database"); - EXPECT_CALL(*mock1, CreateSession) - .WillRepeatedly( - Return(ByMove(Status(StatusCode::kInternal, "init failure")))); - EXPECT_CALL(*mock1, BatchCreateSessions) - .WillOnce(Return(ByMove(MakeSessionsResponse({"c1s1", "c1s2", "c1s3"})))); - EXPECT_CALL(*mock1, AsyncDeleteSession(_, _, _, SessionNameIs("c1s1"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock1, AsyncDeleteSession(_, _, _, SessionNameIs("c1s2"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock1, AsyncDeleteSession(_, _, _, SessionNameIs("c1s3"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock2, CreateSession) - .WillRepeatedly( - Return(ByMove(Status(StatusCode::kInternal, "init failure")))); - EXPECT_CALL(*mock2, BatchCreateSessions) - .WillOnce(Return(ByMove(MakeSessionsResponse({"c2s1", "c2s2", "c2s3"})))); - EXPECT_CALL(*mock2, AsyncDeleteSession(_, _, _, SessionNameIs("c2s1"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock2, AsyncDeleteSession(_, _, _, SessionNameIs("c2s2"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock2, AsyncDeleteSession(_, _, _, SessionNameIs("c2s3"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock3, CreateSession) - .WillRepeatedly( - Return(ByMove(Status(StatusCode::kInternal, "init failure")))); - EXPECT_CALL(*mock3, BatchCreateSessions) - .WillOnce(Return(ByMove(MakeSessionsResponse({"c3s1", "c3s2", "c3s3"})))); - EXPECT_CALL(*mock3, AsyncDeleteSession(_, _, _, SessionNameIs("c3s1"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock3, AsyncDeleteSession(_, _, _, SessionNameIs("c3s2"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock3, AsyncDeleteSession(_, _, _, SessionNameIs("c3s3"))) - .WillOnce(Return(make_ready_future(Status{}))); - - google::cloud::internal::AutomaticallyCreatedBackgroundThreads threads; - // note that min_sessions will effectively be reduced to 9 - // (max_sessions_per_channel * num_channels). - auto pool = MakeTestSessionPool( - db, {mock1, mock2, mock3}, threads.cq(), - Options{} - .set(3) - .set( - spanner::ActionOnExhaustion::kFail)); - std::vector sessions; - std::vector session_names; - for (int i = 1; i <= 9; ++i) { - auto session = pool->Allocate(); - ASSERT_STATUS_OK(session); - session_names.push_back((*session)->session_name()); - sessions.push_back(*std::move(session)); - } - EXPECT_THAT(session_names, - UnorderedElementsAre("c1s1", "c1s2", "c1s3", "c2s1", "c2s2", - "c2s3", "c3s1", "c3s2", "c3s3")); - auto session = pool->Allocate(); - EXPECT_THAT(session, StatusIs(StatusCode::kResourceExhausted, - "session pool exhausted")); -} -#endif - TEST_F(SessionPoolTest, GetStubForStublessSession) { auto mock = std::make_shared(); auto db = spanner::Database("project", "instance", "database"); @@ -825,7 +388,6 @@ TEST_F(SessionPoolTest, MultilpexedSessionReplacementSuccess) { background_interval) .set( replacement_interval)); - // .set({})); auto s1 = pool->Multiplexed(); ASSERT_STATUS_OK(s1); @@ -848,7 +410,7 @@ TEST_F(SessionPoolTest, MultilpexedSessionReplacementRpcPermanentFailure) { EXPECT_CALL( *mock, CreateSession(_, _, AllOf(DatabaseIs(db.FullName()), IsMultiplexed()))) - .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed1"})))); + .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, AsyncCreateSession(_, _, _, _)) .WillOnce(Return(make_ready_future(StatusOr( Status(StatusCode::kResourceExhausted, "retry policy exhausted"))))); @@ -867,173 +429,22 @@ TEST_F(SessionPoolTest, MultilpexedSessionReplacementRpcPermanentFailure) { background_interval) .set( replacement_interval)); - // .set({})); auto s1 = pool->Multiplexed(); ASSERT_STATUS_OK(s1); - EXPECT_EQ((*s1)->session_name(), "multiplexed1"); + EXPECT_EQ((*s1)->session_name(), "multiplexed"); clock->AdvanceTime(background_interval); impl->SimulateCompletion(true); auto s2 = pool->Multiplexed(); ASSERT_STATUS_OK(s2); - EXPECT_EQ((*s2)->session_name(), "multiplexed1"); + EXPECT_EQ((*s2)->session_name(), "multiplexed"); // Cancel all pending operations, satisfying any remaining futures. impl->SimulateCompletion(false); } -#if 0 -TEST_F(SessionPoolTest, SessionRefresh) { - auto mock = std::make_shared>(); - EXPECT_CALL(*mock, BatchCreateSessions) - .WillOnce(Return(ByMove(MakeSessionsResponse({"s1"})))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"s2"})))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s1"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s2"))) - .WillOnce(Return(make_ready_future(Status{}))); - - google::spanner::v1::ResultSet result; - auto constexpr kResultSetText = R"pb( - metadata: { - row_type: { fields: { type: { code: INT64 } } } - transaction: {} - } - rows: { values: { string_value: "1" } } - )pb"; - ASSERT_TRUE(TextFormat::ParseFromString(kResultSetText, &result)); - - EXPECT_CALL(*mock, AsyncExecuteSql) - .WillOnce( - [&result](CompletionQueue&, auto, auto, - google::spanner::v1::ExecuteSqlRequest const& request) { - EXPECT_EQ("s2", request.session()); - return make_ready_future(make_status_or(std::move(result))); - }); - - auto db = spanner::Database("project", "instance", "database"); - auto impl = std::make_shared(); - auto keep_alive_interval = std::chrono::seconds(1); - auto clock = std::make_shared(); - auto pool = MakeTestSessionPool( - db, {mock}, CompletionQueue(impl), - Options{} - .set(keep_alive_interval) - .set(clock)); - - // Allocate and release two session, "s1" and "s2". This will satisfy the - // BatchCreateSessions() expectations. - { - auto s1 = pool->Allocate(); - ASSERT_STATUS_OK(s1); - EXPECT_EQ("s1", (*s1)->session_name()); - { - auto s2 = pool->Allocate(); - ASSERT_STATUS_OK(s2); - EXPECT_EQ("s2", (*s2)->session_name()); - } - // Wait for "s2" to need refreshing before releasing "s1". - clock->AdvanceTime(keep_alive_interval * 2); - } - - // Simulate completion of pending operations, which will result in - // a call to RefreshExpiringSessions(). This should refresh "s2" and - // satisfy the AsyncExecuteSql() expectation. - impl->SimulateCompletion(true); - - // We should still be able to allocate sessions "s1" and "s2". - auto s1 = pool->Allocate(); - ASSERT_STATUS_OK(s1); - EXPECT_EQ("s1", (*s1)->session_name()); - auto s2 = pool->Allocate(); - ASSERT_STATUS_OK(s2); - EXPECT_EQ("s2", (*s2)->session_name()); - - // Cancel all pending operations, satisfying any remaining futures. When - // compiling with exceptions disabled the destructors eventually invoke - // `std::abort()`. On real programs, shutting down the completion queue - // will have the same effect. - impl->SimulateCompletion(false); -} - -#endif - -#if 0 -TEST_F(SessionPoolTest, SessionRefreshNotFound) { - auto mock = std::make_shared>(); - EXPECT_CALL(*mock, BatchCreateSessions) - .WillOnce(Return(ByMove(MakeSessionsResponse({"s1"})))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"s2"})))) - .WillOnce(Return(ByMove(MakeSessionsResponse({"s3"})))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s1"))) - .WillOnce(Return(make_ready_future(Status{}))); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s2"))).Times(0); - EXPECT_CALL(*mock, AsyncDeleteSession(_, _, _, SessionNameIs("s3"))) - .WillOnce(Return(make_ready_future(Status{}))); - - EXPECT_CALL(*mock, AsyncExecuteSql) - .WillOnce([](CompletionQueue&, auto, auto, - google::spanner::v1::ExecuteSqlRequest const& request) { - EXPECT_EQ("s2", request.session()); - // The "SELECT 1" refresh returns "Session not found". - return make_ready_future(StatusOr( - spanner_testing::SessionNotFoundError(request.session()))); - }); - - auto db = spanner::Database("project", "instance", "database"); - auto impl = std::make_shared(); - auto keep_alive_interval = std::chrono::seconds(1); - auto clock = std::make_shared(); - auto pool = MakeTestSessionPool( - db, {mock}, CompletionQueue(impl), - Options{} - .set(keep_alive_interval) - .set(clock)); - - // Allocate and release two session, "s1" and "s2". This will satisfy the - // the first two BatchCreateSessions() expectations. - { - auto s1 = pool->Allocate(); - ASSERT_STATUS_OK(s1); - EXPECT_EQ("s1", (*s1)->session_name()); - { - auto s2 = pool->Allocate(); - ASSERT_STATUS_OK(s2); - EXPECT_EQ("s2", (*s2)->session_name()); - } - // Wait for "s2" to need refreshing before releasing "s1". - clock->AdvanceTime(keep_alive_interval * 2); - } - EXPECT_EQ(pool->total_sessions(), 2); - - // Simulate completion of pending operations, which will result in - // a call to RefreshExpiringSessions(). This should refresh "s2" and - // satisfy the AsyncExecuteSql() expectation, which fails the call. - impl->SimulateCompletion(true); - EXPECT_EQ(pool->total_sessions(), 1); - - // We should still be able to allocate session "s1". - auto s1 = pool->Allocate(); - ASSERT_STATUS_OK(s1); - EXPECT_EQ("s1", (*s1)->session_name()); - EXPECT_EQ(pool->total_sessions(), 1); - - // However "s2" will be gone now, so a new allocation will produce - // "s3", satisfying the final BatchCreateSessions() expectation. - auto s3 = pool->Allocate(); - ASSERT_STATUS_OK(s3); - EXPECT_EQ("s3", (*s3)->session_name()); - EXPECT_EQ(pool->total_sessions(), 2); - - // Cancel all pending operations, satisfying any remaining futures. When - // compiling with exceptions disabled the destructors eventually invoke - // `std::abort()`. In non-test programs, the completion queue does this - // automatically as part of its shutdown. - impl->SimulateCompletion(false); -} -#endif } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace spanner_internal diff --git a/google/cloud/spanner/transaction.cc b/google/cloud/spanner/transaction.cc index ea21d55462aab..393f02906b32b 100644 --- a/google/cloud/spanner/transaction.cc +++ b/google/cloud/spanner/transaction.cc @@ -11,12 +11,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. - +#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/transaction.h" #include "google/cloud/spanner/internal/session.h" #include "google/cloud/spanner/internal/transaction_impl.h" -// do no reorder -#include "google/cloud/internal/disable_deprecation_warnings.inc" #include "google/cloud/spanner/options.h" #include "google/protobuf/duration.pb.h" From 943a22d16221ff453bfda8ceda8e6bb292cf74b3 Mon Sep 17 00:00:00 2001 From: Scott Hart Date: Wed, 4 Feb 2026 15:59:46 -0500 Subject: [PATCH 4/5] clang tidy --- google/cloud/bigtable/examples/table_admin_snippets.cc | 4 ++-- google/cloud/spanner/internal/connection_impl_test.cc | 3 --- google/cloud/spanner/internal/session_pool_test.cc | 7 ++----- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/google/cloud/bigtable/examples/table_admin_snippets.cc b/google/cloud/bigtable/examples/table_admin_snippets.cc index 6e6499a19d647..3f95b4b1fafd5 100644 --- a/google/cloud/bigtable/examples/table_admin_snippets.cc +++ b/google/cloud/bigtable/examples/table_admin_snippets.cc @@ -622,7 +622,7 @@ void DropRowsByPrefix( } void WaitForConsistencyCheck( - google::cloud::bigtable_admin::BigtableTableAdminClient admin, + google::cloud::bigtable_admin::BigtableTableAdminClient const& admin, std::vector const& argv) { //! [wait for consistency check] namespace cbt = ::google::cloud::bigtable; @@ -631,7 +631,7 @@ void WaitForConsistencyCheck( using ::google::cloud::future; using ::google::cloud::Status; using ::google::cloud::StatusOr; - [](cbta::BigtableTableAdminClient, std::string const& project_id, + [](cbta::BigtableTableAdminClient const&, std::string const& project_id, std::string const& instance_id, std::string const& table_id) { auto client = cbta::BigtableTableAdminClient( cbta::MakeBigtableTableAdminConnection()); diff --git a/google/cloud/spanner/internal/connection_impl_test.cc b/google/cloud/spanner/internal/connection_impl_test.cc index 20de839d7876b..5b8595ec3a4e4 100644 --- a/google/cloud/spanner/internal/connection_impl_test.cc +++ b/google/cloud/spanner/internal/connection_impl_test.cc @@ -90,8 +90,6 @@ using ::testing::Property; using ::testing::Return; using ::testing::Sequence; using ::testing::SetArgPointee; -using ::testing::StartsWith; -using ::testing::StrictMock; using ::testing::UnorderedElementsAre; using ::testing::UnorderedPointwise; using ::testing::Unused; @@ -3663,7 +3661,6 @@ TEST(ConnectionImplTest, MultipleThreads) { auto db = spanner::Database("project", "instance", "database"); std::string const session_prefix = "test-session-prefix-"; std::string const role = "TestRole"; - std::atomic session_counter(0); EXPECT_CALL(*mock, CreateSession(_, _, AllOf(IsMultiplexed()))) .WillOnce(Return(ByMove(MakeMultiplexedSession({"multiplexed"})))); EXPECT_CALL(*mock, Rollback) diff --git a/google/cloud/spanner/internal/session_pool_test.cc b/google/cloud/spanner/internal/session_pool_test.cc index 39029b9af5c21..17b7cafdbf914 100644 --- a/google/cloud/spanner/internal/session_pool_test.cc +++ b/google/cloud/spanner/internal/session_pool_test.cc @@ -47,7 +47,6 @@ namespace { using ::google::cloud::testing_util::FakeCompletionQueueImpl; using ::google::cloud::testing_util::FakeSteadyClock; using ::google::cloud::testing_util::StatusIs; -using ::google::protobuf::TextFormat; using ::testing::_; using ::testing::AllOf; using ::testing::AnyOf; @@ -57,8 +56,6 @@ using ::testing::HasSubstr; using ::testing::Not; using ::testing::Pair; using ::testing::Return; -using ::testing::StrictMock; -using ::testing::UnorderedElementsAre; auto constexpr kRouteToLeader = "x-goog-spanner-route-to-leader"; @@ -279,8 +276,8 @@ TEST_F(SessionPoolTest, ReuseSession) { EXPECT_CALL( *mock, CreateSession(_, _, AllOf(DatabaseIs(db.FullName()), IsMultiplexed()))) - .WillOnce([this](grpc::ClientContext& context, Options const&, - google::spanner::v1::CreateSessionRequest const&) { + .WillOnce([](grpc::ClientContext&, Options const&, + google::spanner::v1::CreateSessionRequest const&) { return MakeMultiplexedSession("multiplexed"); }); From 8b3bd0b451115df63a30f4c529f1daa6aa19f7b3 Mon Sep 17 00:00:00 2001 From: Scott Hart Date: Thu, 5 Feb 2026 17:48:51 -0500 Subject: [PATCH 5/5] disable some tests until emulator can be updated --- google/cloud/spanner/integration_tests/client_stress_test.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/google/cloud/spanner/integration_tests/client_stress_test.cc b/google/cloud/spanner/integration_tests/client_stress_test.cc index f5f253ca57c09..eab83e81d0b6f 100644 --- a/google/cloud/spanner/integration_tests/client_stress_test.cc +++ b/google/cloud/spanner/integration_tests/client_stress_test.cc @@ -148,6 +148,8 @@ TEST_F(ClientStressTest, ParseArgs) { /// @test Stress test the library using ExecuteQuery calls. TEST_F(ClientStressTest, UpsertAndSelect) { + // TODO(#15939): Update emulator and enable this test. + if (UsingEmulator()) GTEST_SKIP(); int const task_count = TaskCount(); auto select_task = [](Client client) { @@ -216,6 +218,8 @@ TEST_F(ClientStressTest, UpsertAndSelect) { /// @test Stress test the library using Read calls. TEST_F(ClientStressTest, UpsertAndRead) { + // TODO(#15939): Update emulator and enable this test. + if (UsingEmulator()) GTEST_SKIP(); int const task_count = TaskCount(); auto read_task = [](Client client) {