Enable shards test for sqlalchemy

Now we have already implemented the sqlalchemy for shards and
catalogue, so this patch will enable the shards test for
sqlalchemy.

Closes-Bug: #1288148

Change-Id: I1bc96419f2525d5211448d68c8c871dda14535a7
This commit is contained in:
Fei Long Wang 2014-03-06 16:38:10 +08:00
parent 364945f990
commit 8835aee20c
5 changed files with 25 additions and 5 deletions

View File

@ -44,3 +44,4 @@ TestQueueFaultyDriver = lc.TestQueueLifecycleFaultyDriver
TestQueueLifecycleMongoDB = lc.TestQueueLifecycleMongoDB TestQueueLifecycleMongoDB = lc.TestQueueLifecycleMongoDB
TestQueueLifecycleSqlalchemy = lc.TestQueueLifecycleSqlalchemy TestQueueLifecycleSqlalchemy = lc.TestQueueLifecycleSqlalchemy
TestShardsMongoDB = test_shards.TestShardsMongoDB TestShardsMongoDB = test_shards.TestShardsMongoDB
TestShardsSqlalchemy = test_shards.TestShardsSqlalchemy

View File

@ -459,10 +459,6 @@ class TestMessagesSqlalchemy(MessagesBaseTest):
config_file = 'wsgi_sqlalchemy.conf' config_file = 'wsgi_sqlalchemy.conf'
# TODO(cpp-cabrera): restore sqlalchemy sharded test suite once shards and
# catalogue get an sqlalchemy implementation.
class TestMessagesMongoDB(MessagesBaseTest): class TestMessagesMongoDB(MessagesBaseTest):
config_file = 'wsgi_mongodb.conf' config_file = 'wsgi_mongodb.conf'

View File

@ -252,7 +252,14 @@ class ShardsBaseTest(base.TestBase):
self.assertIn('shards', results) self.assertIn('shards', results)
shard_list = results['shards'] shard_list = results['shards']
self.assertEqual(len(shard_list), min(limit, count)) self.assertEqual(len(shard_list), min(limit, count))
for (i, s), expect in zip(enumerate(shard_list), expected): for s in shard_list:
# NOTE(flwang): It can't assumed that both sqlalchemy and
# mongodb can return query result with the same order. Just
# like the order they're inserted. Actually, sqlalchemy can't
# guarantee that. So we're leveraging the relationship between
# shard weight and the index of shards fixture to get the
# right shard to verify.
expect = expected[s['weight']]
path, weight = expect[:2] path, weight = expect[:2]
self._shard_expect(s, path, weight, self.doc['uri']) self._shard_expect(s, path, weight, self.doc['uri'])
if detailed: if detailed:
@ -291,3 +298,11 @@ class TestShardsMongoDB(ShardsBaseTest):
@testing.requires_mongodb @testing.requires_mongodb
def setUp(self): def setUp(self):
super(TestShardsMongoDB, self).setUp() super(TestShardsMongoDB, self).setUp()
class TestShardsSqlalchemy(ShardsBaseTest):
config_file = 'wsgi_sqlalchemy.conf'
def setUp(self):
super(TestShardsSqlalchemy, self).setUp()

View File

@ -86,6 +86,10 @@ class TestShardsMongoDB(wsgi.TestShardsMongoDB):
url_prefix = URL_PREFIX url_prefix = URL_PREFIX
class TestShardsSqlalchemy(wsgi.TestShardsSqlalchemy):
url_prefix = URL_PREFIX
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# v1.0 only # v1.0 only
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------

View File

@ -88,6 +88,10 @@ class TestShardsMongoDB(wsgi.TestShardsMongoDB):
url_prefix = URL_PREFIX url_prefix = URL_PREFIX
class TestShardsSqlalchemy(wsgi.TestShardsSqlalchemy):
url_prefix = URL_PREFIX
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# v1.1 only # v1.1 only
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------