Skip to content

Commit a147495

Browse files
committed
chore: refine prerelease_deps to conditionally run system tests
1 parent e5af288 commit a147495

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

packages/google-cloud-spanner/noxfile.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
DEFAULT_PYTHON_VERSION = "3.14"
3838

3939
DEFAULT_MOCK_SERVER_TESTS_PYTHON_VERSION = "3.12"
40-
SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.14"]
40+
SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.12"]
4141

4242
UNIT_TEST_PYTHON_VERSIONS: List[str] = [
4343
"3.9",
@@ -656,6 +656,7 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
656656
system_test_path = os.path.join("tests", "system.py")
657657
system_test_folder_path = os.path.join("tests", "system")
658658

659+
<<<<<<< HEAD
659660
if os.environ.get("SPANNER_EMULATOR_HOST"):
660661
# Run tests against the emulator
661662
run_system = True
@@ -710,6 +711,41 @@ def prerelease_deps(session, protobuf_implementation, database_dialect):
710711

711712
=======
712713
>>>>>>> d4bff6eaee2 (chore: improves logic within prerelease_deps session)
714+
=======
715+
# Only run system tests for one protobuf implementation on real Spanner to speed up the build.
716+
if os.environ.get("SPANNER_EMULATOR_HOST") or protobuf_implementation == "python":
717+
# Sanity check: Only run system tests if credentials or emulator are set.
718+
if os.environ.get("GOOGLE_APPLICATION_CREDENTIALS") or os.environ.get("SPANNER_EMULATOR_HOST"):
719+
# Only run system tests if found.
720+
if os.path.exists(system_test_path):
721+
session.run(
722+
"py.test",
723+
"--verbose",
724+
f"--junitxml=system_{session.python}_sponge_log.xml",
725+
system_test_path,
726+
*session.posargs,
727+
env={
728+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
729+
"SPANNER_DATABASE_DIALECT": database_dialect,
730+
"SKIP_BACKUP_TESTS": "true",
731+
},
732+
)
733+
elif os.path.exists(system_test_folder_path):
734+
session.run(
735+
"py.test",
736+
"--verbose",
737+
f"--junitxml=system_{session.python}_sponge_log.xml",
738+
system_test_folder_path,
739+
*session.posargs,
740+
env={
741+
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
742+
"SPANNER_DATABASE_DIALECT": database_dialect,
743+
"SKIP_BACKUP_TESTS": "true",
744+
},
745+
)
746+
else:
747+
session.log("Skipping system tests because credentials/emulator are missing")
748+
>>>>>>> 3cda3a846be (chore: refine prerelease_deps to conditionally run system tests)
713749

714750
@nox.session(python=DEFAULT_PYTHON_VERSION)
715751
def mypy(session):

0 commit comments

Comments
 (0)