Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
Merged
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
41 changes: 29 additions & 12 deletions tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
CREATE_INSTANCE = os.getenv("GOOGLE_CLOUD_TESTS_CREATE_SPANNER_INSTANCE") is not None
USE_EMULATOR = os.getenv("SPANNER_EMULATOR_HOST") is not None
SKIP_BACKUP_TESTS = os.getenv("SKIP_BACKUP_TESTS") is not None
SPANNER_OPERATION_TIMEOUT_IN_SECONDS = int(
os.getenv("SPANNER_OPERATION_TIMEOUT_IN_SECONDS", 60)
)

if CREATE_INSTANCE:
INSTANCE_ID = "google-cloud" + unique_resource_id("-")
Expand Down Expand Up @@ -149,7 +152,9 @@ def setUpModule():
INSTANCE_ID, config_name, labels=labels
)
created_op = Config.INSTANCE.create()
created_op.result(30) # block until completion
created_op.result(
SPANNER_OPERATION_TIMEOUT_IN_SECONDS
) # block until completion

else:
Config.INSTANCE = Config.CLIENT.instance(INSTANCE_ID)
Expand Down Expand Up @@ -208,7 +213,9 @@ def test_create_instance(self):
self.instances_to_delete.append(instance)

# We want to make sure the operation completes.
operation.result(30) # raises on failure / timeout.
operation.result(
SPANNER_OPERATION_TIMEOUT_IN_SECONDS
) # raises on failure / timeout.

# Create a new instance instance and make sure it is the same.
instance_alt = Config.CLIENT.instance(
Expand All @@ -227,7 +234,9 @@ def test_update_instance(self):
operation = Config.INSTANCE.update()

# We want to make sure the operation completes.
operation.result(30) # raises on failure / timeout.
operation.result(
SPANNER_OPERATION_TIMEOUT_IN_SECONDS
) # raises on failure / timeout.

# Create a new instance instance and reload it.
instance_alt = Config.CLIENT.instance(INSTANCE_ID, None)
Expand Down Expand Up @@ -308,7 +317,9 @@ def setUpClass(cls):
cls.DATABASE_NAME, ddl_statements=ddl_statements, pool=pool
)
operation = cls._db.create()
operation.result(30) # raises on failure / timeout.
operation.result(
SPANNER_OPERATION_TIMEOUT_IN_SECONDS
) # raises on failure / timeout.

@classmethod
def tearDownClass(cls):
Expand Down Expand Up @@ -337,7 +348,9 @@ def test_create_database(self):
self.to_delete.append(temp_db)

# We want to make sure the operation completes.
operation.result(30) # raises on failure / timeout.
operation.result(
SPANNER_OPERATION_TIMEOUT_IN_SECONDS
) # raises on failure / timeout.

database_ids = [database.name for database in Config.INSTANCE.list_databases()]
self.assertIn(temp_db.name, database_ids)
Expand Down Expand Up @@ -483,8 +496,8 @@ def setUpClass(cls):
cls._dbs = [db1, db2]
op1 = db1.create()
op2 = db2.create()
op1.result(30) # raises on failure / timeout.
op2.result(30) # raises on failure / timeout.
op1.result(SPANNER_OPERATION_TIMEOUT_IN_SECONDS) # raises on failure / timeout.
op2.result(SPANNER_OPERATION_TIMEOUT_IN_SECONDS) # raises on failure / timeout.

current_config = Config.INSTANCE.configuration_name
same_config_instance_id = "same-config" + unique_resource_id("-")
Expand All @@ -494,7 +507,7 @@ def setUpClass(cls):
same_config_instance_id, current_config, labels=labels
)
op = cls._same_config_instance.create()
op.result(30)
op.result(SPANNER_OPERATION_TIMEOUT_IN_SECONDS)
cls._instances = [cls._same_config_instance]

retry = RetryErrors(exceptions.ServiceUnavailable)
Expand All @@ -513,7 +526,7 @@ def setUpClass(cls):
diff_config_instance_id, diff_configs[0], labels=labels
)
op = cls._diff_config_instance.create()
op.result(30)
op.result(SPANNER_OPERATION_TIMEOUT_IN_SECONDS)
cls._instances.append(cls._diff_config_instance)

@classmethod
Expand Down Expand Up @@ -675,7 +688,7 @@ def test_multi_create_cancel_update_error_restore_errors(self):
return
new_db = self._diff_config_instance.database("diff_config")
op = new_db.create()
op.result(30)
op.result(SPANNER_OPERATION_TIMEOUT_IN_SECONDS)
self.to_drop.append(new_db)
with self.assertRaises(exceptions.InvalidArgument):
new_db.restore(source=backup1)
Expand Down Expand Up @@ -866,7 +879,9 @@ def setUpClass(cls):
cls.DATABASE_NAME, ddl_statements=ddl_statements, pool=pool
)
operation = cls._db.create()
operation.result(30) # raises on failure / timeout.
operation.result(
SPANNER_OPERATION_TIMEOUT_IN_SECONDS
) # raises on failure / timeout.

@classmethod
def tearDownClass(cls):
Expand Down Expand Up @@ -1788,7 +1803,9 @@ def test_read_w_index(self):
self.to_delete.append(_DatabaseDropper(temp_db))

# We want to make sure the operation completes.
operation.result(30) # raises on failure / timeout.
operation.result(
SPANNER_OPERATION_TIMEOUT_IN_SECONDS
) # raises on failure / timeout.
committed = self._set_up_table(row_count, database=temp_db)

with temp_db.snapshot(read_timestamp=committed) as snapshot:
Expand Down
13 changes: 11 additions & 2 deletions tests/system/test_system_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
)


SPANNER_OPERATION_TIMEOUT_IN_SECONDS = int(
os.getenv("SPANNER_OPERATION_TIMEOUT_IN_SECONDS", 60)
)


def setUpModule():
if USE_EMULATOR:
from google.auth.credentials import AnonymousCredentials
Expand Down Expand Up @@ -91,7 +96,9 @@ def setUpModule():
INSTANCE_ID, config_name, labels=labels
)
created_op = Config.INSTANCE.create()
created_op.result(30) # block until completion
created_op.result(
SPANNER_OPERATION_TIMEOUT_IN_SECONDS
) # block until completion

else:
Config.INSTANCE = Config.CLIENT.instance(INSTANCE_ID)
Expand Down Expand Up @@ -126,7 +133,9 @@ def setUpClass(cls):
ddl_statements=cls.DDL_STATEMENTS,
pool=BurstyPool(labels={"testcase": "database_api"}),
)
cls._db.create().result(30) # raises on failure / timeout.
cls._db.create().result(
SPANNER_OPERATION_TIMEOUT_IN_SECONDS
) # raises on failure / timeout.

@classmethod
def tearDownClass(cls):
Expand Down