Skip to content

ci(spanner): inject mux sessions into some integration tests #15364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions google/cloud/spanner/integration_tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

load(":spanner_client_integration_tests.bzl", "spanner_client_integration_tests")
load(":spanner_client_session_mode_sensitive_integration_tests.bzl", "spanner_client_session_mode_sensitive_integration_tests")

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

Expand All @@ -37,3 +38,30 @@ licenses(["notice"]) # Apache 2.0
"@com_google_googletest//:gtest_main",
],
) for test in spanner_client_integration_tests]

VARIATIONS = {
"session-pool": {"GOOGLE_CLOUD_CPP_SPANNER_TESTING_SESSION_MODE": "pool"},
"session-multiplexed": {"GOOGLE_CLOUD_CPP_SPANNER_TESTING_SESSION_MODE": "multiplexed"},
}

[cc_test(
name = test.replace("/", "_").replace(".cc", "") + "-" + v_label,
timeout = "eternal",
srcs = [test],
env = v_env,
tags = [
"integration-test",
"integration-test-" + v_label,
],
deps = [
"//:common",
"//:spanner",
"//:spanner_mocks",
"//google/cloud/spanner:spanner_client_testing_private",
"//google/cloud/testing_util:google_cloud_cpp_testing_grpc_private",
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
"//protos:system_includes",
"//protos/google/cloud/spanner/testing:singer_cc_proto",
"@com_google_googletest//:gtest_main",
],
) for test in spanner_client_session_mode_sensitive_integration_tests for v_label, v_env in VARIATIONS.items()]
12 changes: 10 additions & 2 deletions google/cloud/spanner/integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,31 @@ function (spanner_client_define_integration_tests)
# cmake-format: sort
backup_extra_integration_test.cc
backup_integration_test.cc
client_integration_test.cc
client_stress_test.cc
data_types_integration_test.cc
database_admin_integration_test.cc
instance_admin_integration_test.cc
session_pool_integration_test.cc)

set(spanner_client_session_mode_sensitive_integration_tests
# cmake-format: sort
client_integration_test.cc)

# Export the list of unit tests to a .bzl file so we do not need to maintain
# the list in two places.
export_list_to_bazel("spanner_client_integration_tests.bzl"
"spanner_client_integration_tests" YEAR "2019")
export_list_to_bazel(
"spanner_client_session_mode_sensitive_integration_tests.bzl"
"spanner_client_session_mode_sensitive_integration_tests" YEAR "2025")

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

# Generate a target for each unit test.
foreach (fname ${spanner_client_integration_tests})
foreach (fname IN
LISTS ${spanner_client_integration_tests}
${spanner_client_session_mode_sensitive_integration_tests})
google_cloud_cpp_add_executable(target "spanner" "${fname}")
target_link_libraries(
${target}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "google/cloud/spanner/mutations.h"
#include "google/cloud/spanner/testing/database_integration_test.h"
#include "google/cloud/credentials.h"
#include "google/cloud/internal/getenv.h"
#include "google/cloud/internal/random.h"
#include "google/cloud/testing_util/status_matchers.h"
#include <gmock/gmock.h>
Expand Down Expand Up @@ -49,9 +50,15 @@ class ClientIntegrationTest : public spanner_testing::DatabaseIntegrationTest {
protected:
static void SetUpTestSuite() {
spanner_testing::DatabaseIntegrationTest::SetUpTestSuite();
client_ = std::make_unique<Client>(MakeConnection(
GetDatabase(),
Options{}.set<GrpcCompressionAlgorithmOption>(GRPC_COMPRESS_GZIP)));
auto options =
Options{}.set<GrpcCompressionAlgorithmOption>(GRPC_COMPRESS_GZIP);
auto session_mode =
internal::GetEnv("GOOGLE_CLOUD_CPP_SPANNER_TESTING_SESSION_MODE");
if (session_mode.has_value() && *session_mode == "multiplexed") {
options.set<spanner_experimental::EnableMultiplexedSessionOption>({});
}
client_ = std::make_unique<Client>(
MakeConnection(GetDatabase(), std::move(options)));
}

void SetUp() override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
spanner_client_integration_tests = [
"backup_extra_integration_test.cc",
"backup_integration_test.cc",
"client_integration_test.cc",
"client_stress_test.cc",
"data_types_integration_test.cc",
"database_admin_integration_test.cc",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
#
# DO NOT EDIT -- GENERATED BY CMake -- Change the CMakeLists.txt file if needed

"""Automatically generated unit tests list - DO NOT EDIT."""

spanner_client_session_mode_sensitive_integration_tests = [
"client_integration_test.cc",
]
3 changes: 2 additions & 1 deletion google/cloud/spanner/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ using SessionPoolOptionList = OptionList<
RouteToLeaderOption, SessionCreatorRoleOption, SessionPoolMinSessionsOption,
SessionPoolMaxSessionsPerChannelOption, SessionPoolMaxIdleSessionsOption,
SessionPoolActionOnExhaustionOption, SessionPoolKeepAliveIntervalOption,
SessionPoolLabelsOption>;
SessionPoolLabelsOption,
spanner_experimental::EnableMultiplexedSessionOption>;

/**
* Option for `google::cloud::Options` to set the optimizer version used in an
Expand Down
Loading