Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
Closed
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
4 changes: 2 additions & 2 deletions .github/.OwlBot.lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.
docker:
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
digest: sha256:5581906b957284864632cde4e9c51d1cc66b0094990b27e689132fe5cd036046
# created: 2025-03-05
digest: sha256:21c50ac6b72047705ceac7b3c84dca11f771f40b5cdfd8931bf1f446a89274e5
# created: 2025-04-14T15:05:23.836138399Z
70 changes: 70 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

DEFAULT_PYTHON_VERSION = "3.8"

DEFAULT_MOCK_SERVER_TESTS_PYTHON_VERSION = "3.12"
DEFAULT_MOCK_SERVER_TESTS_PYTHON_VERSION = "3.12"
UNIT_TEST_PYTHON_VERSIONS: List[str] = [
"3.7",
Expand Down Expand Up @@ -193,6 +194,30 @@ def install_unittest_dependencies(session, *constraints):
*session.posargs,
)

# XXX Work around Kokoro image's older pip, which borks the OT install.
session.run("pip", "install", "--upgrade", "pip")
constraints_path = str(
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
)
session.install("-e", ".[tracing]", "-c", constraints_path)
# XXX: Dump installed versions to debug OT issue
session.run("pip", "list")

# Run py.test against the unit tests with OpenTelemetry.
session.run(
"py.test",
"--quiet",
"--cov=google.cloud.spanner",
"--cov=google.cloud",
"--cov=tests.unit",
"--cov-append",
"--cov-config=.coveragerc",
"--cov-report=",
"--cov-fail-under=0",
os.path.join("tests", "unit"),
*session.posargs,
)


@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
@nox.parametrize(
Expand Down Expand Up @@ -263,6 +288,34 @@ def mockserver(session):
)


@nox.session(python=DEFAULT_MOCK_SERVER_TESTS_PYTHON_VERSION)
def mockserver(session):
# Install all test dependencies, then install this package in-place.

constraints_path = str(
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
)
# install_unittest_dependencies(session, "-c", constraints_path)
standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES
session.install(*standard_deps, "-c", constraints_path)
session.install("-e", ".", "-c", constraints_path)

# Run py.test against the mockserver tests.
session.run(
"py.test",
"--quiet",
f"--junitxml=unit_{session.python}_sponge_log.xml",
"--cov=google",
"--cov=tests/unit",
"--cov-append",
"--cov-config=.coveragerc",
"--cov-report=",
"--cov-fail-under=0",
os.path.join("tests", "mockserver_tests"),
*session.posargs,
)


def install_systemtest_dependencies(session, *constraints):
# Use pre-release gRPC for system tests.
# Exclude version 1.52.0rc1 which has a known issue.
Expand Down Expand Up @@ -327,6 +380,17 @@ def system(session, protobuf_implementation, database_dialect):
if os.environ.get("SPANNER_EMULATOR_HOST") and database_dialect == "POSTGRESQL":
session.skip("Postgresql is not supported by Emulator yet.")

# Sanity check: Only run tests if the environment variable is set.
if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", "") and not os.environ.get(
"SPANNER_EMULATOR_HOST", ""
):
session.skip(
"Credentials or emulator host must be set via environment variable"
)
# If POSTGRESQL tests and Emulator, skip the tests
if os.environ.get("SPANNER_EMULATOR_HOST") and database_dialect == "POSTGRESQL":
session.skip("Postgresql is not supported by Emulator yet.")

# Install pyopenssl for mTLS testing.
if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true":
session.install("pyopenssl")
Expand All @@ -339,6 +403,12 @@ def system(session, protobuf_implementation, database_dialect):

install_systemtest_dependencies(session, "-c", constraints_path)

# TODO(https://github.com/googleapis/synthtool/issues/1976):
# Remove the 'cpp' implementation once support for Protobuf 3.x is dropped.
# The 'cpp' implementation requires Protobuf<4.
if protobuf_implementation == "cpp":
session.install("protobuf<4")

# TODO(https://github.com/googleapis/synthtool/issues/1976):
# Remove the 'cpp' implementation once support for Protobuf 3.x is dropped.
# The 'cpp' implementation requires Protobuf<4.
Expand Down
Loading