Merge "Tests: Define fake_constants as constants"

This commit is contained in:
Jenkins 2016-04-15 17:38:20 +00:00 committed by Gerrit Code Review
commit e84f42b1f0
3 changed files with 77 additions and 42 deletions

View File

@ -13,37 +13,72 @@
# under the License.
attachment_id = '4dc3bb12-ad75-41b9-ab2c-7609e743e600'
ATTACHMENT_ID = '4dc3bb12-ad75-41b9-ab2c-7609e743e600'
attachment2_id = 'ac2439fe-c071-468f-94e3-547bedb95de0'
ATTACHMENT2_ID = 'ac2439fe-c071-468f-94e3-547bedb95de0'
backup_id = '707844eb-6d8a-4ac1-8b98-618e1c0b3a3a'
BACKUP_ID = '707844eb-6d8a-4ac1-8b98-618e1c0b3a3a'
backup2_id = '40e8462a-c9d8-462f-a810-b732a1790535'
BACKUP2_ID = '40e8462a-c9d8-462f-a810-b732a1790535'
backup3_id = '30ae7641-017e-4221-a642-855687c8bd71'
BACKUP3_ID = '30ae7641-017e-4221-a642-855687c8bd71'
cgsnapshot_id = '5e34cce3-bc97-46b7-a127-5cfb95ef445d'
CGSNAPSHOT_ID = '5e34cce3-bc97-46b7-a127-5cfb95ef445d'
cgsnapshot2_id = '5c36d762-d6ba-4f04-bd07-88a298cc410a'
CGSNAPHOT2_ID = '5c36d762-d6ba-4f04-bd07-88a298cc410a'
cgsnapshot3_id = '5f392156-fc03-492a-9cb8-e46a7eedaf33'
CGSNAPSHOT3_ID = '5f392156-fc03-492a-9cb8-e46a7eedaf33'
consistency_group_id = 'f18abf73-79ee-4f2b-8d4f-1c044148f117'
CONSISTENCY_GROUP_ID = 'f18abf73-79ee-4f2b-8d4f-1c044148f117'
image_id = 'e79161cd-5f9d-4007-8823-81a807a64332'
IMAGE_ID = 'e79161cd-5f9d-4007-8823-81a807a64332'
instance_id = 'fa617131-cdbc-45dc-afff-f21f17ae054e'
INSTANCE_ID = 'fa617131-cdbc-45dc-afff-f21f17ae054e'
key_id = '9112ecec-fb9d-4299-a948-ffb52650a5b5'
KEY_ID = '9112ecec-fb9d-4299-a948-ffb52650a5b5'
object_id = 'd7c5b12f-d57d-4762-99ab-db5f62ae3569'
OBJECT_ID = 'd7c5b12f-d57d-4762-99ab-db5f62ae3569'
object2_id = '51f5b8fa-c13c-48ba-8c9d-b470466cbc9c'
OBJECT2_ID = '51f5b8fa-c13c-48ba-8c9d-b470466cbc9c'
object3_id = '7bf5ffa9-18a2-4b64-aab4-0798b53ee4e7'
OBJECT3_ID = '7bf5ffa9-18a2-4b64-aab4-0798b53ee4e7'
project_id = '89afd400-b646-4bbc-b12b-c0a4d63e5bd3'
PROJECT_ID = '89afd400-b646-4bbc-b12b-c0a4d63e5bd3'
project2_id = '452ebfbc-55d9-402a-87af-65061916c24b'
PROJECT2_ID = '452ebfbc-55d9-402a-87af-65061916c24b'
project3_id = 'f6c912d7-bf30-4b12-af81-a9e0b2f85f85'
PROJECT3_ID = 'f6c912d7-bf30-4b12-af81-a9e0b2f85f85'
provider_id = '60087173-e899-470a-9e3a-ba4cffa3e3e3'
PROVIDER_ID = '60087173-e899-470a-9e3a-ba4cffa3e3e3'
snapshot_id = '253b2878-ec60-4793-ad19-e65496ec7aab'
SNAPSHOT_ID = '253b2878-ec60-4793-ad19-e65496ec7aab'
snapshot2_id = 'c02c44fa-5665-4a26-9e66-2ebaf25e5d2d'
SNAPSHOT2_ID = 'c02c44fa-5665-4a26-9e66-2ebaf25e5d2d'
snapshot3_id = '454f9970-1e05-4193-a3ed-5c390c3faa18'
SNAPSHOT3_ID = '454f9970-1e05-4193-a3ed-5c390c3faa18'
user_id = 'c853ca26-e8ea-4797-8a52-ee124a013d0e'
USER_ID = 'c853ca26-e8ea-4797-8a52-ee124a013d0e'
user2_id = '95f7b7ed-bd7f-426e-b05f-f1ffeb4f09df'
USER2_ID = '95f7b7ed-bd7f-426e-b05f-f1ffeb4f09df'
volume_id = '1e5177e7-95e5-4a0f-b170-e45f4b469f6a'
VOLUME_ID = '1e5177e7-95e5-4a0f-b170-e45f4b469f6a'
volume2_id = '43a09914-e495-475f-b862-0bda3c8918e4'
VOLUME2_ID = '43a09914-e495-475f-b862-0bda3c8918e4'
volume3_id = '1b1cf149-219c-44ac-aee3-13121a7f86a7'
VOLUME3_ID = '1b1cf149-219c-44ac-aee3-13121a7f86a7'
volume4_id = '904d4602-4301-4e9b-8df1-8133b51904e6'
VOLUME4_ID = '904d4602-4301-4e9b-8df1-8133b51904e6'
volume5_id = '17b0e01d-3d2d-4c31-a1aa-c962420bc3dc'
VOLUME5_ID = '17b0e01d-3d2d-4c31-a1aa-c962420bc3dc'
volume_name_id = 'ee73d33c-52ed-4cb7-a8a9-2687c1205c22'
VOLUME_NAME_ID = 'ee73d33c-52ed-4cb7-a8a9-2687c1205c22'
volume2_name_id = '63fbdd21-03bc-4309-b867-2893848f86af'
VOLUME2_NAME_ID = '63fbdd21-03bc-4309-b867-2893848f86af'
volume_type_id = '4e9e6d23-eed0-426d-b90a-28f87a94b6fe'
VOLUME_TYPE_ID = '4e9e6d23-eed0-426d-b90a-28f87a94b6fe'
volume_type2_id = 'c4daaf47-c530-4901-b28e-f5f0a359c4e6'
VOLUME_TYPE2_ID = 'c4daaf47-c530-4901-b28e-f5f0a359c4e6'
volume_type3_id = 'a3d55d15-eeb1-4816-ada9-bf82decc09b3'
VOLUME_TYPE3_ID = 'a3d55d15-eeb1-4816-ada9-bf82decc09b3'
will_not_be_found_id = 'ce816f65-c5aa-46d6-bd62-5272752d584a'
WILL_NOT_BE_FOUND_ID = 'ce816f65-c5aa-46d6-bd62-5272752d584a'

