Tests: lower case all fake uuid constants
Midway through the valid uuid conversion project, we decided to use upper-case fake constant uuids. For backwards compatibility, we put both upper-case and lower-case versions of each constant in the fake_constants file, with the goal of returning and removing the lower-case versions when their usages had been converted to upper-case. This commit converts the lower-case usages of the constants to upper-case and removes the lower-case definitions from the constants file. Change-Id: I89e394fe6d0e0483c0816ae133f929616b340538
This commit is contained in:
parent
ed6d50bed6
commit
8c3abfdfb0
@ -1734,7 +1734,7 @@ class BackupsAPITestCase(test.TestCase):
|
||||
project_id = fake.PROJECT_ID
|
||||
backup_service = 'fake'
|
||||
ctx = context.RequestContext(fake.USER_ID, project_id, is_admin=True)
|
||||
backup = objects.Backup(ctx, id=fake.backup_id, user_id=fake.USER_ID,
|
||||
backup = objects.Backup(ctx, id=fake.BACKUP_ID, user_id=fake.USER_ID,
|
||||
project_id=project_id,
|
||||
status=fields.BackupStatus.AVAILABLE)
|
||||
backup_url = backup.encode_record()
|
||||
@ -1755,10 +1755,10 @@ class BackupsAPITestCase(test.TestCase):
|
||||
# verify that request is successful
|
||||
self.assertEqual(201, res.status_int)
|
||||
self.assertIn('id', res_dict['backup'])
|
||||
self.assertEqual(fake.backup_id, res_dict['backup']['id'])
|
||||
self.assertEqual(fake.BACKUP_ID, res_dict['backup']['id'])
|
||||
|
||||
# Verify that entry in DB is as expected
|
||||
db_backup = objects.Backup.get_by_id(ctx, fake.backup_id)
|
||||
db_backup = objects.Backup.get_by_id(ctx, fake.BACKUP_ID)
|
||||
self.assertEqual(ctx.project_id, db_backup.project_id)
|
||||
self.assertEqual(ctx.user_id, db_backup.user_id)
|
||||
self.assertEqual(backup_api.IMPORT_VOLUME_ID, db_backup.volume_id)
|
||||
@ -1774,8 +1774,8 @@ class BackupsAPITestCase(test.TestCase):
|
||||
utils.replace_obj_loader(self, objects.Backup)
|
||||
|
||||
# Original backup belonged to a different user_id and project_id
|
||||
backup = objects.Backup(ctx, id=fake.backup_id, user_id=fake.USER2_ID,
|
||||
project_id=fake.project2_id,
|
||||
backup = objects.Backup(ctx, id=fake.BACKUP_ID, user_id=fake.USER2_ID,
|
||||
project_id=fake.PROJECT2_ID,
|
||||
status=fields.BackupStatus.AVAILABLE)
|
||||
backup_url = backup.encode_record()
|
||||
|
||||
@ -1800,10 +1800,10 @@ class BackupsAPITestCase(test.TestCase):
|
||||
# verify that request is successful
|
||||
self.assertEqual(201, res.status_int)
|
||||
self.assertIn('id', res_dict['backup'])
|
||||
self.assertEqual(fake.backup_id, res_dict['backup']['id'])
|
||||
self.assertEqual(fake.BACKUP_ID, res_dict['backup']['id'])
|
||||
|
||||
# Verify that entry in DB is as expected, with new project and user_id
|
||||
db_backup = objects.Backup.get_by_id(ctx, fake.backup_id)
|
||||
db_backup = objects.Backup.get_by_id(ctx, fake.BACKUP_ID)
|
||||
self.assertEqual(ctx.project_id, db_backup.project_id)
|
||||
self.assertEqual(ctx.user_id, db_backup.user_id)
|
||||
self.assertEqual(backup_api.IMPORT_VOLUME_ID, db_backup.volume_id)
|
||||
|
@ -467,7 +467,7 @@ class VolumeRetypeActionsTest(VolumeActionsTest):
|
||||
d1 = {'id': fake.VOLUME_TYPE_ID,
|
||||
'qos_specs_id': fake.QOS_SPEC_ID,
|
||||
'extra_specs': {}}
|
||||
d2 = {'id': fake.volume_type2_id,
|
||||
d2 = {'id': fake.VOLUME_TYPE2_ID,
|
||||
'qos_specs_id': fake.QOS_SPEC2_ID,
|
||||
'extra_specs': {}}
|
||||
return d1 if d1['id'] == args[1] else d2
|
||||
@ -495,7 +495,7 @@ class VolumeRetypeActionsTest(VolumeActionsTest):
|
||||
fake.USER_ID, fake.PROJECT_ID, auth_token=True)
|
||||
|
||||
def _retype_volume_exec(self, expected_status,
|
||||
new_type=fake.volume_type2_id):
|
||||
new_type=fake.VOLUME_TYPE2_ID):
|
||||
req = webob.Request.blank('/v2/%s/volumes/%s/action' %
|
||||
(fake.PROJECT_ID, fake.VOLUME_ID))
|
||||
req.method = 'POST'
|
||||
|
@ -48,7 +48,7 @@ def fake_db_volume_get(*args, **kwargs):
|
||||
|
||||
|
||||
def fake_volume_api_get(*args, **kwargs):
|
||||
ctx = context.RequestContext(fake.user_id, fake.PROJECT_ID, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
db_volume = fake_db_volume_get()
|
||||
return fake_volume.fake_volume_obj(ctx, **db_volume)
|
||||
|
||||
@ -76,7 +76,7 @@ class VolumeHostAttributeTest(test.TestCase):
|
||||
self.UUID = uuid.uuid4()
|
||||
|
||||
def test_get_volume_allowed(self):
|
||||
ctx = context.RequestContext(fake.user_id, fake.PROJECT_ID, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
req = webob.Request.blank('/v2/%s/volumes/%s' % (
|
||||
fake.PROJECT_ID, self.UUID))
|
||||
req.method = 'GET'
|
||||
@ -86,7 +86,7 @@ class VolumeHostAttributeTest(test.TestCase):
|
||||
self.assertEqual('host001', vol['os-vol-host-attr:host'])
|
||||
|
||||
def test_get_volume_unallowed(self):
|
||||
ctx = context.RequestContext(fake.user_id, fake.PROJECT_ID, False)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, False)
|
||||
req = webob.Request.blank('/v2/%s/volumes/%s' % (
|
||||
fake.PROJECT_ID, self.UUID))
|
||||
req.method = 'GET'
|
||||
@ -96,7 +96,7 @@ class VolumeHostAttributeTest(test.TestCase):
|
||||
self.assertNotIn('os-vol-host-attr:host', vol)
|
||||
|
||||
def test_list_detail_volumes_allowed(self):
|
||||
ctx = context.RequestContext(fake.user_id, fake.PROJECT_ID, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
req = webob.Request.blank('/v2/%s/volumes/detail' % fake.PROJECT_ID)
|
||||
req.method = 'GET'
|
||||
req.environ['cinder.context'] = ctx
|
||||
@ -105,7 +105,7 @@ class VolumeHostAttributeTest(test.TestCase):
|
||||
self.assertEqual('host001', vol[0]['os-vol-host-attr:host'])
|
||||
|
||||
def test_list_detail_volumes_unallowed(self):
|
||||
ctx = context.RequestContext(fake.user_id, fake.PROJECT_ID, False)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, False)
|
||||
req = webob.Request.blank('/v2/%s/volumes/detail' % fake.PROJECT_ID)
|
||||
req.method = 'GET'
|
||||
req.environ['cinder.context'] = ctx
|
||||
@ -114,7 +114,7 @@ class VolumeHostAttributeTest(test.TestCase):
|
||||
self.assertNotIn('os-vol-host-attr:host', vol[0])
|
||||
|
||||
def test_list_simple_volumes_no_host(self):
|
||||
ctx = context.RequestContext(fake.user_id, fake.PROJECT_ID, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
req = webob.Request.blank('/v2/%s/volumes' % fake.PROJECT_ID)
|
||||
req.method = 'GET'
|
||||
req.environ['cinder.context'] = ctx
|
||||
|
@ -32,7 +32,7 @@ PROJECT_ID = '88fd1da4-f464-4a87-9ce5-26f2f40743b9'
|
||||
def fake_volume_get(*args, **kwargs):
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, False)
|
||||
vol = {
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'project_id': PROJECT_ID,
|
||||
}
|
||||
return fake_volume.fake_volume_obj(ctx, **vol)
|
||||
|
@ -506,7 +506,7 @@ class VolumeTypeEncryptionTest(test.TestCase):
|
||||
req_body=jsonutils.dump_as_bytes(update_body),
|
||||
req_headers='application/json',
|
||||
url='/v2/%s/types/%s/encryption/' +
|
||||
fake.encryption_key_id)
|
||||
fake.ENCRYPTION_KEY_ID)
|
||||
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
self.assertEqual(512, res_dict['encryption']['key_size'])
|
||||
@ -534,7 +534,7 @@ class VolumeTypeEncryptionTest(test.TestCase):
|
||||
req_body=jsonutils.dump_as_bytes(update_body),
|
||||
req_headers='application/json',
|
||||
url='/v2/%s/types/%s/encryption/' +
|
||||
fake.encryption_key_id)
|
||||
fake.ENCRYPTION_KEY_ID)
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
expected = {
|
||||
@ -603,7 +603,7 @@ class VolumeTypeEncryptionTest(test.TestCase):
|
||||
req_body=jsonutils.dump_as_bytes(update_body),
|
||||
req_headers='application/json',
|
||||
url='/v2/%s/types/%s/encryption/' +
|
||||
fake.encryption_key_id)
|
||||
fake.ENCRYPTION_KEY_ID)
|
||||
self.assertEqual(400, res.status_code)
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
expected = {
|
||||
|
@ -99,7 +99,7 @@ class FakeToken(object):
|
||||
|
||||
class FakeRequestContext(context.RequestContext):
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['auth_token'] = kwargs.get(fake.user_id, fake.project_id)
|
||||
kwargs['auth_token'] = kwargs.get(fake.USER_ID, fake.PROJECT_ID)
|
||||
super(FakeRequestContext, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
@ -118,8 +118,8 @@ class HTTPRequest(webob.Request):
|
||||
version = kwargs.pop('version', api_version._MIN_API_VERSION)
|
||||
out = os_wsgi.Request.blank(*args, **kwargs)
|
||||
out.environ['cinder.context'] = FakeRequestContext(
|
||||
fake.user_id,
|
||||
fake.project_id,
|
||||
fake.USER_ID,
|
||||
fake.PROJECT_ID,
|
||||
is_admin=use_admin_context)
|
||||
out.api_version_request = api_version.APIVersionRequest(version)
|
||||
return out
|
||||
|
@ -28,8 +28,8 @@ DEFAULT_VOL_TYPE = "vol_type_name"
|
||||
def stub_volume(id, **kwargs):
|
||||
volume = {
|
||||
'id': id,
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.project_id,
|
||||
'user_id': fake.USER_ID,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'host': 'fakehost',
|
||||
'size': 1,
|
||||
'availability_zone': 'fakeaz',
|
||||
@ -47,7 +47,7 @@ def stub_volume(id, **kwargs):
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
'snapshot_id': None,
|
||||
'source_volid': None,
|
||||
'volume_type_id': fake.volume_type_id,
|
||||
'volume_type_id': fake.VOLUME_TYPE_ID,
|
||||
'volume_admin_metadata': [{'key': 'attached_mode', 'value': 'rw'},
|
||||
{'key': 'readonly', 'value': 'False'}],
|
||||
'volume_type': fake_volume.fake_db_volume_type(name=DEFAULT_VOL_TYPE),
|
||||
@ -65,7 +65,7 @@ def stub_volume(id, **kwargs):
|
||||
|
||||
def stub_volume_create(self, context, size, name, description, snapshot,
|
||||
**param):
|
||||
vol = stub_volume(fake.volume_id)
|
||||
vol = stub_volume(fake.VOLUME_ID)
|
||||
vol['size'] = size
|
||||
vol['display_name'] = name
|
||||
vol['display_description'] = description
|
||||
@ -105,7 +105,7 @@ def stub_volume_delete(self, context, *args, **param):
|
||||
|
||||
|
||||
def stub_volume_get(self, context, volume_id, viewable_admin_meta=False):
|
||||
if volume_id == fake.will_not_be_found_id:
|
||||
if volume_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.VolumeNotFound(volume_id)
|
||||
|
||||
if viewable_admin_meta:
|
||||
@ -135,7 +135,7 @@ def stub_volume_api_get_all_by_project(self, context, marker, limit,
|
||||
filters=None,
|
||||
viewable_admin_meta=False,
|
||||
offset=None):
|
||||
vol = stub_volume_get(self, context, fake.volume_id,
|
||||
vol = stub_volume_get(self, context, fake.VOLUME_ID,
|
||||
viewable_admin_meta=viewable_admin_meta)
|
||||
vol_obj = fake_volume.fake_volume_obj(context, **vol)
|
||||
return objects.VolumeList(objects=[vol_obj])
|
||||
@ -144,28 +144,28 @@ def stub_volume_api_get_all_by_project(self, context, marker, limit,
|
||||
def stub_volume_get_all(context, search_opts=None, marker=None, limit=None,
|
||||
sort_keys=None, sort_dirs=None, filters=None,
|
||||
viewable_admin_meta=False, offset=None):
|
||||
return [stub_volume(fake.volume_id, project_id=fake.project_id),
|
||||
stub_volume(fake.volume2_id, project_id=fake.project2_id),
|
||||
stub_volume(fake.volume3_id, project_id=fake.project3_id)]
|
||||
return [stub_volume(fake.VOLUME_ID, project_id=fake.PROJECT_ID),
|
||||
stub_volume(fake.VOLUME2_ID, project_id=fake.PROJECT2_ID),
|
||||
stub_volume(fake.VOLUME3_ID, project_id=fake.PROJECT3_ID)]
|
||||
|
||||
|
||||
def stub_volume_get_all_by_project(self, context, marker, limit,
|
||||
sort_keys=None, sort_dirs=None,
|
||||
filters=None,
|
||||
viewable_admin_meta=False, offset=None):
|
||||
return [stub_volume_get(self, context, fake.volume_id,
|
||||
return [stub_volume_get(self, context, fake.VOLUME_ID,
|
||||
viewable_admin_meta=True)]
|
||||
|
||||
|
||||
def stub_snapshot(id, **kwargs):
|
||||
snapshot = {'id': id,
|
||||
'volume_id': fake.snapshot_id,
|
||||
'volume_id': fake.SNAPSHOT_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 100,
|
||||
'created_at': None,
|
||||
'display_name': 'Default name',
|
||||
'display_description': 'Default description',
|
||||
'project_id': fake.project_id,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'snapshot_metadata': []}
|
||||
|
||||
snapshot.update(kwargs)
|
||||
@ -174,15 +174,15 @@ def stub_snapshot(id, **kwargs):
|
||||
|
||||
def stub_snapshot_get_all(context, filters=None, marker=None, limit=None,
|
||||
sort_keys=None, sort_dirs=None, offset=None):
|
||||
return [stub_snapshot(fake.snapshot_id, project_id=fake.project_id),
|
||||
stub_snapshot(fake.snapshot2_id, project_id=fake.project2_id),
|
||||
stub_snapshot(fake.snapshot3_id, project_id=fake.project3_id)]
|
||||
return [stub_snapshot(fake.SNAPSHOT_ID, project_id=fake.PROJECT_ID),
|
||||
stub_snapshot(fake.SNAPSHOT2_ID, project_id=fake.PROJECT2_ID),
|
||||
stub_snapshot(fake.SNAPSHOT3_ID, project_id=fake.PROJECT3_ID)]
|
||||
|
||||
|
||||
def stub_snapshot_get_all_by_project(context, project_id, filters=None,
|
||||
marker=None, limit=None, sort_keys=None,
|
||||
sort_dirs=None, offset=None):
|
||||
return [stub_snapshot(fake.volume_id)]
|
||||
return [stub_snapshot(fake.VOLUME_ID)]
|
||||
|
||||
|
||||
def stub_snapshot_update(self, context, *args, **param):
|
||||
|
@ -79,7 +79,7 @@ class LimitsControllerTest(BaseLimitTestSuite):
|
||||
"action": "index",
|
||||
"controller": "",
|
||||
})
|
||||
context = cinder.context.RequestContext(fake.user_id, fake.project_id)
|
||||
context = cinder.context.RequestContext(fake.USER_ID, fake.PROJECT_ID)
|
||||
request.environ["cinder.context"] = context
|
||||
return request
|
||||
|
||||
|
@ -44,13 +44,13 @@ def return_new_snapshot_metadata(context, snapshot_id, metadata, delete):
|
||||
|
||||
|
||||
def return_empty_container_metadata(context, snapshot_id, metadata, delete):
|
||||
if snapshot_id == fake.will_not_be_found_id:
|
||||
if snapshot_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.SnapshotNotFound(snapshot_id)
|
||||
return {}
|
||||
|
||||
|
||||
def stub_snapshot_metadata(snapshot_id):
|
||||
if snapshot_id == fake.will_not_be_found_id:
|
||||
if snapshot_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.SnapshotNotFound(snapshot_id)
|
||||
metadata = {
|
||||
"key1": "value1",
|
||||
@ -61,7 +61,7 @@ def stub_snapshot_metadata(snapshot_id):
|
||||
|
||||
|
||||
def stub_snapshot_metadata_insensitive(snapshot_id):
|
||||
if snapshot_id == fake.will_not_be_found_id:
|
||||
if snapshot_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.SnapshotNotFound(snapshot_id)
|
||||
metadata = {
|
||||
"key1": "value1",
|
||||
@ -73,7 +73,7 @@ def stub_snapshot_metadata_insensitive(snapshot_id):
|
||||
|
||||
|
||||
def stub_new_snapshot_metadata(snapshot_id):
|
||||
if snapshot_id == fake.will_not_be_found_id:
|
||||
if snapshot_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.SnapshotNotFound(snapshot_id)
|
||||
metadata = {
|
||||
'key10': 'value10',
|
||||
@ -84,7 +84,7 @@ def stub_new_snapshot_metadata(snapshot_id):
|
||||
|
||||
|
||||
def return_snapshot(context, snapshot_id):
|
||||
if snapshot_id == fake.will_not_be_found_id:
|
||||
if snapshot_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.SnapshotNotFound(snapshot_id)
|
||||
return {'id': '0cc3346e-9fef-4445-abe6-5d2b2690ec64',
|
||||
'name': 'fake',
|
||||
@ -93,7 +93,7 @@ def return_snapshot(context, snapshot_id):
|
||||
|
||||
|
||||
def stub_get(self, context, volume_id, *args, **kwargs):
|
||||
if volume_id == fake.will_not_be_found_id:
|
||||
if volume_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.VolumeNotFound(volume_id)
|
||||
vol = {'id': volume_id,
|
||||
'size': 100,
|
||||
@ -127,10 +127,10 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
self.snapshot_controller = snapshots.SnapshotsController(self.ext_mgr)
|
||||
self.controller = snapshot_metadata.Controller()
|
||||
self.url = '/v1/%s/snapshots/%s/metadata' % (
|
||||
fake.project_id, fake.snapshot_id)
|
||||
fake.PROJECT_ID, fake.SNAPSHOT_ID)
|
||||
|
||||
snap = {"volume_size": 100,
|
||||
"volume_id": fake.volume_id,
|
||||
"volume_id": fake.VOLUME_ID,
|
||||
"display_name": "Snapshot Test Name",
|
||||
"display_description": "Snapshot Test Desc",
|
||||
"availability_zone": "zone1:host1",
|
||||
@ -143,10 +143,10 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
@mock.patch('cinder.objects.Snapshot.get_by_id')
|
||||
def test_index(self, snapshot_get_by_id):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_obj['metadata'] = {'key1': 'value1',
|
||||
'key2': 'value2',
|
||||
@ -154,7 +154,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
res_dict = self.controller.index(req, fake.snapshot_id)
|
||||
res_dict = self.controller.index(req, fake.SNAPSHOT_ID)
|
||||
|
||||
expected = {
|
||||
'metadata': {
|
||||
@ -168,7 +168,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
@mock.patch('cinder.objects.Snapshot.get_by_id')
|
||||
def test_index_nonexistent_snapshot(self, snapshot_get_by_id):
|
||||
snapshot_get_by_id.side_effect = \
|
||||
exc.SnapshotNotFound(snapshot_id=fake.will_not_be_found_id)
|
||||
exc.SnapshotNotFound(snapshot_id=fake.WILL_NOT_BE_FOUND_ID)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
@ -177,72 +177,72 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
@mock.patch('cinder.objects.Snapshot.get_by_id')
|
||||
def test_index_no_data(self, snapshot_get_by_id):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
res_dict = self.controller.index(req, fake.snapshot_id)
|
||||
res_dict = self.controller.index(req, fake.SNAPSHOT_ID)
|
||||
expected = {'metadata': {}}
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
@mock.patch('cinder.objects.Snapshot.get_by_id')
|
||||
def test_show(self, snapshot_get_by_id):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_obj['metadata'] = {'key2': 'value2'}
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key2')
|
||||
res_dict = self.controller.show(req, fake.snapshot_id, 'key2')
|
||||
res_dict = self.controller.show(req, fake.SNAPSHOT_ID, 'key2')
|
||||
expected = {'meta': {'key2': 'value2'}}
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
@mock.patch('cinder.objects.Snapshot.get_by_id')
|
||||
def test_show_nonexistent_snapshot(self, snapshot_get_by_id):
|
||||
snapshot_get_by_id.side_effect = \
|
||||
exc.SnapshotNotFound(snapshot_id=fake.will_not_be_found_id)
|
||||
exc.SnapshotNotFound(snapshot_id=fake.WILL_NOT_BE_FOUND_ID)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key2')
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.show, req, fake.snapshot_id, 'key2')
|
||||
self.controller.show, req, fake.SNAPSHOT_ID, 'key2')
|
||||
|
||||
@mock.patch('cinder.objects.Snapshot.get_by_id')
|
||||
def test_show_meta_not_found(self, snapshot_get_by_id):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key6')
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.show, req, fake.snapshot_id, 'key6')
|
||||
self.controller.show, req, fake.SNAPSHOT_ID, 'key6')
|
||||
|
||||
@mock.patch('cinder.db.snapshot_metadata_delete')
|
||||
@mock.patch('cinder.objects.Snapshot.get_by_id')
|
||||
def test_delete(self, snapshot_get_by_id, snapshot_metadata_delete):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_obj['metadata'] = {'key2': 'value2'}
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key2')
|
||||
req.method = 'DELETE'
|
||||
res = self.controller.delete(req, fake.snapshot_id, 'key2')
|
||||
res = self.controller.delete(req, fake.SNAPSHOT_ID, 'key2')
|
||||
|
||||
self.assertEqual(200, res.status_int)
|
||||
|
||||
@ -251,15 +251,15 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.method = 'DELETE'
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.delete, req,
|
||||
fake.will_not_be_found_id, 'key1')
|
||||
fake.WILL_NOT_BE_FOUND_ID, 'key1')
|
||||
|
||||
@mock.patch('cinder.objects.Snapshot.get_by_id')
|
||||
def test_delete_meta_not_found(self, snapshot_get_by_id):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -267,7 +267,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.method = 'DELETE'
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.delete, req,
|
||||
fake.snapshot_id, 'key6')
|
||||
fake.SNAPSHOT_ID, 'key6')
|
||||
|
||||
@mock.patch('cinder.db.snapshot_update')
|
||||
@mock.patch('cinder.objects.Volume.get_by_id')
|
||||
@ -275,10 +275,10 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
def test_create(self, snapshot_get_by_id, volume_get_by_id,
|
||||
snapshot_update):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
fake_volume_obj = fake_volume.fake_volume_obj(ctx)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
@ -294,7 +294,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
"key2": "value2",
|
||||
"key3": "value3"}}
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
res_dict = self.controller.create(req, fake.snapshot_id, body)
|
||||
res_dict = self.controller.create(req, fake.SNAPSHOT_ID, body)
|
||||
self.assertEqual(body, res_dict)
|
||||
|
||||
@mock.patch('cinder.db.snapshot_update')
|
||||
@ -302,10 +302,10 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
def test_create_with_keys_in_uppercase_and_lowercase(
|
||||
self, snapshot_get_by_id, snapshot_update):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -328,7 +328,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
"key3": "value3",
|
||||
"KEY4": "value4"}}
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
res_dict = self.controller.create(req, fake.snapshot_id, body)
|
||||
res_dict = self.controller.create(req, fake.SNAPSHOT_ID, body)
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
def test_create_empty_body(self):
|
||||
@ -339,7 +339,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, req, fake.snapshot_id, None)
|
||||
self.controller.create, req, fake.SNAPSHOT_ID, None)
|
||||
|
||||
def test_create_item_empty_key(self):
|
||||
self.stubs.Set(cinder.db, 'snapshot_metadata_update',
|
||||
@ -351,7 +351,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, req, fake.snapshot_id, body)
|
||||
self.controller.create, req, fake.SNAPSHOT_ID, body)
|
||||
|
||||
def test_create_item_key_too_long(self):
|
||||
self.stubs.Set(cinder.db, 'snapshot_metadata_update',
|
||||
@ -364,7 +364,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create,
|
||||
req, fake.snapshot_id, body)
|
||||
req, fake.SNAPSHOT_ID, body)
|
||||
|
||||
def test_create_nonexistent_snapshot(self):
|
||||
self.stubs.Set(cinder.db, 'snapshot_metadata_update',
|
||||
@ -377,16 +377,16 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.create, req,
|
||||
fake.will_not_be_found_id, body)
|
||||
fake.WILL_NOT_BE_FOUND_ID, body)
|
||||
|
||||
@mock.patch('cinder.db.snapshot_update')
|
||||
@mock.patch('cinder.objects.Snapshot.get_by_id')
|
||||
def test_update_all(self, snapshot_get_by_id, snapshot_update):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': []
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -403,7 +403,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
},
|
||||
}
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
res_dict = self.controller.update_all(req, fake.snapshot_id, expected)
|
||||
res_dict = self.controller.update_all(req, fake.SNAPSHOT_ID, expected)
|
||||
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
@ -415,10 +415,10 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
def test_update_all_with_keys_in_uppercase_and_lowercase(
|
||||
self, snapshot_get_by_id, snapshot_update):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -443,7 +443,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
},
|
||||
}
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
res_dict = self.controller.update_all(req, fake.snapshot_id, body)
|
||||
res_dict = self.controller.update_all(req, fake.SNAPSHOT_ID, body)
|
||||
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
@ -452,10 +452,10 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
def test_update_all_empty_container(self, snapshot_get_by_id,
|
||||
snapshot_update):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': []
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -466,7 +466,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.content_type = "application/json"
|
||||
expected = {'metadata': {}}
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
res_dict = self.controller.update_all(req, fake.snapshot_id, expected)
|
||||
res_dict = self.controller.update_all(req, fake.SNAPSHOT_ID, expected)
|
||||
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
@ -480,7 +480,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update_all, req, fake.snapshot_id,
|
||||
self.controller.update_all, req, fake.SNAPSHOT_ID,
|
||||
expected)
|
||||
|
||||
@mock.patch('cinder.db.sqlalchemy.api._snapshot_get')
|
||||
@ -494,7 +494,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update_all, req, fake.snapshot_id,
|
||||
self.controller.update_all, req, fake.SNAPSHOT_ID,
|
||||
expected)
|
||||
|
||||
def test_update_all_nonexistent_snapshot(self):
|
||||
@ -506,7 +506,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.update_all, req,
|
||||
fake.will_not_be_found_id, body)
|
||||
fake.WILL_NOT_BE_FOUND_ID, body)
|
||||
|
||||
@mock.patch('cinder.db.snapshot_metadata_update', return_value=dict())
|
||||
@mock.patch('cinder.db.snapshot_update')
|
||||
@ -514,10 +514,10 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
def test_update_item(self, snapshot_get_by_id,
|
||||
snapshot_update, snapshot_metadata_update):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -526,7 +526,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
res_dict = self.controller.update(req, fake.snapshot_id, 'key1', body)
|
||||
res_dict = self.controller.update(req, fake.SNAPSHOT_ID, 'key1', body)
|
||||
expected = {'meta': {'key1': 'value1'}}
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
@ -540,7 +540,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.update, req,
|
||||
fake.will_not_be_found_id, 'key1',
|
||||
fake.WILL_NOT_BE_FOUND_ID, 'key1',
|
||||
body)
|
||||
|
||||
def test_update_item_empty_body(self):
|
||||
@ -552,7 +552,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update, req,
|
||||
fake.snapshot_id, 'key1',
|
||||
fake.SNAPSHOT_ID, 'key1',
|
||||
None)
|
||||
|
||||
@mock.patch('cinder.db.sqlalchemy.api._snapshot_get')
|
||||
@ -567,15 +567,15 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update, req,
|
||||
fake.snapshot_id, '', body)
|
||||
fake.SNAPSHOT_ID, '', body)
|
||||
|
||||
@mock.patch('cinder.objects.Snapshot.get_by_id')
|
||||
def test_update_item_key_too_long(self, snapshot_get_by_id):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -589,15 +589,15 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.update,
|
||||
req, fake.snapshot_id, ("a" * 260), body)
|
||||
req, fake.SNAPSHOT_ID, ("a" * 260), body)
|
||||
|
||||
@mock.patch('cinder.objects.Snapshot.get_by_id')
|
||||
def test_update_item_value_too_long(self, snapshot_get_by_id):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -611,7 +611,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.update,
|
||||
req, fake.snapshot_id, "key1", body)
|
||||
req, fake.SNAPSHOT_ID, "key1", body)
|
||||
|
||||
def test_update_item_too_many_keys(self):
|
||||
self.stubs.Set(cinder.db, 'snapshot_metadata_update',
|
||||
@ -624,7 +624,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update, req,
|
||||
fake.snapshot_id, 'key1',
|
||||
fake.SNAPSHOT_ID, 'key1',
|
||||
body)
|
||||
|
||||
def test_update_item_body_uri_mismatch(self):
|
||||
@ -637,16 +637,16 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update, req, fake.snapshot_id, 'bad',
|
||||
self.controller.update, req, fake.SNAPSHOT_ID, 'bad',
|
||||
body)
|
||||
|
||||
@mock.patch('cinder.objects.Snapshot.get_by_id')
|
||||
def test_invalid_metadata_items_on_create(self, snapshot_get_by_id):
|
||||
snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -660,16 +660,16 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
data = {"metadata": {"a" * 260: "value1"}}
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.create, req, fake.snapshot_id, data)
|
||||
self.controller.create, req, fake.SNAPSHOT_ID, data)
|
||||
|
||||
# test for long value
|
||||
data = {"metadata": {"key": "v" * 260}}
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.create, req, fake.snapshot_id, data)
|
||||
self.controller.create, req, fake.SNAPSHOT_ID, data)
|
||||
|
||||
# test for empty key.
|
||||
data = {"metadata": {"": "value1"}}
|
||||
req.body = jsonutils.dump_as_bytes(data)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, req, fake.snapshot_id, data)
|
||||
self.controller.create, req, fake.SNAPSHOT_ID, data)
|
||||
|
@ -30,13 +30,13 @@ from cinder.tests.unit import fake_volume
|
||||
from cinder import volume
|
||||
|
||||
|
||||
UUID = fake.snapshot_id
|
||||
INVALID_UUID = fake.will_not_be_found_id
|
||||
UUID = fake.SNAPSHOT_ID
|
||||
INVALID_UUID = fake.WILL_NOT_BE_FOUND_ID
|
||||
|
||||
|
||||
def _get_default_snapshot_param():
|
||||
return {'id': UUID,
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 100,
|
||||
'created_at': None,
|
||||
@ -86,7 +86,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
def test_snapshot_create(self):
|
||||
self.stubs.Set(volume.api.API, "create_snapshot", stub_snapshot_create)
|
||||
self.stubs.Set(volume.api.API, 'get', stubs.stub_volume_get)
|
||||
snapshot = {"volume_id": fake.volume_id,
|
||||
snapshot = {"volume_id": fake.VOLUME_ID,
|
||||
"force": False,
|
||||
"display_name": "Snapshot Test Name",
|
||||
"display_description": "Snapshot Test Desc"}
|
||||
@ -105,7 +105,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
"create_snapshot_force",
|
||||
stub_snapshot_create)
|
||||
self.stubs.Set(volume.api.API, 'get', stubs.stub_volume_get)
|
||||
snapshot = {"volume_id": fake.volume_id,
|
||||
snapshot = {"volume_id": fake.VOLUME_ID,
|
||||
"force": True,
|
||||
"display_name": "Snapshot Test Name",
|
||||
"display_description": "Snapshot Test Desc"}
|
||||
@ -119,7 +119,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
self.assertEqual(snapshot['display_description'],
|
||||
resp_dict['snapshot']['display_description'])
|
||||
|
||||
snapshot = {"volume_id": fake.snapshot_id,
|
||||
snapshot = {"volume_id": fake.SNAPSHOT_ID,
|
||||
"force": "**&&^^%%$$##@@",
|
||||
"display_name": "Snapshot Test Name",
|
||||
"display_description": "Snapshot Test Desc"}
|
||||
@ -153,14 +153,14 @@ class SnapshotApiTest(test.TestCase):
|
||||
snapshot_metadata_get, update_snapshot):
|
||||
snapshot = {
|
||||
'id': UUID,
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 100,
|
||||
'display_name': 'Default name',
|
||||
'display_description': 'Default description',
|
||||
'expected_attrs': ['metadata'],
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
fake_volume_obj = fake_volume.fake_volume_obj(ctx)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
@ -172,7 +172,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
res_dict = self.controller.update(req, UUID, body)
|
||||
expected = {'snapshot': {
|
||||
'id': UUID,
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': u'available',
|
||||
'size': 100,
|
||||
'created_at': None,
|
||||
@ -213,14 +213,14 @@ class SnapshotApiTest(test.TestCase):
|
||||
snapshot_metadata_get, delete_snapshot):
|
||||
snapshot = {
|
||||
'id': UUID,
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 100,
|
||||
'display_name': 'Default name',
|
||||
'display_description': 'Default description',
|
||||
'expected_attrs': ['metadata'],
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
fake_volume_obj = fake_volume.fake_volume_obj(ctx)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
@ -247,14 +247,14 @@ class SnapshotApiTest(test.TestCase):
|
||||
snapshot_metadata_get):
|
||||
snapshot = {
|
||||
'id': UUID,
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 100,
|
||||
'display_name': 'Default name',
|
||||
'display_description': 'Default description',
|
||||
'expected_attrs': ['metadata'],
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
fake_volume_obj = fake_volume.fake_volume_obj(ctx)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
@ -282,14 +282,14 @@ class SnapshotApiTest(test.TestCase):
|
||||
volume_get_by_id, snapshot_metadata_get):
|
||||
snapshot = {
|
||||
'id': UUID,
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 100,
|
||||
'display_name': 'Default name',
|
||||
'display_description': 'Default description',
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
fake_volume_obj = fake_volume.fake_volume_obj(ctx)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
@ -310,7 +310,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
@mock.patch('cinder.db.snapshot_metadata_get', return_value=dict())
|
||||
def test_admin_list_snapshots_limited_to_project(self,
|
||||
snapshot_metadata_get):
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/snapshots' % fake.project_id,
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/snapshots' % fake.PROJECT_ID,
|
||||
use_admin_context=True)
|
||||
res = self.controller.index(req)
|
||||
|
||||
@ -326,11 +326,11 @@ class SnapshotApiTest(test.TestCase):
|
||||
limit=None, sort_keys=None,
|
||||
sort_dirs=None, offset=None):
|
||||
return [
|
||||
stubs.stub_snapshot(fake.snapshot_id,
|
||||
stubs.stub_snapshot(fake.SNAPSHOT_ID,
|
||||
display_name='backup1'),
|
||||
stubs.stub_snapshot(fake.snapshot2_id,
|
||||
stubs.stub_snapshot(fake.SNAPSHOT2_ID,
|
||||
display_name='backup2'),
|
||||
stubs.stub_snapshot(fake.snapshot3_id,
|
||||
stubs.stub_snapshot(fake.SNAPSHOT3_ID,
|
||||
display_name='backup3'),
|
||||
]
|
||||
|
||||
@ -338,13 +338,13 @@ class SnapshotApiTest(test.TestCase):
|
||||
stub_snapshot_get_all_by_project)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/snapshots?limit=1\
|
||||
&offset=1' % fake.project_id,
|
||||
&offset=1' % fake.PROJECT_ID,
|
||||
use_admin_context=is_admin)
|
||||
res = self.controller.index(req)
|
||||
|
||||
self.assertIn('snapshots', res)
|
||||
self.assertEqual(1, len(res['snapshots']))
|
||||
self.assertEqual(fake.snapshot2_id, res['snapshots'][0]['id'])
|
||||
self.assertEqual(fake.SNAPSHOT2_ID, res['snapshots'][0]['id'])
|
||||
|
||||
# admin case
|
||||
list_snapshots_with_limit_and_offset(is_admin=True)
|
||||
@ -354,7 +354,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
@mock.patch('cinder.db.snapshot_metadata_get', return_value=dict())
|
||||
def test_admin_list_snapshots_all_tenants(self, snapshot_metadata_get):
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v1/%s/snapshots?all_tenants=1' % fake.project_id,
|
||||
'/v1/%s/snapshots?all_tenants=1' % fake.PROJECT_ID,
|
||||
use_admin_context=True)
|
||||
res = self.controller.index(req)
|
||||
self.assertIn('snapshots', res)
|
||||
@ -364,14 +364,14 @@ class SnapshotApiTest(test.TestCase):
|
||||
def test_all_tenants_non_admin_gets_all_tenants(self,
|
||||
snapshot_metadata_get):
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v1/%s/snapshots?all_tenants=1' % fake.project_id)
|
||||
'/v1/%s/snapshots?all_tenants=1' % fake.PROJECT_ID)
|
||||
res = self.controller.index(req)
|
||||
self.assertIn('snapshots', res)
|
||||
self.assertEqual(1, len(res['snapshots']))
|
||||
|
||||
@mock.patch('cinder.db.snapshot_metadata_get', return_value=dict())
|
||||
def test_non_admin_get_by_project(self, snapshot_metadata_get):
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/snapshots' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/snapshots' % fake.PROJECT_ID)
|
||||
res = self.controller.index(req)
|
||||
self.assertIn('snapshots', res)
|
||||
self.assertEqual(1, len(res['snapshots']))
|
||||
@ -386,7 +386,7 @@ class SnapshotsUnprocessableEntityTestCase(test.TestCase):
|
||||
self.controller = snapshots.SnapshotsController()
|
||||
|
||||
def _unprocessable_snapshot_create(self, body):
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/snapshots' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/snapshots' % fake.PROJECT_ID)
|
||||
req.method = 'POST'
|
||||
|
||||
self.assertRaises(webob.exc.HTTPUnprocessableEntity,
|
||||
|
@ -38,8 +38,8 @@ def stub_volume_type(id):
|
||||
|
||||
def return_volume_types_get_all_types(context, search_opts=None):
|
||||
d = {}
|
||||
for vtype in [fake.volume_type_id, fake.volume_type2_id,
|
||||
fake.volume_type3_id]:
|
||||
for vtype in [fake.VOLUME_TYPE_ID, fake.VOLUME_TYPE2_ID,
|
||||
fake.VOLUME_TYPE3_ID]:
|
||||
vtype_name = 'vol_type_%s' % vtype
|
||||
d[vtype_name] = stub_volume_type(vtype)
|
||||
return d
|
||||
@ -50,7 +50,7 @@ def return_empty_volume_types_get_all_types(context, search_opts=None):
|
||||
|
||||
|
||||
def return_volume_types_get_volume_type(context, id):
|
||||
if id == fake.will_not_be_found_id:
|
||||
if id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exception.VolumeTypeNotFound(volume_type_id=id)
|
||||
return stub_volume_type(id)
|
||||
|
||||
@ -64,14 +64,14 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
self.stubs.Set(volume_types, 'get_all_types',
|
||||
return_volume_types_get_all_types)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/types' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/types' % fake.PROJECT_ID)
|
||||
res_dict = self.controller.index(req)
|
||||
|
||||
self.assertEqual(3, len(res_dict['volume_types']))
|
||||
|
||||
expected_names = ['vol_type_%s' % fake.volume_type_id,
|
||||
'vol_type_%s' % fake.volume_type2_id,
|
||||
'vol_type_%s' % fake.volume_type3_id]
|
||||
expected_names = ['vol_type_%s' % fake.VOLUME_TYPE_ID,
|
||||
'vol_type_%s' % fake.VOLUME_TYPE2_ID,
|
||||
'vol_type_%s' % fake.VOLUME_TYPE3_ID]
|
||||
|
||||
actual_names = map(lambda e: e['name'], res_dict['volume_types'])
|
||||
self.assertEqual(set(expected_names), set(actual_names))
|
||||
@ -82,7 +82,7 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
self.stubs.Set(volume_types, 'get_all_types',
|
||||
return_empty_volume_types_get_all_types)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/types' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/types' % fake.PROJECT_ID)
|
||||
res_dict = self.controller.index(req)
|
||||
|
||||
self.assertEqual(0, len(res_dict['volume_types']))
|
||||
@ -91,8 +91,8 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
self.stubs.Set(volume_types, 'get_volume_type',
|
||||
return_volume_types_get_volume_type)
|
||||
|
||||
type_id = fake.volume_type_id
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/types/' % fake.project_id
|
||||
type_id = fake.VOLUME_TYPE_ID
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/types/' % fake.PROJECT_ID
|
||||
+ type_id)
|
||||
res_dict = self.controller.show(req, type_id)
|
||||
|
||||
@ -106,10 +106,10 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
return_volume_types_get_volume_type)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/types/%s' %
|
||||
(fake.project_id,
|
||||
fake.will_not_be_found_id))
|
||||
(fake.PROJECT_ID,
|
||||
fake.WILL_NOT_BE_FOUND_ID))
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.show,
|
||||
req, fake.will_not_be_found_id)
|
||||
req, fake.WILL_NOT_BE_FOUND_ID)
|
||||
|
||||
def test_view_builder_show(self):
|
||||
view_builder = views_types.ViewBuilder()
|
||||
@ -122,7 +122,7 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
extra_specs={},
|
||||
deleted_at=None,
|
||||
description=None,
|
||||
id=fake.volume_type_id)
|
||||
id=fake.VOLUME_TYPE_ID)
|
||||
|
||||
request = fakes.HTTPRequest.blank("/v1")
|
||||
output = view_builder.show(request, raw_volume_type)
|
||||
@ -132,7 +132,7 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
extra_specs={},
|
||||
description=None,
|
||||
is_public=None,
|
||||
id=fake.volume_type_id)
|
||||
id=fake.VOLUME_TYPE_ID)
|
||||
self.assertDictMatch(expected_volume_type, output['volume_type'])
|
||||
|
||||
def test_view_builder_list(self):
|
||||
|
@ -59,26 +59,26 @@ def return_volume_metadata(context, volume_id):
|
||||
|
||||
|
||||
def return_empty_volume_metadata(context, volume_id):
|
||||
if volume_id == fake.will_not_be_found_id:
|
||||
if volume_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.VolumeNotFound(volume_id)
|
||||
return {}
|
||||
|
||||
|
||||
def return_empty_container_metadata(context, volume_id, metadata,
|
||||
delete, meta_type):
|
||||
if volume_id == fake.will_not_be_found_id:
|
||||
if volume_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.VolumeNotFound(volume_id)
|
||||
return {}
|
||||
|
||||
|
||||
def delete_volume_metadata(context, volume_id, key, meta_type):
|
||||
if volume_id == fake.will_not_be_found_id:
|
||||
if volume_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.VolumeNotFound(volume_id)
|
||||
pass
|
||||
|
||||
|
||||
def stub_volume_metadata(volume_id):
|
||||
if volume_id == fake.will_not_be_found_id:
|
||||
if volume_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.VolumeNotFound(volume_id)
|
||||
metadata = {
|
||||
"key1": "value1",
|
||||
@ -89,7 +89,7 @@ def stub_volume_metadata(volume_id):
|
||||
|
||||
|
||||
def stub_new_volume_metadata(volume_id):
|
||||
if volume_id == fake.will_not_be_found_id:
|
||||
if volume_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.VolumeNotFound(volume_id)
|
||||
metadata = {
|
||||
'key10': 'value10',
|
||||
@ -100,7 +100,7 @@ def stub_new_volume_metadata(volume_id):
|
||||
|
||||
|
||||
def stub_volume_metadata_insensitive(volume_id):
|
||||
if volume_id == fake.will_not_be_found_id:
|
||||
if volume_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.VolumeNotFound(volume_id)
|
||||
metadata = {
|
||||
"key1": "value1",
|
||||
@ -112,7 +112,7 @@ def stub_volume_metadata_insensitive(volume_id):
|
||||
|
||||
|
||||
def stub_max_volume_metadata(volume_id):
|
||||
if volume_id == fake.will_not_be_found_id:
|
||||
if volume_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.VolumeNotFound(volume_id)
|
||||
metadata = {"metadata": {}}
|
||||
for num in range(CONF.quota_metadata_items):
|
||||
@ -121,7 +121,7 @@ def stub_max_volume_metadata(volume_id):
|
||||
|
||||
|
||||
def get_volume(self, context, volume_id, *args, **kwargs):
|
||||
if volume_id == fake.will_not_be_found_id:
|
||||
if volume_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.VolumeNotFound('bogus test message')
|
||||
vol = {'id': volume_id,
|
||||
'size': 100,
|
||||
@ -151,7 +151,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
self.volume_controller = volumes.VolumeController(self.ext_mgr)
|
||||
self.controller = volume_metadata.Controller()
|
||||
self.url = '/v1/%s/volumes/%s/metadata' % (
|
||||
fake.project_id, fake.volume_id)
|
||||
fake.PROJECT_ID, fake.VOLUME_ID)
|
||||
|
||||
vol = {"size": 100,
|
||||
"display_name": "Volume Test Name",
|
||||
@ -164,7 +164,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
|
||||
def test_index(self):
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
res_dict = self.controller.index(req, fake.volume_id)
|
||||
res_dict = self.controller.index(req, fake.VOLUME_ID)
|
||||
|
||||
expected = {
|
||||
'metadata': {
|
||||
@ -179,19 +179,19 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.index,
|
||||
req, fake.will_not_be_found_id)
|
||||
req, fake.WILL_NOT_BE_FOUND_ID)
|
||||
|
||||
def test_index_no_metadata(self):
|
||||
self.stubs.Set(cinder.db, 'volume_metadata_get',
|
||||
return_empty_volume_metadata)
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
res_dict = self.controller.index(req, fake.volume_id)
|
||||
res_dict = self.controller.index(req, fake.VOLUME_ID)
|
||||
expected = {'metadata': {}}
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
def test_show(self):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key2')
|
||||
res_dict = self.controller.show(req, fake.volume_id, 'key2')
|
||||
res_dict = self.controller.show(req, fake.VOLUME_ID, 'key2')
|
||||
expected = {'meta': {'key2': 'value2'}}
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
@ -199,19 +199,19 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key2')
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.show, req,
|
||||
fake.will_not_be_found_id, 'key2')
|
||||
fake.WILL_NOT_BE_FOUND_ID, 'key2')
|
||||
|
||||
def test_show_meta_not_found(self):
|
||||
self.stubs.Set(cinder.db, 'volume_metadata_get',
|
||||
return_empty_volume_metadata)
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key6')
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.show, req, fake.volume_id, 'key6')
|
||||
self.controller.show, req, fake.VOLUME_ID, 'key6')
|
||||
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_delete')
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_get')
|
||||
def test_delete(self, metadata_get, metadata_delete):
|
||||
fake_volume = {'id': fake.volume_id, 'status': 'available'}
|
||||
fake_volume = {'id': fake.VOLUME_ID, 'status': 'available'}
|
||||
fake_context = mock.Mock()
|
||||
metadata_get.side_effect = return_volume_metadata
|
||||
metadata_delete.side_effect = delete_volume_metadata
|
||||
@ -222,9 +222,9 @@ class volumeMetaDataTest(test.TestCase):
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
'get') as get_volume:
|
||||
get_volume.return_value = fake_volume
|
||||
res = self.controller.delete(req, fake.volume_id, 'key2')
|
||||
res = self.controller.delete(req, fake.VOLUME_ID, 'key2')
|
||||
self.assertEqual(200, res.status_int)
|
||||
get_volume.assert_called_with(fake_context, fake.volume_id)
|
||||
get_volume.assert_called_with(fake_context, fake.VOLUME_ID)
|
||||
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_get')
|
||||
def test_delete_nonexistent_volume(self, metadata_get):
|
||||
@ -235,7 +235,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.environ['cinder.context'] = fake_context
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete,
|
||||
req, fake.will_not_be_found_id, 'key1')
|
||||
req, fake.WILL_NOT_BE_FOUND_ID, 'key1')
|
||||
|
||||
def test_delete_meta_not_found(self):
|
||||
self.stubs.Set(cinder.db, 'volume_metadata_get',
|
||||
@ -243,12 +243,12 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key6')
|
||||
req.method = 'DELETE'
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.delete, req, fake.volume_id, 'key6')
|
||||
self.controller.delete, req, fake.VOLUME_ID, 'key6')
|
||||
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_update')
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_get')
|
||||
def test_create(self, metadata_get, metadata_update):
|
||||
fake_volume = {'id': fake.volume_id, 'status': 'available'}
|
||||
fake_volume = {'id': fake.VOLUME_ID, 'status': 'available'}
|
||||
fake_context = mock.Mock()
|
||||
metadata_get.side_effect = return_empty_volume_metadata
|
||||
metadata_update.side_effect = return_create_volume_metadata
|
||||
@ -264,7 +264,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
'get') as get_volume:
|
||||
get_volume.return_value = fake_volume
|
||||
res_dict = self.controller.create(req, fake.volume_id, body)
|
||||
res_dict = self.controller.create(req, fake.VOLUME_ID, body)
|
||||
self.assertEqual(body, res_dict)
|
||||
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_update')
|
||||
@ -273,7 +273,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
metadata_update):
|
||||
# if the keys in uppercase_and_lowercase, should return the one
|
||||
# which server added
|
||||
fake_volume = {'id': fake.volume_id, 'status': 'available'}
|
||||
fake_volume = {'id': fake.VOLUME_ID, 'status': 'available'}
|
||||
fake_context = mock.Mock()
|
||||
metadata_get.side_effect = return_empty_volume_metadata
|
||||
metadata_update.side_effect = return_create_volume_metadata_insensitive
|
||||
@ -297,7 +297,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
'get') as get_volume:
|
||||
get_volume.return_value = fake_volume
|
||||
res_dict = self.controller.create(req, fake.volume_id, body)
|
||||
res_dict = self.controller.create(req, fake.VOLUME_ID, body)
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
def test_create_empty_body(self):
|
||||
@ -308,7 +308,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, req, fake.volume_id, None)
|
||||
self.controller.create, req, fake.VOLUME_ID, None)
|
||||
|
||||
def test_create_item_empty_key(self):
|
||||
self.stubs.Set(cinder.db, 'volume_metadata_update',
|
||||
@ -320,7 +320,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, req, fake.volume_id, body)
|
||||
self.controller.create, req, fake.VOLUME_ID, body)
|
||||
|
||||
def test_create_item_key_too_long(self):
|
||||
self.stubs.Set(cinder.db, 'volume_metadata_update',
|
||||
@ -333,7 +333,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create,
|
||||
req, fake.volume_id, body)
|
||||
req, fake.VOLUME_ID, body)
|
||||
|
||||
def test_create_nonexistent_volume(self):
|
||||
self.stubs.Set(cinder.db, 'volume_metadata_get',
|
||||
@ -348,11 +348,11 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.create, req,
|
||||
fake.will_not_be_found_id, body)
|
||||
fake.WILL_NOT_BE_FOUND_ID, body)
|
||||
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_update')
|
||||
def test_update_all(self, metadata_update):
|
||||
fake_volume = {'id': fake.volume_id, 'status': 'available'}
|
||||
fake_volume = {'id': fake.VOLUME_ID, 'status': 'available'}
|
||||
fake_context = mock.Mock()
|
||||
metadata_update.side_effect = return_new_volume_metadata
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
@ -371,17 +371,17 @@ class volumeMetaDataTest(test.TestCase):
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
'get') as get_volume:
|
||||
get_volume.return_value = fake_volume
|
||||
res_dict = self.controller.update_all(req, fake.volume_id,
|
||||
res_dict = self.controller.update_all(req, fake.VOLUME_ID,
|
||||
expected)
|
||||
self.assertEqual(expected, res_dict)
|
||||
get_volume.assert_called_once_with(fake_context, fake.volume_id)
|
||||
get_volume.assert_called_once_with(fake_context, fake.VOLUME_ID)
|
||||
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_update')
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_get')
|
||||
def test_update_all_with_keys_in_uppercase_and_lowercase(self,
|
||||
metadata_get,
|
||||
metadata_update):
|
||||
fake_volume = {'id': fake.volume_id, 'status': 'available'}
|
||||
fake_volume = {'id': fake.VOLUME_ID, 'status': 'available'}
|
||||
fake_context = mock.Mock()
|
||||
metadata_get.side_effect = return_create_volume_metadata
|
||||
metadata_update.side_effect = return_new_volume_metadata
|
||||
@ -409,13 +409,13 @@ class volumeMetaDataTest(test.TestCase):
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
'get') as get_volume:
|
||||
get_volume.return_value = fake_volume
|
||||
res_dict = self.controller.update_all(req, fake.volume_id, body)
|
||||
res_dict = self.controller.update_all(req, fake.VOLUME_ID, body)
|
||||
self.assertEqual(expected, res_dict)
|
||||
get_volume.assert_called_once_with(fake_context, fake.volume_id)
|
||||
get_volume.assert_called_once_with(fake_context, fake.VOLUME_ID)
|
||||
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_update')
|
||||
def test_update_all_empty_container(self, metadata_update):
|
||||
fake_volume = {'id': fake.volume_id, 'status': 'available'}
|
||||
fake_volume = {'id': fake.VOLUME_ID, 'status': 'available'}
|
||||
fake_context = mock.Mock()
|
||||
metadata_update.side_effect = return_empty_container_metadata
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
@ -428,14 +428,14 @@ class volumeMetaDataTest(test.TestCase):
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
'get') as get_volume:
|
||||
get_volume.return_value = fake_volume
|
||||
res_dict = self.controller.update_all(req, fake.volume_id,
|
||||
res_dict = self.controller.update_all(req, fake.VOLUME_ID,
|
||||
expected)
|
||||
self.assertEqual(expected, res_dict)
|
||||
get_volume.assert_called_once_with(fake_context, fake.volume_id)
|
||||
get_volume.assert_called_once_with(fake_context, fake.VOLUME_ID)
|
||||
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_update')
|
||||
def test_update_item_value_too_long(self, metadata_update):
|
||||
fake_volume = {'id': fake.volume_id, 'status': 'available'}
|
||||
fake_volume = {'id': fake.VOLUME_ID, 'status': 'available'}
|
||||
fake_context = mock.Mock()
|
||||
metadata_update.side_effect = return_create_volume_metadata
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
@ -450,9 +450,9 @@ class volumeMetaDataTest(test.TestCase):
|
||||
get_volume.return_value = fake_volume
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.update,
|
||||
req, fake.volume_id, "key1", body)
|
||||
req, fake.VOLUME_ID, "key1", body)
|
||||
self.assertFalse(metadata_update.called)
|
||||
get_volume.assert_called_once_with(fake_context, fake.volume_id)
|
||||
get_volume.assert_called_once_with(fake_context, fake.VOLUME_ID)
|
||||
|
||||
def test_update_all_malformed_container(self):
|
||||
self.stubs.Set(cinder.db, 'volume_metadata_update',
|
||||
@ -464,12 +464,12 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.body = jsonutils.dump_as_bytes(expected)
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update_all, req, fake.volume_id,
|
||||
self.controller.update_all, req, fake.VOLUME_ID,
|
||||
expected)
|
||||
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_update')
|
||||
def test_update_all_malformed_data(self, metadata_update):
|
||||
fake_volume = {'id': fake.volume_id, 'status': 'available'}
|
||||
fake_volume = {'id': fake.VOLUME_ID, 'status': 'available'}
|
||||
fake_context = mock.Mock()
|
||||
metadata_update.side_effect = return_create_volume_metadata
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
@ -483,7 +483,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
'get') as get_volume:
|
||||
get_volume.return_value = fake_volume
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update_all, req, fake.volume_id,
|
||||
self.controller.update_all, req, fake.VOLUME_ID,
|
||||
expected)
|
||||
|
||||
def test_update_all_nonexistent_volume(self):
|
||||
@ -495,11 +495,11 @@ class volumeMetaDataTest(test.TestCase):
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.update_all, req,
|
||||
fake.will_not_be_found_id, body)
|
||||
fake.WILL_NOT_BE_FOUND_ID, body)
|
||||
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_update')
|
||||
def test_update_item(self, metadata_update):
|
||||
fake_volume = {'id': fake.volume_id, 'status': 'available'}
|
||||
fake_volume = {'id': fake.VOLUME_ID, 'status': 'available'}
|
||||
fake_context = mock.Mock()
|
||||
metadata_update.side_effect = return_create_volume_metadata
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
@ -512,16 +512,16 @@ class volumeMetaDataTest(test.TestCase):
|
||||
with mock.patch.object(self.controller.volume_api,
|
||||
'get') as get_volume:
|
||||
get_volume.return_value = fake_volume
|
||||
res_dict = self.controller.update(req, fake.volume_id, 'key1',
|
||||
res_dict = self.controller.update(req, fake.VOLUME_ID, 'key1',
|
||||
body)
|
||||
expected = {'meta': {'key1': 'value1'}}
|
||||
self.assertEqual(expected, res_dict)
|
||||
get_volume.assert_called_once_with(fake_context, fake.volume_id)
|
||||
get_volume.assert_called_once_with(fake_context, fake.VOLUME_ID)
|
||||
|
||||
def test_update_item_nonexistent_volume(self):
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v1.1/%s/volumes/%s/metadata/key1' % (
|
||||
fake.project_id, fake.will_not_be_found_id))
|
||||
fake.PROJECT_ID, fake.WILL_NOT_BE_FOUND_ID))
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
@ -529,7 +529,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.update, req,
|
||||
fake.will_not_be_found_id, 'key1',
|
||||
fake.WILL_NOT_BE_FOUND_ID, 'key1',
|
||||
body)
|
||||
|
||||
def test_update_item_empty_body(self):
|
||||
@ -540,12 +540,12 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update, req, fake.volume_id, 'key1',
|
||||
self.controller.update, req, fake.VOLUME_ID, 'key1',
|
||||
None)
|
||||
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_update')
|
||||
def test_update_item_empty_key(self, metadata_update):
|
||||
fake_volume = {'id': fake.volume_id, 'status': 'available'}
|
||||
fake_volume = {'id': fake.VOLUME_ID, 'status': 'available'}
|
||||
fake_context = mock.Mock()
|
||||
metadata_update.side_effect = return_create_volume_metadata
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
@ -559,14 +559,14 @@ class volumeMetaDataTest(test.TestCase):
|
||||
'get') as get_volume:
|
||||
get_volume.return_value = fake_volume
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update, req, fake.volume_id,
|
||||
self.controller.update, req, fake.VOLUME_ID,
|
||||
'', body)
|
||||
self.assertFalse(metadata_update.called)
|
||||
get_volume.assert_called_once_with(fake_context, fake.volume_id)
|
||||
get_volume.assert_called_once_with(fake_context, fake.VOLUME_ID)
|
||||
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_update')
|
||||
def test_update_item_key_too_long(self, metadata_update):
|
||||
fake_volume = {'id': fake.volume_id, 'status': 'available'}
|
||||
fake_volume = {'id': fake.VOLUME_ID, 'status': 'available'}
|
||||
fake_context = mock.Mock()
|
||||
metadata_update.side_effect = return_create_volume_metadata
|
||||
req = fakes.HTTPRequest.blank(self.url + '/key1')
|
||||
@ -581,9 +581,9 @@ class volumeMetaDataTest(test.TestCase):
|
||||
get_volume.return_value = fake_volume
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.update,
|
||||
req, fake.volume_id, ("a" * 260), body)
|
||||
req, fake.VOLUME_ID, ("a" * 260), body)
|
||||
self.assertFalse(metadata_update.called)
|
||||
get_volume.assert_called_once_with(fake_context, fake.volume_id)
|
||||
get_volume.assert_called_once_with(fake_context, fake.VOLUME_ID)
|
||||
|
||||
def test_update_item_too_many_keys(self):
|
||||
self.stubs.Set(cinder.db, 'volume_metadata_update',
|
||||
@ -595,7 +595,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update, req, fake.volume_id, 'key1',
|
||||
self.controller.update, req, fake.VOLUME_ID, 'key1',
|
||||
body)
|
||||
|
||||
def test_update_item_body_uri_mismatch(self):
|
||||
@ -608,12 +608,12 @@ class volumeMetaDataTest(test.TestCase):
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update, req, fake.volume_id, 'bad',
|
||||
self.controller.update, req, fake.VOLUME_ID, 'bad',
|
||||
body)
|
||||
|
||||
@mock.patch.object(cinder.db, 'volume_metadata_update')
|
||||
def test_invalid_metadata_items_on_create(self, metadata_update):
|
||||
fake_volume = {'id': fake.volume_id, 'status': 'available'}
|
||||
fake_volume = {'id': fake.VOLUME_ID, 'status': 'available'}
|
||||
fake_context = mock.Mock()
|
||||
metadata_update.side_effect = return_create_volume_metadata
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
@ -630,7 +630,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
get_volume.return_value = fake_volume
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.create, req,
|
||||
fake.volume_id, data)
|
||||
fake.VOLUME_ID, data)
|
||||
|
||||
# test for long value
|
||||
data = {"metadata": {"key": "v" * 260}}
|
||||
@ -642,7 +642,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
get_volume.return_value = fake_volume
|
||||
self.assertRaises(webob.exc.HTTPRequestEntityTooLarge,
|
||||
self.controller.create, req,
|
||||
fake.volume_id, data)
|
||||
fake.VOLUME_ID, data)
|
||||
|
||||
# test for empty key.
|
||||
data = {"metadata": {"": "value1"}}
|
||||
@ -654,4 +654,4 @@ class volumeMetaDataTest(test.TestCase):
|
||||
get_volume.return_value = fake_volume
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create, req,
|
||||
fake.volume_id, data)
|
||||
fake.VOLUME_ID, data)
|
||||
|
@ -77,7 +77,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'snapshot_id': None,
|
||||
'source_volid': None,
|
||||
'metadata': {},
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'created_at': datetime.datetime(
|
||||
1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
@ -168,7 +168,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'snapshot_id': None,
|
||||
'source_volid': None,
|
||||
'metadata': {},
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'created_at': datetime.datetime(
|
||||
1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
@ -237,9 +237,9 @@ class VolumeApiTest(test.TestCase):
|
||||
"display_name": "Updated Test Name",
|
||||
}
|
||||
body = {"volume": updates}
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.VOLUME_ID)
|
||||
self.assertEqual(0, len(self.notifier.notifications))
|
||||
res_dict = self.controller.update(req, fake.volume_id, body)
|
||||
res_dict = self.controller.update(req, fake.VOLUME_ID, body)
|
||||
expected = {'volume': {
|
||||
'status': 'fakestatus',
|
||||
'display_description': 'displaydesc',
|
||||
@ -254,7 +254,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'source_volid': None,
|
||||
'metadata': {'attached_mode': 'rw',
|
||||
'readonly': 'False'},
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'created_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
'size': 1}}
|
||||
@ -276,9 +276,9 @@ class VolumeApiTest(test.TestCase):
|
||||
"metadata": {"qos_max_iops": 2000}
|
||||
}
|
||||
body = {"volume": updates}
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.VOLUME_ID)
|
||||
self.assertEqual(0, len(self.notifier.notifications))
|
||||
res_dict = self.controller.update(req, fake.volume_id, body)
|
||||
res_dict = self.controller.update(req, fake.VOLUME_ID, body)
|
||||
expected = {'volume': {
|
||||
'status': 'fakestatus',
|
||||
'display_description': 'displaydesc',
|
||||
@ -294,7 +294,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'metadata': {"qos_max_iops": '2000',
|
||||
"readonly": "False",
|
||||
"attached_mode": "rw"},
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'created_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
'size': 1
|
||||
@ -310,32 +310,32 @@ class VolumeApiTest(test.TestCase):
|
||||
stubs_volume_admin_metadata_get)
|
||||
self.stubs.Set(volume_api.API, "update", stubs.stub_volume_update)
|
||||
|
||||
volume = stubs.stub_volume(fake.volume_id)
|
||||
volume = stubs.stub_volume(fake.VOLUME_ID)
|
||||
del volume['name']
|
||||
del volume['volume_type']
|
||||
del volume['volume_type_id']
|
||||
volume['metadata'] = {'key': 'value'}
|
||||
db.volume_create(context.get_admin_context(), volume)
|
||||
db.volume_admin_metadata_update(context.get_admin_context(),
|
||||
fake.volume_id,
|
||||
fake.VOLUME_ID,
|
||||
{"readonly": "True",
|
||||
"invisible_key": "invisible_value"},
|
||||
False)
|
||||
values = {'volume_id': fake.volume_id, }
|
||||
values = {'volume_id': fake.VOLUME_ID, }
|
||||
attachment = db.volume_attach(context.get_admin_context(), values)
|
||||
db.volume_attached(context.get_admin_context(),
|
||||
attachment['id'], fake.instance_id,
|
||||
attachment['id'], fake.INSTANCE_ID,
|
||||
None, '/')
|
||||
|
||||
updates = {
|
||||
"display_name": "Updated Test Name",
|
||||
}
|
||||
body = {"volume": updates}
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.VOLUME_ID)
|
||||
self.assertEqual(0, len(self.notifier.notifications))
|
||||
admin_ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
admin_ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
req.environ['cinder.context'] = admin_ctx
|
||||
res_dict = self.controller.update(req, fake.volume_id, body)
|
||||
res_dict = self.controller.update(req, fake.VOLUME_ID, body)
|
||||
expected = {'volume': {
|
||||
'status': 'in-use',
|
||||
'display_description': 'displaydesc',
|
||||
@ -344,9 +344,9 @@ class VolumeApiTest(test.TestCase):
|
||||
'encrypted': False,
|
||||
'attachments': [{
|
||||
'attachment_id': attachment['id'],
|
||||
'id': fake.volume_id,
|
||||
'volume_id': fake.volume_id,
|
||||
'server_id': fake.instance_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'server_id': fake.INSTANCE_ID,
|
||||
'host_name': None,
|
||||
'device': '/'
|
||||
}],
|
||||
@ -357,7 +357,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'source_volid': None,
|
||||
'metadata': {'key': 'value',
|
||||
'readonly': 'True'},
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'created_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
'size': 1}}
|
||||
@ -369,14 +369,14 @@ class VolumeApiTest(test.TestCase):
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/1')
|
||||
self.assertRaises(webob.exc.HTTPUnprocessableEntity,
|
||||
self.controller.update,
|
||||
req, fake.volume_id, body)
|
||||
req, fake.VOLUME_ID, body)
|
||||
|
||||
def test_update_invalid_body(self):
|
||||
body = {'display_name': 'missing top level volume key'}
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/1')
|
||||
self.assertRaises(webob.exc.HTTPUnprocessableEntity,
|
||||
self.controller.update,
|
||||
req, fake.volume_id, body)
|
||||
req, fake.VOLUME_ID, body)
|
||||
|
||||
def test_update_not_found(self):
|
||||
|
||||
@ -386,10 +386,10 @@ class VolumeApiTest(test.TestCase):
|
||||
body = {"volume": updates}
|
||||
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v1/volumes/%s' % fake.will_not_be_found_id)
|
||||
'/v1/volumes/%s' % fake.WILL_NOT_BE_FOUND_ID)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.update,
|
||||
req, fake.will_not_be_found_id, body)
|
||||
req, fake.WILL_NOT_BE_FOUND_ID, body)
|
||||
|
||||
def test_volume_list(self):
|
||||
def stubs_volume_admin_metadata_get(context, volume_id):
|
||||
@ -418,7 +418,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'source_volid': None,
|
||||
'metadata': {'attached_mode': 'rw',
|
||||
'readonly': 'False'},
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'created_at': datetime.datetime(
|
||||
1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
@ -428,24 +428,24 @@ class VolumeApiTest(test.TestCase):
|
||||
self.assertEqual(1, len(req.cached_resource()))
|
||||
|
||||
def test_volume_list_with_admin_metadata(self):
|
||||
volume = stubs.stub_volume(fake.volume_id)
|
||||
volume = stubs.stub_volume(fake.VOLUME_ID)
|
||||
del volume['name']
|
||||
del volume['volume_type']
|
||||
del volume['volume_type_id']
|
||||
volume['metadata'] = {'key': 'value'}
|
||||
db.volume_create(context.get_admin_context(), volume)
|
||||
db.volume_admin_metadata_update(context.get_admin_context(),
|
||||
fake.volume_id,
|
||||
fake.VOLUME_ID,
|
||||
{"readonly": "True",
|
||||
"invisible_key": "invisible_value"},
|
||||
False)
|
||||
values = {'volume_id': fake.volume_id, }
|
||||
values = {'volume_id': fake.VOLUME_ID, }
|
||||
attachment = db.volume_attach(context.get_admin_context(), values)
|
||||
db.volume_attached(context.get_admin_context(),
|
||||
attachment['id'], fake.instance_id, None, '/')
|
||||
attachment['id'], fake.INSTANCE_ID, None, '/')
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes')
|
||||
admin_ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
admin_ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
req.environ['cinder.context'] = admin_ctx
|
||||
res_dict = self.controller.index(req)
|
||||
expected = {'volumes': [{'status': 'in-use',
|
||||
@ -456,10 +456,10 @@ class VolumeApiTest(test.TestCase):
|
||||
'attachments': [
|
||||
{'attachment_id': attachment['id'],
|
||||
'device': '/',
|
||||
'server_id': fake.instance_id,
|
||||
'server_id': fake.INSTANCE_ID,
|
||||
'host_name': None,
|
||||
'id': fake.volume_id,
|
||||
'volume_id': fake.volume_id}],
|
||||
'id': fake.VOLUME_ID,
|
||||
'volume_id': fake.VOLUME_ID}],
|
||||
'multiattach': 'false',
|
||||
'bootable': 'false',
|
||||
'volume_type': None,
|
||||
@ -467,7 +467,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'source_volid': None,
|
||||
'metadata': {'key': 'value',
|
||||
'readonly': 'True'},
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'created_at': datetime.datetime(
|
||||
1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
@ -498,7 +498,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'source_volid': None,
|
||||
'metadata': {'attached_mode': 'rw',
|
||||
'readonly': 'False'},
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'created_at': datetime.datetime(
|
||||
1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
@ -508,24 +508,24 @@ class VolumeApiTest(test.TestCase):
|
||||
self.assertEqual(1, len(req.cached_resource()))
|
||||
|
||||
def test_volume_list_detail_with_admin_metadata(self):
|
||||
volume = stubs.stub_volume(fake.volume_id)
|
||||
volume = stubs.stub_volume(fake.VOLUME_ID)
|
||||
del volume['name']
|
||||
del volume['volume_type']
|
||||
del volume['volume_type_id']
|
||||
volume['metadata'] = {'key': 'value'}
|
||||
db.volume_create(context.get_admin_context(), volume)
|
||||
db.volume_admin_metadata_update(context.get_admin_context(),
|
||||
fake.volume_id,
|
||||
fake.VOLUME_ID,
|
||||
{"readonly": "True",
|
||||
"invisible_key": "invisible_value"},
|
||||
False)
|
||||
values = {'volume_id': fake.volume_id, }
|
||||
values = {'volume_id': fake.VOLUME_ID, }
|
||||
attachment = db.volume_attach(context.get_admin_context(), values)
|
||||
db.volume_attached(context.get_admin_context(),
|
||||
attachment['id'], fake.instance_id, None, '/')
|
||||
attachment['id'], fake.INSTANCE_ID, None, '/')
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/detail')
|
||||
admin_ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
admin_ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
req.environ['cinder.context'] = admin_ctx
|
||||
res_dict = self.controller.index(req)
|
||||
expected = {'volumes': [{'status': 'in-use',
|
||||
@ -536,10 +536,10 @@ class VolumeApiTest(test.TestCase):
|
||||
'attachments': [
|
||||
{'attachment_id': attachment['id'],
|
||||
'device': '/',
|
||||
'server_id': fake.instance_id,
|
||||
'server_id': fake.INSTANCE_ID,
|
||||
'host_name': None,
|
||||
'id': fake.volume_id,
|
||||
'volume_id': fake.volume_id}],
|
||||
'id': fake.VOLUME_ID,
|
||||
'volume_id': fake.VOLUME_ID}],
|
||||
'multiattach': 'false',
|
||||
'bootable': 'false',
|
||||
'volume_type': None,
|
||||
@ -547,7 +547,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'source_volid': None,
|
||||
'metadata': {'key': 'value',
|
||||
'readonly': 'True'},
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'created_at': datetime.datetime(
|
||||
1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
@ -562,8 +562,8 @@ class VolumeApiTest(test.TestCase):
|
||||
@mock.patch.object(db.sqlalchemy.api, '_volume_type_get_full',
|
||||
side_effect=stubs.stub_volume_type_get, autospec=True)
|
||||
def test_volume_show(self, *args):
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.volume_id)
|
||||
res_dict = self.controller.show(req, fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.VOLUME_ID)
|
||||
res_dict = self.controller.show(req, fake.VOLUME_ID)
|
||||
expected = {'volume': {'status': 'fakestatus',
|
||||
'display_description': 'displaydesc',
|
||||
'availability_zone': 'fakeaz',
|
||||
@ -577,14 +577,14 @@ class VolumeApiTest(test.TestCase):
|
||||
'source_volid': None,
|
||||
'metadata': {'attached_mode': 'rw',
|
||||
'readonly': 'False'},
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'created_at': datetime.datetime(
|
||||
1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
'size': 1}}
|
||||
self.assertEqual(expected, res_dict)
|
||||
# Finally test that we cached the returned volume
|
||||
self.assertIsNotNone(req.cached_resource_by_id(fake.volume_id))
|
||||
self.assertIsNotNone(req.cached_resource_by_id(fake.VOLUME_ID))
|
||||
|
||||
def test_volume_show_no_attachments(self):
|
||||
def stub_volume_get(self, context, volume_id, **kwargs):
|
||||
@ -595,8 +595,8 @@ class VolumeApiTest(test.TestCase):
|
||||
self.stubs.Set(db.sqlalchemy.api, '_volume_type_get_full',
|
||||
stubs.stub_volume_type_get)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.volume_id)
|
||||
res_dict = self.controller.show(req, fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.VOLUME_ID)
|
||||
res_dict = self.controller.show(req, fake.VOLUME_ID)
|
||||
expected = {'volume': {'status': 'fakestatus',
|
||||
'display_description': 'displaydesc',
|
||||
'availability_zone': 'fakeaz',
|
||||
@ -609,7 +609,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'snapshot_id': None,
|
||||
'source_volid': None,
|
||||
'metadata': {'readonly': 'False'},
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'created_at': datetime.datetime(
|
||||
1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
@ -626,8 +626,8 @@ class VolumeApiTest(test.TestCase):
|
||||
self.stubs.Set(db.sqlalchemy.api, '_volume_type_get_full',
|
||||
stubs.stub_volume_type_get)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.volume_id)
|
||||
res_dict = self.controller.show(req, fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.VOLUME_ID)
|
||||
res_dict = self.controller.show(req, fake.VOLUME_ID)
|
||||
expected = {'volume': {'status': 'fakestatus',
|
||||
'display_description': 'displaydesc',
|
||||
'availability_zone': 'fakeaz',
|
||||
@ -641,7 +641,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'source_volid': None,
|
||||
'metadata': {'attached_mode': 'rw',
|
||||
'readonly': 'False'},
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'created_at': datetime.datetime(
|
||||
1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
@ -651,13 +651,13 @@ class VolumeApiTest(test.TestCase):
|
||||
def test_volume_show_no_volume(self):
|
||||
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v1/volumes/%s' % fake.will_not_be_found_id)
|
||||
'/v1/volumes/%s' % fake.WILL_NOT_BE_FOUND_ID)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.show,
|
||||
req,
|
||||
fake.will_not_be_found_id)
|
||||
fake.WILL_NOT_BE_FOUND_ID)
|
||||
# Finally test that we did not cache anything
|
||||
self.assertIsNone(req.cached_resource_by_id(fake.will_not_be_found_id))
|
||||
self.assertIsNone(req.cached_resource_by_id(fake.WILL_NOT_BE_FOUND_ID))
|
||||
|
||||
def test_volume_detail_limit_offset(self):
|
||||
def volume_detail_limit_offset(is_admin):
|
||||
@ -667,8 +667,8 @@ class VolumeApiTest(test.TestCase):
|
||||
viewable_admin_meta=False,
|
||||
offset=None):
|
||||
return [
|
||||
stubs.stub_volume(fake.volume_id, display_name='vol1'),
|
||||
stubs.stub_volume(fake.volume2_id, display_name='vol2'),
|
||||
stubs.stub_volume(fake.VOLUME_ID, display_name='vol1'),
|
||||
stubs.stub_volume(fake.VOLUME2_ID, display_name='vol2'),
|
||||
]
|
||||
|
||||
self.stubs.Set(db, 'volume_get_all_by_project',
|
||||
@ -683,7 +683,7 @@ class VolumeApiTest(test.TestCase):
|
||||
res_dict = self.controller.index(req)
|
||||
volumes = res_dict['volumes']
|
||||
self.assertEqual(1, len(volumes))
|
||||
self.assertEqual(fake.volume2_id, volumes[0]['id'])
|
||||
self.assertEqual(fake.VOLUME2_ID, volumes[0]['id'])
|
||||
|
||||
# admin case
|
||||
volume_detail_limit_offset(is_admin=True)
|
||||
@ -691,26 +691,26 @@ class VolumeApiTest(test.TestCase):
|
||||
volume_detail_limit_offset(is_admin=False)
|
||||
|
||||
def test_volume_show_with_admin_metadata(self):
|
||||
volume = stubs.stub_volume(fake.volume_id)
|
||||
volume = stubs.stub_volume(fake.VOLUME_ID)
|
||||
del volume['name']
|
||||
del volume['volume_type']
|
||||
del volume['volume_type_id']
|
||||
volume['metadata'] = {'key': 'value'}
|
||||
db.volume_create(context.get_admin_context(), volume)
|
||||
db.volume_admin_metadata_update(context.get_admin_context(),
|
||||
fake.volume_id,
|
||||
fake.VOLUME_ID,
|
||||
{"readonly": "True",
|
||||
"invisible_key": "invisible_value"},
|
||||
False)
|
||||
values = {'volume_id': fake.volume_id, }
|
||||
values = {'volume_id': fake.VOLUME_ID, }
|
||||
attachment = db.volume_attach(context.get_admin_context(), values)
|
||||
db.volume_attached(context.get_admin_context(),
|
||||
attachment['id'], fake.instance_id, None, '/')
|
||||
attachment['id'], fake.INSTANCE_ID, None, '/')
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.volume_id)
|
||||
admin_ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.VOLUME_ID)
|
||||
admin_ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
req.environ['cinder.context'] = admin_ctx
|
||||
res_dict = self.controller.show(req, fake.volume_id)
|
||||
res_dict = self.controller.show(req, fake.VOLUME_ID)
|
||||
expected = {'volume': {'status': 'in-use',
|
||||
'display_description': 'displaydesc',
|
||||
'availability_zone': 'fakeaz',
|
||||
@ -719,10 +719,10 @@ class VolumeApiTest(test.TestCase):
|
||||
'attachments': [
|
||||
{'attachment_id': attachment['id'],
|
||||
'device': '/',
|
||||
'server_id': fake.instance_id,
|
||||
'server_id': fake.INSTANCE_ID,
|
||||
'host_name': None,
|
||||
'id': fake.volume_id,
|
||||
'volume_id': fake.volume_id}],
|
||||
'id': fake.VOLUME_ID,
|
||||
'volume_id': fake.VOLUME_ID}],
|
||||
'multiattach': 'false',
|
||||
'bootable': 'false',
|
||||
'volume_type': None,
|
||||
@ -730,7 +730,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'source_volid': None,
|
||||
'metadata': {'key': 'value',
|
||||
'readonly': 'True'},
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'created_at': datetime.datetime(
|
||||
1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
@ -739,15 +739,15 @@ class VolumeApiTest(test.TestCase):
|
||||
|
||||
def test_volume_show_with_encrypted_volume(self):
|
||||
def stub_volume_get(self, context, volume_id, **kwargs):
|
||||
vol = stubs.stub_volume(volume_id, encryption_key_id=fake.key_id)
|
||||
vol = stubs.stub_volume(volume_id, encryption_key_id=fake.KEY_ID)
|
||||
return fake_volume.fake_volume_obj(context, **vol)
|
||||
|
||||
self.stubs.Set(volume_api.API, 'get', stub_volume_get)
|
||||
self.stubs.Set(db.sqlalchemy.api, '_volume_type_get_full',
|
||||
stubs.stub_volume_type_get)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.volume_id)
|
||||
res_dict = self.controller.show(req, fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.VOLUME_ID)
|
||||
res_dict = self.controller.show(req, fake.VOLUME_ID)
|
||||
self.assertTrue(res_dict['volume']['encrypted'])
|
||||
|
||||
def test_volume_show_with_unencrypted_volume(self):
|
||||
@ -755,32 +755,32 @@ class VolumeApiTest(test.TestCase):
|
||||
self.stubs.Set(db.sqlalchemy.api, '_volume_type_get_full',
|
||||
stubs.stub_volume_type_get)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.volume_id)
|
||||
res_dict = self.controller.show(req, fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.VOLUME_ID)
|
||||
res_dict = self.controller.show(req, fake.VOLUME_ID)
|
||||
self.assertEqual(False, res_dict['volume']['encrypted'])
|
||||
|
||||
def test_volume_delete(self):
|
||||
self.stubs.Set(db.sqlalchemy.api, 'volume_get',
|
||||
stubs.stub_volume_get_db)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.volume_id)
|
||||
resp = self.controller.delete(req, fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/volumes/%s' % fake.VOLUME_ID)
|
||||
resp = self.controller.delete(req, fake.VOLUME_ID)
|
||||
self.assertEqual(202, resp.status_int)
|
||||
|
||||
def test_volume_delete_no_volume(self):
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v1/volumes/%s' % fake.will_not_be_found_id)
|
||||
'/v1/volumes/%s' % fake.WILL_NOT_BE_FOUND_ID)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.delete,
|
||||
req,
|
||||
fake.will_not_be_found_id)
|
||||
fake.WILL_NOT_BE_FOUND_ID)
|
||||
|
||||
def test_admin_list_volumes_limited_to_project(self):
|
||||
self.stubs.Set(db, 'volume_get_all_by_project',
|
||||
stubs.stub_volume_get_all_by_project)
|
||||
self.stubs.Set(db.sqlalchemy.api, '_volume_type_get_full',
|
||||
stubs.stub_volume_type_get)
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/volumes' % fake.project_id,
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/volumes' % fake.PROJECT_ID,
|
||||
use_admin_context=True)
|
||||
res = self.controller.index(req)
|
||||
|
||||
@ -791,7 +791,7 @@ class VolumeApiTest(test.TestCase):
|
||||
self.stubs.Set(db.sqlalchemy.api, '_volume_type_get_full',
|
||||
stubs.stub_volume_type_get)
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v1/%s/volumes?all_tenants=1' % fake.project_id,
|
||||
'/v1/%s/volumes?all_tenants=1' % fake.PROJECT_ID,
|
||||
use_admin_context=True)
|
||||
res = self.controller.index(req)
|
||||
self.assertIn('volumes', res)
|
||||
@ -805,7 +805,7 @@ class VolumeApiTest(test.TestCase):
|
||||
stubs.stub_volume_type_get)
|
||||
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v1/%s/volumes?all_tenants=1' % fake.project_id)
|
||||
'/v1/%s/volumes?all_tenants=1' % fake.PROJECT_ID)
|
||||
res = self.controller.index(req)
|
||||
self.assertIn('volumes', res)
|
||||
self.assertEqual(1, len(res['volumes']))
|
||||
@ -817,7 +817,7 @@ class VolumeApiTest(test.TestCase):
|
||||
self.stubs.Set(db.sqlalchemy.api, '_volume_type_get_full',
|
||||
stubs.stub_volume_type_get)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/volumes' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/volumes' % fake.PROJECT_ID)
|
||||
res = self.controller.index(req)
|
||||
self.assertIn('volumes', res)
|
||||
self.assertEqual(1, len(res['volumes']))
|
||||
@ -870,7 +870,7 @@ class VolumesUnprocessableEntityTestCase(test.TestCase):
|
||||
self.controller = volumes.VolumeController(self.ext_mgr)
|
||||
|
||||
def _unprocessable_volume_create(self, body):
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/volumes' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v1/%s/volumes' % fake.PROJECT_ID)
|
||||
req.method = 'POST'
|
||||
|
||||
self.assertRaises(webob.exc.HTTPUnprocessableEntity,
|
||||
|
@ -27,7 +27,7 @@ DEFAULT_VOL_DESCRIPTION = "displaydesc"
|
||||
DEFAULT_VOL_SIZE = 1
|
||||
DEFAULT_VOL_TYPE = "vol_type_name"
|
||||
DEFAULT_VOL_STATUS = "fakestatus"
|
||||
DEFAULT_VOL_ID = fake.volume_id
|
||||
DEFAULT_VOL_ID = fake.VOLUME_ID
|
||||
|
||||
# TODO(vbala): api.v1 tests use hard-coded "fakeaz" for verifying
|
||||
# post-conditions. Update value to "zone1:host1" once we remove
|
||||
@ -38,8 +38,8 @@ DEFAULT_AZ = "fakeaz"
|
||||
def stub_volume(id, **kwargs):
|
||||
volume = {
|
||||
'id': id,
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.project_id,
|
||||
'user_id': fake.USER_ID,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'host': 'fakehost',
|
||||
'size': DEFAULT_VOL_SIZE,
|
||||
'availability_zone': DEFAULT_AZ,
|
||||
@ -114,7 +114,7 @@ def stub_image_service_detail(self, context, **kwargs):
|
||||
def stub_volume_create_from_image(self, context, size, name, description,
|
||||
snapshot, volume_type, metadata,
|
||||
availability_zone):
|
||||
vol = stub_volume(fake.volume_id)
|
||||
vol = stub_volume(fake.VOLUME_ID)
|
||||
vol['status'] = 'creating'
|
||||
vol['size'] = size
|
||||
vol['display_name'] = name
|
||||
@ -163,16 +163,16 @@ def stub_volume_api_get(self, context, volume_id, viewable_admin_meta=False):
|
||||
def stub_volume_get_all(context, search_opts=None, marker=None, limit=None,
|
||||
sort_keys=None, sort_dirs=None, filters=None,
|
||||
viewable_admin_meta=False, offset=None):
|
||||
return [stub_volume(fake.volume_id, project_id=fake.project_id),
|
||||
stub_volume(fake.volume2_id, project_id=fake.project2_id),
|
||||
stub_volume(fake.volume3_id, project_id=fake.project3_id)]
|
||||
return [stub_volume(fake.VOLUME_ID, project_id=fake.PROJECT_ID),
|
||||
stub_volume(fake.VOLUME2_ID, project_id=fake.PROJECT2_ID),
|
||||
stub_volume(fake.VOLUME3_ID, project_id=fake.PROJECT3_ID)]
|
||||
|
||||
|
||||
def stub_volume_get_all_by_project(self, context, marker, limit,
|
||||
sort_keys=None, sort_dirs=None,
|
||||
filters=None,
|
||||
viewable_admin_meta=False, offset=None):
|
||||
return [stub_volume_get(self, context, fake.volume_id,
|
||||
return [stub_volume_get(self, context, fake.VOLUME_ID,
|
||||
viewable_admin_meta=True)]
|
||||
|
||||
|
||||
@ -181,7 +181,7 @@ def stub_volume_api_get_all_by_project(self, context, marker, limit,
|
||||
filters=None,
|
||||
viewable_admin_meta=False,
|
||||
offset=None):
|
||||
vol = stub_volume_get(self, context, fake.volume_id,
|
||||
vol = stub_volume_get(self, context, fake.VOLUME_ID,
|
||||
viewable_admin_meta=viewable_admin_meta)
|
||||
vol_obj = fake_volume.fake_volume_obj(context, **vol)
|
||||
return objects.VolumeList(objects=[vol_obj])
|
||||
@ -189,13 +189,13 @@ def stub_volume_api_get_all_by_project(self, context, marker, limit,
|
||||
|
||||
def stub_snapshot(id, **kwargs):
|
||||
snapshot = {'id': id,
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 100,
|
||||
'created_at': None,
|
||||
'display_name': 'Default name',
|
||||
'display_description': 'Default description',
|
||||
'project_id': fake.project_id,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'snapshot_metadata': []}
|
||||
|
||||
snapshot.update(kwargs)
|
||||
@ -204,15 +204,15 @@ def stub_snapshot(id, **kwargs):
|
||||
|
||||
def stub_snapshot_get_all(context, filters=None, marker=None, limit=None,
|
||||
sort_keys=None, sort_dirs=None, offset=None):
|
||||
return [stub_snapshot(fake.volume_id, project_id=fake.project_id),
|
||||
stub_snapshot(fake.volume2_id, project_id=fake.project2_id),
|
||||
stub_snapshot(fake.volume3_id, project_id=fake.project3_id)]
|
||||
return [stub_snapshot(fake.VOLUME_ID, project_id=fake.PROJECT_ID),
|
||||
stub_snapshot(fake.VOLUME2_ID, project_id=fake.PROJECT2_ID),
|
||||
stub_snapshot(fake.VOLUME3_ID, project_id=fake.PROJECT3_ID)]
|
||||
|
||||
|
||||
def stub_snapshot_get_all_by_project(context, project_id, filters=None,
|
||||
marker=None, limit=None, sort_keys=None,
|
||||
sort_dirs=None, offset=None):
|
||||
return [stub_snapshot(fake.snapshot_id)]
|
||||
return [stub_snapshot(fake.SNAPSHOT_ID)]
|
||||
|
||||
|
||||
def stub_snapshot_update(self, context, *args, **param):
|
||||
@ -224,7 +224,7 @@ def stub_service_get_all_by_topic(context, topic, disabled=None):
|
||||
|
||||
|
||||
def stub_snapshot_get(self, context, snapshot_id):
|
||||
if snapshot_id == fake.will_not_be_found_id:
|
||||
if snapshot_id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exc.SnapshotNotFound(snapshot_id=snapshot_id)
|
||||
|
||||
return stub_snapshot(snapshot_id)
|
||||
|
@ -86,7 +86,7 @@ def return_snapshot(context, snapshot_id):
|
||||
|
||||
|
||||
def stub_get(context, *args, **kwargs):
|
||||
vol = {'id': fake.volume_id,
|
||||
vol = {'id': fake.VOLUME_ID,
|
||||
'size': 100,
|
||||
'name': 'fake',
|
||||
'host': 'fake-host',
|
||||
@ -125,10 +125,10 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
self.controller = snapshot_metadata.Controller()
|
||||
self.req_id = str(uuid.uuid4())
|
||||
self.url = '/v2/%s/snapshots/%s/metadata' % (
|
||||
fake.project_id, self.req_id)
|
||||
fake.PROJECT_ID, self.req_id)
|
||||
|
||||
snap = {"volume_size": 100,
|
||||
"volume_id": fake.volume_id,
|
||||
"volume_id": fake.VOLUME_ID,
|
||||
"display_name": "Volume Test Name",
|
||||
"display_description": "Volume Test Desc",
|
||||
"availability_zone": "zone1:host1",
|
||||
@ -144,7 +144,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_obj['metadata'] = {'key1': 'value1',
|
||||
'key2': 'value2',
|
||||
@ -178,7 +178,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -193,7 +193,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_obj['metadata'] = {'key2': 'value2'}
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
@ -218,7 +218,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -233,7 +233,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_obj['metadata'] = {'key2': 'value2'}
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
@ -258,7 +258,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -276,7 +276,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
fake_volume_obj = fake_volume.fake_volume_obj(ctx)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
@ -303,7 +303,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -385,7 +385,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': []
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -417,7 +417,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -454,7 +454,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': []
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -515,7 +515,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -532,7 +532,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
self.stubs.Set(cinder.db, 'snapshot_get',
|
||||
return_snapshot_nonexistent)
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v2/%s/snapshots/asdf/metadata/key1' % fake.project_id)
|
||||
'/v2/%s/snapshots/asdf/metadata/key1' % fake.PROJECT_ID)
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
@ -572,7 +572,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -594,7 +594,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
@ -642,7 +642,7 @@ class SnapshotMetaDataTest(test.TestCase):
|
||||
'id': self.req_id,
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
|
||||
|
@ -43,7 +43,7 @@ INVALID_UUID = '00000000-0000-0000-0000-000000000002'
|
||||
def _get_default_snapshot_param():
|
||||
return {
|
||||
'id': UUID,
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 100,
|
||||
'created_at': None,
|
||||
@ -85,7 +85,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
self.stubs.Set(db, 'snapshot_get_all',
|
||||
stubs.stub_snapshot_get_all)
|
||||
|
||||
self.ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
self.ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
|
||||
@mock.patch(
|
||||
'cinder.api.openstack.wsgi.Controller.validate_name_and_description')
|
||||
@ -174,14 +174,14 @@ class SnapshotApiTest(test.TestCase):
|
||||
snapshot_metadata_get, update_snapshot):
|
||||
snapshot = {
|
||||
'id': UUID,
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 100,
|
||||
'display_name': 'Default name',
|
||||
'display_description': 'Default description',
|
||||
'expected_attrs': ['metadata'],
|
||||
}
|
||||
ctx = context.RequestContext(fake.project_id, fake.user_id, True)
|
||||
ctx = context.RequestContext(fake.PROJECT_ID, fake.USER_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
fake_volume_obj = fake_volume.fake_volume_obj(ctx)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
@ -196,7 +196,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
expected = {
|
||||
'snapshot': {
|
||||
'id': UUID,
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': u'available',
|
||||
'size': 100,
|
||||
'created_at': None,
|
||||
@ -241,14 +241,14 @@ class SnapshotApiTest(test.TestCase):
|
||||
snapshot_metadata_get, delete_snapshot):
|
||||
snapshot = {
|
||||
'id': UUID,
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 100,
|
||||
'display_name': 'Default name',
|
||||
'display_description': 'Default description',
|
||||
'expected_attrs': ['metadata'],
|
||||
}
|
||||
ctx = context.RequestContext(fake.project_id, fake.user_id, True)
|
||||
ctx = context.RequestContext(fake.PROJECT_ID, fake.USER_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
fake_volume_obj = fake_volume.fake_volume_obj(ctx)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
@ -273,14 +273,14 @@ class SnapshotApiTest(test.TestCase):
|
||||
snapshot_metadata_get):
|
||||
snapshot = {
|
||||
'id': UUID,
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 100,
|
||||
'display_name': 'Default name',
|
||||
'display_description': 'Default description',
|
||||
'expected_attrs': ['metadata'],
|
||||
}
|
||||
ctx = context.RequestContext(fake.project_id, fake.user_id, True)
|
||||
ctx = context.RequestContext(fake.PROJECT_ID, fake.USER_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
fake_volume_obj = fake_volume.fake_volume_obj(ctx)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
@ -306,14 +306,14 @@ class SnapshotApiTest(test.TestCase):
|
||||
volume_get_by_id, snapshot_metadata_get):
|
||||
snapshot = {
|
||||
'id': UUID,
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 100,
|
||||
'display_name': 'Default name',
|
||||
'display_description': 'Default description',
|
||||
'expected_attrs': ['metadata']
|
||||
}
|
||||
ctx = context.RequestContext(fake.project_id, fake.user_id, True)
|
||||
ctx = context.RequestContext(fake.PROJECT_ID, fake.USER_ID, True)
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot)
|
||||
fake_volume_obj = fake_volume.fake_volume_obj(ctx)
|
||||
snapshot_get_by_id.return_value = snapshot_obj
|
||||
@ -335,7 +335,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
@mock.patch('cinder.db.snapshot_metadata_get', return_value=dict())
|
||||
def test_admin_list_snapshots_limited_to_project(self,
|
||||
snapshot_metadata_get):
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/snapshots' % fake.project_id,
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/snapshots' % fake.PROJECT_ID,
|
||||
use_admin_context=True)
|
||||
res = self.controller.index(req)
|
||||
|
||||
@ -347,7 +347,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
snapshot_metadata_get):
|
||||
def list_snapshots_with_limit_and_offset(snaps, is_admin):
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/snapshots?limit=1'
|
||||
'&offset=1' % fake.project_id,
|
||||
'&offset=1' % fake.PROJECT_ID,
|
||||
use_admin_context=is_admin)
|
||||
res = self.controller.index(req)
|
||||
|
||||
@ -407,7 +407,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.index, req)
|
||||
|
||||
def _assert_list_next(self, expected_query=None, project=fake.project_id,
|
||||
def _assert_list_next(self, expected_query=None, project=fake.PROJECT_ID,
|
||||
**kwargs):
|
||||
"""Check a page of snapshots list."""
|
||||
# Since we are accessing v2 api directly we don't need to specify
|
||||
@ -520,7 +520,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
@mock.patch('cinder.db.snapshot_metadata_get', return_value=dict())
|
||||
def test_admin_list_snapshots_all_tenants(self, snapshot_metadata_get):
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/snapshots?all_tenants=1' %
|
||||
fake.project_id,
|
||||
fake.PROJECT_ID,
|
||||
use_admin_context=True)
|
||||
res = self.controller.index(req)
|
||||
self.assertIn('snapshots', res)
|
||||
@ -533,7 +533,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
def get_all(context, filters=None, marker=None, limit=None,
|
||||
sort_keys=None, sort_dirs=None, offset=None):
|
||||
if 'project_id' in filters and 'tenant1' in filters['project_id']:
|
||||
return [stubs.stub_snapshot(fake.volume_id,
|
||||
return [stubs.stub_snapshot(fake.VOLUME_ID,
|
||||
tenant_id='tenant1')]
|
||||
else:
|
||||
return []
|
||||
@ -541,7 +541,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
snapshot_get_all.side_effect = get_all
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/snapshots?all_tenants=1'
|
||||
'&project_id=tenant1' % fake.project_id,
|
||||
'&project_id=tenant1' % fake.PROJECT_ID,
|
||||
use_admin_context=True)
|
||||
res = self.controller.index(req)
|
||||
self.assertIn('snapshots', res)
|
||||
@ -551,20 +551,20 @@ class SnapshotApiTest(test.TestCase):
|
||||
def test_all_tenants_non_admin_gets_all_tenants(self,
|
||||
snapshot_metadata_get):
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/snapshots?all_tenants=1' %
|
||||
fake.project_id)
|
||||
fake.PROJECT_ID)
|
||||
res = self.controller.index(req)
|
||||
self.assertIn('snapshots', res)
|
||||
self.assertEqual(1, len(res['snapshots']))
|
||||
|
||||
@mock.patch('cinder.db.snapshot_metadata_get', return_value=dict())
|
||||
def test_non_admin_get_by_project(self, snapshot_metadata_get):
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/snapshots' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/snapshots' % fake.PROJECT_ID)
|
||||
res = self.controller.index(req)
|
||||
self.assertIn('snapshots', res)
|
||||
self.assertEqual(1, len(res['snapshots']))
|
||||
|
||||
def _create_snapshot_bad_body(self, body):
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/snapshots' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/snapshots' % fake.PROJECT_ID)
|
||||
req.method = 'POST'
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
|
@ -70,7 +70,7 @@ def return_empty_volume_types_get_all_types(context, filters=None, marker=None,
|
||||
|
||||
|
||||
def return_volume_types_get_volume_type(context, id):
|
||||
if id == fake.will_not_be_found_id:
|
||||
if id == fake.WILL_NOT_BE_FOUND_ID:
|
||||
raise exception.VolumeTypeNotFound(volume_type_id=id)
|
||||
return stub_volume_type(id)
|
||||
|
||||
@ -93,8 +93,8 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
def setUp(self):
|
||||
super(VolumeTypesApiTest, self).setUp()
|
||||
self.controller = types.VolumeTypesController()
|
||||
self.ctxt = context.RequestContext(user_id=fake.user_id,
|
||||
project_id=fake.project_id,
|
||||
self.ctxt = context.RequestContext(user_id=fake.USER_ID,
|
||||
project_id=fake.PROJECT_ID,
|
||||
is_admin=True)
|
||||
self.type_id1 = self._create_volume_type('volume_type1',
|
||||
{'key1': 'value1'})
|
||||
@ -102,13 +102,13 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
{'key2': 'value2'})
|
||||
self.type_id3 = self._create_volume_type('volume_type3',
|
||||
{'key3': 'value3'}, False,
|
||||
[fake.project_id])
|
||||
[fake.PROJECT_ID])
|
||||
|
||||
def test_volume_types_index(self):
|
||||
self.stubs.Set(volume_types, 'get_all_types',
|
||||
return_volume_types_get_all_types)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types' % fake.project_id,
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types' % fake.PROJECT_ID,
|
||||
use_admin_context=True)
|
||||
res_dict = self.controller.index(req)
|
||||
|
||||
@ -124,13 +124,13 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
self.stubs.Set(volume_types, 'get_all_types',
|
||||
return_empty_volume_types_get_all_types)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types' % fake.PROJECT_ID)
|
||||
res_dict = self.controller.index(req)
|
||||
|
||||
self.assertEqual(0, len(res_dict['volume_types']))
|
||||
|
||||
def test_volume_types_index_with_limit(self):
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types?limit=1' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types?limit=1' % fake.PROJECT_ID)
|
||||
req.environ['cinder.context'] = self.ctxt
|
||||
res = self.controller.index(req)
|
||||
|
||||
@ -139,26 +139,26 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
|
||||
expect_next_link = ('http://localhost/v2/%s/types?limit=1'
|
||||
'&marker=%s' %
|
||||
(fake.project_id, res['volume_types'][0]['id']))
|
||||
(fake.PROJECT_ID, res['volume_types'][0]['id']))
|
||||
self.assertEqual(expect_next_link, res['volume_type_links'][0]['href'])
|
||||
|
||||
def test_volume_types_index_with_offset(self):
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v2/%s/types?offset=1' % fake.project_id)
|
||||
'/v2/%s/types?offset=1' % fake.PROJECT_ID)
|
||||
req.environ['cinder.context'] = self.ctxt
|
||||
res = self.controller.index(req)
|
||||
|
||||
self.assertEqual(2, len(res['volume_types']))
|
||||
|
||||
def test_volume_types_index_with_offset_out_of_range(self):
|
||||
url = '/v2/%s/types?offset=424366766556787' % fake.project_id
|
||||
url = '/v2/%s/types?offset=424366766556787' % fake.PROJECT_ID
|
||||
req = fakes.HTTPRequest.blank(url)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.index, req)
|
||||
|
||||
def test_volume_types_index_with_limit_and_offset(self):
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v2/%s/types?limit=2&offset=1' % fake.project_id)
|
||||
'/v2/%s/types?limit=2&offset=1' % fake.PROJECT_ID)
|
||||
req.environ['cinder.context'] = self.ctxt
|
||||
res = self.controller.index(req)
|
||||
|
||||
@ -169,7 +169,7 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
def test_volume_types_index_with_limit_and_marker(self):
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types?limit=1'
|
||||
'&marker=%s' %
|
||||
(fake.project_id,
|
||||
(fake.PROJECT_ID,
|
||||
self.type_id2))
|
||||
req.environ['cinder.context'] = self.ctxt
|
||||
res = self.controller.index(req)
|
||||
@ -179,7 +179,7 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
|
||||
def test_volume_types_index_with_valid_filter(self):
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v2/%s/types?is_public=True' % fake.project_id)
|
||||
'/v2/%s/types?is_public=True' % fake.PROJECT_ID)
|
||||
req.environ['cinder.context'] = self.ctxt
|
||||
res = self.controller.index(req)
|
||||
|
||||
@ -190,14 +190,14 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
|
||||
def test_volume_types_index_with_invalid_filter(self):
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v2/%s/types?id=%s' % (fake.project_id, self.type_id1))
|
||||
'/v2/%s/types?id=%s' % (fake.PROJECT_ID, self.type_id1))
|
||||
req.environ['cinder.context'] = self.ctxt
|
||||
res = self.controller.index(req)
|
||||
|
||||
self.assertEqual(3, len(res['volume_types']))
|
||||
|
||||
def test_volume_types_index_with_sort_keys(self):
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types?sort=id' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types?sort=id' % fake.PROJECT_ID)
|
||||
req.environ['cinder.context'] = self.ctxt
|
||||
res = self.controller.index(req)
|
||||
expect_result = [self.type_id1, self.type_id2, self.type_id3]
|
||||
@ -210,7 +210,7 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
|
||||
def test_volume_types_index_with_sort_and_limit(self):
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v2/%s/types?sort=id&limit=2' % fake.project_id)
|
||||
'/v2/%s/types?sort=id&limit=2' % fake.PROJECT_ID)
|
||||
req.environ['cinder.context'] = self.ctxt
|
||||
res = self.controller.index(req)
|
||||
expect_result = [self.type_id1, self.type_id2, self.type_id3]
|
||||
@ -222,7 +222,7 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
|
||||
def test_volume_types_index_with_sort_keys_and_sort_dirs(self):
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v2/%s/types?sort=id:asc' % fake.project_id)
|
||||
'/v2/%s/types?sort=id:asc' % fake.PROJECT_ID)
|
||||
req.environ['cinder.context'] = self.ctxt
|
||||
res = self.controller.index(req)
|
||||
expect_result = [self.type_id1, self.type_id2, self.type_id3]
|
||||
@ -238,7 +238,7 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
return_volume_types_get_volume_type)
|
||||
|
||||
type_id = str(uuid.uuid4())
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types/' % fake.project_id
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types/' % fake.PROJECT_ID
|
||||
+ type_id)
|
||||
res_dict = self.controller.show(req, type_id)
|
||||
|
||||
@ -252,15 +252,15 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
return_volume_types_get_volume_type)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types/%s' %
|
||||
(fake.project_id,
|
||||
fake.will_not_be_found_id))
|
||||
(fake.PROJECT_ID,
|
||||
fake.WILL_NOT_BE_FOUND_ID))
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.show,
|
||||
req, fake.will_not_be_found_id)
|
||||
req, fake.WILL_NOT_BE_FOUND_ID)
|
||||
|
||||
def test_get_default(self):
|
||||
self.stubs.Set(volume_types, 'get_default_volume_type',
|
||||
return_volume_types_get_default)
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types/default' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types/default' % fake.PROJECT_ID)
|
||||
req.method = 'GET'
|
||||
res_dict = self.controller.show(req, 'default')
|
||||
self.assertEqual(1, len(res_dict))
|
||||
@ -271,7 +271,7 @@ class VolumeTypesApiTest(test.TestCase):
|
||||
def test_get_default_not_found(self):
|
||||
self.stubs.Set(volume_types, 'get_default_volume_type',
|
||||
return_volume_types_get_default_not_found)
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types/default' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/types/default' % fake.PROJECT_ID)
|
||||
req.method = 'GET'
|
||||
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
|
@ -143,7 +143,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
self.controller = volume_metadata.Controller()
|
||||
self.req_id = str(uuid.uuid4())
|
||||
self.url = '/v2/%s/volumes/%s/metadata' % (
|
||||
fake.project_id, self.req_id)
|
||||
fake.PROJECT_ID, self.req_id)
|
||||
|
||||
vol = {"size": 100,
|
||||
"display_name": "Volume Test Name",
|
||||
@ -584,7 +584,7 @@ class volumeMetaDataTest(test.TestCase):
|
||||
self.stubs.Set(db, 'volume_get',
|
||||
return_volume_nonexistent)
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v2/%s/volumes/asdf/metadata/key1' % fake.project_id)
|
||||
'/v2/%s/volumes/asdf/metadata/key1' % fake.PROJECT_ID)
|
||||
req.method = 'PUT'
|
||||
body = {"meta": {"key1": "value1"}}
|
||||
req.body = jsonutils.dump_as_bytes(body)
|
||||
|
@ -64,7 +64,7 @@ class VolumeApiTest(test.TestCase):
|
||||
self.stubs.Set(db, 'service_get_all_by_topic',
|
||||
stubs.stub_service_get_all_by_topic)
|
||||
self.maxDiff = None
|
||||
self.ctxt = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
self.ctxt = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
|
||||
@mock.patch(
|
||||
'cinder.api.openstack.wsgi.Controller.validate_name_and_description')
|
||||
@ -188,10 +188,10 @@ class VolumeApiTest(test.TestCase):
|
||||
'id': stubs.DEFAULT_VOL_ID,
|
||||
'links':
|
||||
[{'href': 'http://localhost/v2/%s/volumes/%s' % (
|
||||
fake.project_id, fake.volume_id),
|
||||
fake.PROJECT_ID, fake.VOLUME_ID),
|
||||
'rel': 'self'},
|
||||
{'href': 'http://localhost/%s/volumes/%s' % (
|
||||
fake.project_id, fake.volume_id),
|
||||
fake.PROJECT_ID, fake.VOLUME_ID),
|
||||
'rel': 'bookmark'}],
|
||||
'metadata': metadata,
|
||||
'name': name,
|
||||
@ -201,7 +201,7 @@ class VolumeApiTest(test.TestCase):
|
||||
'snapshot_id': snapshot_id,
|
||||
'source_volid': source_volid,
|
||||
'status': status,
|
||||
'user_id': fake.user_id,
|
||||
'user_id': fake.USER_ID,
|
||||
'volume_type': volume_type,
|
||||
'encrypted': False}}
|
||||
|
||||
@ -233,7 +233,7 @@ class VolumeApiTest(test.TestCase):
|
||||
get_snapshot.side_effect = stubs.stub_snapshot_get
|
||||
volume_type_get.side_effect = stubs.stub_volume_type_get
|
||||
|
||||
snapshot_id = fake.snapshot_id
|
||||
snapshot_id = fake.SNAPSHOT_ID
|
||||
vol = self._vol_in_request_body(snapshot_id=snapshot_id)
|
||||
body = {"volume": vol}
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes')
|
||||
@ -257,7 +257,7 @@ class VolumeApiTest(test.TestCase):
|
||||
|
||||
get_snapshot.side_effect = stubs.stub_snapshot_get
|
||||
|
||||
snapshot_id = fake.will_not_be_found_id
|
||||
snapshot_id = fake.WILL_NOT_BE_FOUND_ID
|
||||
vol = self._vol_in_request_body(snapshot_id=snapshot_id)
|
||||
body = {"volume": vol}
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes')
|
||||
@ -305,7 +305,7 @@ class VolumeApiTest(test.TestCase):
|
||||
|
||||
get_volume.side_effect = stubs.stub_volume_get_notfound
|
||||
|
||||
source_volid = fake.volume_id
|
||||
source_volid = fake.VOLUME_ID
|
||||
vol = self._vol_in_request_body(source_volid=source_volid)
|
||||
body = {"volume": vol}
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes')
|
||||
@ -323,7 +323,7 @@ class VolumeApiTest(test.TestCase):
|
||||
|
||||
get_volume.side_effect = stubs.stub_volume_get_notfound
|
||||
|
||||
source_replica = fake.volume_id
|
||||
source_replica = fake.VOLUME_ID
|
||||
vol = self._vol_in_request_body(source_replica=source_replica)
|
||||
body = {"volume": vol}
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes')
|
||||
@ -578,9 +578,9 @@ class VolumeApiTest(test.TestCase):
|
||||
"name": "Updated Test Name",
|
||||
}
|
||||
body = {"volume": updates}
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
self.assertEqual(0, len(self.notifier.notifications))
|
||||
res_dict = self.controller.update(req, fake.volume_id, body)
|
||||
res_dict = self.controller.update(req, fake.VOLUME_ID, body)
|
||||
expected = self._expected_vol_from_controller(
|
||||
availability_zone=stubs.DEFAULT_AZ, name="Updated Test Name",
|
||||
metadata={'attached_mode': 'rw', 'readonly': 'False'})
|
||||
@ -601,9 +601,9 @@ class VolumeApiTest(test.TestCase):
|
||||
"display_description": "Updated Test Description",
|
||||
}
|
||||
body = {"volume": updates}
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
self.assertEqual(0, len(self.notifier.notifications))
|
||||
res_dict = self.controller.update(req, fake.volume_id, body)
|
||||
res_dict = self.controller.update(req, fake.VOLUME_ID, body)
|
||||
expected = self._expected_vol_from_controller(
|
||||
availability_zone=stubs.DEFAULT_AZ, name="Updated Test Name",
|
||||
description="Updated Test Description",
|
||||
@ -628,9 +628,9 @@ class VolumeApiTest(test.TestCase):
|
||||
"display_description": "Not Shown Description",
|
||||
}
|
||||
body = {"volume": updates}
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
self.assertEqual(0, len(self.notifier.notifications))
|
||||
res_dict = self.controller.update(req, fake.volume_id, body)
|
||||
res_dict = self.controller.update(req, fake.VOLUME_ID, body)
|
||||
expected = self._expected_vol_from_controller(
|
||||
availability_zone=stubs.DEFAULT_AZ,
|
||||
name="New Name", description="New Description",
|
||||
@ -651,9 +651,9 @@ class VolumeApiTest(test.TestCase):
|
||||
"metadata": {"qos_max_iops": 2000}
|
||||
}
|
||||
body = {"volume": updates}
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
self.assertEqual(0, len(self.notifier.notifications))
|
||||
res_dict = self.controller.update(req, fake.volume_id, body)
|
||||
res_dict = self.controller.update(req, fake.VOLUME_ID, body)
|
||||
expected = self._expected_vol_from_controller(
|
||||
availability_zone=stubs.DEFAULT_AZ,
|
||||
metadata={'attached_mode': 'rw', 'readonly': 'False',
|
||||
@ -667,7 +667,7 @@ class VolumeApiTest(test.TestCase):
|
||||
def test_volume_update_with_admin_metadata(self, mock_validate):
|
||||
self.stubs.Set(volume_api.API, "update", stubs.stub_volume_update)
|
||||
|
||||
volume = stubs.stub_volume(fake.volume_id)
|
||||
volume = stubs.stub_volume(fake.VOLUME_ID)
|
||||
del volume['name']
|
||||
del volume['volume_type']
|
||||
del volume['volume_type_id']
|
||||
@ -675,33 +675,33 @@ class VolumeApiTest(test.TestCase):
|
||||
db.volume_create(context.get_admin_context(), volume)
|
||||
|
||||
db.volume_admin_metadata_update(context.get_admin_context(),
|
||||
fake.volume_id,
|
||||
fake.VOLUME_ID,
|
||||
{"readonly": "True",
|
||||
"invisible_key": "invisible_value"},
|
||||
False)
|
||||
values = {'volume_id': fake.volume_id, }
|
||||
values = {'volume_id': fake.VOLUME_ID, }
|
||||
attachment = db.volume_attach(context.get_admin_context(), values)
|
||||
db.volume_attached(context.get_admin_context(),
|
||||
attachment['id'], fake.instance_id, None, '/')
|
||||
attachment['id'], fake.INSTANCE_ID, None, '/')
|
||||
attach_tmp = db.volume_attachment_get(context.get_admin_context(),
|
||||
attachment['id'])
|
||||
volume_tmp = db.volume_get(context.get_admin_context(), fake.volume_id)
|
||||
volume_tmp = db.volume_get(context.get_admin_context(), fake.VOLUME_ID)
|
||||
updates = {
|
||||
"name": "Updated Test Name",
|
||||
}
|
||||
body = {"volume": updates}
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
self.assertEqual(0, len(self.notifier.notifications))
|
||||
admin_ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
admin_ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
req.environ['cinder.context'] = admin_ctx
|
||||
res_dict = self.controller.update(req, fake.volume_id, body)
|
||||
res_dict = self.controller.update(req, fake.VOLUME_ID, body)
|
||||
expected = self._expected_vol_from_controller(
|
||||
availability_zone=stubs.DEFAULT_AZ, volume_type=None,
|
||||
status='in-use', name='Updated Test Name',
|
||||
attachments=[{'id': fake.volume_id,
|
||||
attachments=[{'id': fake.VOLUME_ID,
|
||||
'attachment_id': attachment['id'],
|
||||
'volume_id': stubs.DEFAULT_VOL_ID,
|
||||
'server_id': fake.instance_id,
|
||||
'server_id': fake.INSTANCE_ID,
|
||||
'host_name': None,
|
||||
'device': '/',
|
||||
'attached_at': attach_tmp['attach_time'].replace(
|
||||
@ -717,19 +717,19 @@ class VolumeApiTest(test.TestCase):
|
||||
|
||||
def test_update_empty_body(self):
|
||||
body = {}
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update,
|
||||
req, fake.volume_id, body)
|
||||
req, fake.VOLUME_ID, body)
|
||||
|
||||
def test_update_invalid_body(self):
|
||||
body = {
|
||||
'name': 'missing top level volume key'
|
||||
}
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.update,
|
||||
req, fake.volume_id, body)
|
||||
req, fake.VOLUME_ID, body)
|
||||
|
||||
def test_update_not_found(self):
|
||||
self.stubs.Set(volume_api.API, "get", stubs.stub_volume_get_notfound)
|
||||
@ -737,10 +737,10 @@ class VolumeApiTest(test.TestCase):
|
||||
"name": "Updated Test Name",
|
||||
}
|
||||
body = {"volume": updates}
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.update,
|
||||
req, fake.volume_id, body)
|
||||
req, fake.VOLUME_ID, body)
|
||||
|
||||
def test_volume_list_summary(self):
|
||||
self.stubs.Set(volume_api.API, 'get_all',
|
||||
@ -754,16 +754,16 @@ class VolumeApiTest(test.TestCase):
|
||||
'volumes': [
|
||||
{
|
||||
'name': stubs.DEFAULT_VOL_NAME,
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'links': [
|
||||
{
|
||||
'href': 'http://localhost/v2/%s/volumes/%s' % (
|
||||
fake.project_id, fake.volume_id),
|
||||
fake.PROJECT_ID, fake.VOLUME_ID),
|
||||
'rel': 'self'
|
||||
},
|
||||
{
|
||||
'href': 'http://localhost/%s/volumes/%s' % (
|
||||
fake.project_id, fake.volume_id),
|
||||
fake.PROJECT_ID, fake.VOLUME_ID),
|
||||
'rel': 'bookmark'
|
||||
}
|
||||
],
|
||||
@ -791,27 +791,27 @@ class VolumeApiTest(test.TestCase):
|
||||
self.assertEqual(1, len(req.cached_resource()))
|
||||
|
||||
def test_volume_list_detail_with_admin_metadata(self):
|
||||
volume = stubs.stub_volume(fake.volume_id)
|
||||
volume = stubs.stub_volume(fake.VOLUME_ID)
|
||||
del volume['name']
|
||||
del volume['volume_type']
|
||||
del volume['volume_type_id']
|
||||
volume['metadata'] = {'key': 'value'}
|
||||
db.volume_create(context.get_admin_context(), volume)
|
||||
db.volume_admin_metadata_update(context.get_admin_context(),
|
||||
fake.volume_id,
|
||||
fake.VOLUME_ID,
|
||||
{"readonly": "True",
|
||||
"invisible_key": "invisible_value"},
|
||||
False)
|
||||
values = {'volume_id': fake.volume_id, }
|
||||
values = {'volume_id': fake.VOLUME_ID, }
|
||||
attachment = db.volume_attach(context.get_admin_context(), values)
|
||||
db.volume_attached(context.get_admin_context(),
|
||||
attachment['id'], fake.instance_id, None, '/')
|
||||
attachment['id'], fake.INSTANCE_ID, None, '/')
|
||||
attach_tmp = db.volume_attachment_get(context.get_admin_context(),
|
||||
attachment['id'])
|
||||
volume_tmp = db.volume_get(context.get_admin_context(), fake.volume_id)
|
||||
volume_tmp = db.volume_get(context.get_admin_context(), fake.VOLUME_ID)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/detail')
|
||||
admin_ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
admin_ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
req.environ['cinder.context'] = admin_ctx
|
||||
res_dict = self.controller.detail(req)
|
||||
exp_vol = self._expected_vol_from_controller(
|
||||
@ -819,9 +819,9 @@ class VolumeApiTest(test.TestCase):
|
||||
status="in-use", volume_type=None,
|
||||
attachments=[{'attachment_id': attachment['id'],
|
||||
'device': '/',
|
||||
'server_id': fake.instance_id,
|
||||
'server_id': fake.INSTANCE_ID,
|
||||
'host_name': None,
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'volume_id': stubs.DEFAULT_VOL_ID,
|
||||
'attached_at': attach_tmp['attach_time'].replace(
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
@ -840,8 +840,8 @@ class VolumeApiTest(test.TestCase):
|
||||
viewable_admin_meta=False,
|
||||
offset=0):
|
||||
return [
|
||||
stubs.stub_volume(fake.volume_id, display_name='vol1'),
|
||||
stubs.stub_volume(fake.volume2_id, display_name='vol2'),
|
||||
stubs.stub_volume(fake.VOLUME_ID, display_name='vol1'),
|
||||
stubs.stub_volume(fake.VOLUME2_ID, display_name='vol2'),
|
||||
]
|
||||
self.stubs.Set(db, 'volume_get_all_by_project',
|
||||
stub_volume_get_all_by_project)
|
||||
@ -851,8 +851,8 @@ class VolumeApiTest(test.TestCase):
|
||||
res_dict = self.controller.index(req)
|
||||
volumes = res_dict['volumes']
|
||||
self.assertEqual(2, len(volumes))
|
||||
self.assertEqual(fake.volume_id, volumes[0]['id'])
|
||||
self.assertEqual(fake.volume2_id, volumes[1]['id'])
|
||||
self.assertEqual(fake.VOLUME_ID, volumes[0]['id'])
|
||||
self.assertEqual(fake.VOLUME2_ID, volumes[1]['id'])
|
||||
|
||||
def test_volume_index_limit(self):
|
||||
self.stubs.Set(db, 'volume_get_all_by_project',
|
||||
@ -874,7 +874,7 @@ class VolumeApiTest(test.TestCase):
|
||||
links = res_dict['volumes_links']
|
||||
self.assertEqual('next', links[0]['rel'])
|
||||
href_parts = urllib.parse.urlparse(links[0]['href'])
|
||||
self.assertEqual('/v2/%s/volumes' % fake.project_id, href_parts.path)
|
||||
self.assertEqual('/v2/%s/volumes' % fake.PROJECT_ID, href_parts.path)
|
||||
params = urllib.parse.parse_qs(href_parts.query)
|
||||
self.assertEqual(str(volumes[0]['id']), params['marker'][0])
|
||||
self.assertEqual('1', params['limit'][0])
|
||||
@ -902,7 +902,7 @@ class VolumeApiTest(test.TestCase):
|
||||
res_dict = self.controller.index(req)
|
||||
volumes = res_dict['volumes']
|
||||
self.assertEqual(1, len(volumes))
|
||||
self.assertEqual(fake.volume_id, volumes[0]['id'])
|
||||
self.assertEqual(fake.VOLUME_ID, volumes[0]['id'])
|
||||
|
||||
def _create_db_volumes(self, num_volumes):
|
||||
volumes = [utils.create_volume(self.ctxt, display_name='vol%s' % i)
|
||||
@ -945,8 +945,8 @@ class VolumeApiTest(test.TestCase):
|
||||
viewable_admin_meta=False,
|
||||
offset=0):
|
||||
return [
|
||||
stubs.stub_volume(fake.volume_id, display_name='vol1'),
|
||||
stubs.stub_volume(fake.volume2_id, display_name='vol2'),
|
||||
stubs.stub_volume(fake.VOLUME_ID, display_name='vol1'),
|
||||
stubs.stub_volume(fake.VOLUME2_ID, display_name='vol2'),
|
||||
]
|
||||
self.stubs.Set(db, 'volume_get_all_by_project',
|
||||
stub_volume_get_all_by_project)
|
||||
@ -957,8 +957,8 @@ class VolumeApiTest(test.TestCase):
|
||||
res_dict = self.controller.detail(req)
|
||||
volumes = res_dict['volumes']
|
||||
self.assertEqual(2, len(volumes))
|
||||
self.assertEqual(fake.volume_id, volumes[0]['id'])
|
||||
self.assertEqual(fake.volume2_id, volumes[1]['id'])
|
||||
self.assertEqual(fake.VOLUME_ID, volumes[0]['id'])
|
||||
self.assertEqual(fake.VOLUME2_ID, volumes[1]['id'])
|
||||
|
||||
def test_volume_detail_limit(self):
|
||||
self.stubs.Set(db, 'volume_get_all_by_project',
|
||||
@ -974,7 +974,7 @@ class VolumeApiTest(test.TestCase):
|
||||
links = res_dict['volumes_links']
|
||||
self.assertEqual('next', links[0]['rel'])
|
||||
href_parts = urllib.parse.urlparse(links[0]['href'])
|
||||
self.assertEqual('/v2/%s/volumes/detail' % fake.project_id,
|
||||
self.assertEqual('/v2/%s/volumes/detail' % fake.PROJECT_ID,
|
||||
href_parts.path)
|
||||
params = urllib.parse.parse_qs(href_parts.query)
|
||||
self.assertTrue('marker' in params)
|
||||
@ -1002,7 +1002,7 @@ class VolumeApiTest(test.TestCase):
|
||||
res_dict = self.controller.detail(req)
|
||||
volumes = res_dict['volumes']
|
||||
self.assertEqual(1, len(volumes))
|
||||
self.assertEqual(fake.volume_id, volumes[0]['id'])
|
||||
self.assertEqual(fake.VOLUME_ID, volumes[0]['id'])
|
||||
|
||||
def test_volume_detail_limit_offset(self):
|
||||
created_volumes = self._create_db_volumes(2)
|
||||
@ -1129,7 +1129,7 @@ class VolumeApiTest(test.TestCase):
|
||||
offset=0):
|
||||
self.assertTrue(filters['no_migration_targets'])
|
||||
self.assertFalse('all_tenants' in filters)
|
||||
return [stubs.stub_volume(fake.volume_id, display_name='vol1')]
|
||||
return [stubs.stub_volume(fake.VOLUME_ID, display_name='vol1')]
|
||||
|
||||
def stub_volume_get_all(context, marker, limit,
|
||||
sort_keys=None, sort_dirs=None,
|
||||
@ -1155,7 +1155,7 @@ class VolumeApiTest(test.TestCase):
|
||||
viewable_admin_meta=False,
|
||||
offset=0):
|
||||
self.assertFalse('no_migration_targets' in filters)
|
||||
return [stubs.stub_volume(fake.volume_id, display_name='vol2')]
|
||||
return [stubs.stub_volume(fake.VOLUME_ID, display_name='vol2')]
|
||||
|
||||
def stub_volume_get_all2(context, marker, limit,
|
||||
sort_keys=None, sort_dirs=None,
|
||||
@ -1186,7 +1186,7 @@ class VolumeApiTest(test.TestCase):
|
||||
viewable_admin_meta=False, offset=0):
|
||||
self.assertFalse('no_migration_targets' in filters)
|
||||
self.assertFalse('all_tenants' in filters)
|
||||
return [stubs.stub_volume(fake.volume3_id, display_name='vol3')]
|
||||
return [stubs.stub_volume(fake.VOLUME3_ID, display_name='vol3')]
|
||||
self.stubs.Set(db, 'volume_get_all_by_project',
|
||||
stub_volume_get_all_by_project3)
|
||||
self.stubs.Set(db, 'volume_get_all', stub_volume_get_all3)
|
||||
@ -1202,14 +1202,14 @@ class VolumeApiTest(test.TestCase):
|
||||
self.stubs.Set(db.sqlalchemy.api, '_volume_type_get_full',
|
||||
stubs.stub_volume_type_get)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
res_dict = self.controller.show(req, fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
res_dict = self.controller.show(req, fake.VOLUME_ID)
|
||||
expected = self._expected_vol_from_controller(
|
||||
availability_zone=stubs.DEFAULT_AZ,
|
||||
metadata={'attached_mode': 'rw', 'readonly': 'False'})
|
||||
self.assertEqual(expected, res_dict)
|
||||
# Finally test that we cached the returned volume
|
||||
self.assertIsNotNone(req.cached_resource_by_id(fake.volume_id))
|
||||
self.assertIsNotNone(req.cached_resource_by_id(fake.VOLUME_ID))
|
||||
|
||||
def test_volume_show_no_attachments(self):
|
||||
def stub_volume_get(self, context, volume_id, **kwargs):
|
||||
@ -1226,8 +1226,8 @@ class VolumeApiTest(test.TestCase):
|
||||
self.stubs.Set(db.sqlalchemy.api, '_volume_type_get_full',
|
||||
stubs.stub_volume_type_get)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
res_dict = self.controller.show(req, fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
res_dict = self.controller.show(req, fake.VOLUME_ID)
|
||||
expected = self._expected_vol_from_controller(
|
||||
availability_zone=stubs.DEFAULT_AZ,
|
||||
metadata={'readonly': 'False'})
|
||||
@ -1237,42 +1237,42 @@ class VolumeApiTest(test.TestCase):
|
||||
def test_volume_show_no_volume(self):
|
||||
self.stubs.Set(volume_api.API, "get", stubs.stub_volume_get_notfound)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.show,
|
||||
req, 1)
|
||||
# Finally test that nothing was cached
|
||||
self.assertIsNone(req.cached_resource_by_id(fake.volume_id))
|
||||
self.assertIsNone(req.cached_resource_by_id(fake.VOLUME_ID))
|
||||
|
||||
def test_volume_show_with_admin_metadata(self):
|
||||
volume = stubs.stub_volume(fake.volume_id)
|
||||
volume = stubs.stub_volume(fake.VOLUME_ID)
|
||||
del volume['name']
|
||||
del volume['volume_type']
|
||||
del volume['volume_type_id']
|
||||
volume['metadata'] = {'key': 'value'}
|
||||
db.volume_create(context.get_admin_context(), volume)
|
||||
db.volume_admin_metadata_update(context.get_admin_context(),
|
||||
fake.volume_id,
|
||||
fake.VOLUME_ID,
|
||||
{"readonly": "True",
|
||||
"invisible_key": "invisible_value"},
|
||||
False)
|
||||
values = {'volume_id': fake.volume_id, }
|
||||
values = {'volume_id': fake.VOLUME_ID, }
|
||||
attachment = db.volume_attach(context.get_admin_context(), values)
|
||||
db.volume_attached(context.get_admin_context(),
|
||||
attachment['id'], fake.instance_id, None, '/')
|
||||
attachment['id'], fake.INSTANCE_ID, None, '/')
|
||||
attach_tmp = db.volume_attachment_get(context.get_admin_context(),
|
||||
attachment['id'])
|
||||
volume_tmp = db.volume_get(context.get_admin_context(), fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
admin_ctx = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
volume_tmp = db.volume_get(context.get_admin_context(), fake.VOLUME_ID)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
admin_ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
req.environ['cinder.context'] = admin_ctx
|
||||
res_dict = self.controller.show(req, fake.volume_id)
|
||||
res_dict = self.controller.show(req, fake.VOLUME_ID)
|
||||
expected = self._expected_vol_from_controller(
|
||||
availability_zone=stubs.DEFAULT_AZ,
|
||||
volume_type=None, status='in-use',
|
||||
attachments=[{'id': fake.volume_id,
|
||||
attachments=[{'id': fake.VOLUME_ID,
|
||||
'attachment_id': attachment['id'],
|
||||
'volume_id': stubs.DEFAULT_VOL_ID,
|
||||
'server_id': fake.instance_id,
|
||||
'server_id': fake.INSTANCE_ID,
|
||||
'host_name': None,
|
||||
'device': '/',
|
||||
'attached_at': attach_tmp['attach_time'].replace(
|
||||
@ -1286,15 +1286,15 @@ class VolumeApiTest(test.TestCase):
|
||||
|
||||
def test_volume_show_with_encrypted_volume(self):
|
||||
def stub_volume_get(self, context, volume_id, **kwargs):
|
||||
vol = stubs.stub_volume(volume_id, encryption_key_id=fake.key_id)
|
||||
vol = stubs.stub_volume(volume_id, encryption_key_id=fake.KEY_ID)
|
||||
return fake_volume.fake_volume_obj(context, **vol)
|
||||
|
||||
self.stubs.Set(volume_api.API, 'get', stub_volume_get)
|
||||
self.stubs.Set(db.sqlalchemy.api, '_volume_type_get_full',
|
||||
stubs.stub_volume_type_get)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
res_dict = self.controller.show(req, fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
res_dict = self.controller.show(req, fake.VOLUME_ID)
|
||||
self.assertTrue(res_dict['volume']['encrypted'])
|
||||
|
||||
def test_volume_show_with_unencrypted_volume(self):
|
||||
@ -1302,15 +1302,15 @@ class VolumeApiTest(test.TestCase):
|
||||
self.stubs.Set(db.sqlalchemy.api, '_volume_type_get_full',
|
||||
stubs.stub_volume_type_get)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
res_dict = self.controller.show(req, fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
res_dict = self.controller.show(req, fake.VOLUME_ID)
|
||||
self.assertEqual(False, res_dict['volume']['encrypted'])
|
||||
|
||||
def test_volume_delete(self):
|
||||
self.stubs.Set(volume_api.API, 'get', stubs.stub_volume_get)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
resp = self.controller.delete(req, fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
resp = self.controller.delete(req, fake.VOLUME_ID)
|
||||
self.assertEqual(202, resp.status_int)
|
||||
|
||||
def test_volume_delete_attached(self):
|
||||
@ -1320,7 +1320,7 @@ class VolumeApiTest(test.TestCase):
|
||||
self.stubs.Set(volume_api.API, "delete", stub_volume_attached)
|
||||
self.stubs.Set(volume_api.API, 'get', stubs.stub_volume_get)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
exp = self.assertRaises(exception.VolumeAttached,
|
||||
self.controller.delete,
|
||||
req, 1)
|
||||
@ -1330,7 +1330,7 @@ class VolumeApiTest(test.TestCase):
|
||||
def test_volume_delete_no_volume(self):
|
||||
self.stubs.Set(volume_api.API, "get", stubs.stub_volume_get_notfound)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.volume_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/volumes/%s' % fake.VOLUME_ID)
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete,
|
||||
req, 1)
|
||||
|
||||
@ -1338,7 +1338,7 @@ class VolumeApiTest(test.TestCase):
|
||||
self.stubs.Set(db, 'volume_get_all_by_project',
|
||||
stubs.stub_volume_get_all_by_project)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/volumes' % fake.project_id,
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/volumes' % fake.PROJECT_ID,
|
||||
use_admin_context=True)
|
||||
res = self.controller.index(req)
|
||||
|
||||
@ -1350,7 +1350,7 @@ class VolumeApiTest(test.TestCase):
|
||||
stubs.stub_volume_get_all_by_project)
|
||||
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v2/%s/volumes?all_tenants=1' % fake.project_id,
|
||||
'/v2/%s/volumes?all_tenants=1' % fake.PROJECT_ID,
|
||||
use_admin_context=True)
|
||||
res = self.controller.index(req)
|
||||
self.assertIn('volumes', res)
|
||||
@ -1362,7 +1362,7 @@ class VolumeApiTest(test.TestCase):
|
||||
self.stubs.Set(volume_api.API, 'get', stubs.stub_volume_get)
|
||||
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v2/%s/volumes?all_tenants=1' % fake.project_id)
|
||||
'/v2/%s/volumes?all_tenants=1' % fake.PROJECT_ID)
|
||||
res = self.controller.index(req)
|
||||
self.assertIn('volumes', res)
|
||||
self.assertEqual(1, len(res['volumes']))
|
||||
@ -1372,13 +1372,13 @@ class VolumeApiTest(test.TestCase):
|
||||
stubs.stub_volume_get_all_by_project)
|
||||
self.stubs.Set(volume_api.API, 'get', stubs.stub_volume_get)
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/volumes' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/volumes' % fake.PROJECT_ID)
|
||||
res = self.controller.index(req)
|
||||
self.assertIn('volumes', res)
|
||||
self.assertEqual(1, len(res['volumes']))
|
||||
|
||||
def _create_volume_bad_request(self, body):
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/volumes' % fake.project_id)
|
||||
req = fakes.HTTPRequest.blank('/v2/%s/volumes' % fake.PROJECT_ID)
|
||||
req.method = 'POST'
|
||||
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
@ -1469,13 +1469,13 @@ class VolumeApiTest(test.TestCase):
|
||||
context = mock.Mock()
|
||||
req.environ = {'cinder.context': context}
|
||||
req.params = {'id': "['%s', '%s', '%s']" % (
|
||||
fake.volume_id, fake.volume2_id, fake.volume3_id)}
|
||||
fake.VOLUME_ID, fake.VOLUME2_ID, fake.VOLUME3_ID)}
|
||||
self.controller._view_builder.detail_list = mock.Mock()
|
||||
self.controller._get_volumes(req, True)
|
||||
get_all.assert_called_once_with(
|
||||
context, None, CONF.osapi_max_limit,
|
||||
sort_keys=['created_at'], sort_dirs=['desc'],
|
||||
filters={'id': [fake.volume_id, fake.volume2_id, fake.volume3_id]},
|
||||
filters={'id': [fake.VOLUME_ID, fake.VOLUME2_ID, fake.VOLUME3_ID]},
|
||||
viewable_admin_meta=True,
|
||||
offset=0)
|
||||
|
||||
@ -1496,7 +1496,7 @@ class VolumeApiTest(test.TestCase):
|
||||
def test_get_volumes_filter_with_status(self, get_all):
|
||||
req = mock.MagicMock()
|
||||
ctxt = context.RequestContext(
|
||||
fake.user_id, fake.project_id, auth_token=True)
|
||||
fake.USER_ID, fake.PROJECT_ID, auth_token=True)
|
||||
req.environ = {'cinder.context': ctxt}
|
||||
req.params = {'status': 'available'}
|
||||
self.controller._view_builder.detail_list = mock.Mock()
|
||||
@ -1511,7 +1511,7 @@ class VolumeApiTest(test.TestCase):
|
||||
def test_get_volumes_filter_with_metadata(self, get_all):
|
||||
req = mock.MagicMock()
|
||||
ctxt = context.RequestContext(
|
||||
fake.user_id, fake.project_id, auth_token=True)
|
||||
fake.USER_ID, fake.PROJECT_ID, auth_token=True)
|
||||
req.environ = {'cinder.context': ctxt}
|
||||
req.params = {'metadata': "{'fake_key': 'fake_value'}"}
|
||||
self.controller._view_builder.detail_list = mock.Mock()
|
||||
@ -1526,7 +1526,7 @@ class VolumeApiTest(test.TestCase):
|
||||
def test_get_volumes_filter_with_availability_zone(self, get_all):
|
||||
req = mock.MagicMock()
|
||||
ctxt = context.RequestContext(
|
||||
fake.user_id, fake.project_id, auth_token=True)
|
||||
fake.USER_ID, fake.PROJECT_ID, auth_token=True)
|
||||
req.environ = {'cinder.context': ctxt}
|
||||
req.params = {'availability_zone': 'nova'}
|
||||
self.controller._view_builder.detail_list = mock.Mock()
|
||||
@ -1541,7 +1541,7 @@ class VolumeApiTest(test.TestCase):
|
||||
def test_get_volumes_filter_with_bootable(self, get_all):
|
||||
req = mock.MagicMock()
|
||||
ctxt = context.RequestContext(
|
||||
fake.user_id, fake.project_id, auth_token=True)
|
||||
fake.USER_ID, fake.PROJECT_ID, auth_token=True)
|
||||
req.environ = {'cinder.context': ctxt}
|
||||
req.params = {'bootable': 1}
|
||||
self.controller._view_builder.detail_list = mock.Mock()
|
||||
@ -1556,7 +1556,7 @@ class VolumeApiTest(test.TestCase):
|
||||
def test_get_volumes_filter_with_invalid_filter(self, get_all):
|
||||
req = mock.MagicMock()
|
||||
ctxt = context.RequestContext(
|
||||
fake.user_id, fake.project_id, auth_token=True)
|
||||
fake.USER_ID, fake.PROJECT_ID, auth_token=True)
|
||||
req.environ = {'cinder.context': ctxt}
|
||||
req.params = {'invalid_filter': 'invalid',
|
||||
'availability_zone': 'nova'}
|
||||
@ -1574,7 +1574,7 @@ class VolumeApiTest(test.TestCase):
|
||||
|
||||
req = mock.MagicMock()
|
||||
ctxt = context.RequestContext(
|
||||
fake.user_id, fake.project_id, auth_token=True)
|
||||
fake.USER_ID, fake.PROJECT_ID, auth_token=True)
|
||||
req.environ = {'cinder.context': ctxt}
|
||||
req.params = {'sort': 'name'}
|
||||
self.controller._view_builder.detail_list = mock.Mock()
|
||||
|
@ -14,10 +14,10 @@ import datetime
|
||||
import iso8601
|
||||
|
||||
from cinder.message import defined_messages
|
||||
from cinder.tests.unit import fake_constants
|
||||
from cinder.tests.unit import fake_constants as fake
|
||||
|
||||
|
||||
FAKE_UUID = fake_constants.object_id
|
||||
FAKE_UUID = fake.OBJECT_ID
|
||||
|
||||
|
||||
def stub_message(id, **kwargs):
|
||||
|
@ -37,7 +37,7 @@ class VolumeApiTest(test.TestCase):
|
||||
|
||||
self.flags(host='fake',
|
||||
notification_driver=[fake_notifier.__name__])
|
||||
self.ctxt = context.RequestContext(fake.user_id, fake.project_id, True)
|
||||
self.ctxt = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True)
|
||||
|
||||
def test_check_volume_filters_called(self):
|
||||
with mock.patch.object(vol_get,
|
||||
|
@ -47,10 +47,10 @@ FAKE_EXPORT_PATH = 'fake/export/path'
|
||||
FAKE_BACKUP_SHARE = '%s:/%s' % (FAKE_HOST, FAKE_EXPORT_PATH)
|
||||
FAKE_BACKUP_PATH = os.path.join(FAKE_BACKUP_MOUNT_POINT_BASE,
|
||||
FAKE_EXPORT_PATH)
|
||||
FAKE_BACKUP_ID = fake.backup_id
|
||||
FAKE_BACKUP_ID_PART1 = fake.backup_id[:2]
|
||||
FAKE_BACKUP_ID_PART2 = fake.backup_id[2:4]
|
||||
FAKE_BACKUP_ID_REST = fake.backup_id[4:]
|
||||
FAKE_BACKUP_ID = fake.BACKUP_ID
|
||||
FAKE_BACKUP_ID_PART1 = fake.BACKUP_ID[:2]
|
||||
FAKE_BACKUP_ID_PART2 = fake.BACKUP_ID[2:4]
|
||||
FAKE_BACKUP_ID_REST = fake.BACKUP_ID[4:]
|
||||
UPDATED_CONTAINER_NAME = os.path.join(FAKE_BACKUP_ID_PART1,
|
||||
FAKE_BACKUP_ID_PART2,
|
||||
FAKE_BACKUP_ID)
|
||||
@ -108,7 +108,7 @@ def fake_md5(arg):
|
||||
class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
"""Test Cases for based on Swift tempest backup tests."""
|
||||
|
||||
_DEFAULT_VOLUME_ID = fake.volume_id
|
||||
_DEFAULT_VOLUME_ID = fake.VOLUME_ID
|
||||
|
||||
def _create_volume_db_entry(self, volume_id=_DEFAULT_VOLUME_ID):
|
||||
vol = {'id': volume_id,
|
||||
@ -119,7 +119,7 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
def _create_backup_db_entry(self,
|
||||
volume_id=_DEFAULT_VOLUME_ID,
|
||||
container='test-container',
|
||||
backup_id=fake.backup_id,
|
||||
backup_id=fake.BACKUP_ID,
|
||||
parent_id=None):
|
||||
|
||||
try:
|
||||
@ -132,8 +132,8 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
'container': container,
|
||||
'volume_id': volume_id,
|
||||
'parent_id': parent_id,
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.project_id,
|
||||
'user_id': fake.USER_ID,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
}
|
||||
return db.backup_create(self.ctxt, backup)['id']
|
||||
|
||||
@ -160,34 +160,34 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
self.volume_file.write(os.urandom(1024))
|
||||
|
||||
def test_backup_uncompressed(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
self._create_backup_db_entry(volume_id=volume_id)
|
||||
self.flags(backup_compression_algorithm='none')
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
|
||||
def test_backup_bz2(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
self._create_backup_db_entry(volume_id=volume_id)
|
||||
self.flags(backup_compression_algorithm='bz2')
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
|
||||
def test_backup_zlib(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
self._create_backup_db_entry(volume_id=volume_id)
|
||||
self.flags(backup_compression_algorithm='zlib')
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
|
||||
def test_backup_default_container(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=None,
|
||||
backup_id=FAKE_BACKUP_ID)
|
||||
@ -204,7 +204,7 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
'_send_progress_notification')
|
||||
def test_backup_default_container_notify(self, _send_progress,
|
||||
_send_progress_end):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=None)
|
||||
# If the backup_object_number_per_notification is set to 1,
|
||||
@ -213,7 +213,7 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
CONF.set_override("backup_enable_progress_timer", False)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
self.assertTrue(_send_progress.called)
|
||||
self.assertTrue(_send_progress_end.called)
|
||||
@ -225,7 +225,7 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
CONF.set_override("backup_object_number_per_notification", 10)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
self.assertFalse(_send_progress.called)
|
||||
self.assertTrue(_send_progress_end.called)
|
||||
@ -238,25 +238,25 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
CONF.set_override("backup_enable_progress_timer", True)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
self.assertTrue(_send_progress.called)
|
||||
self.assertTrue(_send_progress_end.called)
|
||||
|
||||
def test_backup_custom_container(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
container_name = 'fake99'
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertEqual(backup['container'], container_name)
|
||||
|
||||
def test_backup_shafile(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
|
||||
def _fake_generate_object_name_prefix(self, backup):
|
||||
az = 'az_fake'
|
||||
@ -276,9 +276,9 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
container=container_name)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertEqual(backup['container'], container_name)
|
||||
|
||||
# Verify sha contents
|
||||
@ -287,7 +287,7 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
len(content1['sha256s']))
|
||||
|
||||
def test_backup_cmp_shafiles(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
|
||||
def _fake_generate_object_name_prefix(self, backup):
|
||||
az = 'az_fake'
|
||||
@ -305,24 +305,24 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
'', 1)
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP_ID)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertEqual(backup['container'], container_name)
|
||||
|
||||
# Create incremental backup with no change to contents
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup2_id,
|
||||
parent_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP2_ID,
|
||||
parent_id=fake.BACKUP_ID)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
service.backup(deltabackup, self.volume_file)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
self.assertEqual(deltabackup['container'], container_name)
|
||||
|
||||
# Compare shas from both files
|
||||
@ -333,7 +333,7 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
self.assertEqual(set(content1['sha256s']), set(content2['sha256s']))
|
||||
|
||||
def test_backup_delta_two_objects_change(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
|
||||
def _fake_generate_object_name_prefix(self, backup):
|
||||
az = 'az_fake'
|
||||
@ -354,12 +354,12 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
'', 1)
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP_ID)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertEqual(backup['container'], container_name)
|
||||
|
||||
# Create incremental backup with no change to contents
|
||||
@ -370,13 +370,13 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup2_id,
|
||||
parent_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP2_ID,
|
||||
parent_id=fake.BACKUP_ID)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
service.backup(deltabackup, self.volume_file)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
self.assertEqual(deltabackup['container'], container_name)
|
||||
|
||||
content1 = service._read_sha256file(backup)
|
||||
@ -387,7 +387,7 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
self.assertNotEqual(content1['sha256s'][20], content2['sha256s'][20])
|
||||
|
||||
def test_backup_delta_two_blocks_in_object_change(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
|
||||
def _fake_generate_object_name_prefix(self, backup):
|
||||
az = 'az_fake'
|
||||
@ -408,12 +408,12 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
'', 1)
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP_ID)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertEqual(backup['container'], container_name)
|
||||
|
||||
# Create incremental backup with no change to contents
|
||||
@ -424,13 +424,13 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup2_id,
|
||||
parent_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP2_ID,
|
||||
parent_id=fake.BACKUP_ID)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
service.backup(deltabackup, self.volume_file)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
self.assertEqual(deltabackup['container'], container_name)
|
||||
|
||||
# Verify that two shas are changed at index 16 and 20
|
||||
@ -446,13 +446,13 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
self._backup_metadata(), we want to check the process of an
|
||||
exception handler.
|
||||
"""
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
|
||||
self._create_backup_db_entry(volume_id=volume_id)
|
||||
self.flags(backup_compression_algorithm='none')
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
|
||||
def fake_backup_metadata(self, backup, object_meta):
|
||||
raise exception.BackupDriverException(message=_('fake'))
|
||||
@ -473,13 +473,13 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
self._backup_metadata(), we want to check the process when the
|
||||
second exception occurs in self.delete().
|
||||
"""
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
|
||||
self._create_backup_db_entry(volume_id=volume_id)
|
||||
self.flags(backup_compression_algorithm='none')
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
|
||||
def fake_backup_metadata(self, backup, object_meta):
|
||||
raise exception.BackupDriverException(message=_('fake'))
|
||||
@ -500,25 +500,25 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
backup, self.volume_file)
|
||||
|
||||
def test_restore_uncompressed(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
|
||||
self._create_backup_db_entry(volume_id=volume_id)
|
||||
self.flags(backup_compression_algorithm='none')
|
||||
self.flags(backup_sha_block_size_bytes=32)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
|
||||
service.backup(backup, self.volume_file)
|
||||
|
||||
with tempfile.NamedTemporaryFile() as restored_file:
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.restore(backup, volume_id, restored_file)
|
||||
self.assertTrue(filecmp.cmp(self.volume_file.name,
|
||||
restored_file.name))
|
||||
|
||||
def test_restore_bz2(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
|
||||
self._create_backup_db_entry(volume_id=volume_id)
|
||||
self.flags(backup_compression_algorithm='bz2')
|
||||
@ -526,17 +526,17 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
self.flags(backup_sha_block_size_bytes=1024)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
|
||||
with tempfile.NamedTemporaryFile() as restored_file:
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.restore(backup, volume_id, restored_file)
|
||||
self.assertTrue(filecmp.cmp(self.volume_file.name,
|
||||
restored_file.name))
|
||||
|
||||
def test_restore_zlib(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
|
||||
self._create_backup_db_entry(volume_id=volume_id)
|
||||
self.flags(backup_compression_algorithm='zlib')
|
||||
@ -544,17 +544,17 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
self.flags(backup_sha_block_size_bytes = 1024)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
|
||||
with tempfile.NamedTemporaryFile() as restored_file:
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.restore(backup, volume_id, restored_file)
|
||||
self.assertTrue(filecmp.cmp(self.volume_file.name,
|
||||
restored_file.name))
|
||||
|
||||
def test_restore_delta(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
|
||||
def _fake_generate_object_name_prefix(self, backup):
|
||||
az = 'az_fake'
|
||||
@ -575,10 +575,10 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
'', 1)
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP_ID)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
|
||||
# Create incremental backup with no change to contents
|
||||
@ -589,25 +589,25 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
|
||||
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup2_id,
|
||||
parent_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP2_ID,
|
||||
parent_id=fake.BACKUP_ID)
|
||||
self.volume_file.seek(0)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
service.backup(deltabackup, self.volume_file, True)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
|
||||
with tempfile.NamedTemporaryFile() as restored_file:
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
service.restore(backup, volume_id,
|
||||
restored_file)
|
||||
self.assertTrue(filecmp.cmp(self.volume_file.name,
|
||||
restored_file.name))
|
||||
|
||||
def test_delete(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
self._create_backup_db_entry(volume_id=volume_id)
|
||||
service = nfs.NFSBackupDriver(self.ctxt)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.delete(backup)
|
||||
|
||||
def test_get_compressor(self):
|
||||
|
@ -33,10 +33,10 @@ FAKE_SHA_BLOCK_SIZE_BYTES = 1024
|
||||
FAKE_BACKUP_ENABLE_PROGRESS_TIMER = True
|
||||
|
||||
FAKE_CONTAINER = 'fake/container'
|
||||
FAKE_BACKUP_ID = fake.backup_id
|
||||
FAKE_BACKUP_ID_PART1 = fake.backup_id[:2]
|
||||
FAKE_BACKUP_ID_PART2 = fake.backup_id[2:4]
|
||||
FAKE_BACKUP_ID_REST = fake.backup_id[4:]
|
||||
FAKE_BACKUP_ID = fake.BACKUP_ID
|
||||
FAKE_BACKUP_ID_PART1 = fake.BACKUP_ID[:2]
|
||||
FAKE_BACKUP_ID_PART2 = fake.BACKUP_ID[2:4]
|
||||
FAKE_BACKUP_ID_REST = fake.BACKUP_ID[4:]
|
||||
FAKE_BACKUP = {'id': FAKE_BACKUP_ID, 'container': None}
|
||||
|
||||
UPDATED_CONTAINER_NAME = os.path.join(FAKE_BACKUP_ID_PART1,
|
||||
|
@ -31,7 +31,7 @@ from cinder.tests.unit import fake_constants as fake
|
||||
class BackupRpcAPITestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
super(BackupRpcAPITestCase, self).setUp()
|
||||
self.context = context.RequestContext(fake.user_id, fake.project_id)
|
||||
self.context = context.RequestContext(fake.USER_ID, fake.PROJECT_ID)
|
||||
self.fake_backup_obj = fake_backup.fake_backup_obj(self.context)
|
||||
|
||||
def _test_backup_api(self, method, rpc_method, server=None, fanout=False,
|
||||
@ -111,7 +111,7 @@ class BackupRpcAPITestCase(test.TestCase):
|
||||
server='fake_volume_host',
|
||||
volume_host='fake_volume_host',
|
||||
backup=self.fake_backup_obj,
|
||||
volume_id=fake.volume_id,
|
||||
volume_id=fake.VOLUME_ID,
|
||||
version='1.1')
|
||||
|
||||
@mock.patch('oslo_messaging.RPCClient.can_send_version', return_value=True)
|
||||
|
@ -21,10 +21,10 @@ from cinder.tests.unit import fake_constants as fake
|
||||
|
||||
def fake_db_backup(**updates):
|
||||
db_backup = {
|
||||
'id': fake.backup_id,
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.project_id,
|
||||
'volume_id': fake.volume_id,
|
||||
'id': fake.BACKUP_ID,
|
||||
'user_id': fake.USER_ID,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': c_fields.BackupStatus.CREATING,
|
||||
'host': 'fake_host',
|
||||
'display_name': 'fake_name',
|
||||
|
@ -20,10 +20,10 @@ from cinder.tests.unit import fake_constants as fake
|
||||
|
||||
def fake_db_cgsnapshot(**updates):
|
||||
db_values = {
|
||||
'id': fake.cgsnapshot_id,
|
||||
'consistencygroup_id': fake.consistency_group_id,
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.project_id,
|
||||
'id': fake.CGSNAPSHOT_ID,
|
||||
'consistencygroup_id': fake.CONSISTENCY_GROUP_ID,
|
||||
'user_id': fake.USER_ID,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
}
|
||||
for name, field in objects.CGSnapshot.fields.items():
|
||||
if name in db_values:
|
||||
|
@ -20,9 +20,9 @@ from cinder.tests.unit import fake_constants as fake
|
||||
|
||||
def fake_db_consistencygroup(**updates):
|
||||
db_values = {
|
||||
'id': fake.consistency_group_id,
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.project_id,
|
||||
'id': fake.CONSISTENCY_GROUP_ID,
|
||||
'user_id': fake.USER_ID,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'host': 'FakeHost',
|
||||
'volumes': [],
|
||||
}
|
||||
|
@ -12,121 +12,62 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
action_failed_id = 'f26f181d-7891-4720-b022-b074ec1733ef'
|
||||
ACTION_FAILED_ID = 'f26f181d-7891-4720-b022-b074ec1733ef'
|
||||
action2_failed_id = '02f53bd8-3514-485b-ba60-2722ef09c016'
|
||||
ACTION2_FAILED_ID = '02f53bd8-3514-485b-ba60-2722ef09c016'
|
||||
already_exists_id = '8f7495fe-5e44-4f33-81af-4b28e9b2952f'
|
||||
ALREADY_EXISTS_ID = '8f7495fe-5e44-4f33-81af-4b28e9b2952f'
|
||||
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'
|
||||
cgsnapshot_name = 'cgsnapshot-5e34cce3-bc97-46b7-a127-5cfb95ef445d'
|
||||
CGSNAPSHOT_NAME = 'cgsnapshot-5e34cce3-bc97-46b7-a127-5cfb95ef445d'
|
||||
cgsnapshot2_id = '5c36d762-d6ba-4f04-bd07-88a298cc410a'
|
||||
CGSNAPSHOT2_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'
|
||||
consistency_group2_id = '8afc8952-9dce-4228-9f8a-706c5cb5fc82'
|
||||
CONSISTENCY_GROUP2_ID = '8afc8952-9dce-4228-9f8a-706c5cb5fc82'
|
||||
encryption_key_id = 'e8387001-745d-45d0-9e4e-0473815ef09a'
|
||||
ENCRYPTION_KEY_ID = 'e8387001-745d-45d0-9e4e-0473815ef09a'
|
||||
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'
|
||||
in_use_id = '8ee42073-4ac2-4099-8c7a-d416630e6aee'
|
||||
IN_USE_ID = '8ee42073-4ac2-4099-8c7a-d416630e6aee'
|
||||
invalid_id = 'f45dcab0-ff2a-46ec-b3b7-74d6f4bb0027'
|
||||
INVALID_ID = 'f45dcab0-ff2a-46ec-b3b7-74d6f4bb0027'
|
||||
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'
|
||||
provider2_id = '1060eccd-64bb-4ed2-86ce-aeaf135a97b8'
|
||||
PROVIDER2_ID = '1060eccd-64bb-4ed2-86ce-aeaf135a97b8'
|
||||
provider3_id = '63736819-1c95-440e-a873-b9d685afede5'
|
||||
PROVIDER3_ID = '63736819-1c95-440e-a873-b9d685afede5'
|
||||
provider4_id = '7db06e02-26b6-4282-945d-7f6c9347a7b0'
|
||||
PROVIDER4_ID = '7db06e02-26b6-4282-945d-7f6c9347a7b0'
|
||||
qos_spec_id = 'fc0f7527-79d7-44be-a4f6-3b24db8e11ac'
|
||||
QOS_SPEC_ID = 'fc0f7527-79d7-44be-a4f6-3b24db8e11ac'
|
||||
qos_spec2_id = 'c561b69d-98d9-478c-815b-6de11f5a09c9'
|
||||
QOS_SPEC2_ID = 'c561b69d-98d9-478c-815b-6de11f5a09c9'
|
||||
qos_spec3_id = '6034720b-f586-4302-a1eb-fe30672069f6'
|
||||
QOS_SPEC3_ID = '6034720b-f586-4302-a1eb-fe30672069f6'
|
||||
raise_id = 'a56762e1-4a30-4008-b997-5a438ec9c457'
|
||||
RAISE_ID = 'a56762e1-4a30-4008-b997-5a438ec9c457'
|
||||
snapshot_id = '253b2878-ec60-4793-ad19-e65496ec7aab'
|
||||
SNAPSHOT_ID = '253b2878-ec60-4793-ad19-e65496ec7aab'
|
||||
snapshot_name = 'snapshot-253b2878-ec60-4793-ad19-e65496ec7aab'
|
||||
SNAPSHOT_NAME = 'snapshot-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'
|
||||
update_failed_id = '110b29df-5e0f-4dbb-840c-ef5963d06933'
|
||||
UPDATE_FAILED_ID = '110b29df-5e0f-4dbb-840c-ef5963d06933'
|
||||
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'
|
||||
volume_name = 'volume-1e5177e7-95e5-4a0f-b170-e45f4b469f6a'
|
||||
VOLUME_NAME = 'volume-1e5177e7-95e5-4a0f-b170-e45f4b469f6a'
|
||||
volume2_id = '43a09914-e495-475f-b862-0bda3c8918e4'
|
||||
VOLUME2_ID = '43a09914-e495-475f-b862-0bda3c8918e4'
|
||||
volume2_name = 'volume-43a09914-e495-475f-b862-0bda3c8918e4'
|
||||
VOLUME2_NAME = 'volume-43a09914-e495-475f-b862-0bda3c8918e4'
|
||||
volume3_id = '1b1cf149-219c-44ac-aee3-13121a7f86a7'
|
||||
VOLUME3_ID = '1b1cf149-219c-44ac-aee3-13121a7f86a7'
|
||||
volume3_name = 'volume-1b1cf149-219c-44ac-aee3-13121a7f86a7'
|
||||
VOLUME3_NAME = 'volume-1b1cf149-219c-44ac-aee3-13121a7f86a7'
|
||||
volume4_id = '904d4602-4301-4e9b-8df1-8133b51904e6'
|
||||
VOLUME4_ID = '904d4602-4301-4e9b-8df1-8133b51904e6'
|
||||
volume4_name = 'volume-904d4602-4301-4e9b-8df1-8133b51904e6'
|
||||
VOLUME4_NAME = 'volume-904d4602-4301-4e9b-8df1-8133b51904e6'
|
||||
volume5_id = '17b0e01d-3d2d-4c31-a1aa-c962420bc3dc'
|
||||
VOLUME5_ID = '17b0e01d-3d2d-4c31-a1aa-c962420bc3dc'
|
||||
volume5_name = 'volume-17b0e01d-3d2d-4c31-a1aa-c962420bc3dc'
|
||||
VOLUME5_NAME = 'volume-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'
|
||||
volume_type4_id = '69943076-754d-4da8-8718-0b0117e9cab1'
|
||||
VOLUME_TYPE4_ID = '69943076-754d-4da8-8718-0b0117e9cab1'
|
||||
volume_type5_id = '1c450d81-8aab-459e-b338-a6569139b835'
|
||||
VOLUME_TYPE5_ID = '1c450d81-8aab-459e-b338-a6569139b835'
|
||||
will_not_be_found_id = 'ce816f65-c5aa-46d6-bd62-5272752d584a'
|
||||
WILL_NOT_BE_FOUND_ID = 'ce816f65-c5aa-46d6-bd62-5272752d584a'
|
||||
|
@ -20,8 +20,8 @@ from cinder.tests.unit import fake_constants as fake
|
||||
|
||||
def fake_db_snapshot(**updates):
|
||||
db_snapshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'volume_id': fake.volume_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': "creating",
|
||||
'progress': '0%',
|
||||
'volume_size': 1,
|
||||
|
@ -20,9 +20,9 @@ from cinder.tests.unit import fake_constants as fake
|
||||
|
||||
def fake_db_volume(**updates):
|
||||
db_volume = {
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'size': 1,
|
||||
'name': 'volume-%s' % fake.volume_id,
|
||||
'name': 'volume-%s' % fake.VOLUME_ID,
|
||||
'availability_zone': 'fake_availability_zone',
|
||||
'status': 'available',
|
||||
'attach_status': 'detached',
|
||||
@ -52,7 +52,7 @@ def fake_db_volume(**updates):
|
||||
|
||||
def fake_db_volume_type(**updates):
|
||||
db_volume_type = {
|
||||
'id': fake.volume_type_id,
|
||||
'id': fake.VOLUME_TYPE_ID,
|
||||
'name': 'type-1',
|
||||
'description': 'A fake volume type',
|
||||
'is_public': True,
|
||||
@ -78,8 +78,8 @@ def fake_db_volume_type(**updates):
|
||||
|
||||
def fake_db_volume_attachment(**updates):
|
||||
db_volume_attachment = {
|
||||
'id': fake.attachment_id,
|
||||
'volume_id': fake.volume_id,
|
||||
'id': fake.ATTACHMENT_ID,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
}
|
||||
|
||||
for name, field in objects.VolumeAttachment.fields.items():
|
||||
|
@ -26,14 +26,14 @@ from cinder.tests.unit import utils
|
||||
|
||||
|
||||
fake_backup = {
|
||||
'id': fake.backup_id,
|
||||
'volume_id': fake.volume_id,
|
||||
'id': fake.BACKUP_ID,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': fields.BackupStatus.CREATING,
|
||||
'size': 1,
|
||||
'display_name': 'fake_name',
|
||||
'display_description': 'fake_description',
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.project_id,
|
||||
'user_id': fake.USER_ID,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'temp_volume_id': None,
|
||||
'temp_snapshot_id': None,
|
||||
'snapshot_id': None,
|
||||
@ -46,10 +46,10 @@ class TestBackup(test_objects.BaseObjectsTestCase):
|
||||
|
||||
@mock.patch('cinder.db.get_by_id', return_value=fake_backup)
|
||||
def test_get_by_id(self, backup_get):
|
||||
backup = objects.Backup.get_by_id(self.context, fake.user_id)
|
||||
backup = objects.Backup.get_by_id(self.context, fake.USER_ID)
|
||||
self._compare(self, fake_backup, backup)
|
||||
backup_get.assert_called_once_with(self.context, models.Backup,
|
||||
fake.user_id)
|
||||
fake.USER_ID)
|
||||
|
||||
@mock.patch('cinder.db.sqlalchemy.api.model_query')
|
||||
def test_get_by_id_no_existing_id(self, model_query):
|
||||
@ -79,7 +79,7 @@ class TestBackup(test_objects.BaseObjectsTestCase):
|
||||
|
||||
@mock.patch('cinder.db.backup_destroy')
|
||||
def test_destroy(self, backup_destroy):
|
||||
backup = objects.Backup(context=self.context, id=fake.backup_id)
|
||||
backup = objects.Backup(context=self.context, id=fake.BACKUP_ID)
|
||||
backup.destroy()
|
||||
self.assertTrue(backup_destroy.called)
|
||||
admin_context = backup_destroy.call_args[0][0]
|
||||
@ -104,7 +104,7 @@ class TestBackup(test_objects.BaseObjectsTestCase):
|
||||
|
||||
def test_import_record(self):
|
||||
utils.replace_obj_loader(self, objects.Backup)
|
||||
backup = objects.Backup(context=self.context, id=fake.backup_id,
|
||||
backup = objects.Backup(context=self.context, id=fake.BACKUP_ID,
|
||||
parent_id=None,
|
||||
num_dependent_backups=0)
|
||||
export_string = backup.encode_record()
|
||||
@ -115,7 +115,7 @@ class TestBackup(test_objects.BaseObjectsTestCase):
|
||||
|
||||
def test_import_record_additional_info(self):
|
||||
utils.replace_obj_loader(self, objects.Backup)
|
||||
backup = objects.Backup(context=self.context, id=fake.backup_id,
|
||||
backup = objects.Backup(context=self.context, id=fake.BACKUP_ID,
|
||||
parent_id=None,
|
||||
num_dependent_backups=0)
|
||||
extra_info = {'driver': {'key1': 'value1', 'key2': 'value2'}}
|
||||
@ -139,7 +139,7 @@ class TestBackup(test_objects.BaseObjectsTestCase):
|
||||
|
||||
def test_import_record_additional_info_cant_overwrite(self):
|
||||
utils.replace_obj_loader(self, objects.Backup)
|
||||
backup = objects.Backup(context=self.context, id=fake.backup_id,
|
||||
backup = objects.Backup(context=self.context, id=fake.BACKUP_ID,
|
||||
parent_id=None,
|
||||
num_dependent_backups=0)
|
||||
export_string = backup.encode_record(id='fake_id')
|
||||
@ -169,7 +169,7 @@ class TestBackup(test_objects.BaseObjectsTestCase):
|
||||
# On the second backup_get, return the backup with an updated
|
||||
# display_name
|
||||
backup_get.side_effect = [db_backup1, db_backup2]
|
||||
backup = objects.Backup.get_by_id(self.context, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.context, fake.BACKUP_ID)
|
||||
self._compare(self, db_backup1, backup)
|
||||
|
||||
# display_name was updated, so a backup refresh should have a new value
|
||||
@ -180,9 +180,9 @@ class TestBackup(test_objects.BaseObjectsTestCase):
|
||||
call_bool = mock.call.__bool__()
|
||||
else:
|
||||
call_bool = mock.call.__nonzero__()
|
||||
backup_get.assert_has_calls([mock.call(self.context, fake.backup_id),
|
||||
backup_get.assert_has_calls([mock.call(self.context, fake.BACKUP_ID),
|
||||
call_bool,
|
||||
mock.call(self.context, fake.backup_id)])
|
||||
mock.call(self.context, fake.BACKUP_ID)])
|
||||
|
||||
|
||||
class TestBackupList(test_objects.BaseObjectsTestCase):
|
||||
|
@ -102,8 +102,8 @@ class TestCinderObject(test_objects.BaseObjectsTestCase):
|
||||
fields = {'id': fields.UUIDField(),
|
||||
'name': fields.StringField()}
|
||||
|
||||
test_obj = MyTestObject(id=fake.object_id, name='foo')
|
||||
refresh_obj = MyTestObject(id=fake.object_id, name='bar')
|
||||
test_obj = MyTestObject(id=fake.OBJECT_ID, name='foo')
|
||||
refresh_obj = MyTestObject(id=fake.OBJECT_ID, name='bar')
|
||||
with mock.patch(
|
||||
'cinder.objects.base.CinderObject.get_by_id') as get_by_id:
|
||||
get_by_id.return_value = refresh_obj
|
||||
@ -118,7 +118,7 @@ class TestCinderObject(test_objects.BaseObjectsTestCase):
|
||||
objects.base.CinderComparableObject):
|
||||
fields = {'uuid': fields.UUIDField()}
|
||||
|
||||
test_obj = MyTestObjectNoId(uuid=fake.object_id, name='foo')
|
||||
test_obj = MyTestObjectNoId(uuid=fake.OBJECT_ID, name='foo')
|
||||
self.assertRaises(NotImplementedError, test_obj.refresh)
|
||||
|
||||
|
||||
|
@ -23,13 +23,13 @@ from cinder.tests.unit.objects.test_consistencygroup import \
|
||||
fake_consistencygroup
|
||||
|
||||
fake_cgsnapshot = {
|
||||
'id': fake.cgsnapshot_id,
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.project_id,
|
||||
'id': fake.CGSNAPSHOT_ID,
|
||||
'user_id': fake.USER_ID,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'name': 'fake_name',
|
||||
'description': 'fake_description',
|
||||
'status': 'creating',
|
||||
'consistencygroup_id': fake.consistency_group_id,
|
||||
'consistencygroup_id': fake.CONSISTENCY_GROUP_ID,
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ class TestCGSnapshot(test_objects.BaseObjectsTestCase):
|
||||
return_value=fake_cgsnapshot)
|
||||
def test_get_by_id(self, cgsnapshot_get):
|
||||
cgsnapshot = objects.CGSnapshot.get_by_id(self.context,
|
||||
fake.cgsnapshot_id)
|
||||
fake.CGSNAPSHOT_ID)
|
||||
self._compare(self, fake_cgsnapshot, cgsnapshot)
|
||||
|
||||
@mock.patch('cinder.db.cgsnapshot_create',
|
||||
@ -53,7 +53,7 @@ class TestCGSnapshot(test_objects.BaseObjectsTestCase):
|
||||
|
||||
def test_create_with_id_except_exception(self):
|
||||
cgsnapshot = objects.CGSnapshot(context=self.context,
|
||||
**{'id': fake.consistency_group_id})
|
||||
**{'id': fake.CONSISTENCY_GROUP_ID})
|
||||
self.assertRaises(exception.ObjectActionError, cgsnapshot.create)
|
||||
|
||||
@mock.patch('cinder.db.cgsnapshot_update')
|
||||
@ -84,7 +84,7 @@ class TestCGSnapshot(test_objects.BaseObjectsTestCase):
|
||||
@mock.patch('cinder.db.cgsnapshot_destroy')
|
||||
def test_destroy(self, cgsnapshot_destroy):
|
||||
cgsnapshot = objects.CGSnapshot(context=self.context,
|
||||
id=fake.cgsnapshot_id)
|
||||
id=fake.CGSNAPSHOT_ID)
|
||||
cgsnapshot.destroy()
|
||||
self.assertTrue(cgsnapshot_destroy.called)
|
||||
admin_context = cgsnapshot_destroy.call_args[0][0]
|
||||
@ -98,15 +98,15 @@ class TestCGSnapshot(test_objects.BaseObjectsTestCase):
|
||||
self.context, objects.CGSnapshot(), fake_cgsnapshot)
|
||||
# Test consistencygroup lazy-loaded field
|
||||
consistencygroup = objects.ConsistencyGroup(
|
||||
context=self.context, id=fake.consistency_group_id)
|
||||
context=self.context, id=fake.CONSISTENCY_GROUP_ID)
|
||||
consistencygroup_get_by_id.return_value = consistencygroup
|
||||
self.assertEqual(consistencygroup, cgsnapshot.consistencygroup)
|
||||
consistencygroup_get_by_id.assert_called_once_with(
|
||||
self.context, cgsnapshot.consistencygroup_id)
|
||||
# Test snapshots lazy-loaded field
|
||||
snapshots_objs = [objects.Snapshot(context=self.context, id=i)
|
||||
for i in [fake.snapshot_id, fake.snapshot2_id,
|
||||
fake.snapshot3_id]]
|
||||
for i in [fake.SNAPSHOT_ID, fake.SNAPSHOT2_ID,
|
||||
fake.SNAPSHOT3_ID]]
|
||||
snapshots = objects.SnapshotList(context=self.context,
|
||||
objects=snapshots_objs)
|
||||
snapshotlist_get_for_cgs.return_value = snapshots
|
||||
@ -124,7 +124,7 @@ class TestCGSnapshot(test_objects.BaseObjectsTestCase):
|
||||
# description
|
||||
cgsnapshot_get.side_effect = [db_cgsnapshot1, db_cgsnapshot2]
|
||||
cgsnapshot = objects.CGSnapshot.get_by_id(self.context,
|
||||
fake.cgsnapshot_id)
|
||||
fake.CGSNAPSHOT_ID)
|
||||
self._compare(self, db_cgsnapshot1, cgsnapshot)
|
||||
|
||||
# description was updated, so a CGSnapshot refresh should have a new
|
||||
@ -136,10 +136,10 @@ class TestCGSnapshot(test_objects.BaseObjectsTestCase):
|
||||
else:
|
||||
call_bool = mock.call.__nonzero__()
|
||||
cgsnapshot_get.assert_has_calls([mock.call(self.context,
|
||||
fake.cgsnapshot_id),
|
||||
fake.CGSNAPSHOT_ID),
|
||||
call_bool,
|
||||
mock.call(self.context,
|
||||
fake.cgsnapshot_id)])
|
||||
fake.CGSNAPSHOT_ID)])
|
||||
|
||||
|
||||
class TestCGSnapshotList(test_objects.BaseObjectsTestCase):
|
||||
|
@ -22,27 +22,27 @@ from cinder.tests.unit import fake_constants as fake
|
||||
from cinder.tests.unit import objects as test_objects
|
||||
|
||||
fake_consistencygroup = {
|
||||
'id': fake.consistency_group_id,
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.project_id,
|
||||
'id': fake.CONSISTENCY_GROUP_ID,
|
||||
'user_id': fake.USER_ID,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'host': 'fake_host',
|
||||
'availability_zone': 'fake_az',
|
||||
'name': 'fake_name',
|
||||
'description': 'fake_description',
|
||||
'volume_type_id': fake.volume_type_id,
|
||||
'volume_type_id': fake.VOLUME_TYPE_ID,
|
||||
'status': fields.ConsistencyGroupStatus.CREATING,
|
||||
'cgsnapshot_id': fake.cgsnapshot_id,
|
||||
'cgsnapshot_id': fake.CGSNAPSHOT_ID,
|
||||
'source_cgid': None,
|
||||
}
|
||||
|
||||
fake_cgsnapshot = {
|
||||
'id': fake.cgsnapshot_id,
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.project_id,
|
||||
'id': fake.CGSNAPSHOT_ID,
|
||||
'user_id': fake.USER_ID,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'name': 'fake_name',
|
||||
'description': 'fake_description',
|
||||
'status': 'creating',
|
||||
'consistencygroup_id': fake.consistency_group_id,
|
||||
'consistencygroup_id': fake.CONSISTENCY_GROUP_ID,
|
||||
}
|
||||
|
||||
|
||||
@ -52,10 +52,10 @@ class TestConsistencyGroup(test_objects.BaseObjectsTestCase):
|
||||
return_value=fake_consistencygroup)
|
||||
def test_get_by_id(self, consistencygroup_get):
|
||||
consistencygroup = objects.ConsistencyGroup.get_by_id(
|
||||
self.context, fake.consistency_group_id)
|
||||
self.context, fake.CONSISTENCY_GROUP_ID)
|
||||
self._compare(self, fake_consistencygroup, consistencygroup)
|
||||
consistencygroup_get.assert_called_once_with(
|
||||
self.context, fake.consistency_group_id)
|
||||
self.context, fake.CONSISTENCY_GROUP_ID)
|
||||
|
||||
@mock.patch('cinder.db.sqlalchemy.api.model_query')
|
||||
def test_get_by_id_no_existing_id(self, model_query):
|
||||
@ -76,7 +76,7 @@ class TestConsistencyGroup(test_objects.BaseObjectsTestCase):
|
||||
|
||||
def test_create_with_id_except_exception(self, ):
|
||||
consistencygroup = objects.ConsistencyGroup(
|
||||
context=self.context, **{'id': fake.consistency_group_id})
|
||||
context=self.context, **{'id': fake.CONSISTENCY_GROUP_ID})
|
||||
self.assertRaises(exception.ObjectActionError, consistencygroup.create)
|
||||
|
||||
@mock.patch('cinder.db.consistencygroup_update')
|
||||
@ -94,8 +94,8 @@ class TestConsistencyGroup(test_objects.BaseObjectsTestCase):
|
||||
consistencygroup = objects.ConsistencyGroup._from_db_object(
|
||||
self.context, objects.ConsistencyGroup(), fake_consistencygroup)
|
||||
cgsnapshots_objs = [objects.CGSnapshot(context=self.context, id=i)
|
||||
for i in [fake.cgsnapshot_id, fake.cgsnapshot2_id,
|
||||
fake.cgsnapshot3_id]]
|
||||
for i in [fake.CGSNAPSHOT_ID, fake.CGSNAPSHOT2_ID,
|
||||
fake.CGSNAPSHOT3_ID]]
|
||||
cgsnapshots = objects.CGSnapshotList(objects=cgsnapshots_objs)
|
||||
consistencygroup.name = 'foobar'
|
||||
consistencygroup.cgsnapshots = cgsnapshots
|
||||
@ -108,8 +108,8 @@ class TestConsistencyGroup(test_objects.BaseObjectsTestCase):
|
||||
consistencygroup = objects.ConsistencyGroup._from_db_object(
|
||||
self.context, objects.ConsistencyGroup(), fake_consistencygroup)
|
||||
volumes_objs = [objects.Volume(context=self.context, id=i)
|
||||
for i in [fake.volume_id, fake.volume2_id,
|
||||
fake.volume3_id]]
|
||||
for i in [fake.VOLUME_ID, fake.VOLUME2_ID,
|
||||
fake.VOLUME3_ID]]
|
||||
volumes = objects.VolumeList(objects=volumes_objs)
|
||||
consistencygroup.name = 'foobar'
|
||||
consistencygroup.volumes = volumes
|
||||
@ -126,8 +126,8 @@ class TestConsistencyGroup(test_objects.BaseObjectsTestCase):
|
||||
self.context, objects.ConsistencyGroup(), fake_consistencygroup)
|
||||
# Test cgsnapshots lazy-loaded field
|
||||
cgsnapshots_objs = [objects.CGSnapshot(context=self.context, id=i)
|
||||
for i in [fake.cgsnapshot_id, fake.cgsnapshot2_id,
|
||||
fake.cgsnapshot3_id]]
|
||||
for i in [fake.CGSNAPSHOT_ID, fake.CGSNAPSHOT2_ID,
|
||||
fake.CGSNAPSHOT3_ID]]
|
||||
cgsnapshots = objects.CGSnapshotList(context=self.context,
|
||||
objects=cgsnapshots_objs)
|
||||
mock_cgsnap_get_all_by_group.return_value = cgsnapshots
|
||||
@ -137,8 +137,8 @@ class TestConsistencyGroup(test_objects.BaseObjectsTestCase):
|
||||
|
||||
# Test volumes lazy-loaded field
|
||||
volume_objs = [objects.Volume(context=self.context, id=i)
|
||||
for i in [fake.volume_id, fake.volume2_id,
|
||||
fake.volume3_id]]
|
||||
for i in [fake.VOLUME_ID, fake.VOLUME2_ID,
|
||||
fake.VOLUME3_ID]]
|
||||
volumes = objects.VolumeList(context=self.context, objects=volume_objs)
|
||||
mock_vol_get_all_by_group.return_value = volumes
|
||||
self.assertEqual(volumes, consistencygroup.volumes)
|
||||
@ -148,7 +148,7 @@ class TestConsistencyGroup(test_objects.BaseObjectsTestCase):
|
||||
@mock.patch('cinder.db.consistencygroup_destroy')
|
||||
def test_destroy(self, consistencygroup_destroy):
|
||||
consistencygroup = objects.ConsistencyGroup(
|
||||
context=self.context, id=fake.consistency_group_id)
|
||||
context=self.context, id=fake.CONSISTENCY_GROUP_ID)
|
||||
consistencygroup.destroy()
|
||||
self.assertTrue(consistencygroup_destroy.called)
|
||||
admin_context = consistencygroup_destroy.call_args[0][0]
|
||||
@ -164,7 +164,7 @@ class TestConsistencyGroup(test_objects.BaseObjectsTestCase):
|
||||
# an updated description
|
||||
consistencygroup_get.side_effect = [db_cg1, db_cg2]
|
||||
cg = objects.ConsistencyGroup.get_by_id(self.context,
|
||||
fake.consistency_group_id)
|
||||
fake.CONSISTENCY_GROUP_ID)
|
||||
self._compare(self, db_cg1, cg)
|
||||
|
||||
# description was updated, so a ConsistencyGroup refresh should have a
|
||||
@ -178,11 +178,11 @@ class TestConsistencyGroup(test_objects.BaseObjectsTestCase):
|
||||
consistencygroup_get.assert_has_calls([
|
||||
mock.call(
|
||||
self.context,
|
||||
fake.consistency_group_id),
|
||||
fake.CONSISTENCY_GROUP_ID),
|
||||
call_bool,
|
||||
mock.call(
|
||||
self.context,
|
||||
fake.consistency_group_id)])
|
||||
fake.CONSISTENCY_GROUP_ID)])
|
||||
|
||||
|
||||
class TestConsistencyGroupList(test_objects.BaseObjectsTestCase):
|
||||
|
@ -31,15 +31,15 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
fake_db_snapshot = fake_snapshot.fake_db_snapshot(
|
||||
cgsnapshot_id=fake.cgsnapshot_id)
|
||||
cgsnapshot_id=fake.CGSNAPSHOT_ID)
|
||||
del fake_db_snapshot['metadata']
|
||||
del fake_db_snapshot['volume']
|
||||
|
||||
|
||||
# NOTE(andrey-mp): make Snapshot object here to check object algorithms
|
||||
fake_snapshot_obj = {
|
||||
'id': fake.snapshot_id,
|
||||
'volume_id': fake.volume_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': "creating",
|
||||
'progress': '0%',
|
||||
'volume_size': 1,
|
||||
@ -81,11 +81,11 @@ class TestSnapshot(test_objects.BaseObjectsTestCase):
|
||||
@mock.patch('cinder.db.snapshot_create')
|
||||
def test_create_with_provider_id(self, snapshot_create):
|
||||
snapshot_create.return_value = copy.deepcopy(fake_db_snapshot)
|
||||
snapshot_create.return_value['provider_id'] = fake.provider_id
|
||||
snapshot_create.return_value['provider_id'] = fake.PROVIDER_ID
|
||||
|
||||
snapshot = objects.Snapshot(context=self.context)
|
||||
snapshot.create()
|
||||
self.assertEqual(fake.provider_id, snapshot.provider_id)
|
||||
self.assertEqual(fake.PROVIDER_ID, snapshot.provider_id)
|
||||
|
||||
@mock.patch('cinder.db.snapshot_update')
|
||||
def test_save(self, snapshot_update):
|
||||
@ -112,36 +112,36 @@ class TestSnapshot(test_objects.BaseObjectsTestCase):
|
||||
snapshot_update.assert_called_once_with(self.context, snapshot.id,
|
||||
{'display_name': 'foobar'})
|
||||
snapshot_metadata_update.assert_called_once_with(self.context,
|
||||
fake.snapshot_id,
|
||||
fake.SNAPSHOT_ID,
|
||||
{'key1': 'value1'},
|
||||
True)
|
||||
|
||||
@mock.patch('cinder.db.snapshot_destroy')
|
||||
def test_destroy(self, snapshot_destroy):
|
||||
snapshot = objects.Snapshot(context=self.context, id=fake.snapshot_id)
|
||||
snapshot = objects.Snapshot(context=self.context, id=fake.SNAPSHOT_ID)
|
||||
snapshot.destroy()
|
||||
snapshot_destroy.assert_called_once_with(self.context,
|
||||
fake.snapshot_id)
|
||||
fake.SNAPSHOT_ID)
|
||||
|
||||
@mock.patch('cinder.db.snapshot_metadata_delete')
|
||||
def test_delete_metadata_key(self, snapshot_metadata_delete):
|
||||
snapshot = objects.Snapshot(self.context, id=fake.snapshot_id)
|
||||
snapshot = objects.Snapshot(self.context, id=fake.SNAPSHOT_ID)
|
||||
snapshot.metadata = {'key1': 'value1', 'key2': 'value2'}
|
||||
self.assertEqual({}, snapshot._orig_metadata)
|
||||
snapshot.delete_metadata_key(self.context, 'key2')
|
||||
self.assertEqual({'key1': 'value1'}, snapshot.metadata)
|
||||
snapshot_metadata_delete.assert_called_once_with(self.context,
|
||||
fake.snapshot_id,
|
||||
fake.SNAPSHOT_ID,
|
||||
'key2')
|
||||
|
||||
def test_obj_fields(self):
|
||||
volume = objects.Volume(context=self.context, id=fake.volume_id,
|
||||
_name_id=fake.volume_name_id)
|
||||
snapshot = objects.Snapshot(context=self.context, id=fake.volume_id,
|
||||
volume = objects.Volume(context=self.context, id=fake.VOLUME_ID,
|
||||
_name_id=fake.VOLUME_NAME_ID)
|
||||
snapshot = objects.Snapshot(context=self.context, id=fake.VOLUME_ID,
|
||||
volume=volume)
|
||||
self.assertEqual(['name', 'volume_name'], snapshot.obj_extra_fields)
|
||||
self.assertEqual('snapshot-%s' % fake.volume_id, snapshot.name)
|
||||
self.assertEqual('volume-%s' % fake.volume_name_id,
|
||||
self.assertEqual('snapshot-%s' % fake.VOLUME_ID, snapshot.name)
|
||||
self.assertEqual('volume-%s' % fake.VOLUME_NAME_ID,
|
||||
snapshot.volume_name)
|
||||
|
||||
@mock.patch('cinder.objects.volume.Volume.get_by_id')
|
||||
@ -150,14 +150,14 @@ class TestSnapshot(test_objects.BaseObjectsTestCase):
|
||||
snapshot = objects.Snapshot._from_db_object(
|
||||
self.context, objects.Snapshot(), fake_db_snapshot)
|
||||
# Test volume lazy-loaded field
|
||||
volume = objects.Volume(context=self.context, id=fake.volume_id)
|
||||
volume = objects.Volume(context=self.context, id=fake.VOLUME_ID)
|
||||
volume_get_by_id.return_value = volume
|
||||
self.assertEqual(volume, snapshot.volume)
|
||||
volume_get_by_id.assert_called_once_with(self.context,
|
||||
snapshot.volume_id)
|
||||
# Test cgsnapshot lazy-loaded field
|
||||
cgsnapshot = objects.CGSnapshot(context=self.context,
|
||||
id=fake.cgsnapshot_id)
|
||||
id=fake.CGSNAPSHOT_ID)
|
||||
cgsnapshot_get_by_id.return_value = cgsnapshot
|
||||
self.assertEqual(cgsnapshot, snapshot.cgsnapshot)
|
||||
cgsnapshot_get_by_id.assert_called_once_with(self.context,
|
||||
@ -184,7 +184,7 @@ class TestSnapshot(test_objects.BaseObjectsTestCase):
|
||||
# On the second snapshot_get, return the snapshot with an updated
|
||||
# display_name
|
||||
snapshot_get.side_effect = [db_snapshot1, db_snapshot2]
|
||||
snapshot = objects.Snapshot.get_by_id(self.context, fake.snapshot_id)
|
||||
snapshot = objects.Snapshot.get_by_id(self.context, fake.SNAPSHOT_ID)
|
||||
self._compare(self, db_snapshot1, snapshot)
|
||||
|
||||
# display_name was updated, so a snapshot refresh should have a new
|
||||
@ -197,10 +197,10 @@ class TestSnapshot(test_objects.BaseObjectsTestCase):
|
||||
call_bool = mock.call.__nonzero__()
|
||||
snapshot_get.assert_has_calls([
|
||||
mock.call(self.context,
|
||||
fake.snapshot_id),
|
||||
fake.SNAPSHOT_ID),
|
||||
call_bool,
|
||||
mock.call(self.context,
|
||||
fake.snapshot_id)])
|
||||
fake.SNAPSHOT_ID)])
|
||||
|
||||
|
||||
class TestSnapshotList(test_objects.BaseObjectsTestCase):
|
||||
|
@ -38,8 +38,8 @@ class TestVolume(test_objects.BaseObjectsTestCase):
|
||||
def test_get_by_id(self, volume_get):
|
||||
db_volume = fake_volume.fake_db_volume()
|
||||
volume_get.return_value = db_volume
|
||||
volume = objects.Volume.get_by_id(self.context, fake.volume_id)
|
||||
volume_get.assert_called_once_with(self.context, fake.volume_id)
|
||||
volume = objects.Volume.get_by_id(self.context, fake.VOLUME_ID)
|
||||
volume_get.assert_called_once_with(self.context, fake.VOLUME_ID)
|
||||
self._compare(self, db_volume, volume)
|
||||
|
||||
@mock.patch('cinder.db.sqlalchemy.api.model_query')
|
||||
@ -143,13 +143,13 @@ class TestVolume(test_objects.BaseObjectsTestCase):
|
||||
self.assertTrue(admin_context.is_admin)
|
||||
|
||||
def test_obj_fields(self):
|
||||
volume = objects.Volume(context=self.context, id=fake.volume_id,
|
||||
name_id=fake.volume_name_id)
|
||||
volume = objects.Volume(context=self.context, id=fake.VOLUME_ID,
|
||||
name_id=fake.VOLUME_NAME_ID)
|
||||
self.assertEqual(['name', 'name_id', 'volume_metadata',
|
||||
'volume_admin_metadata', 'volume_glance_metadata'],
|
||||
volume.obj_extra_fields)
|
||||
self.assertEqual('volume-%s' % fake.volume_name_id, volume.name)
|
||||
self.assertEqual(fake.volume_name_id, volume.name_id)
|
||||
self.assertEqual('volume-%s' % fake.VOLUME_NAME_ID, volume.name)
|
||||
self.assertEqual(fake.VOLUME_NAME_ID, volume.name_id)
|
||||
|
||||
def test_obj_field_previous_status(self):
|
||||
volume = objects.Volume(context=self.context,
|
||||
@ -158,12 +158,12 @@ class TestVolume(test_objects.BaseObjectsTestCase):
|
||||
|
||||
@mock.patch('cinder.db.volume_metadata_delete')
|
||||
def test_delete_metadata_key(self, metadata_delete):
|
||||
volume = objects.Volume(self.context, id=fake.volume_id)
|
||||
volume = objects.Volume(self.context, id=fake.VOLUME_ID)
|
||||
volume.metadata = {'key1': 'value1', 'key2': 'value2'}
|
||||
self.assertEqual({}, volume._orig_metadata)
|
||||
volume.delete_metadata_key('key2')
|
||||
self.assertEqual({'key1': 'value1'}, volume.metadata)
|
||||
metadata_delete.assert_called_once_with(self.context, fake.volume_id,
|
||||
metadata_delete.assert_called_once_with(self.context, fake.VOLUME_ID,
|
||||
'key2')
|
||||
|
||||
@mock.patch('cinder.db.volume_metadata_get')
|
||||
@ -200,11 +200,11 @@ class TestVolume(test_objects.BaseObjectsTestCase):
|
||||
|
||||
# Case2. volume2.volume_type_id = 1
|
||||
fake2 = fake_volume.fake_db_volume()
|
||||
fake2.update({'volume_type_id': fake.volume_id})
|
||||
fake2.update({'volume_type_id': fake.VOLUME_ID})
|
||||
volume2 = objects.Volume._from_db_object(
|
||||
self.context, objects.Volume(), fake2)
|
||||
volume_type = objects.VolumeType(context=self.context,
|
||||
id=fake.volume_type_id)
|
||||
id=fake.VOLUME_TYPE_ID)
|
||||
mock_vt_get_by_id.return_value = volume_type
|
||||
self.assertEqual(volume_type, volume2.volume_type)
|
||||
mock_vt_get_by_id.assert_called_once_with(self.context,
|
||||
@ -212,7 +212,7 @@ class TestVolume(test_objects.BaseObjectsTestCase):
|
||||
|
||||
# Test consistencygroup lazy-loaded field
|
||||
consistencygroup = objects.ConsistencyGroup(
|
||||
context=self.context, id=fake.consistency_group_id)
|
||||
context=self.context, id=fake.CONSISTENCY_GROUP_ID)
|
||||
mock_cg_get_by_id.return_value = consistencygroup
|
||||
self.assertEqual(consistencygroup, volume.consistencygroup)
|
||||
mock_cg_get_by_id.assert_called_once_with(self.context,
|
||||
@ -220,7 +220,7 @@ class TestVolume(test_objects.BaseObjectsTestCase):
|
||||
|
||||
# Test snapshots lazy-loaded field
|
||||
snapshots = objects.SnapshotList(context=self.context,
|
||||
id=fake.snapshot_id)
|
||||
id=fake.SNAPSHOT_ID)
|
||||
mock_sl_get_all_for_volume.return_value = snapshots
|
||||
self.assertEqual(snapshots, volume.snapshots)
|
||||
mock_sl_get_all_for_volume.assert_called_once_with(self.context,
|
||||
@ -228,7 +228,7 @@ class TestVolume(test_objects.BaseObjectsTestCase):
|
||||
|
||||
# Test volume_attachment lazy-loaded field
|
||||
va_objs = [objects.VolumeAttachment(context=self.context, id=i)
|
||||
for i in [fake.object_id, fake.object2_id, fake.object3_id]]
|
||||
for i in [fake.OBJECT_ID, fake.OBJECT2_ID, fake.OBJECT3_ID]]
|
||||
va_list = objects.VolumeAttachmentList(context=self.context,
|
||||
objects=va_objs)
|
||||
mock_va_get_all_by_vol.return_value = va_list
|
||||
@ -293,7 +293,7 @@ class TestVolume(test_objects.BaseObjectsTestCase):
|
||||
# On the second volume_get, return the volume with an updated
|
||||
# display_name
|
||||
volume_get.side_effect = [db_volume1, db_volume2]
|
||||
volume = objects.Volume.get_by_id(self.context, fake.volume_id)
|
||||
volume = objects.Volume.get_by_id(self.context, fake.VOLUME_ID)
|
||||
self._compare(self, db_volume1, volume)
|
||||
|
||||
# display_name was updated, so a volume refresh should have a new value
|
||||
@ -304,9 +304,9 @@ class TestVolume(test_objects.BaseObjectsTestCase):
|
||||
call_bool = mock.call.__bool__()
|
||||
else:
|
||||
call_bool = mock.call.__nonzero__()
|
||||
volume_get.assert_has_calls([mock.call(self.context, fake.volume_id),
|
||||
volume_get.assert_has_calls([mock.call(self.context, fake.VOLUME_ID),
|
||||
call_bool,
|
||||
mock.call(self.context, fake.volume_id)])
|
||||
mock.call(self.context, fake.VOLUME_ID)])
|
||||
|
||||
def test_metadata_aliases(self):
|
||||
volume = objects.Volume(context=self.context)
|
||||
@ -337,20 +337,20 @@ class TestVolume(test_objects.BaseObjectsTestCase):
|
||||
|
||||
@mock.patch('cinder.db.volume_metadata_update', return_value={})
|
||||
@mock.patch('cinder.db.volume_update')
|
||||
@ddt.data({'src_vol_type_id': fake.volume_type_id,
|
||||
'dest_vol_type_id': fake.volume_type2_id},
|
||||
@ddt.data({'src_vol_type_id': fake.VOLUME_TYPE_ID,
|
||||
'dest_vol_type_id': fake.VOLUME_TYPE2_ID},
|
||||
{'src_vol_type_id': None,
|
||||
'dest_vol_type_id': fake.volume_type2_id})
|
||||
'dest_vol_type_id': fake.VOLUME_TYPE2_ID})
|
||||
@ddt.unpack
|
||||
def test_finish_volume_migration(self, volume_update, metadata_update,
|
||||
src_vol_type_id, dest_vol_type_id):
|
||||
src_volume_db = fake_volume.fake_db_volume(
|
||||
**{'id': fake.volume_id, 'volume_type_id': src_vol_type_id})
|
||||
**{'id': fake.VOLUME_ID, 'volume_type_id': src_vol_type_id})
|
||||
if src_vol_type_id:
|
||||
src_volume_db['volume_type'] = fake_volume.fake_db_volume_type(
|
||||
id=src_vol_type_id)
|
||||
dest_volume_db = fake_volume.fake_db_volume(
|
||||
**{'id': fake.volume2_id, 'volume_type_id': dest_vol_type_id})
|
||||
**{'id': fake.VOLUME2_ID, 'volume_type_id': dest_vol_type_id})
|
||||
if dest_vol_type_id:
|
||||
dest_volume_db['volume_type'] = fake_volume.fake_db_volume_type(
|
||||
id=dest_vol_type_id)
|
||||
|
@ -28,7 +28,7 @@ class TestVolumeAttachment(test_objects.BaseObjectsTestCase):
|
||||
db_attachment = fake_volume.fake_db_volume_attachment()
|
||||
volume_attachment_get.return_value = db_attachment
|
||||
attachment = objects.VolumeAttachment.get_by_id(self.context,
|
||||
fake.attachment_id)
|
||||
fake.ATTACHMENT_ID)
|
||||
self._compare(self, db_attachment, attachment)
|
||||
|
||||
@mock.patch('cinder.db.volume_attachment_update')
|
||||
@ -49,7 +49,7 @@ class TestVolumeAttachment(test_objects.BaseObjectsTestCase):
|
||||
# with an updated mountpoint
|
||||
attachment_get.side_effect = [db_attachment1, db_attachment2]
|
||||
attachment = objects.VolumeAttachment.get_by_id(self.context,
|
||||
fake.attachment_id)
|
||||
fake.ATTACHMENT_ID)
|
||||
self._compare(self, db_attachment1, attachment)
|
||||
|
||||
# mountpoint was updated, so a volume attachment refresh should have a
|
||||
@ -61,10 +61,10 @@ class TestVolumeAttachment(test_objects.BaseObjectsTestCase):
|
||||
else:
|
||||
call_bool = mock.call.__nonzero__()
|
||||
attachment_get.assert_has_calls([mock.call(self.context,
|
||||
fake.attachment_id),
|
||||
fake.ATTACHMENT_ID),
|
||||
call_bool,
|
||||
mock.call(self.context,
|
||||
fake.attachment_id)])
|
||||
fake.ATTACHMENT_ID)])
|
||||
|
||||
|
||||
class TestVolumeAttachmentList(test_objects.BaseObjectsTestCase):
|
||||
|
@ -28,7 +28,7 @@ class TestVolumeType(test_objects.BaseObjectsTestCase):
|
||||
db_volume_type = fake_volume.fake_db_volume_type()
|
||||
volume_type_get.return_value = db_volume_type
|
||||
volume_type = objects.VolumeType.get_by_id(self.context,
|
||||
fake.volume_type_id)
|
||||
fake.VOLUME_TYPE_ID)
|
||||
self._compare(self, db_volume_type, volume_type)
|
||||
|
||||
@mock.patch('cinder.volume.volume_types.create')
|
||||
@ -82,7 +82,7 @@ class TestVolumeType(test_objects.BaseObjectsTestCase):
|
||||
# updated description
|
||||
volume_type_get.side_effect = [db_type1, db_type2]
|
||||
volume_type = objects.VolumeType.get_by_id(self.context,
|
||||
fake.volume_type_id)
|
||||
fake.VOLUME_TYPE_ID)
|
||||
self._compare(self, db_type1, volume_type)
|
||||
|
||||
# description was updated, so a volume type refresh should have a new
|
||||
@ -94,10 +94,10 @@ class TestVolumeType(test_objects.BaseObjectsTestCase):
|
||||
else:
|
||||
call_bool = mock.call.__nonzero__()
|
||||
volume_type_get.assert_has_calls([mock.call(self.context,
|
||||
fake.volume_type_id),
|
||||
fake.VOLUME_TYPE_ID),
|
||||
call_bool,
|
||||
mock.call(self.context,
|
||||
fake.volume_type_id)])
|
||||
fake.VOLUME_TYPE_ID)])
|
||||
|
||||
|
||||
class TestVolumeTypeList(test_objects.BaseObjectsTestCase):
|
||||
|
@ -36,7 +36,7 @@ class HostFiltersTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(HostFiltersTestCase, self).setUp()
|
||||
self.context = context.RequestContext(fake.user_id, fake.project_id)
|
||||
self.context = context.RequestContext(fake.USER_ID, fake.PROJECT_ID)
|
||||
# This has a side effect of testing 'get_filter_classes'
|
||||
# when specifying a method (in this case, our standard filters)
|
||||
filter_handler = filters.HostFilterHandler('cinder.scheduler.filters')
|
||||
|
@ -301,7 +301,7 @@ class SchedulerManagerTestCase(test.TestCase):
|
||||
|
||||
ex = exception.CinderException('test')
|
||||
mock_cg.side_effect = ex
|
||||
group_id = fake.consistency_group_id
|
||||
group_id = fake.CONSISTENCY_GROUP_ID
|
||||
self.assertRaises(exception.CinderException,
|
||||
self.manager.create_consistencygroup,
|
||||
self.context,
|
||||
@ -337,7 +337,7 @@ class SchedulerTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
super(SchedulerTestCase, self).setUp()
|
||||
self.driver = self.driver_cls()
|
||||
self.context = context.RequestContext(fake.user_id, fake.project_id)
|
||||
self.context = context.RequestContext(fake.USER_ID, fake.PROJECT_ID)
|
||||
self.topic = 'fake_topic'
|
||||
|
||||
@mock.patch('cinder.scheduler.driver.Scheduler.'
|
||||
@ -380,7 +380,7 @@ class SchedulerDriverModuleTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(SchedulerDriverModuleTestCase, self).setUp()
|
||||
self.context = context.RequestContext(fake.user_id, fake.project_id)
|
||||
self.context = context.RequestContext(fake.USER_ID, fake.PROJECT_ID)
|
||||
|
||||
@mock.patch('cinder.db.volume_update')
|
||||
@mock.patch('cinder.objects.volume.Volume.get_by_id')
|
||||
|
@ -134,8 +134,8 @@ class GoogleBackupDriverTestCase(test.TestCase):
|
||||
'container': container,
|
||||
'volume_id': volume_id,
|
||||
'parent_id': parent_id,
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.project_id,
|
||||
'user_id': fake.USER_ID,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'service_metadata': service_metadata,
|
||||
}
|
||||
backup = objects.Backup(context=self.ctxt, **kwargs)
|
||||
|
@ -71,7 +71,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
def _create_backup_db_entry(self,
|
||||
volume_id=_DEFAULT_VOLUME_ID,
|
||||
container='test-container',
|
||||
backup_id=fake.backup_id, parent_id=None,
|
||||
backup_id=fake.BACKUP_ID, parent_id=None,
|
||||
service_metadata=None):
|
||||
|
||||
try:
|
||||
@ -84,8 +84,8 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
'container': container,
|
||||
'volume_id': volume_id,
|
||||
'parent_id': parent_id,
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.project_id,
|
||||
'user_id': fake.USER_ID,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'service_metadata': service_metadata,
|
||||
}
|
||||
return db.backup_create(self.ctxt, backup)['id']
|
||||
@ -159,7 +159,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
u'endpoints': [{
|
||||
u'publicURL':
|
||||
u'http://example.com'}]}]
|
||||
self.ctxt.project_id = fake.project_id
|
||||
self.ctxt.project_id = fake.PROJECT_ID
|
||||
self.override_config("backup_swift_url",
|
||||
"http://public.example.com/")
|
||||
backup = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
@ -178,7 +178,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
u'endpoints': [{
|
||||
u'adminURL':
|
||||
u'http://example.com'}]}]
|
||||
self.ctxt.project_id = fake.project_id
|
||||
self.ctxt.project_id = fake.PROJECT_ID
|
||||
self.override_config("backup_swift_auth_url",
|
||||
"http://public.example.com/")
|
||||
backup = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
@ -233,7 +233,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
self.flags(backup_compression_algorithm='none')
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
|
||||
def test_backup_bz2(self):
|
||||
@ -242,7 +242,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
self.flags(backup_compression_algorithm='bz2')
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
|
||||
def test_backup_zlib(self):
|
||||
@ -251,7 +251,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
self.flags(backup_compression_algorithm='zlib')
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
|
||||
@mock.patch.object(db, 'backup_update', wraps=db.backup_update)
|
||||
@ -261,9 +261,9 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
container=None)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertEqual('volumebackups', backup['container'])
|
||||
self.assertEqual(3, backup_update_mock.call_count)
|
||||
|
||||
@ -274,10 +274,10 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
container='existing_name')
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
|
||||
service.backup(backup, self.volume_file)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertEqual('existing_name', backup['container'])
|
||||
# Make sure we are not making a DB update when we are using the same
|
||||
# value that's already in the DB.
|
||||
@ -290,11 +290,11 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
container=None)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
with mock.patch.object(service, 'update_container_name',
|
||||
return_value='driver_name'):
|
||||
service.backup(backup, self.volume_file)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertEqual('driver_name', backup['container'])
|
||||
self.assertEqual(3, backup_update_mock.call_count)
|
||||
|
||||
@ -313,7 +313,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
CONF.set_override("backup_swift_enable_progress_timer", False)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
self.assertTrue(_send_progress.called)
|
||||
self.assertTrue(_send_progress_end.called)
|
||||
@ -325,7 +325,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
CONF.set_override("backup_object_number_per_notification", 10)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
self.assertFalse(_send_progress.called)
|
||||
self.assertTrue(_send_progress_end.called)
|
||||
@ -338,7 +338,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
CONF.set_override("backup_swift_enable_progress_timer", True)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
self.assertTrue(_send_progress.called)
|
||||
self.assertTrue(_send_progress_end.called)
|
||||
@ -350,9 +350,9 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
container=container_name)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertEqual(container_name, backup['container'])
|
||||
|
||||
def test_backup_shafile(self):
|
||||
@ -378,9 +378,9 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
fake_swift_client2.FakeSwiftClient2.Connection)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertEqual(container_name, backup['container'])
|
||||
|
||||
# Verify sha contents
|
||||
@ -407,28 +407,28 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
'', 1)
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP_ID)
|
||||
self.stubs.Set(swift, 'Connection',
|
||||
fake_swift_client2.FakeSwiftClient2.Connection)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertEqual(container_name, backup['container'])
|
||||
|
||||
# Create incremental backup with no change to contents
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup2_id,
|
||||
parent_id= fake.backup_id)
|
||||
backup_id=fake.BACKUP2_ID,
|
||||
parent_id= fake.BACKUP_ID)
|
||||
self.stubs.Set(swift, 'Connection',
|
||||
fake_swift_client2.FakeSwiftClient2.Connection)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
service.backup(deltabackup, self.volume_file)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
self.assertEqual(container_name, deltabackup['container'])
|
||||
|
||||
# Compare shas from both files
|
||||
@ -460,14 +460,14 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
'', 1)
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP_ID)
|
||||
self.stubs.Set(swift, 'Connection',
|
||||
fake_swift_client2.FakeSwiftClient2.Connection)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertEqual(container_name, backup['container'])
|
||||
|
||||
# Create incremental backup with no change to contents
|
||||
@ -478,15 +478,15 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup2_id,
|
||||
parent_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP2_ID,
|
||||
parent_id=fake.BACKUP_ID)
|
||||
self.stubs.Set(swift, 'Connection',
|
||||
fake_swift_client2.FakeSwiftClient2.Connection)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
service.backup(deltabackup, self.volume_file)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
self.assertEqual(container_name, deltabackup['container'])
|
||||
|
||||
content1 = service._read_sha256file(backup)
|
||||
@ -518,14 +518,14 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
'', 1)
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP_ID)
|
||||
self.stubs.Set(swift, 'Connection',
|
||||
fake_swift_client2.FakeSwiftClient2.Connection)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertEqual(container_name, backup['container'])
|
||||
|
||||
# Create incremental backup with no change to contents
|
||||
@ -536,15 +536,15 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup2_id,
|
||||
parent_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP2_ID,
|
||||
parent_id=fake.BACKUP_ID)
|
||||
self.stubs.Set(swift, 'Connection',
|
||||
fake_swift_client2.FakeSwiftClient2.Connection)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
service.backup(deltabackup, self.volume_file)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
self.assertEqual(container_name, deltabackup['container'])
|
||||
|
||||
# Verify that two shas are changed at index 16 and 20
|
||||
@ -560,7 +560,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
container=container_name)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertRaises(exception.SwiftConnectionFailed,
|
||||
service.backup,
|
||||
backup, self.volume_file)
|
||||
@ -578,7 +578,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
self.flags(backup_compression_algorithm='none')
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
|
||||
def fake_backup_metadata(self, backup, object_meta):
|
||||
raise exception.BackupDriverException(message=_('fake'))
|
||||
@ -605,7 +605,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
self.flags(backup_compression_algorithm='none')
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
|
||||
def fake_backup_metadata(self, backup, object_meta):
|
||||
raise exception.BackupDriverException(message=_('fake'))
|
||||
@ -631,7 +631,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
|
||||
with tempfile.NamedTemporaryFile() as volume_file:
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.restore(backup, volume_id, volume_file)
|
||||
|
||||
def test_restore_delta(self):
|
||||
@ -656,12 +656,12 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
'', 1)
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP_ID)
|
||||
self.stubs.Set(swift, 'Connection',
|
||||
fake_swift_client2.FakeSwiftClient2.Connection)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
self.volume_file.seek(0)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.backup(backup, self.volume_file)
|
||||
|
||||
# Create incremental backup with no change to contents
|
||||
@ -672,15 +672,15 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
container=container_name,
|
||||
backup_id=fake.backup2_id,
|
||||
parent_id=fake.backup_id)
|
||||
backup_id=fake.BACKUP2_ID,
|
||||
parent_id=fake.BACKUP_ID)
|
||||
self.volume_file.seek(0)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
service.backup(deltabackup, self.volume_file, True)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
deltabackup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
|
||||
with tempfile.NamedTemporaryFile() as restored_file:
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
service.restore(backup, volume_id,
|
||||
restored_file)
|
||||
self.assertTrue(filecmp.cmp(self.volume_file.name,
|
||||
@ -694,7 +694,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
|
||||
with tempfile.NamedTemporaryFile() as volume_file:
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertRaises(exception.SwiftConnectionFailed,
|
||||
service.restore,
|
||||
backup, volume_id, volume_file)
|
||||
@ -707,7 +707,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
|
||||
with tempfile.NamedTemporaryFile() as volume_file:
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertRaises(exception.InvalidBackup,
|
||||
service.restore,
|
||||
backup, volume_id, volume_file)
|
||||
@ -718,7 +718,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
self._create_backup_db_entry(volume_id=volume_id,
|
||||
service_metadata=object_prefix)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.delete(backup)
|
||||
|
||||
def test_delete_wraps_socket_error(self):
|
||||
@ -729,7 +729,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
container=container_name,
|
||||
service_metadata=object_prefix)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertRaises(exception.SwiftConnectionFailed,
|
||||
service.delete,
|
||||
backup)
|
||||
@ -746,7 +746,7 @@ class BackupSwiftTestCase(test.TestCase):
|
||||
|
||||
self._create_backup_db_entry(volume_id=volume_id)
|
||||
service = swift_dr.SwiftBackupDriver(self.ctxt)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
service.delete(backup)
|
||||
|
||||
def test_get_compressor(self):
|
||||
|
@ -259,21 +259,21 @@ class BackupTSMTestCase(test.TestCase):
|
||||
backup = {'id': backup_id,
|
||||
'size': 1,
|
||||
'container': 'test-container',
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'service_metadata': service_metadata,
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.project_id,
|
||||
'user_id': fake.USER_ID,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
}
|
||||
return db.backup_create(self.ctxt, backup)['id']
|
||||
|
||||
def test_backup_image(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
mode = 'image'
|
||||
self._create_volume_db_entry(volume_id)
|
||||
|
||||
backup_id1 = fake.backup_id
|
||||
backup_id2 = fake.backup2_id
|
||||
backup_id3 = fake.backup3_id
|
||||
backup_id1 = fake.BACKUP_ID
|
||||
backup_id2 = fake.BACKUP2_ID
|
||||
backup_id3 = fake.BACKUP3_ID
|
||||
self._create_backup_db_entry(backup_id1, mode)
|
||||
self._create_backup_db_entry(backup_id2, mode)
|
||||
self._create_backup_db_entry(backup_id3, mode)
|
||||
@ -300,24 +300,24 @@ class BackupTSMTestCase(test.TestCase):
|
||||
self.driver.delete(backup1)
|
||||
|
||||
def test_backup_file(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
mode = 'file'
|
||||
self.stubs.Set(os, 'stat', fake_stat_file)
|
||||
self._create_volume_db_entry(volume_id)
|
||||
|
||||
self._create_backup_db_entry(fake.backup_id, mode)
|
||||
self._create_backup_db_entry(fake.backup2_id, mode)
|
||||
self._create_backup_db_entry(fake.BACKUP_ID, mode)
|
||||
self._create_backup_db_entry(fake.BACKUP2_ID, mode)
|
||||
|
||||
with open(VOLUME_PATH, 'w+') as volume_file:
|
||||
# Create two backups of the volume
|
||||
backup1 = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup1 = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.driver.backup(backup1, volume_file)
|
||||
backup2 = objects.Backup.get_by_id(self.ctxt, fake.backup2_id)
|
||||
backup2 = objects.Backup.get_by_id(self.ctxt, fake.BACKUP2_ID)
|
||||
self.driver.backup(backup2, volume_file)
|
||||
|
||||
# Create a backup that fails
|
||||
self._create_backup_db_entry(fake.backup3_id, mode)
|
||||
fail_back = objects.Backup.get_by_id(self.ctxt, fake.backup3_id)
|
||||
self._create_backup_db_entry(fake.BACKUP3_ID, mode)
|
||||
fail_back = objects.Backup.get_by_id(self.ctxt, fake.BACKUP3_ID)
|
||||
self.sim.error_injection('backup', 'fail')
|
||||
self.assertRaises(exception.InvalidBackup,
|
||||
self.driver.backup, fail_back, volume_file)
|
||||
@ -331,16 +331,16 @@ class BackupTSMTestCase(test.TestCase):
|
||||
self.driver.delete(backup2)
|
||||
|
||||
def test_backup_invalid_mode(self):
|
||||
volume_id = fake.volume_id
|
||||
volume_id = fake.VOLUME_ID
|
||||
mode = 'illegal'
|
||||
self.stubs.Set(os, 'stat', fake_stat_illegal)
|
||||
self._create_volume_db_entry(volume_id)
|
||||
|
||||
self._create_backup_db_entry(fake.backup_id, mode)
|
||||
self._create_backup_db_entry(fake.BACKUP_ID, mode)
|
||||
|
||||
with open(VOLUME_PATH, 'w+') as volume_file:
|
||||
# Create two backups of the volume
|
||||
backup1 = objects.Backup.get_by_id(self.ctxt, fake.backup_id)
|
||||
backup1 = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
|
||||
self.assertRaises(exception.InvalidBackup,
|
||||
self.driver.backup, backup1, volume_file)
|
||||
|
||||
|
@ -47,7 +47,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
|
||||
provider_location='1 2 3 /dev/loop1',
|
||||
provider_auth='a b c',
|
||||
attached_mode='rw',
|
||||
id=fake.volume_id)
|
||||
id=fake.VOLUME_ID)
|
||||
TEST_CONNECTOR = {'host': 'localhost1'}
|
||||
|
||||
data = self.drv.initialize_connection(TEST_VOLUME1, TEST_CONNECTOR)
|
||||
@ -63,7 +63,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
|
||||
provider_location='1 2 3 /dev/loop2',
|
||||
provider_auth='d e f',
|
||||
attached_mode='rw',
|
||||
id=fake.volume2_id)
|
||||
id=fake.VOLUME2_ID)
|
||||
_init_conn.return_value = 'data'
|
||||
|
||||
data = self.drv.initialize_connection(TEST_VOLUME2, TEST_CONNECTOR)
|
||||
@ -75,7 +75,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
|
||||
'target_iqn': '2',
|
||||
'target_lun': 3,
|
||||
'target_portal': '1',
|
||||
'volume_id': fake.volume2_id}}
|
||||
'volume_id': fake.VOLUME2_ID}}
|
||||
|
||||
self.assertEqual(expected_data['data'], data['data'])
|
||||
|
||||
@ -91,7 +91,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
|
||||
@mock.patch('os.path.exists', return_value=True)
|
||||
@mock.patch('cinder.volume.utils.clear_volume')
|
||||
def test_delete_volume_path_exist(self, _clear_volume, _exists):
|
||||
TEST_VOLUME = obj_volume.Volume(name_id=fake.volume_name_id,
|
||||
TEST_VOLUME = obj_volume.Volume(name_id=fake.VOLUME_NAME_ID,
|
||||
size=1,
|
||||
provider_location='/dev/loop1',
|
||||
display_name='vol1',
|
||||
@ -120,7 +120,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
|
||||
lp_mocked.assert_called_once_with(TEST_VOLUME2)
|
||||
|
||||
def test__update_provider_location(self):
|
||||
TEST_VOLUME = obj_volume.Volume(name_id=fake.volume_name_id,
|
||||
TEST_VOLUME = obj_volume.Volume(name_id=fake.VOLUME_NAME_ID,
|
||||
size=1,
|
||||
display_name='vol1')
|
||||
with mock.patch.object(obj_volume.Volume, 'update') as update_mocked, \
|
||||
@ -130,7 +130,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
|
||||
save_mocked.assert_called_once_with()
|
||||
|
||||
def test_create_volume(self):
|
||||
TEST_VOLUME = obj_volume.Volume(name_id=fake.volume_name_id,
|
||||
TEST_VOLUME = obj_volume.Volume(name_id=fake.VOLUME_NAME_ID,
|
||||
size=1,
|
||||
display_name='vol1')
|
||||
|
||||
@ -167,11 +167,11 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
|
||||
|
||||
@mock.patch('cinder.volume.utils.copy_volume')
|
||||
def test_create_cloned_volume(self, _copy_volume):
|
||||
TEST_SRC = obj_volume.Volume(id=fake.volume_id,
|
||||
name_id=fake.volume_name_id,
|
||||
TEST_SRC = obj_volume.Volume(id=fake.VOLUME_ID,
|
||||
name_id=fake.VOLUME_NAME_ID,
|
||||
size=1,
|
||||
provider_location='/dev/loop1')
|
||||
TEST_VOLUME = obj_volume.Volume(name_id=fake.volume2_name_id,
|
||||
TEST_VOLUME = obj_volume.Volume(name_id=fake.VOLUME2_NAME_ID,
|
||||
size=1,
|
||||
display_name='vol1')
|
||||
|
||||
@ -198,7 +198,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
|
||||
|
||||
@mock.patch.object(cinder.image.image_utils, 'fetch_to_raw')
|
||||
def test_copy_image_to_volume(self, _fetch_to_raw):
|
||||
TEST_VOLUME = obj_volume.Volume(name_id=fake.volume_name_id,
|
||||
TEST_VOLUME = obj_volume.Volume(name_id=fake.VOLUME_NAME_ID,
|
||||
size=1,
|
||||
provider_location='/dev/loop1')
|
||||
TEST_IMAGE_SERVICE = "image_service"
|
||||
@ -322,14 +322,14 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
|
||||
|
||||
@mock.patch('cinder.volume.utils.copy_volume')
|
||||
def test_create_snapshot(self, _copy_volume):
|
||||
TEST_VOLUME = obj_volume.Volume(id=fake.volume_id,
|
||||
name_id=fake.volume_name_id,
|
||||
TEST_VOLUME = obj_volume.Volume(id=fake.VOLUME_ID,
|
||||
name_id=fake.VOLUME_NAME_ID,
|
||||
size=1,
|
||||
display_name='vol1',
|
||||
status='available',
|
||||
provider_location='/dev/loop1')
|
||||
TEST_SNAP = obj_snap.Snapshot(id=fake.snapshot_id,
|
||||
volume_id=fake.volume_id,
|
||||
TEST_SNAP = obj_snap.Snapshot(id=fake.SNAPSHOT_ID,
|
||||
volume_id=fake.VOLUME_ID,
|
||||
volume_size=1024,
|
||||
provider_location='/dev/loop2',
|
||||
volume=TEST_VOLUME)
|
||||
@ -352,14 +352,14 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
|
||||
TEST_SNAP, '/dev/loop2')
|
||||
|
||||
def test_create_snapshot_with_not_available_volume(self):
|
||||
TEST_VOLUME = obj_volume.Volume(id=fake.volume_id,
|
||||
name_id=fake.volume_name_id,
|
||||
TEST_VOLUME = obj_volume.Volume(id=fake.VOLUME_ID,
|
||||
name_id=fake.VOLUME_NAME_ID,
|
||||
size=1,
|
||||
display_name='vol1',
|
||||
status='in use',
|
||||
provider_location='/dev/loop1')
|
||||
TEST_SNAP = obj_snap.Snapshot(id=fake.snapshot_id,
|
||||
volume_id=fake.volume_id,
|
||||
TEST_SNAP = obj_snap.Snapshot(id=fake.SNAPSHOT_ID,
|
||||
volume_id=fake.VOLUME_ID,
|
||||
volume_size=1024,
|
||||
provider_location='/dev/loop2',
|
||||
volume=TEST_VOLUME)
|
||||
@ -369,11 +369,11 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
|
||||
|
||||
@mock.patch('cinder.volume.utils.copy_volume')
|
||||
def test_create_volume_from_snapshot(self, _copy_volume):
|
||||
TEST_SNAP = obj_snap.Snapshot(volume_id=fake.volume_id,
|
||||
TEST_SNAP = obj_snap.Snapshot(volume_id=fake.VOLUME_ID,
|
||||
volume_size=1024,
|
||||
provider_location='/dev/loop1')
|
||||
TEST_VOLUME = obj_volume.Volume(id=fake.volume_id,
|
||||
name_id=fake.volume_name_id,
|
||||
TEST_VOLUME = obj_volume.Volume(id=fake.VOLUME_ID,
|
||||
name_id=fake.VOLUME_NAME_ID,
|
||||
size=1,
|
||||
display_name='vol1',
|
||||
provider_location='/dev/loop2')
|
||||
@ -400,7 +400,7 @@ class TestBlockDeviceDriver(cinder.test.TestCase):
|
||||
@mock.patch('os.path.exists', return_value=True)
|
||||
@mock.patch('cinder.volume.utils.clear_volume')
|
||||
def test_delete_snapshot(self, _clear_volume, _exists):
|
||||
TEST_SNAP = obj_snap.Snapshot(volume_id=fake.volume_id,
|
||||
TEST_SNAP = obj_snap.Snapshot(volume_id=fake.VOLUME_ID,
|
||||
provider_location='/dev/loop1',
|
||||
status='available')
|
||||
|
||||
|
@ -206,7 +206,7 @@ class DellSCSanFCDriverTestCase(test.TestCase):
|
||||
mock_close_connection,
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
volume = {'id': fake.volume_id}
|
||||
volume = {'id': fake.VOLUME_ID}
|
||||
connector = self.connector
|
||||
res = self.driver.initialize_connection(volume, connector)
|
||||
expected = {'data':
|
||||
@ -222,7 +222,7 @@ class DellSCSanFCDriverTestCase(test.TestCase):
|
||||
|
||||
self.assertEqual(expected, res, 'Unexpected return data')
|
||||
# verify find_volume has been called and that is has been called twice
|
||||
mock_find_volume.assert_called_once_with(fake.volume_id, None)
|
||||
mock_find_volume.assert_called_once_with(fake.VOLUME_ID, None)
|
||||
mock_get_volume.assert_called_once_with(self.VOLUME[u'instanceId'])
|
||||
|
||||
@mock.patch.object(dell_storagecenter_api.StorageCenterApi,
|
||||
@ -249,7 +249,7 @@ class DellSCSanFCDriverTestCase(test.TestCase):
|
||||
mock_close_connection,
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
volume = {'id': fake.volume_id}
|
||||
volume = {'id': fake.VOLUME_ID}
|
||||
connector = self.connector
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.driver.initialize_connection,
|
||||
@ -280,7 +280,7 @@ class DellSCSanFCDriverTestCase(test.TestCase):
|
||||
mock_close_connection,
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
volume = {'id': fake.volume_id}
|
||||
volume = {'id': fake.VOLUME_ID}
|
||||
connector = self.connector
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.driver.initialize_connection,
|
||||
@ -307,7 +307,7 @@ class DellSCSanFCDriverTestCase(test.TestCase):
|
||||
mock_close_connection,
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
volume = {'id': fake.volume_id}
|
||||
volume = {'id': fake.VOLUME_ID}
|
||||
connector = self.connector
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.driver.initialize_connection,
|
||||
@ -335,7 +335,7 @@ class DellSCSanFCDriverTestCase(test.TestCase):
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
# Test case where map_volume returns None (no mappings)
|
||||
volume = {'id': fake.volume_id}
|
||||
volume = {'id': fake.VOLUME_ID}
|
||||
connector = self.connector
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.driver.initialize_connection,
|
||||
@ -372,7 +372,7 @@ class DellSCSanFCDriverTestCase(test.TestCase):
|
||||
mock_close_connection,
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
volume = {'id': fake.volume_id}
|
||||
volume = {'id': fake.VOLUME_ID}
|
||||
connector = self.connector
|
||||
res = self.driver.terminate_connection(volume, connector)
|
||||
mock_unmap_volume.assert_called_once_with(self.VOLUME, self.SCSERVER)
|
||||
@ -410,7 +410,7 @@ class DellSCSanFCDriverTestCase(test.TestCase):
|
||||
mock_close_connection,
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
volume = {'id': fake.volume_id}
|
||||
volume = {'id': fake.VOLUME_ID}
|
||||
connector = self.connector
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.driver.terminate_connection,
|
||||
@ -447,7 +447,7 @@ class DellSCSanFCDriverTestCase(test.TestCase):
|
||||
mock_close_connection,
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
volume = {'id': fake.volume_id}
|
||||
volume = {'id': fake.VOLUME_ID}
|
||||
connector = self.connector
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.driver.terminate_connection,
|
||||
@ -480,7 +480,7 @@ class DellSCSanFCDriverTestCase(test.TestCase):
|
||||
mock_close_connection,
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
volume = {'id': fake.volume_id}
|
||||
volume = {'id': fake.VOLUME_ID}
|
||||
connector = self.connector
|
||||
# self.assertRaises(exception.VolumeBackendAPIException,
|
||||
# self.driver.terminate_connection,
|
||||
@ -521,7 +521,7 @@ class DellSCSanFCDriverTestCase(test.TestCase):
|
||||
mock_close_connection,
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
volume = {'id': fake.volume_id}
|
||||
volume = {'id': fake.VOLUME_ID}
|
||||
connector = self.connector
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.driver.terminate_connection,
|
||||
@ -559,7 +559,7 @@ class DellSCSanFCDriverTestCase(test.TestCase):
|
||||
mock_open_connection,
|
||||
mock_init):
|
||||
# Test case where get_volume_count is zero
|
||||
volume = {'id': fake.volume_id}
|
||||
volume = {'id': fake.VOLUME_ID}
|
||||
connector = self.connector
|
||||
res = self.driver.terminate_connection(volume, connector)
|
||||
mock_unmap_volume.assert_called_once_with(self.VOLUME, self.SCSERVER)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -285,30 +285,30 @@ REPLICATED_PGSNAPS = [
|
||||
"data_transferred": 318
|
||||
}]
|
||||
REPLICATED_VOLUME_OBJS = [
|
||||
fake_volume.fake_volume_obj(None, id=fake.volume_id),
|
||||
fake_volume.fake_volume_obj(None, id=fake.volume2_id),
|
||||
fake_volume.fake_volume_obj(None, id=fake.volume3_id),
|
||||
fake_volume.fake_volume_obj(None, id=fake.VOLUME_ID),
|
||||
fake_volume.fake_volume_obj(None, id=fake.VOLUME2_ID),
|
||||
fake_volume.fake_volume_obj(None, id=fake.VOLUME3_ID),
|
||||
]
|
||||
REPLICATED_VOLUME_SNAPS = [
|
||||
{
|
||||
"source": "array1:volume-%s-cinder" % fake.volume_id,
|
||||
"source": "array1:volume-%s-cinder" % fake.VOLUME_ID,
|
||||
"serial": "BBA481C01639104E0001D5F7",
|
||||
"created": "2014-12-04T22:59:38Z",
|
||||
"name": "array1:cinder-repl-pg.2.volume-%s-cinder" % fake.volume_id,
|
||||
"name": "array1:cinder-repl-pg.2.volume-%s-cinder" % fake.VOLUME_ID,
|
||||
"size": 1048576
|
||||
},
|
||||
{
|
||||
"source": "array1:volume-%s-cinder" % fake.volume2_id,
|
||||
"source": "array1:volume-%s-cinder" % fake.VOLUME2_ID,
|
||||
"serial": "BBA481C01639104E0001D5F8",
|
||||
"created": "2014-12-04T22:59:38Z",
|
||||
"name": "array1:cinder-repl-pg.2.volume-%s-cinder" % fake.volume2_id,
|
||||
"name": "array1:cinder-repl-pg.2.volume-%s-cinder" % fake.VOLUME2_ID,
|
||||
"size": 1048576
|
||||
},
|
||||
{
|
||||
"source": "array1:volume-%s-cinder" % fake.volume3_id,
|
||||
"source": "array1:volume-%s-cinder" % fake.VOLUME3_ID,
|
||||
"serial": "BBA481C01639104E0001D5F9",
|
||||
"created": "2014-12-04T22:59:38Z",
|
||||
"name": "array1:cinder-repl-pg.2.volume-%s-cinder" % fake.volume3_id,
|
||||
"name": "array1:cinder-repl-pg.2.volume-%s-cinder" % fake.VOLUME3_ID,
|
||||
"size": 1048576
|
||||
}
|
||||
]
|
||||
|
@ -34,7 +34,7 @@ from cinder.objects import fields
|
||||
from cinder import quota
|
||||
from cinder import quota_utils
|
||||
from cinder import test
|
||||
from cinder.tests.unit import fake_constants as fakes
|
||||
from cinder.tests.unit import fake_constants as fake
|
||||
import cinder.tests.unit.image.fake
|
||||
from cinder import volume
|
||||
|
||||
@ -62,8 +62,8 @@ class QuotaIntegrationTestCase(test.TestCase):
|
||||
quota_backups=2,
|
||||
quota_backup_gigabytes=20)
|
||||
|
||||
self.user_id = fakes.user_id
|
||||
self.project_id = fakes.project_id
|
||||
self.user_id = fake.USER_ID
|
||||
self.project_id = fake.PROJECT_ID
|
||||
self.context = context.RequestContext(self.user_id,
|
||||
self.project_id,
|
||||
is_admin=True)
|
||||
@ -91,8 +91,8 @@ class QuotaIntegrationTestCase(test.TestCase):
|
||||
|
||||
def _create_snapshot(self, volume):
|
||||
snapshot = objects.Snapshot(self.context)
|
||||
snapshot.user_id = self.user_id or fakes.user_id
|
||||
snapshot.project_id = self.project_id or fakes.project_id
|
||||
snapshot.user_id = self.user_id or fake.USER_ID
|
||||
snapshot.project_id = self.project_id or fake.PROJECT_ID
|
||||
snapshot.volume_id = volume['id']
|
||||
snapshot.volume_size = volume['size']
|
||||
snapshot.host = volume['host']
|
||||
|
@ -116,10 +116,10 @@ class SheepdogDriverTestDataGenerator(object):
|
||||
|
||||
TEST_VOL_DATA = {
|
||||
'size': 1,
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'provider_auth': None,
|
||||
'host': 'host@backendsec#unit_test_pool',
|
||||
'project_id': fake.project_id,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'provider_location': 'location',
|
||||
'display_name': 'vol1',
|
||||
'display_description': 'unit test volume',
|
||||
@ -129,10 +129,10 @@ class SheepdogDriverTestDataGenerator(object):
|
||||
|
||||
TEST_CLONED_VOL_DATA = {
|
||||
'size': 2,
|
||||
'id': fake.volume2_id,
|
||||
'id': fake.VOLUME2_ID,
|
||||
'provider_auth': None,
|
||||
'host': 'host@backendsec#unit_test_pool',
|
||||
'project_id': fake.project_id,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'provider_location': 'location',
|
||||
'display_name': 'vol3',
|
||||
'display_description': 'unit test cloned volume',
|
||||
@ -141,11 +141,11 @@ class SheepdogDriverTestDataGenerator(object):
|
||||
}
|
||||
|
||||
TEST_SNAPSHOT_DATA = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
}
|
||||
|
||||
TEST_BACKUP_VOL_DATA = {
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
}
|
||||
|
||||
COLLIE_NODE_INFO = """
|
||||
|
@ -4234,8 +4234,8 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
|
||||
new=testutils.ZeroIntervalLoopingCall)
|
||||
def test_storwize_consistency_group_snapshot(self):
|
||||
cg_type = self._create_consistency_group_volume_type()
|
||||
self.ctxt.user_id = fake.user_id
|
||||
self.ctxt.project_id = fake.project_id
|
||||
self.ctxt.user_id = fake.USER_ID
|
||||
self.ctxt.project_id = fake.PROJECT_ID
|
||||
cg = self._create_consistencygroup_in_db(volume_type_id=cg_type['id'])
|
||||
|
||||
model_update = self.driver.create_consistencygroup(self.ctxt, cg)
|
||||
@ -4273,8 +4273,8 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
|
||||
def test_storwize_consistency_group_from_src_invalid(self):
|
||||
# Invalid input case for create cg from src
|
||||
cg_type = self._create_consistency_group_volume_type()
|
||||
self.ctxt.user_id = fake.user_id
|
||||
self.ctxt.project_id = fake.project_id
|
||||
self.ctxt.user_id = fake.USER_ID
|
||||
self.ctxt.project_id = fake.PROJECT_ID
|
||||
# create cg in db
|
||||
cg = self._create_consistencygroup_in_db(volume_type_id=cg_type['id'])
|
||||
|
||||
@ -4353,8 +4353,8 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
|
||||
def test_storwize_consistency_group_from_src(self):
|
||||
# Valid case for create cg from src
|
||||
cg_type = self._create_consistency_group_volume_type()
|
||||
self.ctxt.user_id = fake.user_id
|
||||
self.ctxt.project_id = fake.project_id
|
||||
self.ctxt.user_id = fake.USER_ID
|
||||
self.ctxt.project_id = fake.PROJECT_ID
|
||||
pool = _get_test_pool()
|
||||
# Create cg in db
|
||||
cg = self._create_consistencygroup_in_db(volume_type_id=cg_type['id'])
|
||||
|
@ -95,8 +95,8 @@ def create_snapshot(volume_id, size=1, metadata=None, ctxt=None,
|
||||
metadata = metadata or {}
|
||||
snap = objects.Snapshot(ctxt or context.get_admin_context())
|
||||
snap.volume_size = size
|
||||
snap.user_id = fake.user_id
|
||||
snap.project_id = fake.project_id
|
||||
snap.user_id = fake.USER_ID
|
||||
snap.project_id = fake.PROJECT_ID
|
||||
snap.volume_id = volume_id
|
||||
snap.status = "creating"
|
||||
if metadata is not None:
|
||||
@ -135,7 +135,7 @@ class BaseVolumeTestCase(test.TestCase):
|
||||
self.volume.message_api = mock.Mock()
|
||||
self.configuration = mock.Mock(conf.Configuration)
|
||||
self.context = context.get_admin_context()
|
||||
self.context.user_id = fake.user_id
|
||||
self.context.user_id = fake.USER_ID
|
||||
# NOTE(mriedem): The id is hard-coded here for tracking race fail
|
||||
# assertions with the notification code, it's part of an
|
||||
# elastic-recheck query so don't remove it or change it.
|
||||
@ -668,7 +668,7 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
'volume_id': volume_id,
|
||||
'volume_type': None,
|
||||
'snapshot_id': None,
|
||||
'user_id': fake.user_id,
|
||||
'user_id': fake.USER_ID,
|
||||
'launched_at': 'DONTCARE',
|
||||
'size': 1,
|
||||
'replication_status': 'disabled',
|
||||
@ -1034,21 +1034,21 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
self.assertIsNotNone(volume['encryption_key_id'])
|
||||
|
||||
def test_create_volume_with_provider_id(self):
|
||||
volume_params_with_provider_id = dict(provider_id=fake.provider_id,
|
||||
volume_params_with_provider_id = dict(provider_id=fake.PROVIDER_ID,
|
||||
**self.volume_params)
|
||||
|
||||
volume = tests_utils.create_volume(self.context,
|
||||
**volume_params_with_provider_id)
|
||||
|
||||
self.volume.create_volume(self.context, volume['id'])
|
||||
self.assertEqual(fake.provider_id, volume['provider_id'])
|
||||
self.assertEqual(fake.PROVIDER_ID, volume['provider_id'])
|
||||
|
||||
@mock.patch.object(keymgr, 'API', new=fake_keymgr.fake_api)
|
||||
def test_create_delete_volume_with_encrypted_volume_type(self):
|
||||
db_vol_type = db.volume_type_create(
|
||||
self.context, {'id': fake.volume_type_id, 'name': 'LUKS'})
|
||||
self.context, {'id': fake.VOLUME_TYPE_ID, 'name': 'LUKS'})
|
||||
db.volume_type_encryption_create(
|
||||
self.context, fake.volume_type_id,
|
||||
self.context, fake.VOLUME_TYPE_ID,
|
||||
{'control_location': 'front-end', 'provider': ENCRYPTION_PROVIDER})
|
||||
|
||||
volume = self.volume_api.create(self.context,
|
||||
@ -1157,10 +1157,10 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
'volume_get_all_by_project') as by_project:
|
||||
with mock.patch.object(volume_api.db,
|
||||
'volume_get_all') as get_all:
|
||||
db_volume = {'volume_type_id': fake.volume_type_id,
|
||||
db_volume = {'volume_type_id': fake.VOLUME_TYPE_ID,
|
||||
'name': 'fake_name',
|
||||
'host': 'fake_host',
|
||||
'id': fake.volume_id}
|
||||
'id': fake.VOLUME_ID}
|
||||
|
||||
volume = fake_volume.fake_db_volume(**db_volume)
|
||||
by_project.return_value = [volume]
|
||||
@ -1248,7 +1248,7 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
biz_type = db.volume_type_get_by_name(context.get_admin_context(),
|
||||
'biz')
|
||||
|
||||
snapshot = {'id': fake.snapshot_id,
|
||||
snapshot = {'id': fake.SNAPSHOT_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 10,
|
||||
'volume_type_id': biz_type['id']}
|
||||
@ -1309,7 +1309,7 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
biz_type = db.volume_type_get_by_name(context.get_admin_context(),
|
||||
'biz')
|
||||
|
||||
source_vol = {'id': fake.volume_id,
|
||||
source_vol = {'id': fake.VOLUME_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 10,
|
||||
'volume_type': biz_type,
|
||||
@ -1380,7 +1380,7 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
'id': '34e54c31-3bc8-5c1d-9fff-2225bcce4b59',
|
||||
'description': None}
|
||||
|
||||
source_vol = {'id': fake.volume_id,
|
||||
source_vol = {'id': fake.VOLUME_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 10,
|
||||
'volume_type': biz_type,
|
||||
@ -1425,13 +1425,13 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
'id': '34e54c31-3bc8-5c1d-9fff-2225bcce4b59',
|
||||
'description': None}
|
||||
|
||||
source_vol = {'id': fake.volume_id,
|
||||
source_vol = {'id': fake.VOLUME_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 10,
|
||||
'volume_type': biz_type,
|
||||
'volume_type_id': biz_type['id']}
|
||||
|
||||
snapshot = {'id': fake.snapshot_id,
|
||||
snapshot = {'id': fake.SNAPSHOT_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 10,
|
||||
'volume_type_id': biz_type['id']}
|
||||
@ -2022,7 +2022,7 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
def test_create_volume_from_snapshot_fail_bad_size(self):
|
||||
"""Test volume can't be created from snapshot with bad volume size."""
|
||||
volume_api = cinder.volume.api.API()
|
||||
snapshot = {'id': fake.snapshot_id,
|
||||
snapshot = {'id': fake.SNAPSHOT_ID,
|
||||
'status': 'available',
|
||||
'volume_size': 10}
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(self.context,
|
||||
@ -2081,9 +2081,9 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
1,
|
||||
'name',
|
||||
'description',
|
||||
snapshot=fake.snapshot_id,
|
||||
image_id=fake.image_id,
|
||||
source_volume=fake.volume_id)
|
||||
snapshot=fake.SNAPSHOT_ID,
|
||||
image_id=fake.IMAGE_ID,
|
||||
source_volume=fake.VOLUME_ID)
|
||||
|
||||
@mock.patch.object(cinder.volume.targets.iscsi.ISCSITarget,
|
||||
'_get_target_chap_auth')
|
||||
@ -2097,10 +2097,10 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
mock_get_target):
|
||||
"""Make sure initialize_connection returns correct information."""
|
||||
_fake_admin_meta = {'fake-key': 'fake-value'}
|
||||
_fake_volume = {'volume_type_id': fake.volume_type_id,
|
||||
_fake_volume = {'volume_type_id': fake.VOLUME_TYPE_ID,
|
||||
'name': 'fake_name',
|
||||
'host': 'fake_host',
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'volume_admin_metadata': _fake_admin_meta}
|
||||
|
||||
_mock_volume_get.return_value = _fake_volume
|
||||
@ -2126,14 +2126,14 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
# initialize_connection() passes qos_specs that is designated to
|
||||
# be consumed by front-end or both front-end and back-end
|
||||
conn_info = self.volume.initialize_connection(self.context,
|
||||
fake.volume_id,
|
||||
fake.VOLUME_ID,
|
||||
connector)
|
||||
self.assertDictMatch(qos_specs_expected,
|
||||
conn_info['data']['qos_specs'])
|
||||
|
||||
qos_values.update({'consumer': 'both'})
|
||||
conn_info = self.volume.initialize_connection(self.context,
|
||||
fake.volume_id,
|
||||
fake.VOLUME_ID,
|
||||
connector)
|
||||
self.assertDictMatch(qos_specs_expected,
|
||||
conn_info['data']['qos_specs'])
|
||||
@ -2142,7 +2142,7 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
qos_values.update({'consumer': 'back-end'})
|
||||
type_qos.return_value = dict(qos_specs=qos_values)
|
||||
conn_info = self.volume.initialize_connection(self.context,
|
||||
fake.volume_id,
|
||||
fake.VOLUME_ID,
|
||||
connector)
|
||||
self.assertIsNone(conn_info['data']['qos_specs'])
|
||||
|
||||
@ -2155,10 +2155,10 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
_mock_create_export):
|
||||
"""Test exception path for create_export failure."""
|
||||
_fake_admin_meta = {'fake-key': 'fake-value'}
|
||||
_fake_volume = {'volume_type_id': fake.volume_type_id,
|
||||
_fake_volume = {'volume_type_id': fake.VOLUME_TYPE_ID,
|
||||
'name': 'fake_name',
|
||||
'host': 'fake_host',
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'volume_admin_metadata': _fake_admin_meta}
|
||||
|
||||
_mock_volume_get.return_value = _fake_volume
|
||||
@ -2170,7 +2170,7 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.volume.initialize_connection,
|
||||
self.context,
|
||||
fake.volume_id,
|
||||
fake.VOLUME_ID,
|
||||
connector)
|
||||
|
||||
@mock.patch.object(cinder.volume.targets.iscsi.ISCSITarget,
|
||||
@ -2193,7 +2193,7 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
fake_volume = {'volume_type_id': None,
|
||||
'name': 'fake_name',
|
||||
'host': 'fake_host',
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'volume_admin_metadata': fake_admin_meta,
|
||||
'encryption_key_id': ('d371e7bb-7392-4c27-'
|
||||
'ac0b-ebd9f5d16078')}
|
||||
@ -3071,8 +3071,8 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
'display_name': None,
|
||||
'snapshot_id': snapshot_id,
|
||||
'status': 'creating',
|
||||
'tenant_id': fake.project_id,
|
||||
'user_id': fake.user_id,
|
||||
'tenant_id': fake.PROJECT_ID,
|
||||
'user_id': fake.USER_ID,
|
||||
'volume_id': volume['id'],
|
||||
'volume_size': 1,
|
||||
'availability_zone': 'nova',
|
||||
@ -3516,7 +3516,7 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
# unnecessary attributes should be removed from image volume
|
||||
vol.consistencygroup = None
|
||||
result = self.volume._clone_image_volume(self.context, vol,
|
||||
{'id': fake.volume_id})
|
||||
{'id': fake.VOLUME_ID})
|
||||
|
||||
self.assertNotEqual(False, result)
|
||||
mock_reserve.assert_called_once_with(self.context, volumes=1,
|
||||
@ -3532,7 +3532,7 @@ class VolumeTestCase(BaseVolumeTestCase):
|
||||
vol = tests_utils.create_volume(self.context, **self.volume_params)
|
||||
with mock.patch.object(objects, 'Volume', side_effect=ValueError):
|
||||
self.assertFalse(self.volume._clone_image_volume(
|
||||
self.context, vol, {'id': fake.volume_id}))
|
||||
self.context, vol, {'id': fake.VOLUME_ID}))
|
||||
|
||||
mock_reserve.assert_called_once_with(self.context, volumes=1,
|
||||
gigabytes=vol.size)
|
||||
@ -4383,7 +4383,7 @@ class VolumeMigrationTestCase(BaseVolumeTestCase):
|
||||
# stub out driver and rpc functions
|
||||
self.stubs.Set(self.volume.driver, 'migrate_volume',
|
||||
lambda x, y, z, new_type_id=None: (
|
||||
True, {'user_id': fake.user_id}))
|
||||
True, {'user_id': fake.USER_ID}))
|
||||
|
||||
volume = tests_utils.create_volume(self.context, size=0,
|
||||
host=CONF.host,
|
||||
@ -4434,7 +4434,7 @@ class VolumeMigrationTestCase(BaseVolumeTestCase):
|
||||
def test_migrate_volume_generic(self, volume_get,
|
||||
migrate_volume_completion,
|
||||
nova_api):
|
||||
fake_db_new_volume = {'status': 'available', 'id': fake.volume_id}
|
||||
fake_db_new_volume = {'status': 'available', 'id': fake.VOLUME_ID}
|
||||
fake_new_volume = fake_volume.fake_db_volume(**fake_db_new_volume)
|
||||
new_volume_obj = fake_volume.fake_volume_obj(self.context,
|
||||
**fake_new_volume)
|
||||
@ -4462,7 +4462,7 @@ class VolumeMigrationTestCase(BaseVolumeTestCase):
|
||||
migrate_volume_completion,
|
||||
nova_api):
|
||||
attached_host = 'some-host'
|
||||
fake_volume_id = fake.volume_id
|
||||
fake_volume_id = fake.VOLUME_ID
|
||||
fake_db_new_volume = {'status': 'available', 'id': fake_volume_id}
|
||||
fake_new_volume = fake_volume.fake_db_volume(**fake_db_new_volume)
|
||||
host_obj = {'host': 'newhost', 'capabilities': {}}
|
||||
@ -4555,7 +4555,7 @@ class VolumeMigrationTestCase(BaseVolumeTestCase):
|
||||
'migrate_volume') as mock_migrate_volume:
|
||||
mock_migrate_volume.side_effect = (
|
||||
lambda x, y, z, new_type_id=None: (
|
||||
True, {'user_id': fake.user_id}))
|
||||
True, {'user_id': fake.USER_ID}))
|
||||
self.volume.migrate_volume(self.context, volume.id, host_obj,
|
||||
False, volume=volume)
|
||||
self.assertEqual('newhost', volume.host)
|
||||
@ -4566,9 +4566,9 @@ class VolumeMigrationTestCase(BaseVolumeTestCase):
|
||||
def test_update_migrated_volume(self, volume_update):
|
||||
fake_host = 'fake_host'
|
||||
fake_new_host = 'fake_new_host'
|
||||
fake_update = {'_name_id': fake.volume2_name_id,
|
||||
fake_update = {'_name_id': fake.VOLUME2_NAME_ID,
|
||||
'provider_location': 'updated_location'}
|
||||
fake_elevated = context.RequestContext(fake.user_id, self.project_id,
|
||||
fake_elevated = context.RequestContext(fake.USER_ID, self.project_id,
|
||||
is_admin=True)
|
||||
volume = tests_utils.create_volume(self.context, size=1,
|
||||
status='available',
|
||||
@ -4577,9 +4577,9 @@ class VolumeMigrationTestCase(BaseVolumeTestCase):
|
||||
self.context, size=1,
|
||||
status='available',
|
||||
provider_location='fake_provider_location',
|
||||
_name_id=fake.volume_name_id,
|
||||
_name_id=fake.VOLUME_NAME_ID,
|
||||
host=fake_new_host)
|
||||
new_volume._name_id = fake.volume_name_id
|
||||
new_volume._name_id = fake.VOLUME_NAME_ID
|
||||
new_volume.provider_location = 'fake_provider_location'
|
||||
fake_update_error = {'_name_id': new_volume._name_id,
|
||||
'provider_location':
|
||||
@ -4603,7 +4603,7 @@ class VolumeMigrationTestCase(BaseVolumeTestCase):
|
||||
volume_update.reset_mock()
|
||||
# Reset the volume objects to their original value, since they
|
||||
# were changed in the last call.
|
||||
new_volume._name_id = fake.volume_name_id
|
||||
new_volume._name_id = fake.VOLUME_NAME_ID
|
||||
new_volume.provider_location = 'fake_provider_location'
|
||||
migrate_update.side_effect = NotImplementedError
|
||||
self.volume.update_migrated_volume(self.context, volume,
|
||||
@ -5106,7 +5106,7 @@ class VolumeMigrationTestCase(BaseVolumeTestCase):
|
||||
class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
||||
def test_delete_volume_in_consistency_group(self):
|
||||
"""Test deleting a volume that's tied to a consistency group fails."""
|
||||
consistencygroup_id = fake.consistency_group_id
|
||||
consistencygroup_id = fake.CONSISTENCY_GROUP_ID
|
||||
volume_api = cinder.volume.api.API()
|
||||
self.volume_params.update({'status': 'available',
|
||||
'consistencygroup_id': consistencygroup_id})
|
||||
@ -5157,7 +5157,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
||||
'availability_zone': 'nova',
|
||||
'tenant_id': self.context.project_id,
|
||||
'created_at': 'DONTCARE',
|
||||
'user_id': fake.user_id,
|
||||
'user_id': fake.USER_ID,
|
||||
'consistencygroup_id': group.id
|
||||
}
|
||||
self.assertDictMatch(expected, msg['payload'])
|
||||
@ -5235,7 +5235,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
||||
'availability_zone': 'nova',
|
||||
'tenant_id': self.context.project_id,
|
||||
'created_at': 'DONTCARE',
|
||||
'user_id': fake.user_id,
|
||||
'user_id': fake.USER_ID,
|
||||
'consistencygroup_id': group.id
|
||||
}
|
||||
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE, cg.status)
|
||||
@ -5341,7 +5341,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
||||
'availability_zone': 'nova',
|
||||
'tenant_id': self.context.project_id,
|
||||
'created_at': 'DONTCARE',
|
||||
'user_id': fake.user_id,
|
||||
'user_id': fake.USER_ID,
|
||||
'consistencygroup_id': group2.id,
|
||||
}
|
||||
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE, cg2.status)
|
||||
@ -5414,21 +5414,21 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
||||
self.volume.delete_consistencygroup(self.context, group)
|
||||
|
||||
def test_sort_snapshots(self):
|
||||
vol1 = {'id': fake.volume_id, 'name': 'volume 1',
|
||||
'snapshot_id': fake.snapshot_id,
|
||||
'consistencygroup_id': fake.consistency_group_id}
|
||||
vol2 = {'id': fake.volume2_id, 'name': 'volume 2',
|
||||
'snapshot_id': fake.snapshot2_id,
|
||||
'consistencygroup_id': fake.consistency_group_id}
|
||||
vol3 = {'id': fake.volume3_id, 'name': 'volume 3',
|
||||
'snapshot_id': fake.snapshot3_id,
|
||||
'consistencygroup_id': fake.consistency_group_id}
|
||||
snp1 = {'id': fake.snapshot_id, 'name': 'snap 1',
|
||||
'cgsnapshot_id': fake.consistency_group_id}
|
||||
snp2 = {'id': fake.snapshot2_id, 'name': 'snap 2',
|
||||
'cgsnapshot_id': fake.consistency_group_id}
|
||||
snp3 = {'id': fake.snapshot3_id, 'name': 'snap 3',
|
||||
'cgsnapshot_id': fake.consistency_group_id}
|
||||
vol1 = {'id': fake.VOLUME_ID, 'name': 'volume 1',
|
||||
'snapshot_id': fake.SNAPSHOT_ID,
|
||||
'consistencygroup_id': fake.CONSISTENCY_GROUP_ID}
|
||||
vol2 = {'id': fake.VOLUME2_ID, 'name': 'volume 2',
|
||||
'snapshot_id': fake.SNAPSHOT2_ID,
|
||||
'consistencygroup_id': fake.CONSISTENCY_GROUP_ID}
|
||||
vol3 = {'id': fake.VOLUME3_ID, 'name': 'volume 3',
|
||||
'snapshot_id': fake.SNAPSHOT3_ID,
|
||||
'consistencygroup_id': fake.CONSISTENCY_GROUP_ID}
|
||||
snp1 = {'id': fake.SNAPSHOT_ID, 'name': 'snap 1',
|
||||
'cgsnapshot_id': fake.CONSISTENCY_GROUP_ID}
|
||||
snp2 = {'id': fake.SNAPSHOT2_ID, 'name': 'snap 2',
|
||||
'cgsnapshot_id': fake.CONSISTENCY_GROUP_ID}
|
||||
snp3 = {'id': fake.SNAPSHOT3_ID, 'name': 'snap 3',
|
||||
'cgsnapshot_id': fake.CONSISTENCY_GROUP_ID}
|
||||
snp1_obj = fake_snapshot.fake_snapshot_obj(self.context, **snp1)
|
||||
snp2_obj = fake_snapshot.fake_snapshot_obj(self.context, **snp2)
|
||||
snp3_obj = fake_snapshot.fake_snapshot_obj(self.context, **snp3)
|
||||
@ -5452,7 +5452,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
||||
i += 1
|
||||
self.assertEqual(vol['snapshot_id'], snap.id)
|
||||
|
||||
snapshots[2]['id'] = fake.will_not_be_found_id
|
||||
snapshots[2]['id'] = fake.WILL_NOT_BE_FOUND_ID
|
||||
self.assertRaises(exception.SnapshotNotFound,
|
||||
self.volume._sort_snapshots,
|
||||
volumes, snapshots)
|
||||
@ -5509,8 +5509,8 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
||||
def _create_cgsnapshot(self, group_id, volume_id, size='0'):
|
||||
"""Create a cgsnapshot object."""
|
||||
cgsnap = objects.CGSnapshot(self.context)
|
||||
cgsnap.user_id = fake.user_id
|
||||
cgsnap.project_id = fake.project_id
|
||||
cgsnap.user_id = fake.USER_ID
|
||||
cgsnap.project_id = fake.PROJECT_ID
|
||||
cgsnap.consistencygroup_id = group_id
|
||||
cgsnap.status = "creating"
|
||||
cgsnap.create()
|
||||
@ -5518,8 +5518,8 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
||||
# Create a snapshot object
|
||||
snap = objects.Snapshot(context.get_admin_context())
|
||||
snap.volume_size = size
|
||||
snap.user_id = fake.user_id
|
||||
snap.project_id = fake.project_id
|
||||
snap.user_id = fake.USER_ID
|
||||
snap.project_id = fake.PROJECT_ID
|
||||
snap.volume_id = volume_id
|
||||
snap.status = "available"
|
||||
snap.cgsnapshot_id = cgsnap.id
|
||||
@ -5580,8 +5580,8 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
||||
'name': None,
|
||||
'cgsnapshot_id': cgsnapshot.id,
|
||||
'status': 'creating',
|
||||
'tenant_id': fake.project_id,
|
||||
'user_id': fake.user_id,
|
||||
'tenant_id': fake.PROJECT_ID,
|
||||
'user_id': fake.USER_ID,
|
||||
'consistencygroup_id': group.id
|
||||
}
|
||||
self.assertDictMatch(expected, msg['payload'])
|
||||
@ -5947,7 +5947,7 @@ class CopyVolumeToImageTestCase(BaseVolumeTestCase):
|
||||
'container_format': 'bare',
|
||||
'disk_format': 'raw'
|
||||
}
|
||||
self.volume_id = fake.volume_id
|
||||
self.volume_id = fake.VOLUME_ID
|
||||
self.addCleanup(db.volume_destroy, self.context, self.volume_id)
|
||||
|
||||
self.volume_attrs = {
|
||||
@ -6208,40 +6208,40 @@ class GetActiveByWindowTestCase(BaseVolumeTestCase):
|
||||
self.ctx = context.get_admin_context(read_deleted="yes")
|
||||
self.db_attrs = [
|
||||
{
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'host': 'devstack',
|
||||
'project_id': fake.project_id,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
|
||||
'deleted': True, 'status': 'deleted',
|
||||
'deleted_at': datetime.datetime(1, 2, 1, 1, 1, 1),
|
||||
},
|
||||
|
||||
{
|
||||
'id': fake.volume2_id,
|
||||
'id': fake.VOLUME2_ID,
|
||||
'host': 'devstack',
|
||||
'project_id': fake.project_id,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
|
||||
'deleted': True, 'status': 'deleted',
|
||||
'deleted_at': datetime.datetime(1, 3, 10, 1, 1, 1),
|
||||
},
|
||||
{
|
||||
'id': fake.volume3_id,
|
||||
'id': fake.VOLUME3_ID,
|
||||
'host': 'devstack',
|
||||
'project_id': fake.project_id,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'created_at': datetime.datetime(1, 1, 1, 1, 1, 1),
|
||||
'deleted': True, 'status': 'deleted',
|
||||
'deleted_at': datetime.datetime(1, 5, 1, 1, 1, 1),
|
||||
},
|
||||
{
|
||||
'id': fake.volume4_id,
|
||||
'id': fake.VOLUME4_ID,
|
||||
'host': 'devstack',
|
||||
'project_id': fake.project_id,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'created_at': datetime.datetime(1, 3, 10, 1, 1, 1),
|
||||
},
|
||||
{
|
||||
'id': fake.volume5_id,
|
||||
'id': fake.VOLUME5_ID,
|
||||
'host': 'devstack',
|
||||
'project_id': fake.project_id,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'created_at': datetime.datetime(1, 5, 1, 1, 1, 1),
|
||||
}
|
||||
]
|
||||
@ -6268,17 +6268,17 @@ class GetActiveByWindowTestCase(BaseVolumeTestCase):
|
||||
self.context,
|
||||
datetime.datetime(1, 3, 1, 1, 1, 1),
|
||||
datetime.datetime(1, 4, 1, 1, 1, 1),
|
||||
project_id=fake.project_id)
|
||||
project_id=fake.PROJECT_ID)
|
||||
self.assertEqual(3, len(volumes))
|
||||
self.assertEqual(fake.volume2_id, volumes[0].id)
|
||||
self.assertEqual(fake.volume3_id, volumes[1].id)
|
||||
self.assertEqual(fake.volume4_id, volumes[2].id)
|
||||
self.assertEqual(fake.VOLUME2_ID, volumes[0].id)
|
||||
self.assertEqual(fake.VOLUME3_ID, volumes[1].id)
|
||||
self.assertEqual(fake.VOLUME4_ID, volumes[2].id)
|
||||
|
||||
def test_snapshot_get_active_by_window(self):
|
||||
# Find all all snapshots valid within a timeframe window.
|
||||
db.volume_create(self.context, {'id': fake.volume_id})
|
||||
db.volume_create(self.context, {'id': fake.VOLUME_ID})
|
||||
for i in range(5):
|
||||
self.db_attrs[i]['volume_id'] = fake.volume_id
|
||||
self.db_attrs[i]['volume_id'] = fake.VOLUME_ID
|
||||
|
||||
# Not in window
|
||||
del self.db_attrs[0]['id']
|
||||
@ -6311,11 +6311,11 @@ class GetActiveByWindowTestCase(BaseVolumeTestCase):
|
||||
datetime.datetime(1, 4, 1, 1, 1, 1)).objects
|
||||
self.assertEqual(3, len(snapshots))
|
||||
self.assertEqual(snap2.id, snapshots[0].id)
|
||||
self.assertEqual(fake.volume_id, snapshots[0].volume_id)
|
||||
self.assertEqual(fake.VOLUME_ID, snapshots[0].volume_id)
|
||||
self.assertEqual(snap3.id, snapshots[1].id)
|
||||
self.assertEqual(fake.volume_id, snapshots[1].volume_id)
|
||||
self.assertEqual(fake.VOLUME_ID, snapshots[1].volume_id)
|
||||
self.assertEqual(snap4.id, snapshots[2].id)
|
||||
self.assertEqual(fake.volume_id, snapshots[2].volume_id)
|
||||
self.assertEqual(fake.VOLUME_ID, snapshots[2].volume_id)
|
||||
|
||||
|
||||
class DriverTestCase(test.TestCase):
|
||||
@ -6374,8 +6374,8 @@ class GenericVolumeDriverTestCase(DriverTestCase):
|
||||
mock_file_open,
|
||||
mock_temporary_chown):
|
||||
vol = tests_utils.create_volume(self.context)
|
||||
self.context.user_id = fake.user_id
|
||||
self.context.project_id = fake.project_id
|
||||
self.context.user_id = fake.USER_ID
|
||||
self.context.project_id = fake.PROJECT_ID
|
||||
backup = tests_utils.create_backup(self.context,
|
||||
vol['id'])
|
||||
backup_obj = objects.Backup.get_by_id(self.context, backup.id)
|
||||
@ -6414,8 +6414,8 @@ class GenericVolumeDriverTestCase(DriverTestCase):
|
||||
status='backing-up',
|
||||
previous_status='in-use')
|
||||
temp_vol = tests_utils.create_volume(self.context)
|
||||
self.context.user_id = fake.user_id
|
||||
self.context.project_id = fake.project_id
|
||||
self.context.user_id = fake.USER_ID
|
||||
self.context.project_id = fake.PROJECT_ID
|
||||
backup = tests_utils.create_backup(self.context,
|
||||
vol['id'])
|
||||
backup_obj = objects.Backup.get_by_id(self.context, backup.id)
|
||||
@ -6470,8 +6470,8 @@ class GenericVolumeDriverTestCase(DriverTestCase):
|
||||
vol = tests_utils.create_volume(self.context,
|
||||
status='backing-up',
|
||||
previous_status='in-use')
|
||||
self.context.user_id = fake.user_id
|
||||
self.context.project_id = fake.project_id
|
||||
self.context.user_id = fake.USER_ID
|
||||
self.context.project_id = fake.PROJECT_ID
|
||||
backup = tests_utils.create_backup(self.context,
|
||||
vol['id'])
|
||||
backup_obj = objects.Backup.get_by_id(self.context, backup.id)
|
||||
@ -6574,8 +6574,8 @@ class GenericVolumeDriverTestCase(DriverTestCase):
|
||||
|
||||
def test_get_backup_device_available(self):
|
||||
vol = tests_utils.create_volume(self.context)
|
||||
self.context.user_id = fake.user_id
|
||||
self.context.project_id = fake.project_id
|
||||
self.context.user_id = fake.USER_ID
|
||||
self.context.project_id = fake.PROJECT_ID
|
||||
backup = tests_utils.create_backup(self.context,
|
||||
vol['id'])
|
||||
backup_obj = objects.Backup.get_by_id(self.context, backup.id)
|
||||
@ -6592,8 +6592,8 @@ class GenericVolumeDriverTestCase(DriverTestCase):
|
||||
status='backing-up',
|
||||
previous_status='in-use')
|
||||
temp_vol = tests_utils.create_volume(self.context)
|
||||
self.context.user_id = fake.user_id
|
||||
self.context.project_id = fake.project_id
|
||||
self.context.user_id = fake.USER_ID
|
||||
self.context.project_id = fake.PROJECT_ID
|
||||
backup = tests_utils.create_backup(self.context,
|
||||
vol['id'])
|
||||
backup_obj = objects.Backup.get_by_id(self.context, backup.id)
|
||||
@ -6610,7 +6610,7 @@ class GenericVolumeDriverTestCase(DriverTestCase):
|
||||
self.assertEqual(temp_vol.id, backup_obj.temp_volume_id)
|
||||
|
||||
def test__create_temp_volume_from_snapshot(self):
|
||||
volume_dict = {'id': fake.snapshot_id,
|
||||
volume_dict = {'id': fake.SNAPSHOT_ID,
|
||||
'host': 'fakehost',
|
||||
'availability_zone': 'fakezone',
|
||||
'size': 1}
|
||||
@ -6781,8 +6781,8 @@ class LVMVolumeDriverTestCase(DriverTestCase):
|
||||
|
||||
backup = {}
|
||||
backup['volume_id'] = volume_id
|
||||
backup['user_id'] = fake.user_id
|
||||
backup['project_id'] = fake.project_id
|
||||
backup['user_id'] = fake.USER_ID
|
||||
backup['project_id'] = fake.PROJECT_ID
|
||||
backup['host'] = socket.gethostname()
|
||||
backup['availability_zone'] = '1'
|
||||
backup['display_name'] = 'test_check_for_setup_error'
|
||||
@ -6808,8 +6808,8 @@ class LVMVolumeDriverTestCase(DriverTestCase):
|
||||
mock_file_open,
|
||||
mock_temporary_chown):
|
||||
vol = tests_utils.create_volume(self.context)
|
||||
self.context.user_id = fake.user_id
|
||||
self.context.project_id = fake.project_id
|
||||
self.context.user_id = fake.USER_ID
|
||||
self.context.project_id = fake.PROJECT_ID
|
||||
backup = tests_utils.create_backup(self.context,
|
||||
vol['id'])
|
||||
backup_obj = objects.Backup.get_by_id(self.context, backup.id)
|
||||
@ -6836,7 +6836,7 @@ class LVMVolumeDriverTestCase(DriverTestCase):
|
||||
|
||||
def test_retype_volume(self):
|
||||
vol = tests_utils.create_volume(self.context)
|
||||
new_type = fake.volume_type_id
|
||||
new_type = fake.VOLUME_TYPE_ID
|
||||
diff = {}
|
||||
host = 'fake_host'
|
||||
retyped = self.volume.driver.retype(self.context, vol, new_type,
|
||||
@ -6844,8 +6844,8 @@ class LVMVolumeDriverTestCase(DriverTestCase):
|
||||
self.assertTrue(retyped)
|
||||
|
||||
def test_update_migrated_volume(self):
|
||||
fake_volume_id = fake.volume_id
|
||||
fake_new_volume_id = fake.volume2_id
|
||||
fake_volume_id = fake.VOLUME_ID
|
||||
fake_new_volume_id = fake.VOLUME2_ID
|
||||
fake_provider = 'fake_provider'
|
||||
original_volume_name = CONF.volume_name_template % fake_volume_id
|
||||
current_name = CONF.volume_name_template % fake_new_volume_id
|
||||
@ -6893,8 +6893,8 @@ class LVMVolumeDriverTestCase(DriverTestCase):
|
||||
vol = tests_utils.create_volume(self.context,
|
||||
status='backing-up',
|
||||
previous_status='in-use')
|
||||
self.context.user_id = fake.user_id
|
||||
self.context.project_id = fake.project_id
|
||||
self.context.user_id = fake.USER_ID
|
||||
self.context.project_id = fake.PROJECT_ID
|
||||
|
||||
mock_volume_get.return_value = vol
|
||||
temp_snapshot = tests_utils.create_snapshot(self.context, vol['id'])
|
||||
@ -7304,7 +7304,7 @@ class LVMVolumeDriverTestCase(DriverTestCase):
|
||||
|
||||
vol_name = 'volume-d8cd1feb-2dcc-404d-9b15-b86fe3bec0a1'
|
||||
ref = {'source-name': 'fake_lv'}
|
||||
vol = {'name': vol_name, 'id': fake.volume_id, 'size': 0}
|
||||
vol = {'name': vol_name, 'id': fake.VOLUME_ID, 'size': 0}
|
||||
|
||||
with mock.patch.object(self.volume.driver.vg, 'rename_volume'):
|
||||
model_update = self.volume.driver.manage_existing(vol, ref)
|
||||
@ -7335,7 +7335,7 @@ class LVMVolumeDriverTestCase(DriverTestCase):
|
||||
self._setup_stubs_for_manage_existing()
|
||||
|
||||
ref = {'source-name': 'fake_lv'}
|
||||
vol = {'name': 'test', 'id': fake.volume_id, 'size': 0}
|
||||
vol = {'name': 'test', 'id': fake.VOLUME_ID, 'size': 0}
|
||||
|
||||
def _rename_volume(old_name, new_name):
|
||||
self.assertEqual(ref['source-name'], old_name)
|
||||
@ -7359,7 +7359,7 @@ class LVMVolumeDriverTestCase(DriverTestCase):
|
||||
self._setup_stubs_for_manage_existing()
|
||||
|
||||
ref = {'source-name': 'fake_lv_bad_size'}
|
||||
vol = {'name': 'test', 'id': fake.volume_id, 'size': 2}
|
||||
vol = {'name': 'test', 'id': fake.VOLUME_ID, 'size': 2}
|
||||
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.volume.driver.manage_existing_get_size,
|
||||
@ -7392,7 +7392,7 @@ class LVMVolumeDriverTestCase(DriverTestCase):
|
||||
self._setup_stubs_for_manage_existing()
|
||||
|
||||
ref = {'source-name': 'fake_lv'}
|
||||
snp = {'name': 'test', 'id': fake.snapshot_id, 'size': 0}
|
||||
snp = {'name': 'test', 'id': fake.SNAPSHOT_ID, 'size': 0}
|
||||
|
||||
def _rename_volume(old_name, new_name):
|
||||
self.assertEqual(ref['source-name'], old_name)
|
||||
@ -7420,7 +7420,7 @@ class LVMVolumeDriverTestCase(DriverTestCase):
|
||||
ref = {'source-name': 'fake_nonexistent_lv'}
|
||||
snp = {
|
||||
'name': 'test',
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'size': 0,
|
||||
'status': 'available',
|
||||
}
|
||||
@ -7439,7 +7439,7 @@ class LVMVolumeDriverTestCase(DriverTestCase):
|
||||
self._setup_stubs_for_manage_existing()
|
||||
|
||||
ref = {'source-name': 'fake_lv_bad_size'}
|
||||
snp = {'name': 'test', 'id': fake.snapshot_id, 'size': 2}
|
||||
snp = {'name': 'test', 'id': fake.SNAPSHOT_ID, 'size': 2}
|
||||
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.volume.driver.manage_existing_snapshot_get_size,
|
||||
|
@ -709,8 +709,8 @@ class VolumeRpcAPITestCase(test.TestCase):
|
||||
def test_manage_existing_snapshot(self, mock_can_send_version):
|
||||
volume_update = {'host': 'fake_host'}
|
||||
snpshot = {
|
||||
'id': fake.snapshot_id,
|
||||
'volume_id': fake.volume_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'status': "creating",
|
||||
'progress': '0%',
|
||||
'volume_size': 0,
|
||||
|
@ -33,8 +33,8 @@ class VolumeTransferTestCase(test.TestCase):
|
||||
"""Test cases for volume transfer code."""
|
||||
def setUp(self):
|
||||
super(VolumeTransferTestCase, self).setUp()
|
||||
self.ctxt = context.RequestContext(user_id=fake.user_id,
|
||||
project_id=fake.project_id)
|
||||
self.ctxt = context.RequestContext(user_id=fake.USER_ID,
|
||||
project_id=fake.PROJECT_ID)
|
||||
self.updated_at = datetime.datetime(1, 1, 1, 1, 1, 1)
|
||||
|
||||
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
|
||||
@ -142,18 +142,18 @@ class VolumeTransferTestCase(test.TestCase):
|
||||
self.addCleanup(svc.stop)
|
||||
tx_api = transfer_api.API()
|
||||
volume = utils.create_volume(self.ctxt,
|
||||
volume_type_id=fake.volume_type_id,
|
||||
volume_type_id=fake.VOLUME_TYPE_ID,
|
||||
updated_at=self.updated_at)
|
||||
transfer = tx_api.create(self.ctxt, volume.id, 'Description')
|
||||
|
||||
self.ctxt.user_id = fake.user2_id
|
||||
self.ctxt.project_id = fake.project2_id
|
||||
self.ctxt.user_id = fake.USER2_ID
|
||||
self.ctxt.project_id = fake.PROJECT2_ID
|
||||
response = tx_api.accept(self.ctxt,
|
||||
transfer['id'],
|
||||
transfer['auth_key'])
|
||||
volume = objects.Volume.get_by_id(self.ctxt, volume.id)
|
||||
self.assertEqual(fake.project2_id, volume.project_id)
|
||||
self.assertEqual(fake.user2_id, volume.user_id)
|
||||
self.assertEqual(fake.PROJECT2_ID, volume.project_id)
|
||||
self.assertEqual(fake.USER2_ID, volume.user_id)
|
||||
|
||||
self.assertEqual(response['volume_id'], volume.id,
|
||||
'Unexpected volume id in response.')
|
||||
@ -171,13 +171,13 @@ class VolumeTransferTestCase(test.TestCase):
|
||||
# QUOTAS.add_volume_type_opts
|
||||
reserve_opt = {'volumes': 1, 'gigabytes': 1}
|
||||
release_opt = {'volumes': -1, 'gigabytes': -1}
|
||||
calls = [mock.call(self.ctxt, reserve_opt, fake.volume_type_id),
|
||||
mock.call(self.ctxt, release_opt, fake.volume_type_id)]
|
||||
calls = [mock.call(self.ctxt, reserve_opt, fake.VOLUME_TYPE_ID),
|
||||
mock.call(self.ctxt, release_opt, fake.VOLUME_TYPE_ID)]
|
||||
mock_quota_voltype.assert_has_calls(calls)
|
||||
|
||||
# QUOTAS.reserve
|
||||
calls = [mock.call(mock.ANY, **reserve_opt),
|
||||
mock.call(mock.ANY, project_id=fake.project_id,
|
||||
mock.call(mock.ANY, project_id=fake.PROJECT_ID,
|
||||
**release_opt)]
|
||||
mock_quota_reserve.assert_has_calls(calls)
|
||||
|
||||
@ -190,7 +190,7 @@ class VolumeTransferTestCase(test.TestCase):
|
||||
self.addCleanup(svc.stop)
|
||||
tx_api = transfer_api.API()
|
||||
volume = utils.create_volume(self.ctxt,
|
||||
volume_type_id=fake.volume_type_id,
|
||||
volume_type_id=fake.VOLUME_TYPE_ID,
|
||||
updated_at=self.updated_at)
|
||||
transfer = tx_api.create(self.ctxt, volume.id, 'Description')
|
||||
fake_overs = ['volumes_lvmdriver-3']
|
||||
@ -204,8 +204,8 @@ class VolumeTransferTestCase(test.TestCase):
|
||||
quotas=fake_quotas,
|
||||
usages=fake_usages)
|
||||
|
||||
self.ctxt.user_id = fake.user2_id
|
||||
self.ctxt.project_id = fake.project2_id
|
||||
self.ctxt.user_id = fake.USER2_ID
|
||||
self.ctxt.project_id = fake.PROJECT2_ID
|
||||
self.assertRaises(exception.VolumeLimitExceeded,
|
||||
tx_api.accept,
|
||||
self.ctxt,
|
||||
@ -222,8 +222,8 @@ class VolumeTransferTestCase(test.TestCase):
|
||||
ts = tx_api.get_all(self.ctxt)
|
||||
self.assertEqual(1, len(ts), 'Unexpected number of transfers.')
|
||||
|
||||
nctxt = context.RequestContext(user_id=fake.user2_id,
|
||||
project_id=fake.project2_id)
|
||||
nctxt = context.RequestContext(user_id=fake.USER2_ID,
|
||||
project_id=fake.PROJECT2_ID)
|
||||
utils.create_volume(nctxt, updated_at=self.updated_at)
|
||||
self.assertRaises(exception.TransferNotFound,
|
||||
tx_api.get,
|
||||
|
@ -119,19 +119,19 @@ class NotifyUsageTestCase(test.TestCase):
|
||||
@mock.patch('cinder.objects.Volume.get_by_id')
|
||||
def test_usage_from_snapshot(self, volume_get_by_id):
|
||||
raw_volume = {
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'availability_zone': 'nova'
|
||||
}
|
||||
ctxt = context.get_admin_context()
|
||||
volume_obj = fake_volume.fake_volume_obj(ctxt, **raw_volume)
|
||||
volume_get_by_id.return_value = volume_obj
|
||||
raw_snapshot = {
|
||||
'project_id': fake.project_id,
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'user_id': fake.USER_ID,
|
||||
'volume': volume_obj,
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'volume_size': 1,
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'display_name': '11',
|
||||
'created_at': '2014-12-11T10:10:00',
|
||||
'status': 'pause',
|
||||
@ -144,12 +144,12 @@ class NotifyUsageTestCase(test.TestCase):
|
||||
snapshot_obj = fake_snapshot.fake_snapshot_obj(ctxt, **raw_snapshot)
|
||||
usage_info = volume_utils._usage_from_snapshot(snapshot_obj)
|
||||
expected_snapshot = {
|
||||
'tenant_id': fake.project_id,
|
||||
'user_id': fake.user_id,
|
||||
'tenant_id': fake.PROJECT_ID,
|
||||
'user_id': fake.USER_ID,
|
||||
'availability_zone': 'nova',
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'volume_size': 1,
|
||||
'snapshot_id': fake.snapshot_id,
|
||||
'snapshot_id': fake.SNAPSHOT_ID,
|
||||
'display_name': '11',
|
||||
'created_at': 'DONTCARE',
|
||||
'status': 'pause',
|
||||
@ -290,20 +290,20 @@ class NotifyUsageTestCase(test.TestCase):
|
||||
|
||||
def test_usage_from_backup(self):
|
||||
raw_backup = {
|
||||
'project_id': fake.project_id,
|
||||
'user_id': fake.user_id,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'user_id': fake.USER_ID,
|
||||
'availability_zone': 'nova',
|
||||
'id': fake.backup_id,
|
||||
'id': fake.BACKUP_ID,
|
||||
'host': 'fake_host',
|
||||
'display_name': 'test_backup',
|
||||
'created_at': datetime.datetime(2015, 1, 1, 1, 1, 1),
|
||||
'status': 'available',
|
||||
'volume_id': fake.volume_id,
|
||||
'volume_id': fake.VOLUME_ID,
|
||||
'size': 1,
|
||||
'service_metadata': None,
|
||||
'service': 'cinder.backup.drivers.swift',
|
||||
'fail_reason': None,
|
||||
'parent_id': fake.backup2_id,
|
||||
'parent_id': fake.BACKUP2_ID,
|
||||
'num_dependent_backups': 0,
|
||||
'snapshot_id': None,
|
||||
}
|
||||
|
@ -104,8 +104,8 @@ def create_snapshot(ctxt,
|
||||
vol = db.volume_get(ctxt, volume_id)
|
||||
snap = objects.Snapshot(ctxt)
|
||||
snap.volume_id = volume_id
|
||||
snap.user_id = ctxt.user_id or fake.user_id
|
||||
snap.project_id = ctxt.project_id or fake.project_id
|
||||
snap.user_id = ctxt.user_id or fake.USER_ID
|
||||
snap.project_id = ctxt.project_id or fake.PROJECT_ID
|
||||
snap.status = status
|
||||
snap.volume_size = vol['size']
|
||||
snap.display_name = display_name
|
||||
@ -129,8 +129,8 @@ def create_consistencygroup(ctxt,
|
||||
|
||||
cg = objects.ConsistencyGroup(ctxt)
|
||||
cg.host = host
|
||||
cg.user_id = ctxt.user_id or fake.user_id
|
||||
cg.project_id = ctxt.project_id or fake.project_id
|
||||
cg.user_id = ctxt.user_id or fake.USER_ID
|
||||
cg.project_id = ctxt.project_id or fake.PROJECT_ID
|
||||
cg.status = status
|
||||
cg.name = name
|
||||
cg.description = description
|
||||
@ -154,8 +154,8 @@ def create_cgsnapshot(ctxt,
|
||||
**kwargs):
|
||||
"""Create a cgsnapshot object in the DB."""
|
||||
cgsnap = objects.CGSnapshot(ctxt)
|
||||
cgsnap.user_id = ctxt.user_id or fake.user_id
|
||||
cgsnap.project_id = ctxt.project_id or fake.project_id
|
||||
cgsnap.user_id = ctxt.user_id or fake.USER_ID
|
||||
cgsnap.project_id = ctxt.project_id or fake.PROJECT_ID
|
||||
cgsnap.status = status
|
||||
cgsnap.name = name
|
||||
cgsnap.description = description
|
||||
|
@ -47,19 +47,19 @@ class TestConsistencyGroups(scaleio.TestScaleIODriver):
|
||||
**{'id': fake.VOLUME2_ID, 'provider_id': fake.PROVIDER2_ID})
|
||||
fake_volume3 = fake_volume.fake_volume_obj(
|
||||
self.ctx,
|
||||
**{'id': fake.volume3_id, 'provider_id': fake.PROVIDER3_ID})
|
||||
**{'id': fake.VOLUME3_ID, 'provider_id': fake.PROVIDER3_ID})
|
||||
fake_volume4 = fake_volume.fake_volume_obj(
|
||||
self.ctx,
|
||||
**{'id': fake.volume4_id, 'provider_id': fake.PROVIDER4_ID})
|
||||
**{'id': fake.VOLUME4_ID, 'provider_id': fake.PROVIDER4_ID})
|
||||
self.volumes = [fake_volume1, fake_volume2]
|
||||
self.volumes2 = [fake_volume3, fake_volume4]
|
||||
fake_snapshot1 = fake_snapshot.fake_snapshot_obj(
|
||||
self.ctx,
|
||||
**{'id': fake.snapshot_id, 'volume_id': fake.VOLUME_ID,
|
||||
**{'id': fake.SNAPSHOT_ID, 'volume_id': fake.VOLUME_ID,
|
||||
'volume': fake_volume1})
|
||||
fake_snapshot2 = fake_snapshot.fake_snapshot_obj(
|
||||
self.ctx,
|
||||
**{'id': fake.snapshot2_id, 'volume_id': fake.VOLUME2_ID, 'volume':
|
||||
**{'id': fake.SNAPSHOT2_ID, 'volume_id': fake.VOLUME2_ID, 'volume':
|
||||
fake_volume2})
|
||||
self.snapshots = [fake_snapshot1, fake_snapshot2]
|
||||
self.snapshot_reply = json.dumps({
|
||||
|
@ -28,15 +28,15 @@ import cinder.volume.drivers.netapp.options as na_opts
|
||||
import cinder.volume.drivers.netapp.utils as na_utils
|
||||
|
||||
FAKE_CINDER_VOLUME = {
|
||||
'id': fake.volume_id,
|
||||
'id': fake.VOLUME_ID,
|
||||
'size': 1,
|
||||
'volume_name': 'lun1',
|
||||
'host': 'hostname@backend#DDP',
|
||||
'os_type': 'linux',
|
||||
'provider_location': 'lun1',
|
||||
'name_id': fake.volume2_id,
|
||||
'name_id': fake.VOLUME2_ID,
|
||||
'provider_auth': 'provider a b',
|
||||
'project_id': fake.project_id,
|
||||
'project_id': fake.PROJECT_ID,
|
||||
'display_name': None,
|
||||
'display_description': 'lun1',
|
||||
'volume_type_id': None,
|
||||
@ -45,17 +45,17 @@ FAKE_CINDER_VOLUME = {
|
||||
}
|
||||
|
||||
FAKE_CINDER_SNAPSHOT = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'volume': FAKE_CINDER_VOLUME,
|
||||
'provider_id': '3400000060080E500023BB3400631F335294A5A8',
|
||||
}
|
||||
|
||||
FAKE_CINDER_CG = {
|
||||
'id': fake.consistency_group_id,
|
||||
'id': fake.CONSISTENCY_GROUP_ID,
|
||||
}
|
||||
|
||||
FAKE_CINDER_CG_SNAPSHOT = {
|
||||
'id': fake.cgsnapshot_id,
|
||||
'id': fake.CGSNAPSHOT_ID,
|
||||
'consistencygroup_id': FAKE_CINDER_CG['id'],
|
||||
}
|
||||
|
||||
@ -693,7 +693,7 @@ SNAPSHOT_GROUP = {
|
||||
}
|
||||
|
||||
SNAPSHOT_IMAGE = {
|
||||
'id': fake.snapshot_id,
|
||||
'id': fake.SNAPSHOT_ID,
|
||||
'baseVol': '0200000060080E500023C734000009825294A534',
|
||||
'status': 'optimal',
|
||||
'pitCapacity': '2147483648',
|
||||
|
Loading…
Reference in New Issue
Block a user