Skip to content

Commit 1844684

Browse files
authored
Avoid sharing database name between testcase classes. (#4285)
Abrupt shutdown (maybe CircleCI auto-cancellation?) can cause them not to be cleaned up.
1 parent 9b55996 commit 1844684

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

spanner/tests/system/test_system.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
else:
5858
INSTANCE_ID = os.environ.get('GOOGLE_CLOUD_TESTS_SPANNER_INSTANCE',
5959
'google-cloud-python-systest')
60-
DATABASE_ID = 'test_database'
6160
EXISTING_INSTANCES = []
6261
COUNTERS_TABLE = 'counters'
6362
COUNTERS_COLUMNS = ('name', 'value')
@@ -237,12 +236,13 @@ def _check_row_data(self, row_data, expected=None):
237236

238237

239238
class TestDatabaseAPI(unittest.TestCase, _TestData):
239+
DATABASE_NAME = 'test_database' + unique_resource_id('_')
240240

241241
@classmethod
242242
def setUpClass(cls):
243243
pool = BurstyPool()
244244
cls._db = Config.INSTANCE.database(
245-
DATABASE_ID, ddl_statements=DDL_STATEMENTS, pool=pool)
245+
cls.DATABASE_NAME, ddl_statements=DDL_STATEMENTS, pool=pool)
246246
cls._db.create()
247247

248248
@classmethod
@@ -376,6 +376,7 @@ def _unit_of_work(transaction, name):
376376

377377

378378
class TestSessionAPI(unittest.TestCase, _TestData):
379+
DATABASE_NAME = 'test_sessions' + unique_resource_id('_')
379380
ALL_TYPES_TABLE = 'all_types'
380381
ALL_TYPES_COLUMNS = (
381382
'list_goes_on',
@@ -407,7 +408,7 @@ class TestSessionAPI(unittest.TestCase, _TestData):
407408
def setUpClass(cls):
408409
pool = BurstyPool()
409410
cls._db = Config.INSTANCE.database(
410-
DATABASE_ID, ddl_statements=DDL_STATEMENTS, pool=pool)
411+
cls.DATABASE_NAME, ddl_statements=DDL_STATEMENTS, pool=pool)
411412
operation = cls._db.create()
412413
operation.result(30) # raises on failure / timeout.
413414

0 commit comments

Comments
 (0)