From 1c32206120b1a6555f8bb7a20a0c4c53ea2f52a8 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 1 Aug 2018 12:27:22 -0400 Subject: [PATCH] Correct sharding tests for provisioned follower The sharding tests created named sqlite databases that were shared across test suites. It is unknown why these suddenly started failing and were not failing before. Change-Id: If2044f914ddaea0db594aa18b9278e24e2c818ea --- test/ext/test_horizontal_shard.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/test/ext/test_horizontal_shard.py b/test/ext/test_horizontal_shard.py index 00dfeb29b6..e270dd3536 100644 --- a/test/ext/test_horizontal_shard.py +++ b/test/ext/test_horizontal_shard.py @@ -296,13 +296,20 @@ class ShardTest(object): ) +from sqlalchemy.testing import provision + + class DistinctEngineShardTest(ShardTest, fixtures.TestBase): def _init_dbs(self): - db1 = testing_engine('sqlite:///shard1.db', - options=dict(pool_threadlocal=True)) - db2 = testing_engine('sqlite:///shard2.db') - db3 = testing_engine('sqlite:///shard3.db') - db4 = testing_engine('sqlite:///shard4.db') + db1 = testing_engine( + 'sqlite:///shard1_%s.db' % provision.FOLLOWER_IDENT, + options=dict(pool_threadlocal=True)) + db2 = testing_engine( + 'sqlite:///shard2_%s.db' % provision.FOLLOWER_IDENT) + db3 = testing_engine( + 'sqlite:///shard3_%s.db' % provision.FOLLOWER_IDENT) + db4 = testing_engine( + 'sqlite:///shard4_%s.db' % provision.FOLLOWER_IDENT) self.dbs = [db1, db2, db3, db4] return self.dbs @@ -313,7 +320,7 @@ class DistinctEngineShardTest(ShardTest, fixtures.TestBase): for db in self.dbs: db.connect().invalidate() for i in range(1, 5): - os.remove("shard%d.db" % i) + os.remove("shard%d_%s.db" % (i, provision.FOLLOWER_IDENT)) class AttachedFileShardTest(ShardTest, fixtures.TestBase): @@ -428,9 +435,11 @@ class RefreshDeferExpireTest(fixtures.DeclarativeMappedTest): class LazyLoadIdentityKeyTest(fixtures.DeclarativeMappedTest): def _init_dbs(self): - self.db1 = db1 = testing_engine('sqlite:///shard1.db', - options=dict(pool_threadlocal=True)) - self.db2 = db2 = testing_engine('sqlite:///shard2.db') + self.db1 = db1 = testing_engine( + 'sqlite:///shard1_%s.db' % provision.FOLLOWER_IDENT, + options=dict(pool_threadlocal=True)) + self.db2 = db2 = testing_engine( + 'sqlite:///shard2_%s.db' % provision.FOLLOWER_IDENT) for db in (db1, db2): self.metadata.create_all(db) @@ -443,7 +452,7 @@ class LazyLoadIdentityKeyTest(fixtures.DeclarativeMappedTest): for db in self.dbs: db.connect().invalidate() for i in range(1, 3): - os.remove("shard%d.db" % i) + os.remove("shard%d_%s.db" % (i, provision.FOLLOWER_IDENT)) @classmethod def setup_classes(cls): -- 2.47.2