Browse Source

Add get bottom_id by top_id and region_name test case

1. What is the problem
Tricircle does not have get bottom id by top_id and
region_name test case

2. What is the solution to the problem
Implement related test case

3. What the features need to be implemented to the Tricircle
No new features

Change-Id: I0ec873f16ff596c28e4c517d6790a3cc1d5f13df
changes/34/432834/3
xiulin yin 6 years ago
parent
commit
e8563aada4
  1. 31
      tricircle/tests/unit/db/test_api.py

31
tricircle/tests/unit/db/test_api.py

@ -39,12 +39,7 @@ class APITest(unittest.TestCase):
}
api.create_pod(self.context, pod_body)
def test_get_bottom_mappings_by_top_id(self):
for i in xrange(3):
pod = {'pod_id': 'test_pod_uuid_%d' % i,
'region_name': 'test_pod_%d' % i,
'az_name': 'test_az_uuid_%d' % i}
api.create_pod(self.context, pod)
def _create_resource_mappings(self):
route1 = {
'top_id': 'top_uuid',
'pod_id': 'test_pod_uuid_0',
@ -59,11 +54,35 @@ class APITest(unittest.TestCase):
'pod_id': 'test_pod_uuid_2',
'bottom_id': 'bottom_uuid_2',
'resource_type': 'neutron'}
routes = [route1, route2, route3]
with self.context.session.begin():
for route in routes:
core.create_resource(
self.context, models.ResourceRouting, route)
def test_get_bottom_id_by_top_id_region_name(self):
self._create_pod(0, 'test_az_uuid_0')
self._create_pod(1, 'test_az_uuid_1')
self._create_pod(2, 'test_az_uuid_2')
self._create_resource_mappings()
region_name = 'test_pod_0'
bottom_id = api.get_bottom_id_by_top_id_region_name(
self.context, 'top_uuid', region_name, 'port')
self.assertIsNone(bottom_id)
region_name = 'test_pod_1'
bottom_id = api.get_bottom_id_by_top_id_region_name(
self.context, 'top_uuid', region_name, 'port')
self.assertEqual(bottom_id, 'bottom_uuid_1')
def test_get_bottom_mappings_by_top_id(self):
for i in xrange(3):
pod = {'pod_id': 'test_pod_uuid_%d' % i,
'region_name': 'test_pod_%d' % i,
'az_name': 'test_az_uuid_%d' % i}
api.create_pod(self.context, pod)
self._create_resource_mappings()
mappings = api.get_bottom_mappings_by_top_id(self.context,
'top_uuid', 'port')
self.assertEqual('test_pod_uuid_1', mappings[0][0]['pod_id'])

Loading…
Cancel
Save