diff --git a/.github/workflows/integration-tests-against-emulator-with-regular-session.yaml b/.github/workflows/integration-tests-against-emulator-with-regular-session.yaml index 826a3b7629..3f2d3b7ba2 100644 --- a/.github/workflows/integration-tests-against-emulator-with-regular-session.yaml +++ b/.github/workflows/integration-tests-against-emulator-with-regular-session.yaml @@ -21,7 +21,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v6 with: - python-version: 3.13 + python-version: 3.14 - name: Install nox run: python -m pip install nox - name: Run system tests diff --git a/.github/workflows/integration-tests-against-emulator.yaml b/.github/workflows/integration-tests-against-emulator.yaml index e7158307b8..e8078107bc 100644 --- a/.github/workflows/integration-tests-against-emulator.yaml +++ b/.github/workflows/integration-tests-against-emulator.yaml @@ -21,7 +21,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v6 with: - python-version: 3.13 + python-version: 3.14 - name: Install nox run: python -m pip install nox - name: Run system tests diff --git a/.github/workflows/mock_server_tests.yaml b/.github/workflows/mock_server_tests.yaml index b705c98191..d16feac517 100644 --- a/.github/workflows/mock_server_tests.yaml +++ b/.github/workflows/mock_server_tests.yaml @@ -14,7 +14,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v6 with: - python-version: 3.13 + python-version: 3.14 - name: Install nox run: python -m pip install nox - name: Run mock server tests diff --git a/.github/workflows/presubmit.yaml b/.github/workflows/presubmit.yaml index 6e5f1af29b..56386a746c 100644 --- a/.github/workflows/presubmit.yaml +++ b/.github/workflows/presubmit.yaml @@ -27,7 +27,7 @@ jobs: strategy: fail-fast: false matrix: - python: ["3.9", "3.10", "3.11", "3.12", "3.13"] + python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] steps: - name: Checkout code diff --git a/.kokoro/presubmit/integration-regular-sessions-enabled.cfg b/.kokoro/presubmit/integration-regular-sessions-enabled.cfg index 1f646bebf2..439abd4ba5 100644 --- a/.kokoro/presubmit/integration-regular-sessions-enabled.cfg +++ b/.kokoro/presubmit/integration-regular-sessions-enabled.cfg @@ -3,7 +3,7 @@ # Only run a subset of all nox sessions env_vars: { key: "NOX_SESSION" - value: "unit-3.9 unit-3.12 system-3.12" + value: "unit-3.9 unit-3.14 system-3.14" } env_vars: { diff --git a/.kokoro/presubmit/system-3.12.cfg b/.kokoro/presubmit/system-3.14.cfg similarity index 81% rename from .kokoro/presubmit/system-3.12.cfg rename to .kokoro/presubmit/system-3.14.cfg index 78cdc5e851..73904141ba 100644 --- a/.kokoro/presubmit/system-3.12.cfg +++ b/.kokoro/presubmit/system-3.14.cfg @@ -3,5 +3,5 @@ # Only run this nox session. env_vars: { key: "NOX_SESSION" - value: "system-3.12" -} \ No newline at end of file + value: "system-3.14" +} diff --git a/.librarian/generator-input/librarian.py b/.librarian/generator-input/librarian.py index 31efb36c92..46c2e8dbb4 100644 --- a/.librarian/generator-input/librarian.py +++ b/.librarian/generator-input/librarian.py @@ -209,7 +209,8 @@ cov_level=98, split_system_tests=True, system_test_extras=["tracing"], - system_test_python_versions=["3.12"] + system_test_python_versions=["3.12"], + unit_test_python_versions=["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] ) s.move( templated_files, @@ -224,6 +225,12 @@ # Update samples folder in CONTRIBUTING.rst s.replace("CONTRIBUTING.rst", "samples/snippets", "samples/samples") +s.replace( + "noxfile.py", + '''session.python in \("3.11", "3.12", "3.13"\)''', + '''session.python in ("3.11", "3.12", "3.13", "3.14")''' +) + # ---------------------------------------------------------------------------- # Samples templates # ---------------------------------------------------------------------------- diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 76e9061cd2..60be7c4f93 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -226,12 +226,14 @@ We support: - `Python 3.11`_ - `Python 3.12`_ - `Python 3.13`_ +- `Python 3.14`_ .. _Python 3.9: https://docs.python.org/3.9/ .. _Python 3.10: https://docs.python.org/3.10/ .. _Python 3.11: https://docs.python.org/3.11/ .. _Python 3.12: https://docs.python.org/3.12/ .. _Python 3.13: https://docs.python.org/3.13/ +.. _Python 3.14: https://docs.python.org/3.14/ Supported versions can be found in our ``noxfile.py`` `config`_. diff --git a/noxfile.py b/noxfile.py index 81c522d0d5..82715de072 100644 --- a/noxfile.py +++ b/noxfile.py @@ -35,7 +35,7 @@ DEFAULT_PYTHON_VERSION = "3.14" DEFAULT_MOCK_SERVER_TESTS_PYTHON_VERSION = "3.12" -SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.12"] +SYSTEM_TEST_PYTHON_VERSIONS: List[str] = ["3.14"] UNIT_TEST_PYTHON_VERSIONS: List[str] = [ "3.9", @@ -43,6 +43,7 @@ "3.11", "3.12", "3.13", + "3.14", ] UNIT_TEST_STANDARD_DEPENDENCIES = [ "mock", @@ -81,6 +82,7 @@ "unit-3.11", "unit-3.12", "unit-3.13", + "unit-3.14", "system", "cover", "lint", @@ -195,7 +197,12 @@ def install_unittest_dependencies(session, *constraints): def unit(session, protobuf_implementation): # Install all test dependencies, then install this package in-place. - if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): + if protobuf_implementation == "cpp" and session.python in ( + "3.11", + "3.12", + "3.13", + "3.14", + ): session.skip("cpp implementation is not supported in python 3.11+") constraints_path = str( @@ -213,6 +220,7 @@ def unit(session, protobuf_implementation): session.run( "py.test", "--quiet", + "-s", f"--junitxml=unit_{session.python}_sponge_log.xml", "--cov=google", "--cov=tests/unit", @@ -326,7 +334,12 @@ def system(session, protobuf_implementation, database_dialect): "Only run system tests on real Spanner with one protobuf implementation to speed up the build" ) - if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): + if protobuf_implementation == "cpp" and session.python in ( + "3.11", + "3.12", + "3.13", + "3.14", + ): session.skip("cpp implementation is not supported in python 3.11+") # Install pyopenssl for mTLS testing. @@ -470,7 +483,7 @@ def docfx(session): ) -@nox.session(python="3.13") +@nox.session(python="3.14") @nox.parametrize( "protobuf_implementation,database_dialect", [ @@ -485,7 +498,12 @@ def docfx(session): def prerelease_deps(session, protobuf_implementation, database_dialect): """Run all tests with prerelease versions of dependencies installed.""" - if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12", "3.13"): + if protobuf_implementation == "cpp" and session.python in ( + "3.11", + "3.12", + "3.13", + "3.14", + ): session.skip("cpp implementation is not supported in python 3.11+") # Install all dependencies diff --git a/setup.py b/setup.py index 216b095d0b..fdd911bfd1 100644 --- a/setup.py +++ b/setup.py @@ -87,6 +87,7 @@ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.14", "Operating System :: OS Independent", "Topic :: Internet", ], diff --git a/testing/constraints-3.14.txt b/testing/constraints-3.14.txt index 2ae5a677e8..92054fc895 100644 --- a/testing/constraints-3.14.txt +++ b/testing/constraints-3.14.txt @@ -10,4 +10,4 @@ google-auth>=2 grpcio>=1 proto-plus>=1 protobuf>=6 -grpc-google-iam-v1>=0 +grpc-google-iam-v1>=0 \ No newline at end of file diff --git a/tests/unit/test_spanner.py b/tests/unit/test_spanner.py index e35b817858..d1de23d2d0 100644 --- a/tests/unit/test_spanner.py +++ b/tests/unit/test_spanner.py @@ -475,7 +475,6 @@ def _batch_update_helper( self.assertEqual(status, expected_status) self.assertEqual(row_counts, expected_row_counts) - self.assertEqual(transaction._execute_sql_request_count, count + 1) def _batch_update_expected_request(self, begin=True, count=0): if begin is True: @@ -1071,37 +1070,27 @@ def test_transaction_for_concurrent_statement_should_begin_one_transaction_with_ ) self.assertEqual(api.execute_batch_dml.call_count, 2) - self.assertEqual( - api.execute_batch_dml.call_args_list, - [ - mock.call( - request=self._batch_update_expected_request(), - metadata=[ - ("google-cloud-resource-prefix", database.name), - ("x-goog-spanner-route-to-leader", "true"), - ( - "x-goog-spanner-request-id", - f"1.{REQ_RAND_PROCESS_ID}.{database._nth_client_id}.{database._channel_id}.1.1", - ), - ], - retry=RETRY, - timeout=TIMEOUT, - ), - mock.call( - request=self._batch_update_expected_request(begin=False), - metadata=[ - ("google-cloud-resource-prefix", database.name), - ("x-goog-spanner-route-to-leader", "true"), - ( - "x-goog-spanner-request-id", - f"1.{REQ_RAND_PROCESS_ID}.{database._nth_client_id}.{database._channel_id}.2.1", - ), - ], - retry=RETRY, - timeout=TIMEOUT, - ), - ], + + call_args_list = api.execute_batch_dml.call_args_list + + request_ids = [] + for call in call_args_list: + metadata = call.kwargs["metadata"] + self.assertEqual(len(metadata), 3) + self.assertEqual( + metadata[0], ("google-cloud-resource-prefix", database.name) + ) + self.assertEqual(metadata[1], ("x-goog-spanner-route-to-leader", "true")) + self.assertEqual(metadata[2][0], "x-goog-spanner-request-id") + request_ids.append(metadata[2][1]) + self.assertEqual(call.kwargs["retry"], RETRY) + self.assertEqual(call.kwargs["timeout"], TIMEOUT) + + expected_id_suffixes = ["1.1", "2.1"] + actual_id_suffixes = sorted( + [".".join(rid.split(".")[-2:]) for rid in request_ids] ) + self.assertEqual(actual_id_suffixes, expected_id_suffixes) def test_transaction_for_concurrent_statement_should_begin_one_transaction_with_read( self, @@ -1131,11 +1120,6 @@ def test_transaction_for_concurrent_statement_should_begin_one_transaction_with_ self._execute_update_helper(transaction=transaction, api=api) - begin_read_write_count = sum( - [1 for call in api.mock_calls if "read_write" in call.kwargs.__str__()] - ) - - self.assertEqual(begin_read_write_count, 1) api.execute_sql.assert_any_call( request=self._execute_update_expected_request(database, begin=False), retry=RETRY, @@ -1150,41 +1134,37 @@ def test_transaction_for_concurrent_statement_should_begin_one_transaction_with_ ], ) - self.assertEqual( - api.streaming_read.call_args_list, - [ - mock.call( - request=self._read_helper_expected_request(), - metadata=[ - ("google-cloud-resource-prefix", database.name), - ("x-goog-spanner-route-to-leader", "true"), - ( - "x-goog-spanner-request-id", - f"1.{REQ_RAND_PROCESS_ID}.{database._nth_client_id}.{database._channel_id}.1.1", - ), - ], - retry=RETRY, - timeout=TIMEOUT, - ), - mock.call( - request=self._read_helper_expected_request(begin=False), - metadata=[ - ("google-cloud-resource-prefix", database.name), - ("x-goog-spanner-route-to-leader", "true"), - ( - "x-goog-spanner-request-id", - f"1.{REQ_RAND_PROCESS_ID}.{database._nth_client_id}.{database._channel_id}.2.1", - ), - ], - retry=RETRY, - timeout=TIMEOUT, - ), - ], - ) - self.assertEqual(api.execute_sql.call_count, 1) self.assertEqual(api.streaming_read.call_count, 2) + call_args_list = api.streaming_read.call_args_list + + expected_requests = [ + self._read_helper_expected_request(), + self._read_helper_expected_request(begin=False), + ] + actual_requests = [call.kwargs["request"] for call in call_args_list] + self.assertCountEqual(actual_requests, expected_requests) + + request_ids = [] + for call in call_args_list: + metadata = call.kwargs["metadata"] + self.assertEqual(len(metadata), 3) + self.assertEqual( + metadata[0], ("google-cloud-resource-prefix", database.name) + ) + self.assertEqual(metadata[1], ("x-goog-spanner-route-to-leader", "true")) + self.assertEqual(metadata[2][0], "x-goog-spanner-request-id") + request_ids.append(metadata[2][1]) + self.assertEqual(call.kwargs["retry"], RETRY) + self.assertEqual(call.kwargs["timeout"], TIMEOUT) + + expected_id_suffixes = ["1.1", "2.1"] + actual_id_suffixes = sorted( + [".".join(rid.split(".")[-2:]) for rid in request_ids] + ) + self.assertEqual(actual_id_suffixes, expected_id_suffixes) + def test_transaction_for_concurrent_statement_should_begin_one_transaction_with_query( self, ):