From af9bb7ecabc685221d0d165011e392b05355421c Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Mon, 30 Oct 2017 18:38:24 -0400 Subject: [PATCH 1/2] Avoid sharing database name between testcase classes. Abrupt shutdown (maybe CircleCI auto-cancellation?) can cause them not to be cleaned up. --- spanner/tests/system/test_system.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spanner/tests/system/test_system.py b/spanner/tests/system/test_system.py index b65c1307b853..7da55222cdfb 100644 --- a/spanner/tests/system/test_system.py +++ b/spanner/tests/system/test_system.py @@ -57,7 +57,6 @@ else: INSTANCE_ID = os.environ.get('GOOGLE_CLOUD_TESTS_SPANNER_INSTANCE', 'google-cloud-python-systest') -DATABASE_ID = 'test_database' EXISTING_INSTANCES = [] COUNTERS_TABLE = 'counters' COUNTERS_COLUMNS = ('name', 'value') @@ -237,12 +236,13 @@ def _check_row_data(self, row_data, expected=None): class TestDatabaseAPI(unittest.TestCase, _TestData): + DATABASE_ID = 'test_database' @classmethod def setUpClass(cls): pool = BurstyPool() cls._db = Config.INSTANCE.database( - DATABASE_ID, ddl_statements=DDL_STATEMENTS, pool=pool) + cls.DATABASE_ID, ddl_statements=DDL_STATEMENTS, pool=pool) cls._db.create() @classmethod @@ -376,6 +376,7 @@ def _unit_of_work(transaction, name): class TestSessionAPI(unittest.TestCase, _TestData): + DATABASE_ID = 'test_sessions' ALL_TYPES_TABLE = 'all_types' ALL_TYPES_COLUMNS = ( 'list_goes_on', @@ -407,7 +408,7 @@ class TestSessionAPI(unittest.TestCase, _TestData): def setUpClass(cls): pool = BurstyPool() cls._db = Config.INSTANCE.database( - DATABASE_ID, ddl_statements=DDL_STATEMENTS, pool=pool) + cls.DATABASE_ID, ddl_statements=DDL_STATEMENTS, pool=pool) operation = cls._db.create() operation.result(30) # raises on failure / timeout. From 1fcdcc48098b933c4b5165e41fd0753918824d07 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Tue, 31 Oct 2017 13:39:31 -0400 Subject: [PATCH 2/2] Mangle database name w/ 'unique_resource_id'. This time for sure, Rocky! --- spanner/tests/system/test_system.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spanner/tests/system/test_system.py b/spanner/tests/system/test_system.py index 7da55222cdfb..3843ea94496c 100644 --- a/spanner/tests/system/test_system.py +++ b/spanner/tests/system/test_system.py @@ -236,13 +236,13 @@ def _check_row_data(self, row_data, expected=None): class TestDatabaseAPI(unittest.TestCase, _TestData): - DATABASE_ID = 'test_database' + DATABASE_NAME = 'test_database' + unique_resource_id('_') @classmethod def setUpClass(cls): pool = BurstyPool() cls._db = Config.INSTANCE.database( - cls.DATABASE_ID, ddl_statements=DDL_STATEMENTS, pool=pool) + cls.DATABASE_NAME, ddl_statements=DDL_STATEMENTS, pool=pool) cls._db.create() @classmethod @@ -376,7 +376,7 @@ def _unit_of_work(transaction, name): class TestSessionAPI(unittest.TestCase, _TestData): - DATABASE_ID = 'test_sessions' + DATABASE_NAME = 'test_sessions' + unique_resource_id('_') ALL_TYPES_TABLE = 'all_types' ALL_TYPES_COLUMNS = ( 'list_goes_on', @@ -408,7 +408,7 @@ class TestSessionAPI(unittest.TestCase, _TestData): def setUpClass(cls): pool = BurstyPool() cls._db = Config.INSTANCE.database( - cls.DATABASE_ID, ddl_statements=DDL_STATEMENTS, pool=pool) + cls.DATABASE_NAME, ddl_statements=DDL_STATEMENTS, pool=pool) operation = cls._db.create() operation.result(30) # raises on failure / timeout.