From df3c68256a05320a8a08c619cbbb273c7b2dbac1 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Sun, 29 Nov 2026 08:23:02 +0000 Subject: [PATCH] fix(spanner): label instances in test_instance_api for stale cleanup test_create_instance and test_create_instance_with_processing_units create temporary Spanner instances without the python-spanner-systests and created labels, so cleanup_old_instances never sweeps them if a CI run crashes. --- .../tests/system/test_instance_api.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/google-cloud-spanner/tests/system/test_instance_api.py b/packages/google-cloud-spanner/tests/system/test_instance_api.py index 2e0ccc0d6f44..1e29666c4300 100644 --- a/packages/google-cloud-spanner/tests/system/test_instance_api.py +++ b/packages/google-cloud-spanner/tests/system/test_instance_api.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import time + import pytest from test_utils import retry @@ -77,7 +79,10 @@ def test_create_instance( instance_operation_timeout, ): alt_instance_id = _helpers.unique_id("new") - instance = spanner_client.instance(alt_instance_id, instance_config.name) + labels = {"python-spanner-systests": "true", "created": str(int(time.time()))} + instance = spanner_client.instance( + alt_instance_id, instance_config.name, labels=labels + ) operation = instance.create() # Make sure this instance gets deleted after the test case. instances_to_delete.append(instance) @@ -102,10 +107,12 @@ def test_create_instance_with_processing_units( ): alt_instance_id = _helpers.unique_id("wpn") processing_units = 5000 + labels = {"python-spanner-systests": "true", "created": str(int(time.time()))} instance = spanner_client.instance( instance_id=alt_instance_id, configuration_name=instance_config.name, processing_units=processing_units, + labels=labels, ) operation = instance.create() # Make sure this instance gets deleted after the test case.