Skip to content

Commit b756cf5

Browse files
authored
ci(spanner): inject mux sessions into some integration tests (#15364)
1 parent 5af3cb7 commit b756cf5

File tree

6 files changed

+71
-7
lines changed

6 files changed

+71
-7
lines changed

google/cloud/spanner/integration_tests/BUILD.bazel

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
load(":spanner_client_integration_tests.bzl", "spanner_client_integration_tests")
16+
load(":spanner_client_session_mode_sensitive_integration_tests.bzl", "spanner_client_session_mode_sensitive_integration_tests")
1617

1718
package(default_visibility = ["//visibility:private"])
1819

@@ -37,3 +38,30 @@ licenses(["notice"]) # Apache 2.0
3738
"@com_google_googletest//:gtest_main",
3839
],
3940
) for test in spanner_client_integration_tests]
41+
42+
VARIATIONS = {
43+
"session-pool": {"GOOGLE_CLOUD_CPP_SPANNER_TESTING_SESSION_MODE": "pool"},
44+
"session-multiplexed": {"GOOGLE_CLOUD_CPP_SPANNER_TESTING_SESSION_MODE": "multiplexed"},
45+
}
46+
47+
[cc_test(
48+
name = test.replace("/", "_").replace(".cc", "") + "-" + v_label,
49+
timeout = "eternal",
50+
srcs = [test],
51+
env = v_env,
52+
tags = [
53+
"integration-test",
54+
"integration-test-" + v_label,
55+
],
56+
deps = [
57+
"//:common",
58+
"//:spanner",
59+
"//:spanner_mocks",
60+
"//google/cloud/spanner:spanner_client_testing_private",
61+
"//google/cloud/testing_util:google_cloud_cpp_testing_grpc_private",
62+
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
63+
"//protos:system_includes",
64+
"//protos/google/cloud/spanner/testing:singer_cc_proto",
65+
"@com_google_googletest//:gtest_main",
66+
],
67+
) for test in spanner_client_session_mode_sensitive_integration_tests for v_label, v_env in VARIATIONS.items()]

google/cloud/spanner/integration_tests/CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,31 @@ function (spanner_client_define_integration_tests)
2525
# cmake-format: sort
2626
backup_extra_integration_test.cc
2727
backup_integration_test.cc
28-
client_integration_test.cc
2928
client_stress_test.cc
3029
data_types_integration_test.cc
3130
database_admin_integration_test.cc
3231
instance_admin_integration_test.cc
3332
session_pool_integration_test.cc)
3433

34+
set(spanner_client_session_mode_sensitive_integration_tests
35+
# cmake-format: sort
36+
client_integration_test.cc)
37+
3538
# Export the list of unit tests to a .bzl file so we do not need to maintain
3639
# the list in two places.
3740
export_list_to_bazel("spanner_client_integration_tests.bzl"
3841
"spanner_client_integration_tests" YEAR "2019")
42+
export_list_to_bazel(
43+
"spanner_client_session_mode_sensitive_integration_tests.bzl"
44+
"spanner_client_session_mode_sensitive_integration_tests" YEAR "2025")
3945

4046
# Create a custom target so we can say "build all the tests"
4147
add_custom_target(spanner-client-integration-tests)
4248

4349
# Generate a target for each unit test.
44-
foreach (fname ${spanner_client_integration_tests})
50+
foreach (fname IN
51+
LISTS ${spanner_client_integration_tests}
52+
${spanner_client_session_mode_sensitive_integration_tests})
4553
google_cloud_cpp_add_executable(target "spanner" "${fname}")
4654
target_link_libraries(
4755
${target}

google/cloud/spanner/integration_tests/client_integration_test.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "google/cloud/spanner/mutations.h"
1919
#include "google/cloud/spanner/testing/database_integration_test.h"
2020
#include "google/cloud/credentials.h"
21+
#include "google/cloud/internal/getenv.h"
2122
#include "google/cloud/internal/random.h"
2223
#include "google/cloud/testing_util/status_matchers.h"
2324
#include <gmock/gmock.h>
@@ -49,9 +50,15 @@ class ClientIntegrationTest : public spanner_testing::DatabaseIntegrationTest {
4950
protected:
5051
static void SetUpTestSuite() {
5152
spanner_testing::DatabaseIntegrationTest::SetUpTestSuite();
52-
client_ = std::make_unique<Client>(MakeConnection(
53-
GetDatabase(),
54-
Options{}.set<GrpcCompressionAlgorithmOption>(GRPC_COMPRESS_GZIP)));
53+
auto options =
54+
Options{}.set<GrpcCompressionAlgorithmOption>(GRPC_COMPRESS_GZIP);
55+
auto session_mode =
56+
internal::GetEnv("GOOGLE_CLOUD_CPP_SPANNER_TESTING_SESSION_MODE");
57+
if (session_mode.has_value() && *session_mode == "multiplexed") {
58+
options.set<spanner_experimental::EnableMultiplexedSessionOption>({});
59+
}
60+
client_ = std::make_unique<Client>(
61+
MakeConnection(GetDatabase(), std::move(options)));
5562
}
5663

5764
void SetUp() override {

google/cloud/spanner/integration_tests/spanner_client_integration_tests.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
spanner_client_integration_tests = [
2020
"backup_extra_integration_test.cc",
2121
"backup_integration_test.cc",
22-
"client_integration_test.cc",
2322
"client_stress_test.cc",
2423
"data_types_integration_test.cc",
2524
"database_admin_integration_test.cc",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# DO NOT EDIT -- GENERATED BY CMake -- Change the CMakeLists.txt file if needed
16+
17+
"""Automatically generated unit tests list - DO NOT EDIT."""
18+
19+
spanner_client_session_mode_sensitive_integration_tests = [
20+
"client_integration_test.cc",
21+
]

google/cloud/spanner/options.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ using SessionPoolOptionList = OptionList<
252252
RouteToLeaderOption, SessionCreatorRoleOption, SessionPoolMinSessionsOption,
253253
SessionPoolMaxSessionsPerChannelOption, SessionPoolMaxIdleSessionsOption,
254254
SessionPoolActionOnExhaustionOption, SessionPoolKeepAliveIntervalOption,
255-
SessionPoolLabelsOption>;
255+
SessionPoolLabelsOption,
256+
spanner_experimental::EnableMultiplexedSessionOption>;
256257

257258
/**
258259
* Option for `google::cloud::Options` to set the optimizer version used in an

0 commit comments

Comments
 (0)