View File

@ -907,7 +907,7 @@ class RBDTestCase(test.TestCase):
'extra_specs': {}}
updates = {'name': 'testvolume',
'host': 'currenthost',
'id': fake.volume_id}
'id': fake.VOLUME_ID}
fake_type = 'high-IOPS'
volume = fake_volume.fake_volume_obj(context, **updates)

View File

@ -35,43 +35,43 @@ class VolumeGlanceMetadataTestCase(test.TestCase):
ctxt = context.get_admin_context()
self.assertRaises(exception.VolumeNotFound,
db.volume_glance_metadata_create,
ctxt, fake.volume_id, 'key1', 'value1')
ctxt, fake.VOLUME_ID, 'key1', 'value1')
self.assertRaises(exception.VolumeNotFound,
db.volume_glance_metadata_get, ctxt, fake.volume_id)
db.volume_glance_metadata_delete_by_volume(ctxt, fake.volume2_id)
db.volume_glance_metadata_get, ctxt, fake.VOLUME_ID)
db.volume_glance_metadata_delete_by_volume(ctxt, fake.VOLUME2_ID)
def test_vol_update_glance_metadata(self):
ctxt = context.get_admin_context()
db.volume_create(ctxt, {'id': fake.volume_id})
db.volume_create(ctxt, {'id': fake.volume2_id})
db.volume_glance_metadata_create(ctxt, fake.volume_id, 'key1',
db.volume_create(ctxt, {'id': fake.VOLUME_ID})
db.volume_create(ctxt, {'id': fake.VOLUME2_ID})
db.volume_glance_metadata_create(ctxt, fake.VOLUME_ID, 'key1',
'value1')
db.volume_glance_metadata_create(ctxt, fake.volume2_id, 'key1',
db.volume_glance_metadata_create(ctxt, fake.VOLUME2_ID, 'key1',
'value1')
db.volume_glance_metadata_create(ctxt, fake.volume2_id, 'key2',
db.volume_glance_metadata_create(ctxt, fake.VOLUME2_ID, 'key2',
'value2')
db.volume_glance_metadata_create(ctxt, fake.volume2_id, 'key3', 123)
db.volume_glance_metadata_create(ctxt, fake.VOLUME2_ID, 'key3', 123)
expected_metadata_1 = {'volume_id': fake.volume_id,
expected_metadata_1 = {'volume_id': fake.VOLUME_ID,
'key': 'key1',
'value': 'value1'}
metadata = db.volume_glance_metadata_get(ctxt, fake.volume_id)
metadata = db.volume_glance_metadata_get(ctxt, fake.VOLUME_ID)
self.assertEqual(1, len(metadata))
for key, value in expected_metadata_1.items():
self.assertEqual(value, metadata[0][key])
expected_metadata_2 = ({'volume_id': fake.volume2_id,
expected_metadata_2 = ({'volume_id': fake.VOLUME2_ID,
'key': 'key1',
'value': 'value1'},
{'volume_id': fake.volume2_id,
{'volume_id': fake.VOLUME2_ID,
'key': 'key2',
'value': 'value2'},
{'volume_id': fake.volume2_id,
{'volume_id': fake.VOLUME2_ID,
'key': 'key3',
'value': '123'})
metadata = db.volume_glance_metadata_get(ctxt, fake.volume2_id)
metadata = db.volume_glance_metadata_get(ctxt, fake.VOLUME2_ID)
self.assertEqual(3, len(metadata))
for expected, meta in zip(expected_metadata_2, metadata):
for key, value in expected.items():
@ -79,32 +79,32 @@ class VolumeGlanceMetadataTestCase(test.TestCase):
self.assertRaises(exception.GlanceMetadataExists,
db.volume_glance_metadata_create,
ctxt, fake.volume_id, 'key1', 'value1a')
ctxt, fake.VOLUME_ID, 'key1', 'value1a')
metadata = db.volume_glance_metadata_get(ctxt, fake.volume_id)
metadata = db.volume_glance_metadata_get(ctxt, fake.VOLUME_ID)
self.assertEqual(1, len(metadata))
for key, value in expected_metadata_1.items():
self.assertEqual(value, metadata[0][key])
def test_vols_get_glance_metadata(self):
ctxt = context.get_admin_context()
db.volume_create(ctxt, {'id': fake.volume_id})
db.volume_create(ctxt, {'id': fake.volume2_id})
db.volume_create(ctxt, {'id': fake.VOLUME_ID})
db.volume_create(ctxt, {'id': fake.VOLUME2_ID})
db.volume_create(ctxt, {'id': '3'})
db.volume_glance_metadata_create(ctxt, fake.volume_id, 'key1',
db.volume_glance_metadata_create(ctxt, fake.VOLUME_ID, 'key1',
'value1')
db.volume_glance_metadata_create(ctxt, fake.volume2_id, 'key2',
db.volume_glance_metadata_create(ctxt, fake.VOLUME2_ID, 'key2',
'value2')
db.volume_glance_metadata_create(ctxt, fake.volume2_id, 'key22',
db.volume_glance_metadata_create(ctxt, fake.VOLUME2_ID, 'key22',
'value22')
metadata = db.volume_glance_metadata_get_all(ctxt)
self.assertEqual(3, len(metadata))
self._assert_metadata_equals(fake.volume_id, 'key1', 'value1',
self._assert_metadata_equals(fake.VOLUME_ID, 'key1', 'value1',
metadata[0])
self._assert_metadata_equals(fake.volume2_id, 'key2', 'value2',
self._assert_metadata_equals(fake.VOLUME2_ID, 'key2', 'value2',
metadata[1])
self._assert_metadata_equals(fake.volume2_id, 'key22', 'value22',
self._assert_metadata_equals(fake.VOLUME2_ID, 'key22', 'value22',
metadata[2])
def _assert_metadata_equals(self, volume_id, key, value, observed):
@ -114,23 +114,23 @@ class VolumeGlanceMetadataTestCase(test.TestCase):
def test_vol_delete_glance_metadata(self):
ctxt = context.get_admin_context()
db.volume_create(ctxt, {'id': fake.volume_id})
db.volume_glance_metadata_delete_by_volume(ctxt, fake.volume_id)
db.volume_glance_metadata_create(ctxt, fake.volume_id, 'key1',
db.volume_create(ctxt, {'id': fake.VOLUME_ID})
db.volume_glance_metadata_delete_by_volume(ctxt, fake.VOLUME_ID)
db.volume_glance_metadata_create(ctxt, fake.VOLUME_ID, 'key1',
'value1')
db.volume_glance_metadata_delete_by_volume(ctxt, fake.volume_id)
db.volume_glance_metadata_delete_by_volume(ctxt, fake.VOLUME_ID)
self.assertRaises(exception.GlanceMetadataNotFound,
db.volume_glance_metadata_get, ctxt, fake.volume_id)
db.volume_glance_metadata_get, ctxt, fake.VOLUME_ID)
def test_vol_glance_metadata_copy_to_snapshot(self):
ctxt = context.get_admin_context()
db.volume_create(ctxt, {'id': fake.volume_id})
snap = objects.Snapshot(ctxt, volume_id=fake.volume_id)
db.volume_create(ctxt, {'id': fake.VOLUME_ID})
snap = objects.Snapshot(ctxt, volume_id=fake.VOLUME_ID)
snap.create()
db.volume_glance_metadata_create(ctxt, fake.volume_id, 'key1',
db.volume_glance_metadata_create(ctxt, fake.VOLUME_ID, 'key1',
'value1')
db.volume_glance_metadata_copy_to_snapshot(ctxt, snap.id,
fake.volume_id)
fake.VOLUME_ID)
expected_meta = {'snapshot_id': snap.id,
'key': 'key1',
@ -143,19 +143,19 @@ class VolumeGlanceMetadataTestCase(test.TestCase):
def test_vol_glance_metadata_copy_from_volume_to_volume(self):
ctxt = context.get_admin_context()
db.volume_create(ctxt, {'id': fake.volume_id})
db.volume_create(ctxt, {'id': fake.volume2_id,
'source_volid': fake.volume_id})
db.volume_glance_metadata_create(ctxt, fake.volume_id, 'key1',
db.volume_create(ctxt, {'id': fake.VOLUME_ID})
db.volume_create(ctxt, {'id': fake.VOLUME2_ID,
'source_volid': fake.VOLUME_ID})
db.volume_glance_metadata_create(ctxt, fake.VOLUME_ID, 'key1',
'value1')
db.volume_glance_metadata_copy_from_volume_to_volume(ctxt,
fake.volume_id,
fake.volume2_id)
fake.VOLUME_ID,
fake.VOLUME2_ID)
expected_meta = {'key': 'key1',
'value': 'value1'}
for meta in db.volume_glance_metadata_get(ctxt, fake.volume2_id):
for meta in db.volume_glance_metadata_get(ctxt, fake.VOLUME2_ID):
for (key, value) in expected_meta.items():
self.assertEqual(value, meta[key])